:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --text: #18201d;
  --muted: #64706b;
  --line: #d8ddd9;
  --accent: #176b52;
  --accent-dark: #0e4f3c;
  --ink-blue: #245b78;
  --soft-green: #e8f2ed;
  --soft-blue: #e9f1f5;
  --bad: #b23a48;
  --good: #217346;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
}

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px clamp(16px, 4vw, 48px);
  position: relative;
  z-index: 2;
}

.brand {
  align-items: center;
  color: var(--text);
  display: flex;
  gap: 10px;
  font-weight: 700;
  text-decoration: none;
}

.brand span {
  align-items: center;
  background: var(--text);
  border-radius: 4px;
  color: #fff;
  display: inline-flex;
  font-size: 0.72rem;
  height: 30px;
  justify-content: center;
  width: 34px;
}

nav {
  align-items: center;
  display: flex;
  gap: 6px;
}

nav > a,
.nav-logout {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 9px 10px;
  text-decoration: none;
}

nav > a:hover,
.nav-logout:hover {
  color: var(--text);
}

.page {
  margin: 0 auto;
  max-width: 1120px;
  padding: 32px 20px 64px;
  width: 100%;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(36, 91, 120, 0.25);
  outline-offset: 2px;
}

.auth-shell {
  align-items: start;
  display: grid;
  gap: clamp(36px, 8vw, 100px);
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 420px);
  /* Anchored near the top with .page's own padding, not centred in the
     viewport -- align-items: center plus a near-full-height min-height
     used to leave a growing dead gap above and below on tall windows. */
  min-height: calc(100vh - 64px);
}

.auth-shell > *,
.dashboard-head > *,
.resume-band > *,
.dashboard-lower > *,
.practice-grid > * {
  min-width: 0;
}

.auth-copy {
  max-width: 590px;
}

.product-mark {
  align-items: center;
  background: var(--text);
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-size: 1.1rem;
  font-weight: 800;
  height: 52px;
  justify-content: center;
  margin-bottom: 28px;
  width: 58px;
}

