:root {
  --ink: #15202b;
  --ink-soft: #334556;
  --muted: #5d6f7f;
  --paper: #eef3f6;
  --paper-2: #e3ebf1;
  --panel: rgba(255, 255, 255, 0.9);
  --line: rgba(21, 32, 43, 0.12);
  --accent: #1769a3;
  --accent-deep: #0f4f7c;
  --accent-soft: #d7e9f6;
  --ok: #1f6b3a;
  --bad: #9b2c2c;
  --shadow: 0 16px 36px rgba(21, 32, 43, 0.08);
  --radius: 16px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Figtree", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
  max-width: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1000px 520px at 8% -8%, #d5e7f5 0%, transparent 55%),
    radial-gradient(800px 460px at 100% 0%, #d9e4ee 0%, transparent 48%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  line-height: 1.5;
  overflow-x: clip;
  max-width: 100%;
  text-align: left;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(21, 32, 43, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 32, 43, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at 50% 20%, black, transparent 75%);
}

.wrap {
  width: min(960px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  padding: 1.15rem 0 0.55rem;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 4.5vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-align: left;
}

.site-header h1 a {
  color: inherit;
  text-decoration: none;
}

.lede {
  margin: 0.45rem 0 0;
  max-width: none;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.progress-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  text-align: left;
}

.progress-track {
  height: 12px;
  border-radius: 999px 0 0 999px;
  background: linear-gradient(
    90deg,
    rgba(23, 105, 163, 0.12) 0%,
    rgba(23, 105, 163, 0.12) 88%,
    rgba(23, 105, 163, 0.04) 100%
  );
  overflow: visible;
  border: 1px solid rgba(23, 105, 163, 0.18);
  border-right: none;
  position: relative;
}

.progress-track::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -10px;
  bottom: -1px;
  width: 12px;
  background: linear-gradient(90deg, rgba(23, 105, 163, 0.12), transparent);
  border-top: 1px solid rgba(23, 105, 163, 0.18);
  border-bottom: 1px solid rgba(23, 105, 163, 0.18);
  pointer-events: none;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: #1769a3;
}

.progress-track.is-past-goal .progress-fill {
  background: #0f5a8c;
}

.progress-track.is-max {
  border-radius: 999px;
  border-right: 1px solid rgba(23, 105, 163, 0.18);
}

.progress-track.is-max::after {
  display: none;
}

.progress-track.is-max .progress-fill {
  border-radius: 999px;
  background: #0a4d78;
}

.progress-goal-mark {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--ink);
  transform: translateX(-50%);
  border-radius: 1px;
  pointer-events: none;
}

.progress-scale {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  min-height: 1.2rem;
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-status {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.2;
}

.progress-goal-label {
  position: absolute;
  transform: translateX(-50%);
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.2;
}

.save-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  line-height: 1.35;
}

.save-progress-aside,
.save-progress-status {
  color: var(--muted);
}

.save-progress-status {
  color: var(--ink-soft);
}



main {
  display: grid;
  gap: 0.85rem;
  padding-bottom: 2.5rem;
}

.progress-panel,
.week-panel,
.test-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 0.95rem 1.15rem 1.05rem;
}

.progress-head,
.week-head,
.test-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.7rem;
  text-align: left;
}

h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  text-align: left;
}

.progress-head p,
.week-range,
.test-head p {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
}

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

.hint {
  display: inline;
  color: var(--muted);
  font-size: 0.92em;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.jump {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.jump input,
#test-input {
  width: 5.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

#test-input {
  width: min(100%, 18rem);
  flex: 1;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: #f7fffc;
}

.btn-primary:hover {
  background: var(--accent-deep);
}

.btn-nav,
.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost {
  margin-top: 0.15rem;
}

.btn.disabled,
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.table-shell {
  overflow-x: visible;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  max-width: 100%;
}

.word-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: auto;
}

