:root {
  color-scheme: dark;
  --bg: #080b12;
  --surface: #111721;
  --surface-raised: #151e2a;
  --line: rgba(220, 233, 248, 0.15);
  --text: #f5f8fc;
  --muted: #a8b6c6;
  --blue: #1eb7ff;
  --orange: #ff8c1a;
  --green: #68d9a5;
  --red: #ff8a7a;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    radial-gradient(circle at 78% 9%, rgba(30, 183, 255, 0.16), transparent 27rem),
    radial-gradient(circle at 8% 60%, rgba(255, 140, 26, 0.1), transparent 26rem),
    var(--bg);
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

button,
select {
  color: inherit;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.shell {
  width: min(1080px, calc(100% - 36px));
  margin: 0 auto;
  padding: 26px 0 34px;
}

.topbar,
.footer-links,
.panel-heading,
.progress-overview,
.mode-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  min-height: 32px;
}

.back-link,
.footer a {
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover,
.footer a:hover {
  color: var(--blue);
}

.data-source {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
}

.data-source::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  content: "";
}

.data-source[data-source="supabase"]::before {
  background: var(--green);
}

.intro {
  max-width: 760px;
  padding: 58px 0 28px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(2.35rem, 6vw, 4.6rem);
  line-height: 0.99;
  letter-spacing: -0.055em;
}

h1 span {
  color: var(--orange);
}

.lede {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(0.98rem, 2vw, 1.12rem);
  line-height: 1.6;
}

.language-bar {
  display: grid;
  grid-template-columns: auto minmax(180px, 300px) 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(17, 23, 33, 0.86);
}

.language-bar label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.language-bar select {
  width: 100%;
  min-height: 44px;
  padding: 0 40px 0 13px;
  border: 1px solid rgba(30, 183, 255, 0.42);
  border-radius: 8px;
  background: #0b111a;
  cursor: pointer;
}

.language-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: right;
}

.progress-overview {
  gap: 26px;
  margin: 20px 0;
  padding: 14px 2px 16px;
  border-bottom: 1px solid var(--line);
}

.progress-copy {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 24px;
}

.progress-copy .eyebrow {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.6rem;
}

.progress-copy strong {
  display: block;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.progress-copy strong span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.progress-track {
  width: min(360px, 100%);
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #202a37;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #66d5ff);
  transition: width 240ms ease;
}

.deck-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.learning-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.8fr);
  align-items: start;
  gap: 18px;
}

.practice-panel,
.deck-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 23, 33, 0.91);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
}

.practice-panel {
  min-height: 430px;
  padding: 22px;
}

.deck-panel {
  padding: 20px;
}

.panel-heading {
  gap: 16px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.025em;
}

.panel-heading .eyebrow {
  margin-bottom: 5px;
}

.mode-step {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.mode-tabs {
  justify-content: flex-start;
  gap: 8px;
  margin: 22px 0 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b1119;
}

.mode-tab {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 750;
  transition: background 150ms ease, color 150ms ease;
}

.mode-tab[aria-selected="true"] {
  background: #203044;
  color: white;
  box-shadow: inset 0 0 0 1px rgba(30, 183, 255, 0.35);
}

.mode-tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.question-label {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.82rem;
}

.question-word {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 780;
  line-height: 1.12;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.question-reading {
  display: block;
  margin-top: 9px;
  color: var(--orange);
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.question-card {
  min-height: 156px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 0 16px;
  padding: 20px;
  border: 1px solid rgba(255, 140, 26, 0.23);
  border-radius: 11px;
  background:
    radial-gradient(circle at 88% 12%, rgba(255, 140, 26, 0.1), transparent 45%),
    #0c121b;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.answer-choice {
  min-height: 68px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 720;
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.answer-choice:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--blue);
  background: #1a2938;
}

.answer-choice:disabled {
  cursor: default;
}

.answer-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

.answer-form input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0a1018;
  color: var(--text);
  font-size: 1rem;
}

.answer-form input::placeholder {
  color: #7f8da0;
}

.submit-button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 9px;
  background: var(--blue);
  color: #061018;
  cursor: pointer;
  font-weight: 800;
}

.submit-button:hover {
  filter: brightness(1.08);
}

.feedback {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.5;
}

.feedback[data-kind="success"] {
  color: var(--green);
}

.feedback[data-kind="error"] {
  color: var(--red);
}

.feedback[data-kind="learned"] {
  color: var(--orange);
}

.deck-mark {
  color: rgba(30, 183, 255, 0.85);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.active-words {
  display: grid;
  gap: 10px;
  margin: 18px 0 14px;
  padding: 0;
  list-style: none;
  counter-reset: words;
}

.word-row {
  position: relative;
  min-height: 72px;
  padding: 12px 12px 11px 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0d131c;
  counter-increment: words;
}

.word-row::before {
  position: absolute;
  top: 13px;
  left: 13px;
  color: var(--orange);
  content: "0" counter(words);
  font-size: 0.75rem;
  font-weight: 850;
}

.word-row-name {
  display: block;
  margin-bottom: 7px;
  font-size: 0.97rem;
  font-weight: 760;
}

.word-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.metric {
  padding: 3px 7px;
  border: 1px solid rgba(168, 182, 198, 0.15);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.63rem;
  line-height: 1.2;
}

.metric.is-done {
  border-color: rgba(104, 217, 165, 0.34);
  color: var(--green);
}

.deck-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.loading,
.complete-message {
  color: var(--muted);
  line-height: 1.6;
}

.complete-message {
  min-height: 250px;
  display: grid;
  align-content: center;
  text-align: center;
}

.complete-message strong {
  display: block;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 1.45rem;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.footer p {
  max-width: 610px;
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.5;
}

.footer-links {
  flex: 0 0 auto;
  gap: 16px;
}

.footer-links a,
.footer-links button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  text-decoration: none;
  white-space: nowrap;
}

.footer-links a:hover,
.footer-links button:hover {
  color: var(--orange);
}

@media (max-width: 780px) {
  .learning-layout {
    grid-template-columns: 1fr;
  }

  .deck-panel {
    order: -1;
  }

  .active-words {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .word-row {
    padding-left: 12px;
    padding-top: 34px;
  }

  .word-row::before {
    top: 11px;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 24px, 1080px);
    padding-top: 16px;
  }

  .intro {
    padding: 42px 0 22px;
  }

  .language-bar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px 12px;
  }

  .language-note {
    grid-column: 1 / -1;
    text-align: left;
  }

  .progress-overview {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .progress-copy {
    width: 100%;
    gap: 15px;
  }

  .progress-track {
    flex: 1;
  }

  .practice-panel,
  .deck-panel {
    padding: 16px;
  }

  .active-words {
    grid-template-columns: 1fr;
  }

  .word-row {
    min-height: 66px;
    padding: 12px 12px 10px 44px;
  }

  .word-row::before {
    top: 13px;
  }

  .answer-grid {
    grid-template-columns: 1fr;
  }

  .answer-choice {
    min-height: 54px;
  }

  .footer-links {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
}

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