.eyebrow,
.section-kicker,
.step-label {
  color: var(--accent);
  display: block;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.auth-copy h1,
.dashboard-head h1,
.onboarding-heading h1 {
  font-size: clamp(2.2rem, 5vw, 4.25rem);
  line-height: 1.04;
  margin: 0 0 18px;
  max-width: 700px;
}

.auth-copy > p:last-child,
.dashboard-head p,
.onboarding-heading p,
.auth-form-panel > p {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.auth-form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(24px, 5vw, 40px);
}

.auth-form-panel h2,
.dashboard-section h2,
.resume-band h2,
.settings-section h2 {
  font-size: 1.35rem;
  margin: 0 0 8px;
}

.stack-form {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.stack-form input {
  font-size: 1.05rem;
  min-height: 48px;
  width: 100%;
}

.stack-form input[type="checkbox"] {
  accent-color: var(--accent);
  min-height: auto;
  width: auto;
}

.stack-form button,
.onboarding-form > button {
  min-height: 48px;
  margin-top: 6px;
}

.form-error {
  background: #fbecee;
  border-left: 4px solid var(--bad);
  color: #7f2934;
  padding: 10px 12px;
}

.onboarding-shell {
  margin: 48px auto 0;
  max-width: 820px;
}

.onboarding-heading h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

.onboarding-form {
  display: grid;
  gap: 28px;
  margin-top: 40px;
}

.onboarding-form fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.onboarding-form legend {
  font-size: 1rem;
  font-weight: 750;
  margin-bottom: 12px;
}

.choice-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-option {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  padding: 18px;
}

.choice-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.choice-option span {
  display: grid;
  gap: 4px;
}

.choice-option small {
  color: var(--muted);
}

.level-options {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, 1fr);
}

.level-options label {
  cursor: pointer;
  position: relative;
}

.level-options input {
  opacity: 0;
  position: absolute;
}

.level-options span {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: flex;
  font-weight: 750;
  justify-content: center;
  min-height: 52px;
}

.level-options input:checked + span {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.dashboard-head {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin-bottom: 28px;
}

.dashboard-head h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
}

.dashboard-head p {
  margin-bottom: 0;
}

.level-badge {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  gap: 10px;
  padding: 10px 12px;
}

.level-badge span {
  color: var(--muted);
  font-size: 0.78rem;
}

.level-badge strong {
  font-size: 1.1rem;
}

.resume-band {
  align-items: center;
  background: var(--text);
  color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 26px 28px;
  width: 100%;
}

.resume-band .section-kicker {
  color: #84d3b7;
}

.resume-band p {
  color: #cbd5d1;
  margin: 0;
}

.primary-action {
  background: #fff;
  border-radius: 6px;
  color: var(--text);
  flex: 0 0 auto;
  font-weight: 750;
  padding: 12px 18px;
  text-decoration: none;
}

.dashboard-section {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 24px;
}

.practice-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.practice-item {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 14px;
  grid-template-columns: 46px 1fr auto;
  padding: 16px;
  text-decoration: none;
}

.practice-item:hover {
  border-color: #9da9a3;
}

.practice-code {
  align-items: center;
  background: var(--soft-green);
  border-radius: 6px;
  color: var(--accent-dark);
  display: flex;
  font-weight: 800;
  height: 46px;
  justify-content: center;
}

.noun-code {
  background: var(--soft-blue);
  color: var(--ink-blue);
}

.practice-item > span:nth-child(2) {
  display: grid;
  gap: 4px;
}

.practice-item small {
  color: var(--muted);
}

.dashboard-lower {
  display: grid;
  gap: 28px;
  grid-template-columns: 1.3fr 0.7fr;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.metric-row > div {
  border-left: 1px solid var(--line);
  display: grid;
  gap: 5px;
  padding: 8px 18px;
}

.metric-row > div:first-child {
  border-left: 0;
  padding-left: 0;
}

.metric-row strong {
  font-size: 1.7rem;
}

.metric-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.preference-form {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 90px auto;
}

.preference-form button {
  align-self: end;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    display: grid;
    gap: 8px;
  }

  nav {
    max-width: 100%;
    overflow-x: auto;
  }

  nav > a,
  .nav-logout {
    white-space: nowrap;
  }

  .page {
    padding: 24px 16px 48px;
  }

  .auth-shell {
    align-items: start;
    gap: 28px;
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .product-mark {
    margin-bottom: 20px;
  }

  .auth-copy h1 {
    font-size: 2.45rem;
    overflow-wrap: anywhere;
  }

  .auth-form-panel,
  .onboarding-shell,
  .dashboard-section,
  .practice-item {
    max-width: 100%;
  }

  .choice-grid,
  .practice-grid,
  .dashboard-lower {
    grid-template-columns: 1fr;
  }

  .level-options {
    grid-template-columns: repeat(3, 1fr);
  }

  .dashboard-head,
  .resume-band {
    align-items: flex-start;
    display: grid;
    gap: 18px;
  }

  .level-badge {
    width: max-content;
  }

  .primary-action {
    text-align: center;
    width: 100%;
  }

  .preference-form {
    grid-template-columns: 1fr 1fr;
  }

  .preference-form button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 430px) {
  .brand {
    font-size: 0.95rem;
  }

  nav {
    gap: 0;
  }

  nav > a,
  .nav-logout {
    font-size: 0.8rem;
    padding: 8px 7px;
  }

  .metric-row > div {
    padding: 8px 10px;
  }

  .metric-row strong {
    font-size: 1.4rem;
  }
}

.panel,
.table-panel,
.flashcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.section-header,
.learn-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.controls,
.level-grid,
.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.level-grid button {
  min-height: 64px;
  min-width: 110px;
}

button,
.button,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  padding: 10px 12px;
}

button,
.button {
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
}

input,
select,
textarea {
  background: #fff;
  color: var(--text);
  min-width: 0;
}

textarea {
  min-height: 96px;
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  margin-top: 16px;
}

.stats-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 16px;
}

.stats-grid span,
.level,
.empty {
  color: var(--muted);
}

.stats-grid strong {
  font-size: 1.8rem;
}