.word-table th,
.word-table td {
  padding: 0.5rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.word-table th {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(238, 243, 246, 0.9);
}

.word-table tr:last-child td {
  border-bottom: none;
}

.rank {
  width: 4rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.lemma {
  white-space: nowrap;
  min-width: 0;
}

.lemma-link {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent-deep);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.lemma-link:hover {
  color: var(--accent);
}

.audio-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  min-width: 1.85rem;
  min-height: 1.85rem;
  aspect-ratio: 1;
  flex-shrink: 0;
  margin-left: 0.35rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-deep);
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.audio-btn:hover {
  background: var(--accent-soft);
  border-color: rgba(23, 105, 163, 0.35);
  color: var(--accent);
}

.icon-speaker {
  width: 1rem;
  height: 1rem;
  display: block;
}

.forms-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.forms-text {
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.35;
  padding-top: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.form-chip {
  display: none;
}

.pos-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(21, 32, 43, 0.06);
  font-size: 0.86rem;
  white-space: nowrap;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(238, 243, 246, 0.85);
  min-width: min(100%, 20rem);
}

.mode-option {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.mode-option:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
}

.mode-option.is-active {
  background: #fff;
  border-color: rgba(23, 105, 163, 0.22);
  color: var(--ink);
  box-shadow: 0 6px 14px rgba(21, 32, 43, 0.06);
}

.mode-option-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  background: rgba(23, 105, 163, 0.1);
  color: var(--accent-deep);
  flex: 0 0 auto;
}

.mode-option-icon .icon-speaker {
  width: 0.9rem;
  height: 0.9rem;
}

.mode-option-def {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.mode-option-copy {
  display: grid;
  gap: 0.05rem;
  min-width: 0;
}

.mode-option-label {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
}

.mode-option-hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.2;
}

.mode-option.is-active .mode-option-hint {
  color: var(--ink-soft);
}

.answered-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.answered-list:empty {
  display: none;
}

.answered-list li {
  display: grid;
  grid-template-columns: 1.75rem 1.25rem minmax(0, 1fr);
  gap: 0.4rem;
  align-items: baseline;
  padding: 0.35rem 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 0.98rem;
  line-height: 1.4;
}

.answered-list li + li {
  border-top: 1px solid var(--line);
}

.answered-num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 600;
}

.answered-ok,
.answered-miss {
  border-color: transparent;
  background: transparent;
}

.answered-mark {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.4;
  text-align: center;
}

.answered-ok .answered-mark {
  color: var(--ok);
}

.answered-miss .answered-mark {
  color: var(--bad);
}

