:root {
  color: #18212b;
  background: #f6f3ed;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 100%;
  line-height: 1.55;
  --ink: #18212b;
  --muted: #59636d;
  --paper: #fffdf9;
  --wash: #f6f3ed;
  --brand: #c94f16;
  --brand-dark: #8e310d;
  --navy: #16324a;
  --border: #d8d2c8;
  --error: #a32121;
  --success: #17643a;
  --focus: #075fa8;
  --shadow: 0 1rem 3rem rgb(37 30 22 / 10%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 20rem;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

a {
  color: var(--brand-dark);
}

:focus-visible {
  outline: 0.2rem solid var(--focus);
  outline-offset: 0.2rem;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.65rem 1rem;
  color: white;
  background: var(--navy);
  border-radius: 0.35rem;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

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

.site-header {
  /* Header-only aubergine palette (in-1521); the global tokens are re-themed separately. */
  --header-top: #40152f;
  --header-bottom: #15040c;
  --header-ink: #fbf6ef;
  --header-accent: #40152f;
  --header-focus: #ffc2e2;
  min-height: 4.75rem;
  padding: 0.75rem clamp(1rem, 4vw, 4rem) 0;
  display: flex;
  align-items: flex-end;
  gap: clamp(1rem, 3vw, 2.5rem);
  color: white;
  background: linear-gradient(to bottom, var(--header-top), var(--header-bottom));
}

/* --focus is too dark on aubergine, so header controls get a light ring (in-1521). */
.site-header :focus-visible {
  outline-color: var(--header-focus);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: white;
  text-decoration: none;
}

.brand-logo {
  width: 15rem;
  height: 2.5rem;
  display: block;
  object-fit: contain;
  object-position: left center;
}

#primary-navigation {
  min-width: 0;
  flex: 1;
  overflow-x: auto;
}

/* Edge fades show which side of an overflowing tab row hides tabs (in-1521). The
   scroll timeline drives them without listeners; it is inactive while nothing
   overflows, which leaves both fades at zero. */
@property --nav-fade-start {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@property --nav-fade-end {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@keyframes nav-fade-start {
  from { --nav-fade-start: 0px; }
  to { --nav-fade-start: 2.5rem; }
}

@keyframes nav-fade-end {
  from { --nav-fade-end: 2.5rem; }
  to { --nav-fade-end: 0px; }
}

@supports (animation-timeline: scroll()) {
  #primary-navigation {
    animation: nav-fade-start linear both, nav-fade-end linear both;
    animation-timeline: scroll(self inline), scroll(self inline);
    animation-range: 0 2.5rem, calc(100% - 2.5rem) 100%;
    mask-image: linear-gradient(
      to right,
      transparent,
      #000 var(--nav-fade-start),
      #000 calc(100% - var(--nav-fade-end)),
      transparent
    );
  }

  /* A fade must never dim the focused tab's ring. */
  #primary-navigation:has(:focus-visible) {
    mask-image: none;
  }
}

.nav-list {
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.15rem;
  list-style: none;
}

.nav-link {
  display: block;
  padding: 0.65rem 0.65rem 0.8rem;
  border-radius: 0.4rem 0.4rem 0 0;
  color: var(--header-ink);
  font-size: 0.925rem;
  text-decoration: none;
  text-underline-offset: 0.16em;
  white-space: nowrap;
}

/* The navigation scrolls and the tabs touch the header's bottom edge, so an
   outer ring would be clipped. The ring is drawn inside the tab instead: light
   against the header, with a dark inner ring against the active tab's wash. */
.nav-link:focus-visible {
  outline-offset: -0.2rem;
}

.nav-link[aria-current="page"]:focus-visible {
  box-shadow: inset 0 0 0 0.35rem var(--header-accent);
}

/* The hidden bold copy reserves the active width, so tabs keep their
   positions across routes (in-1521). Its empty alternative text keeps it out
   of the accessible name. */
.nav-label {
  display: inline-flex;
  flex-direction: column;
}

.nav-label::after {
  content: attr(data-text) / "";
  height: 0;
  overflow: hidden;
  font-weight: 750;
  visibility: hidden;
  user-select: none;
  pointer-events: none;
}

.nav-link:hover {
  color: white;
  background: rgb(255 255 255 / 13%);
}

.nav-link[aria-current="page"] {
  color: var(--header-accent);
  background: var(--wash);
  font-weight: 750;
  text-decoration: none;
}

/* Forced colours flatten the wash, so the current tab is underlined instead. */
@media (forced-colors: active) {
  .nav-link[aria-current="page"] .nav-label {
    text-decoration: underline;
    text-decoration-thickness: 0.15em;
  }
}

/* Pending friend requests and challenge invitations (in-1260). */
.nav-badge {
  display: inline-block;
  min-width: 1.35em;
  margin-left: 0.35em;
  padding: 0 0.35em;
  /* The transparent border keeps the badge outlined in forced colors. */
  border: 1px solid transparent;
  border-radius: 999px;
  color: white;
  background: var(--brand-dark);
  font-size: 0.75rem;
  font-weight: 750;
  line-height: 1.35em;
  text-align: center;
  vertical-align: 0.1em;
}

.header-actions,
.button-row,
.profile-row,
.dialog-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.locale-control {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
}

.locale-control select {
  min-height: 2.65rem;
  padding: 0.35rem 2rem 0.35rem 0.65rem;
  border: 1px solid #d8bccb;
  border-radius: 0.35rem;
  color: var(--ink);
  background: white;
}

.global-status {
  min-height: 0;
  padding: 0 clamp(1rem, 4vw, 4rem);
  color: white;
  background: var(--success);
  text-align: center;
}

.global-status:not(:empty) {
  padding-block: 0.5rem;
}

.global-status[data-kind="error"] {
  background: var(--error);
}

main {
  width: min(76rem, 100%);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 5.5rem) clamp(1rem, 4vw, 4rem);
  flex: 1;
}

/* Route and skip-link focus targets the content, not an interactive control (in-1555). */
#main-content:focus {
  outline: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
  align-items: center;
  gap: clamp(2rem, 7vw, 6rem);
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--brand-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  color: var(--navy);
  line-height: 1.15;
}

