:root {
  --ink: #263a48;
  --muted: #75848c;
  --accent: #4f8188;
  --accent-dark: #38666e;
  --accent-soft: #eaf2f3;
  --line: #e0e9eb;
  --surface: #ffffff;
}

body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 10% 0%, rgba(218, 234, 237, 0.72), transparent 34rem),
    linear-gradient(180deg, #f4f7f8 0%, #fbfcfc 56%, #f4f7f8 100%);
  font-family:
    Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

main.container {
  max-width: 1080px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-block: 0.55rem !important;
}

#learnSection {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.app-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.8rem;
}

.app-heading {
  min-width: 0;
}

.app-title {
  margin-bottom: 0.1rem;
  color: var(--ink);
  font-size: clamp(1.05rem, 2vw, 1.4rem);
  letter-spacing: -0.035em;
}

.app-subtitle {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.25;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.35rem;
}

.top-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 2rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.74rem;
  font-weight: 650;
  white-space: nowrap;
}

.clear-menu {
  position: relative;
}

.clear-menu summary {
  list-style: none;
  cursor: pointer;
}

.clear-menu summary::-webkit-details-marker {
  display: none;
}

.clear-menu-panel {
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.35rem);
  right: 0;
  display: grid;
  min-width: 9.5rem;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 8px 24px rgba(38, 63, 76, 0.14);
}

.clear-menu-panel .btn {
  justify-content: flex-start;
  padding: 0.45rem 0.55rem;
  color: var(--ink);
  text-align: left;
}

.clear-menu-panel .btn:hover:not(:disabled) {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.clear-menu-panel .btn:disabled {
  color: #9aa8a0;
  opacity: 0.65;
}

.level-nav {
  flex: 0 0 auto;
  overflow: hidden;
  margin-bottom: 0.4rem !important;
}

.level-slider {
  justify-content: center;
  overflow-x: auto;
  padding: 0.2rem 0.2rem 0.35rem;
  scroll-snap-type: x mandatory;
  scrollbar-color: #b5c9cc transparent;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.level-slider::-webkit-scrollbar {
  height: 5px;
}

.level-slider::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #b5c9cc;
}

.level-option {
  flex: 0 0 auto;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  color: #596e78;
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.76rem;
  font-weight: 650;
  scroll-snap-align: center;
  transition:
    color 0.18s ease,
    background-color 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.level-option:hover {
  border-color: #b6d0d2;
  color: var(--accent-dark);
  background: #f2f8f8;
  transform: translateY(-1px);
}

.level-option.is-selected,
.level-option.is-selected:hover {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
  box-shadow: 0 5px 14px rgba(79, 129, 136, 0.2);
}

.level-option:focus-visible,
.speak-btn:focus-visible,
.sentence-card .btn:focus-visible {
  outline: 3px solid rgba(79, 129, 136, 0.28);
  outline-offset: 2px;
}

.progress-card,
.test-card {
  border: 1px solid rgba(224, 233, 235, 0.9) !important;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 32px rgba(38, 63, 76, 0.065);
}

.progress-card {
  flex: 0 0 auto;
}

.progress-card .card-body {
  padding: 0.55rem 0.8rem;
}

#levelTitle {
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
}

#progressText {
  color: var(--muted) !important;
}

.progress {
  height: 0.3rem;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f3;
}

.progress-bar {
  border-radius: inherit;
  background: linear-gradient(90deg, #83b9b5, var(--accent));
  transition: width 0.3s ease;
}

#cards,
#testBody {
  max-height: 60vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #b5c9cc transparent;
  scrollbar-width: thin;
}

#cards {
  flex: 1 1 0;
  min-height: 0;
  margin: 0;
}

#cards::-webkit-scrollbar,
#testBody::-webkit-scrollbar {
  width: 7px;
}

#cards::-webkit-scrollbar-thumb,
#testBody::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: #b5c9cc;
  background-clip: padding-box;
}

.sentence-card {
  border: 1px solid var(--line) !important;
  border-left: 4px solid #a9c9cc !important;
  background: var(--surface);
  box-shadow: 0 5px 16px rgba(38, 63, 76, 0.055) !important;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}