.answered-main {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.answered-line {
  display: block;
  min-width: 0;
}

.answered-other {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  gap: 0.4rem;
  align-items: baseline;
  margin-top: 0.1rem;
}

.answered-mark-spacer {
  visibility: hidden;
}

.answered-word,
.answered-def,
.answered-sep {
  display: inline;
}

.answered-sep {
  font-weight: 400;
  color: var(--muted);
  margin-right: 0.15em;
}

.answered-word {
  font-weight: 700;
  color: var(--ink);
}

.answered-word.is-typed {
  font-weight: 600;
  color: var(--muted);
}

.answered-def {
  font-weight: 400;
  color: var(--ink-soft);
}

.answered-def.is-typed,
.answered-other .answered-def {
  color: var(--muted);
}

.listen-caption {
  display: none;
}

.test-counter,
.test-score {
  display: inline-block;
}

.test-done {
  display: grid;
  gap: 0.55rem;
  justify-items: start;
  padding: 0.5rem 0 0.15rem;
}

.test-done[hidden] {
  display: none !important;
}

.test-done-score {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  font-weight: 700;
  line-height: 1;
  color: var(--accent-deep);
}

.done-of {
  font-size: 0.55em;
  color: var(--muted);
  font-weight: 600;
}

.test-current[hidden] {
  display: none !important;
}

.audio-btn {
  margin-left: 0;
}

.audio-btn-lg {
  width: 2.35rem;
  height: 2.35rem;
  min-width: 2.35rem;
  min-height: 2.35rem;
  flex-shrink: 0;
}

.audio-btn-lg .icon-speaker {
  width: 1.15rem;
  height: 1.15rem;
}

.lemma .audio-btn {
  margin-left: 0.35rem;
}

.forms-row .audio-btn {
  margin-left: 0;
}

.test-prompt-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.test-current {
  display: grid;
  gap: 0.75rem;
}

.test-done {
  display: grid;
  gap: 0.75rem;
  justify-items: start;
  padding: 0.35rem 0 0.15rem;
}

.test-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.test-prompt-row .test-prompt {
  flex: 1;
  min-width: 0;
}

.test-prompt {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 700;
  line-height: 1.25;
}

.test-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.site-footer {
  padding: 1.25rem 0 2rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.site-footer a {
  color: var(--accent-deep);
  font-weight: 600;
}

.site-footer p {
  margin: 0.35rem 0;
}

.th-short {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .wrap {
    width: min(960px, calc(100% - 1rem));
  }

  .eyebrow,
  .lede {
    display: none;
  }

  .site-header {
    padding: 0.55rem 0 0.2rem;
  }

  .site-header h1 {
    font-size: 1.45rem;
  }

  main {
    gap: 0.55rem;
    padding-bottom: 1.25rem;
  }

  .week-head,
  .test-head,
  .progress-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    margin-bottom: 0.45rem;
  }

  .week-head > div,
  .test-head > div {
    text-align: left;
  }

  .week-head h2,
  .progress-title,
  .test-head h2 {
    font-size: 1.05rem;
  }

  .pager {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.3rem;
    align-items: center;
    width: 100%;
  }

  .pager .btn-nav {
    flex: none;
    width: auto;
    padding: 0.32rem 0.45rem;
    font-size: 0.82rem;
    border-radius: 9px;
    white-space: nowrap;
  }

  .pager-label {
    display: none;
  }

  .jump {
    width: auto;
    min-width: 0;
    justify-content: center;
  }

  .jump input {
    width: 3.4rem;
    flex: none;
    padding: 0.32rem 0.3rem;
    font-size: 0.85rem;
  }

  .jump .btn-nav {
    padding: 0.32rem 0.45rem;
  }

  .mode-switch {
    min-width: 0;
    width: 100%;
  }

  .mode-option {
    padding: 0.4rem 0.45rem;
  }

  .mode-option-hint {
    display: none;
  }

  .progress-panel,
  .week-panel,
  .test-panel {
    padding: 0.55rem 0.65rem 0.6rem;
  }

  .progress-track {
    height: 9px;
  }

  .progress-scale {
    min-height: 1rem;
    font-size: 0.75rem;
  }

  .progress-status,
  .progress-goal-label {
    font-size: 0.75rem;
  }

  .save-progress {
    margin-top: 0.45rem;
    gap: 0.35rem;
  }

  .save-progress-aside {
    display: none;
  }

  .save-progress .btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
  }

  /* Dense table: all 10 rows on screen, no sideways scroll */
  .table-shell {
    overflow: hidden;
    border-radius: 10px;
  }

  .word-table {
    table-layout: auto;
    width: 100%;
    min-width: 0;
  }

  .word-table th {
    font-size: 0.65rem;
    letter-spacing: 0.04em;
    padding: 0.28rem 0.35rem;
  }

  .word-table td {
    padding: 0.22rem 0.35rem;
    vertical-align: middle;
  }

  .word-table .pos,
  .word-table th:nth-child(3) {
    display: none;
  }

  /* Shrink rank + word to content; forms gets leftover width */
  .th-full {
    display: none;
  }

  .th-short {
    display: inline;
  }

  .rank,
  .word-table th:nth-child(1) {
    width: 1%;
    white-space: nowrap;
    font-size: 0.78rem;
    line-height: 1.35;
    padding-left: 0.3rem;
    padding-right: 0.2rem;
    letter-spacing: 0;
    text-align: right;
  }

  .word-table th:nth-child(1) {
    font-size: 0.7rem;
  }

  .lemma,
  .word-table th:nth-child(2) {
    width: 1%;
    white-space: nowrap;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
  }

  .lemma-link {
    font-size: 0.9rem;
    line-height: 1.35;
    text-underline-offset: 2px;
  }

  .inflections,
  .word-table th:nth-child(4) {
    width: auto;
  }

  .forms-row {
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
  }

  .forms-text {
    font-size: 0.78rem;
    line-height: 1.35;
    padding-top: 0;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
  }

  .audio-btn {
    width: 1.45rem;
    height: 1.45rem;
    min-width: 1.45rem;
    min-height: 1.45rem;
  }

  .icon-speaker {
    width: 0.78rem;
    height: 0.78rem;
  }

  .pos-pill {
    font-size: 0.75rem;
    padding: 0.12rem 0.4rem;
  }
}

/* Extra-short viewports: keep trimming chrome */
@media (max-height: 720px) {
  .eyebrow,
  .lede {
    display: none;
  }

  .site-header {
    padding: 0.5rem 0 0.15rem;
  }

  main {
    gap: 0.5rem;
  }

  .progress-panel,
  .week-panel {
    padding: 0.5rem 0.6rem 0.55rem;
  }

  .week-head {
    margin-bottom: 0.35rem;
  }
}