.flashcard {
  margin: 0 auto;
  max-width: 760px;
  min-height: 420px;
}

.card-front {
  align-content: center;
  display: grid;
  justify-items: center;
  min-height: 360px;
  text-align: center;
}

.card-front h1,
.card-back h1 {
  font-size: clamp(2rem, 8vw, 4.5rem);
  letter-spacing: 0;
  margin: 8px 0;
}

.translation {
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 700;
}

.recall-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 8px 0 18px;
}

.recall-choices button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-width: 58px;
  padding: 10px;
}

.recall-choices .choice-correct {
  background: var(--good);
  color: #fff;
}

.recall-choices .choice-wrong {
  background: var(--bad);
  color: #fff;
}

.recall-choices button.choice-correct::after { content: " \2713"; }

.recall-choices button.choice-wrong::after { content: " \2717"; }

/* Marked-up choices carried onto the answer side after a pick. */
.recall-choices-result {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.recall-choices-result button:not(.choice-correct):not(.choice-wrong) {
  opacity: 0.45;
}

.prompt-gloss {
  color: var(--muted);
  font-size: 0.95rem;
}

.cloze {
  font-size: 1.25rem;
  max-width: 560px;
}

.answer-callout {
  background: #edf8f2;
  border-left: 4px solid var(--good);
  font-size: 1.15rem;
  font-weight: 700;
  padding: 12px 14px;
}

.word-information div {
  grid-template-columns: 120px 1fr;
}

.case-table {
  border: 1px solid var(--line);
  display: grid;
}

.case-table div {
  display: grid;
  gap: 10px;
  grid-template-columns: 110px 150px 1fr;
  padding: 10px 12px;
}

.case-table div + div {
  border-top: 1px solid var(--line);
}

.content-grid {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 20px;
}

.card-section {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 20px;
}

.conjugation-section h2 {
  color: #005a9c;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.conjugation-table {
  border: 1px solid #edf1f5;
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
}

.conjugation-cell {
  border-bottom: 1px solid #edf1f5;
  border-right: 1px solid #edf1f5;
  padding: 14px 12px;
}

.conjugation-cell:nth-child(3n) {
  border-right: 0;
}

.conjugation-cell:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.conjugation-cell h3 {
  font-size: 1.05rem;
  margin: 0 0 14px;
  text-align: center;
}

.conjugation-rows {
  display: grid;
  gap: 12px;
}

.conjugation-rows p {
  margin: 0;
}

.conjugation-rows strong {
  color: #005a9c;
}

.conjugation-rows .person {
  color: #2f3f4f;
}

.example-stack {
  display: grid;
  gap: 14px;
}

.example-row {
  display: grid;
  gap: 5px;
}

.example-row h3 {
  font-size: 1rem;
  margin: 4px 0;
  text-transform: uppercase;
}

.example-row .tr {
  color: var(--muted);
}

.columns {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

dl div,
.compact div {
  display: grid;
  grid-template-columns: 110px 1fr;
  padding: 5px 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
}

.hidden {
  display: none;
}

.review-actions {
  justify-content: space-between;
  margin-top: 24px;
}

.bad {
  background: var(--bad);
}

.good {
  background: var(--good);
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
}

.verb-form {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.verb-form button,
.verb-form textarea,
.error {
  grid-column: 1 / -1;
}

.error {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 6px;
  color: var(--bad);
  padding: 12px;
}

@media (max-width: 640px) {
  .topbar,
  .section-header,
  .learn-header {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    flex-wrap: wrap;
  }

  .panel,
  .table-panel,
  .flashcard {
    padding: 16px;
  }

  .conjugation-table {
    grid-template-columns: 1fr;
  }

  .case-table div {
    grid-template-columns: 90px 1fr;
  }

  .case-table div span:last-child {
    grid-column: 1 / -1;
  }

  .conjugation-cell,
  .conjugation-cell:nth-child(3n),
  .conjugation-cell:nth-last-child(-n + 3) {
    border-bottom: 1px solid #edf1f5;
    border-right: 0;
  }

  .conjugation-cell:last-child {
    border-bottom: 0;
  }
}