.sentence-card:hover {
  border-left-color: var(--accent) !important;
  box-shadow: 0 10px 24px rgba(38, 63, 76, 0.1) !important;
  transform: translateY(-2px);
}

.sentence-card.is-done {
  border-left-color: #6d9d97 !important;
  background: #fbfdfd;
}

.sentence-card .fs-6 {
  color: var(--ink);
  line-height: 1.55;
}

.sentence-card .text-secondary {
  color: #738187 !important;
  font-size: 0.92rem;
  line-height: 1.65;
}

.speak-btn {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-color: #d5e5e6;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 1rem;
  line-height: 1;
}

.speak-btn:hover {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.sentence-card .btn-outline-success {
  border-color: #b7d1d3;
  color: var(--accent-dark);
  font-weight: 650;
}

.sentence-card .btn-outline-success:hover {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.sentence-card .btn-success {
  border-color: #638f91;
  background: #638f91;
  font-weight: 650;
}

#moreArea .btn {
  margin-top: 0.25rem;
  padding: 0.3rem 0.85rem;
  border-color: #c7d8db;
  color: var(--accent-dark);
  font-weight: 600;
  font-size: 0.72rem;
}

#moreArea .btn:hover {
  color: #fff;
  background: var(--accent);
}

#startTestBtn {
  border: 0;
  background: var(--ink);
  box-shadow: 0 3px 10px rgba(38, 58, 72, 0.13);
  font-size: 0.74rem;
  font-weight: 650;
  transition:
    background-color 0.18s ease,
    transform 0.18s ease;
}

#startTestBtn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.test-card {
  flex: 1 1 auto;
  min-height: 0;
}

.test-card > div:first-child {
  flex: 0 0 auto;
  padding: 0.55rem 0.75rem 0 !important;
}

.test-card #testBody {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.65rem 0.75rem !important;
}

.test-card fieldset {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #fcfefe;
}

.test-card legend {
  float: none;
  width: auto;
  margin-bottom: 0.35rem;
  color: var(--ink);
  line-height: 1.55;
  font-size: 0.82rem;
}

.test-card .form-check {
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
  font-size: 0.78rem;
}

.test-card .form-check-input:checked {
  border-color: var(--accent);
  background-color: var(--accent);
}

@media (max-width: 575.98px) {
  main.container {
    padding-inline: 0.65rem !important;
  }

  .app-title {
    font-size: 1rem;
  }

  .app-subtitle {
    font-size: 0.64rem;
  }

  .app-header {
    gap: 0.4rem;
    min-height: 2.5rem;
  }

  .top-actions {
    gap: 0.25rem;
  }

  .top-actions .btn {
    min-height: 1.85rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.68rem;
  }

  .level-slider {
    justify-content: flex-start;
    gap: 0.35rem !important;
    padding-inline: 0.1rem;
    scroll-padding-inline: 0.1rem;
  }

  .level-option {
    padding: 0.35rem 0.65rem;
    font-size: 0.68rem;
  }

  #levelTitle {
    font-size: 0.78rem;
  }

  #progressText {
    font-size: 0.62rem !important;
  }

  .sentence-card .card-body {
    padding: 0.75rem !important;
  }

  .sentence-card .fs-6 {
    font-size: 0.78rem !important;
  }

  .sentence-card .text-secondary {
    margin-bottom: 0.5rem !important;
    font-size: 0.72rem;
  }

  .speak-btn {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.78rem;
  }

  .sentence-card .btn-sm {
    padding-block: 0.25rem;
    font-size: 0.68rem;
  }

  .test-card fieldset {
    padding: 0.55rem 0.65rem;
  }

  .test-card legend {
    font-size: 0.72rem;
  }

  .test-card .form-check-label {
    font-size: 0.7rem;
  }
}

@media (max-height: 600px) {
  main.container {
    padding-block: 0.3rem !important;
  }

  .app-header {
    min-height: 2.1rem;
  }

  .level-nav {
    margin-bottom: 0.2rem !important;
  }

  .level-option {
    padding-block: 0.28rem;
  }

  .progress-card {
    margin-bottom: 0.3rem !important;
  }

  .progress-card .card-body {
    padding-block: 0.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