h1 {
  max-width: 18ch;
  margin: 0 0 1.25rem;
  font-size: clamp(2.15rem, 6vw, 4.7rem);
  letter-spacing: -0.045em;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.hero > div > p:not(.eyebrow) {
  max-width: 39rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.panel {
  padding: clamp(1.2rem, 4vw, 2rem);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.panel > :first-child,
.page-heading > :first-child {
  margin-top: 0;
}

.panel > :last-child,
.page-heading > :last-child {
  margin-bottom: 0;
}

.language-form,
.stack,
dialog form {
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

label {
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #777f86;
  border-radius: 0.35rem;
  background: white;
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border: 0.15rem solid var(--error);
}

.hint,
.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.button {
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.4rem;
  font-weight: 750;
}

.button-primary {
  color: white;
  background: var(--brand);
  border-color: var(--brand-dark);
}

.button-primary:hover {
  background: var(--brand-dark);
}

.button-secondary {
  color: var(--navy);
  background: white;
  border-color: #9aa6af;
}

.button-quiet {
  color: var(--brand-dark);
  background: transparent;
  text-decoration: underline;
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.form-error {
  padding: 0.75rem;
  border-left: 0.3rem solid var(--error);
  color: var(--error);
  background: #fff1f0;
  font-weight: 650;
}

.check-control {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-weight: 500;
}

.check-control input {
  width: 1.25rem;
  min-height: 1.25rem;
  margin-top: 0.15rem;
}

.page-heading {
  max-width: 46rem;
  margin-bottom: 2rem;
}

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

main.study-main {
  padding-block: clamp(1rem, 2.5vw, 2rem);
}

.learn-page > .page-heading {
  max-width: 76rem;
  margin: 0 auto 0.65rem;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.75rem;
}

.learn-page > .page-heading h1,
.learn-page > .page-heading p {
  margin: 0;
}

.learn-page > .page-heading h1 {
  max-width: none;
  flex: none;
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  letter-spacing: -0.025em;
}

.learn-page > .page-heading p {
  color: var(--muted);
  font-size: 0.92rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 1rem;
  align-items: start;
  align-content: start;
}

.account-layout {
  display: grid;
  gap: 1rem;
  width: min(48rem, 100%);
  align-content: start;
  align-items: start;
}

.account-layout .panel {
  min-width: 0;
  width: 100%;
}

.account-layout .panel > .button,
.account-layout form > .button {
  justify-self: start;
}

.account-layout .button-row {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.account-layout .account-signed-out {
  width: min(32rem, 100%);
}

.placeholder-panel {
  width: min(42rem, 100%);
}

.quiz-run,
.progress-dashboard {
  min-width: 0;
  width: min(64rem, 100%);
  margin-inline: auto;
}

.quiz-score {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
  text-align: center;
}

.quiz-outcome {
  padding: 0.75rem 1rem;
  border-left: 0.35rem solid currentColor;
  border-radius: 0.35rem;
  font-weight: 800;
}

.quiz-correct {
  color: var(--success);
  background: #f2faf5;
}

.quiz-incorrect {
  color: var(--error);
  background: #fff7f5;
}

.quiz-question fieldset {
  min-width: 0;
  padding: 0;
  border: 0;
}

.quiz-question legend {
  color: var(--muted);
  font-weight: 750;
}

.quiz-prompt {
  margin-block: 0.75rem 1rem;
  color: var(--navy);
  font-size: clamp(1.5rem, 4vw, 2.35rem);
  font-weight: 750;
}

.quiz-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.quiz-choice {
  min-height: 3.5rem;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border: 1px solid #9aa6af;
  border-radius: 0.45rem;
  background: white;
  font-weight: 650;
}

.quiz-choice:has(input:checked) {
  border-color: var(--focus);
  box-shadow: inset 0 0 0 0.1rem var(--focus);
}

.quiz-choice input {
  width: 1.25rem;
  min-height: 1.25rem;
  flex: none;
}

.placement-result {
  padding: 0.85rem;
  border-radius: 0.4rem;
  color: var(--navy);
  background: #edf6f5;
  font-weight: 800;
}

.progress-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.progress-totals h2 {
  grid-column: 1 / -1;
  margin-block: 0;
}

.progress-stat {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: var(--paper);
}

.progress-stat span,
.progress-stat strong {
  display: block;
}

.progress-stat span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.progress-stat strong {
  margin-top: 0.2rem;
  color: var(--navy);
  font-size: 1.4rem;
}

.progress-dashboard .stack,
.progress-dashboard .panel {
  min-width: 0;
}

.progress-stat {
  overflow-wrap: anywhere;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

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

.data-table th,
.data-table td {
  padding: 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  font-size: 0.82rem;
}

.current-ranking {
  background: #e6f4eb;
  font-weight: 800;
}

.ranking-gap th {
  padding-top: 1rem;
  text-align: left;
}

.ranking-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  /* Long metric labels must not widen the panel on narrow screens. */
  min-width: 0;
}

.milestone-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
  list-style: none;
}

.milestone-list li {
  padding: 0.75rem;
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(0, 2fr) auto;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.milestone-list time,
.empty-state {
  color: var(--muted);
}

.friends-layout {
  display: grid;
  gap: 1rem;
  width: min(48rem, 100%);
  align-content: start;
}

.friends-layout .button-row {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.friend-code code {
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  overflow-wrap: anywhere;
}

.friends-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
  list-style: none;
}

.friends-list li {
  padding: 0.75rem 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.friends-list li > div:first-child {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.friends-list .challenge-form {
  grid-column: 1 / -1;
}

.account-identity,
.challenge-scores {
  margin: 0.35rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.account-identity div,
.challenge-scores div {
  display: grid;
}

.account-identity dt,
.challenge-scores dt {
  color: var(--muted);
  font-size: 0.92rem;
}

.challenge-scores dd {
  margin: 0;
  font-weight: 750;
}

.account-identity dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 35rem) {
  .friends-list li {
    grid-template-columns: minmax(0, 1fr);
  }
}

.course-summary,
.study-panel,
.study-status {
  width: min(48rem, 100%);
  margin-inline: auto;
}

.study-session,
.study-workspace {
  width: min(76rem, 100%);
  margin-inline: auto;
}

.study-session {
  gap: 0.75rem;
}

/* The exercise fills the first column. Feedback, its details and the
   registration invitation stack in the second; the last, flexible row absorbs
   the exercise height so the feedback rows stay joined. */
.study-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto auto auto 1fr;
  align-items: start;
  gap: 0 1rem;
}

.study-workspace > .study-panel {
  width: 100%;
  margin: 0;
  padding: 1rem clamp(1rem, 2vw, 1.5rem);
}

.study-workspace > .study-exercise {
  grid-column: 1;
  grid-row: 1 / -1;
}

.study-workspace > .study-feedback,
.study-workspace > .study-feedback-details,
.study-workspace > .study-registration {
  grid-column: 2;
}

.study-workspace > .study-feedback { grid-row: 1; }
.study-workspace > .study-feedback-details { grid-row: 2; }

.study-workspace > .study-registration {
  grid-row: 3;
  margin-top: 1rem;
}

/* Side by side, the result and its details read as one panel. */
.study-workspace > .study-feedback:has(~ .study-feedback-details) {
  padding-bottom: 0.75rem;
  border-bottom-width: 0;
  border-end-start-radius: 0;
  border-end-end-radius: 0;
}

.study-feedback-details {
  display: grid;
  gap: 0.75rem;
  box-shadow: none;
}

.study-workspace > .study-feedback-details {
  padding-top: 0;
  border-top-width: 0;
  border-start-start-radius: 0;
  border-start-end-radius: 0;
}

.feedback-diagnosis {
  margin: 0;
  line-height: 1.5;
}

/* A rival's name is user text; long names wrap instead of widening the panel. */
.rivalry-message {
  margin: 0;
  line-height: 1.5;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.study-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: color-mix(in srgb, var(--paper) 82%, var(--wash));
}

.study-status-facts {
  flex: 1 1 20rem;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr));
  gap: 0.65rem;
}

.study-status-facts div {
  min-width: 0;
}

.study-status-facts dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

/* Generation diagnostics for the debug account (in-1389). */
.study-debug {
  width: min(76rem, 100%);
  margin-inline: auto;
  padding: 0.6rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 0.65rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.study-debug summary {
  font-weight: 750;
  cursor: pointer;
}

.study-debug dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.2rem 0.75rem;
  margin: 0.5rem 0 0;
}

.study-debug dt {
  font-weight: 750;
}

.study-debug dd {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

.streak-rainbow {
  flex: none;
  width: 5.5rem;
  height: auto;
  margin-inline-start: auto;
}

.rainbow-band {
  fill: none;
  stroke-width: 6;
}

.rainbow-band-violet { stroke: #8f00ff; }
.rainbow-band-indigo { stroke: #4b0082; }
.rainbow-band-blue { stroke: #005dee; }
.rainbow-band-green { stroke: #2cb500; }
.rainbow-band-yellow { stroke: #ffd500; }
.rainbow-band-orange { stroke: #ff8c00; }
.rainbow-band-red { stroke: #e00000; }

.study-status-facts dd {
  margin: 0.1rem 0 0;
  color: var(--navy);
  font-weight: 800;
  overflow-wrap: anywhere;
}

/* Mastered out of all words, with a thin bar for the share (in-1522). */
.status-words-bar {
  display: block;
  width: 100%;
  height: 0.3rem;
  margin-top: 0.25rem;
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: var(--border);
  color: var(--success);
  overflow: hidden;
}

.status-words-bar::-webkit-progress-bar {
  background: var(--border);
}

.status-words-bar::-webkit-progress-value {
  background: var(--success);
}

.status-words-bar::-moz-progress-bar {
  background: var(--success);
}

/* Points are a score, not learning progress: the brand accent sets them apart. */
.study-status-facts .status-points dd {
  color: var(--brand-dark);
}

.course-summary {
  width: min(76rem, 100%);
  margin-top: 0;
  margin-bottom: 0.65rem;
  color: var(--muted);
  text-align: center;
}

.answer-form {
  display: grid;
  gap: 0.9rem;
}

.study-workspace .answer-form {
  gap: 0.65rem;
}

.study-instruction {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.study-question {
  --question-border: #b9d6d2;
  --question-background: #edf6f5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin: 0.4rem 0 1rem;
}

.study-prompt {
  align-self: stretch;
  margin: 0;
  color: var(--navy);
  font-size: clamp(1.65rem, 5vw, 2.8rem);
  font-weight: 720;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.study-workspace .study-question {
  margin-block: 0.15rem 0.35rem;
}

/* The question and its level tab share the direction colours (in-1541). */
.study-question-reverse {
  --question-border: #b8a3af;
  --question-background: #ede6ea;
}

.study-prompt-forward,
.study-prompt-reverse {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--question-border);
  border-radius: 0.5rem;
  background: var(--question-background);
}

.study-question:has(> .study-level) > .study-prompt {
  border-top-right-radius: 0;
}

/* The tab joins the question's top border, flush with its right edge. */
.study-level {
  position: relative;
  margin: 0 0 -1px;
  padding: 0.18rem 0.65rem 0.12rem;
  border: 1px solid var(--question-border);
  border-bottom: 0;
  border-radius: 0.5rem 0.5rem 0 0;
  color: var(--navy);
  background: var(--question-background);
  font-size: 0.8rem;
  font-weight: 800;
}

.study-guidance {
  margin: 0;
  padding: 0.75rem 0.9rem 0.75rem 2rem;
  border-left: 0.25rem solid #b27a00;
  border-radius: 0.35rem;
  background: #fff8dd;
}

.study-guidance li {
  list-style: none;
}

.study-examples {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--wash);
}

.study-examples > h2 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
}

.study-examples section + section {
  margin-top: 0.65rem;
}

.study-examples h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.study-examples p {
  margin: 0.15rem 0 0;
  overflow-wrap: anywhere;
}

.study-examples strong {
  text-decoration: underline;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.12em;
}

.answer-form input {
  min-height: 3.4rem;
  font-size: 1.12rem;
}

/* A small aside under the answer field, not body text (in-1532). */
.study-abbreviations {
  display: grid;
  gap: 0.1rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.study-abbreviations > p {
  margin: 0;
  overflow-wrap: anywhere;
}

.study-abbreviations > p:first-child {
  font-weight: 700;
}

.study-abbreviations > p + p {
  color: var(--navy);
}

.study-actions {
  margin-top: 0.35rem;
}

.pending-answer input[readonly],
.study-failure input[readonly] {
  color: var(--navy);
  background: var(--wash);
}

.study-answer-pending {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.study-answer-pending::before {
  width: 0.8rem;
  height: 0.8rem;
  border: 0.14rem solid color-mix(in srgb, var(--brand) 28%, transparent);
  border-top-color: var(--brand);
  border-radius: 50%;
  content: "";
  animation: pending-answer-spin 0.8s linear infinite;
}

@keyframes pending-answer-spin {
  to { transform: rotate(360deg); }
}

.study-feedback {
  border-width: 1px;
  box-shadow: none;
  padding: 1rem 1.5rem;
  gap: 0.75rem;
}

.study-feedback > p {
  margin: 0;
  line-height: 1.5;
}

.feedback-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
}

.feedback-heading::before {
  display: inline-grid;
  flex: 0 0 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
  box-sizing: border-box;
  place-items: center;
  /* Matches the 900-weight glyph and bold heading at both ring sizes (in-1523). */
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
}

.feedback-correct {
  border-color: var(--success);
  background: #f2faf5;
}

.feedback-correct h2 {
  color: var(--success);
}

.feedback-correct h2::before,
.feedback-correct .feedback-heading::before {
  content: "✓";
}

.feedback-incorrect {
  border-color: var(--error);
  background: #fff7f5;
}

.feedback-incorrect h2 {
  color: var(--error);
}

/* A bare ✗ rather than a ringed ×, which read as a close button (in-1531). */
.feedback-incorrect h2::before,
.feedback-incorrect .feedback-heading::before {
  content: "✗";
  border: 0;
}

/* Without the ring the glyph carries the mark alone, so it scales with the heading. */
.study-feedback.feedback-incorrect .feedback-heading::before {
  font-size: 1.3em;
}

.feedback-warning {
  margin-block: 0;
  border: 0.12rem solid #8a6500;
  border-left-width: 0.45rem;
  border-radius: 0.45rem;
  background: #fff9df;
}

.feedback-warning h2 {
  margin-block: 0 0.4rem;
  color: #684b00;
  font-size: 1.25rem;
}

.feedback-warning p {
  margin-block: 0;
}

.correction {
  margin: 0;
  display: grid;
  gap: 0;
}

.correction > div {
  display: grid;
  grid-template-columns: minmax(0, 10rem) minmax(0, 1fr);
  align-items: baseline;
  gap: 0.35rem 1rem;
  padding-block: 0.65rem;
}

.correction > div + div {
  border-block-start: 1px solid var(--border);
}

.correction dt {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.correction dd {
  min-width: 0;
  margin: 0;
  font-size: 1.08rem;
  overflow-wrap: anywhere;
}

.correction dd.has-replay {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 480px) {
  .correction > div {
    grid-template-columns: minmax(0, 1fr);
  }
}

.correction-phrase {
  flex: 0 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
}

.replay-button {
  position: relative;
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.4em;
  height: 1.2em;
  padding: 0;
  border: 0;
  border-radius: 0.3rem;
  color: var(--muted);
  background: none;
  line-height: 1;
  cursor: pointer;
}

/* The icon stays text-sized while the touch target extends past it without affecting layout. */
.replay-button::after {
  content: "";
  position: absolute;
  inset: -0.8rem;
}

.replay-button:hover {
  color: var(--ink);
}

.replay-icon {
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.replay-icon path:first-child {
  fill: currentColor;
}

.correction mark {
  padding-inline: 0.08em;
  border-block-end: 0.16em double currentColor;
  color: inherit;
  background: #fff0a8;
  font-weight: 800;
}

.correction-help {
  padding-block-start: 0.35rem;
  border-block-start: 1px solid var(--border);
}

.correction-help summary {
  min-height: 2.75rem;
  padding-block: 0.7rem;
  color: var(--brand-dark);
  font-weight: 800;
  cursor: pointer;
}

.word-help {
  display: grid;
  gap: 0.5rem;
}

.word-help div {
  display: grid;
  grid-template-columns: minmax(7rem, 0.3fr) minmax(0, 1fr);
  gap: 0.75rem;
}

.word-help dt {
  color: var(--muted);
  font-weight: 750;
}

.word-help dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.correction-help h3 {
  margin-block-end: 0.45rem;
  font-size: 1rem;
}

.conjugation-help {
  display: grid;
  gap: 0.35rem;
  margin-block: 0;
  padding-inline-start: 1.4rem;
  overflow-wrap: anywhere;
}

.registration-prompt {
  margin-top: 0.5rem;
  padding: 1rem;
  border: 1px dashed #9aa6af;
  border-radius: 0.45rem;
  background: var(--paper);
}

.registration-prompt h3,
.registration-prompt p {
  margin-top: 0;
}

.registration-prompt h3 {
  font-size: 1.1rem;
}

.error-code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.85rem;
}

.profile-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  list-style: none;
}

.courses-panel {
  border-top: 0.25rem solid var(--brand);
  background: linear-gradient(135deg, #fff4e8, var(--paper) 45%);
}

.courses-panel > h2 {
  margin-bottom: 0.5rem;
}

.profile-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--paper);
}

.course-monogram {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.8rem;
  color: var(--navy);
  background: #e9edf3;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.profile-details {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.profile-row .button {
  text-align: center;
  text-decoration: none;
}

.profile-row[data-selected="true"] {
  border-color: var(--success);
  background: #f0f8f2;
  box-shadow: inset 0.25rem 0 var(--success);
}

.profile-row[data-selected="true"] .course-monogram {
  color: var(--success);
  background: #dceee1;
}

.course-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.course-add-form .form-error {
  grid-column: 1 / -1;
}

.course-add-form select {
  min-width: 0;
}

.tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  color: var(--success);
  background: #e6f4eb;
  font-size: 0.82rem;
  font-weight: 750;
}

.loading-panel {
  min-height: 15rem;
  display: grid;
  place-items: center;
}

.loading-panel p::before {
  content: "";
  width: 1rem;
  height: 1rem;
  margin-right: 0.65rem;
  display: inline-block;
  border: 0.2rem solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  vertical-align: -0.15rem;
  animation: spin 0.8s linear infinite;
}

dialog {
  width: min(32rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: 0;
  border: 0;
  border-radius: 0.75rem;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 1.25rem 5rem rgb(0 0 0 / 35%);
}

dialog::backdrop {
  background: rgb(9 24 36 / 72%);
}

.dialog-frame {
  padding: clamp(1.2rem, 5vw, 2rem);
}

.dialog-heading {
  justify-content: space-between;
  margin-bottom: 1rem;
}

.dialog-heading h2 {
  margin: 0;
}

.icon-button {
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  color: var(--navy);
  background: transparent;
  font-size: 1.7rem;
}

.icon-button:hover {
  background: var(--wash);
}

.site-footer {
  padding: 1.25rem clamp(1rem, 4vw, 4rem);
  color: #dbe5eb;
  background: var(--navy);
  text-align: center;
}

.site-footer p {
  margin: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 52rem) {
  .site-header {
    flex-wrap: wrap;
  }

  #primary-navigation {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .header-actions {
    margin-left: auto;
  }

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

  .learn-page > .page-heading {
    display: block;
    text-align: center;
  }

  .learn-page > .page-heading p {
    margin-top: 0.25rem;
  }

  .study-workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    gap: 0.5rem;
  }

  .study-workspace > .study-exercise,
  .study-workspace > .study-feedback,
  .study-workspace > .study-feedback-details,
  .study-workspace > .study-registration {
    grid-column: 1;
    grid-row: auto;
    margin-top: 0;
  }

  /* With the on-screen keyboard open a phone shows only a few hundred pixels:
     the previous correction and the new question, its input and its actions
     come first; diagnosis, guidance, examples and abbreviations follow them. */
  .study-workspace {
    scroll-margin-top: 0.25rem;
  }

  .study-workspace > .study-feedback {
    gap: 0.25rem;
    padding: 0.45rem 0.85rem;
  }

  /* Stacked, the details become a separate panel after the exercise. */
  .study-workspace > .study-feedback:has(~ .study-feedback-details) {
    padding-bottom: 0.45rem;
    border-bottom-width: 1px;
    border-radius: 0.8rem;
  }

  .study-workspace > .study-feedback-details {
    padding: 0.75rem 0.85rem;
    border-top-width: 1px;
    border-radius: 0.8rem;
  }

  /* A correct answer's heading says enough; its details would only push the
     next question down (in-1472). */
  .study-workspace > .study-feedback-details.feedback-correct {
    display: none;
  }

  /* The debug account's diagnostics are for desktop review; on a phone they
     would only crowd the exercise (in-1477). */
  .study-debug {
    display: none;
  }

  .study-workspace > .feedback-warning:is(.study-feedback, .study-feedback-details) {
    border-block-width: 0.12rem;
    border-radius: 0.45rem;
  }

  .study-feedback .feedback-heading {
    gap: 0.5rem;
    font-size: 1.05rem;
  }

  .study-feedback .feedback-heading::before {
    flex-basis: 1.4rem;
    width: 1.4rem;
    height: 1.4rem;
    font-size: 0.95rem;
  }

  .study-feedback .correction > div {
    gap: 0.1rem 1rem;
    padding-block: 0.25rem;
  }

  .study-feedback .correction dt {
    font-size: 0.75rem;
    line-height: 1.2;
  }

  .study-feedback .correction dd {
    font-size: 1rem;
    line-height: 1.35;
  }

  .study-workspace > .study-exercise {
    gap: 0.45rem;
    padding: 0.5rem 0.85rem 0.65rem;
  }

  .study-exercise > .study-guidance,
  .study-exercise > .study-examples,
  .study-exercise > .study-abbreviations {
    order: 1;
  }

  .study-exercise .study-instruction {
    font-size: 0.75rem;
    line-height: 1.2;
  }

  .study-exercise .study-question {
    margin-block: 0;
  }

  /* A compact level tab keeps the answer actions above the keyboard. */
  .study-exercise .study-level {
    padding: 0 0.5rem 0.05rem;
    font-size: 0.7rem;
    line-height: 1.3;
  }

  .study-exercise .study-prompt {
    padding-block: 0.3rem;
    font-size: 1.2rem;
  }

  /* The instruction above the question already says what to type. */
  .study-exercise > label[for="study-answer"] {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .study-exercise input {
    min-height: 2.75rem;
  }

  .study-exercise .study-actions {
    flex-flow: row wrap;
    gap: 0.5rem;
    margin-top: 0;
  }

  .study-exercise .study-actions .button {
    flex: 1 1 8rem;
    width: auto;
  }

  .progress-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 35rem) {
  .site-header,
  .header-actions,
  .button-row,
  .profile-row {
    align-items: stretch;
  }

  .header-actions {
    width: 100%;
    margin-left: 0;
  }

  .locale-control {
    flex: 1;
  }

  .locale-control select {
    min-width: 0;
  }

  .button-row,
  .profile-row {
    flex-direction: column;
  }

  .button-row .button,
  .profile-row .button {
    width: 100%;
  }

  .study-status {
    padding: 0.5rem 0.75rem;
  }

  .study-status-facts {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 4.5rem), 1fr));
    gap: 0.4rem 0.65rem;
  }

  .study-status-facts dt {
    font-size: 0.7rem;
  }

  .study-status-facts div {
    display: grid;
    align-content: space-between;
  }

  .quiz-choices,
  .progress-totals,
  .ranking-filters,
  .milestone-list li {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

.chart-panel-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.chart-panel-heading h2 { margin: 0; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 0.15rem; background: var(--wash); }
.segmented .button { min-height: 2.2rem; padding: 0.3rem 0.9rem; border: 0; border-radius: 999px; background: transparent; box-shadow: none; font-size: 0.9rem; }
.segmented .button[aria-pressed="true"] { background: var(--navy); color: white; }

.stack-chart {
  position: relative;
  width: min(100%, 560px);
  height: 300px;
  color: var(--muted);
  margin: 0.5rem auto 0;
  border-radius: 0.35rem;
}
.stack-chart:focus-visible, .practice-plot:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.stack-chart canvas { display: block; width: 100%; height: 300px; }
.chart-category, .chart-tick { position: absolute; pointer-events: none; font-size: 0.7rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-category { transform: translate(-50%, 4px); color: var(--ink); font-weight: 600; }
.chart-category-vertical { writing-mode: vertical-rl; transform: translate(-50%, 4px) rotate(180deg); }
.chart-tick { transform: translate(-100%, -50%); }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem 1.25rem; margin: 0; padding: 0; list-style: none; font-size: 0.9rem; }
.chart-legend li { display: inline-flex; align-items: center; gap: 0.35rem; }
.chart-legend strong { font-variant-numeric: tabular-nums; }
.chart-swatch { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 0.2rem; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 12%); }
.chart-readout { min-height: 1.6em; margin: 0; text-align: center; font-weight: 600; overflow-wrap: anywhere; }


.practice-controls { display: flex; flex-wrap: wrap; gap: .5rem; }
.practice-controls [aria-pressed="true"] { text-decoration: underline; font-weight: bold; }
.practice-figure { position: relative; height: 400px; margin: 0 auto; padding: 32px 20px 0 44px; width: min(100%, 366px); box-sizing: border-box; font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.practice-plot { position: relative; width: 100%; height: 180px; }
.practice-plot canvas { display: block; width: 100%; height: 180px; }
.practice-legend { position: absolute; top: 6px; left: 44px; font-size: 0.8rem; color: var(--ink); }
.practice-legend::before { content: ""; display: inline-block; width: 20px; border-top: 3px solid #294FC9; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.practice-axis { position: absolute; left: 2px; right: calc(100% - 40px); top: 40px; height: 164px; display: flex; flex-direction: column; justify-content: space-between; text-align: right; overflow-wrap: anywhere; }
.practice-dates { position: relative; height: 60px; }
.practice-dates span { position: absolute; top: 8px; transform: translateX(-100%) rotate(-45deg); transform-origin: right top; white-space: nowrap; }

.retention-figure { width: min(100%, 666px); height: 500px; padding-left: 46px; }
.retention-plot, .retention-plot canvas { height: 360px; }
.retention-axis { top: 48px; height: 328px; }
.retention-horizons span:first-child { transform: rotate(-45deg); transform-origin: left top; }
.chart-marker { position: absolute; z-index: 1; width: 0.75rem; height: 0.75rem; border: 2px solid white; border-radius: 50%; background: #294FC9; box-shadow: 0 0 0 1px #294FC9; transform: translate(-50%, -50%); pointer-events: none; }
.chart-unavailable { border-bottom: 1px solid var(--border); }

.progress-dashboard select, .ranking-filters select { width: auto; max-width: 100%; min-width: 0; }

@media (max-width: 35rem) {
  .profile-row {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .profile-row .button {
    grid-column: 1 / -1;
  }

  .course-add-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .account-layout .course-add-form > .button {
    width: 100%;
  }
}

.progress-bars { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; gap: 0.8rem; width: 100%; margin-top: 0.5rem; }
.progress-bars:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.progress-bar-row { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; gap: 0.8rem; }
.progress-bar-label { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; }
/* Inline level contents keep WebKit's subgrid sizing wide enough for the swatch and full label. */
.progress-bars:not(.theme-bars) .progress-bar-label { display: block; white-space: nowrap; }
.progress-level-swatch { display: inline-block; width: 0.8rem; height: 0.8rem; margin-inline-end: 0.4rem; vertical-align: middle; border: 1px solid var(--muted); border-radius: 2px; }
.progress-level-swatch[data-level="0"] { background: #fff; }
.progress-level-swatch[data-level="1"] { background: #ffd500; }
.progress-level-swatch[data-level="2"] { background: #228b22; }
.progress-level-swatch[data-level="3"] { background: #2463eb; }
.progress-level-swatch[data-level="4"] { background: #000; }
/* Themes have no belt color of their own. */
.progress-level-swatch[data-level="5"] { background: linear-gradient(135deg, #fff 20%, #ffd500 20% 40%, #228b22 40% 60%, #2463eb 60% 80%, #000 80%); }
.progress-bar-track { display: block; width: 100%; height: 1.5rem; overflow: visible; }
.progress-bar-empty { fill: var(--paper); stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.progress-bar-figure { display: flex; justify-content: space-between; gap: 1rem; font-variant-numeric: tabular-nums; }
.progress-bar-figure span:first-child { min-width: 3ch; text-align: right; }
.progress-bar-figure span:last-child { min-width: 9ch; text-align: right; }
@media (max-width: 36rem) {
  .progress-bars { grid-template-columns: max-content minmax(0, 1fr); }
  .progress-bar-row { gap: 0.25rem 0.5rem; }
  .progress-bar-figure { grid-column: 2; flex-wrap: wrap; gap: 0.25rem 0.5rem; font-size: 0.85rem; }
  .progress-bar-figure span:last-child { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
}
.chart-panel { grid-template-columns: minmax(0, 1fr); }

.theme-bars { grid-template-columns: fit-content(35%) minmax(0, 1fr) max-content; }
.theme-bars .progress-bar-label { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 36rem) {
  .theme-bars { grid-template-columns: fit-content(45%) minmax(0, 1fr); }
}
