:root {
  color-scheme: light dark;
  --paper: #f6f6ef;
  --surface: #fffef9;
  --ink: #202c24;
  --muted: #59665c;
  --line: #dce1d4;
  --accent: #256449;
  --wash: #e5eee4;
  --edge: #778779;
  --hint: #80551e;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --chip-radius: 8px;
  --control-radius: 12px;
  --card-radius: 16px;
  --hit: 28px;
  --motion-feedback: 120ms;
  --motion-selection: 180ms;
  --motion-reveal: 240ms;
  --motion-offset: 6px;
  --motion-ease: cubic-bezier(0.23, 1, 0.32, 1);
  --button: #254e39;
  --buttonText: #fffdf2;
  font-family: "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
}
header,
main,
footer {
  width: min(1064px, calc(100% - 64px));
  margin-inline: auto;
}
header,
.account,
.compose-actions,
.map-head,
.question,
footer {
  display: flex;
  align-items: center;
}
header {
  justify-content: space-between;
  padding: 27px 0;
  border-bottom: 1px solid var(--line);
}
a {
  color: inherit;
}
.wordmark {
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-weight: 700;
  font-size: 27px;
  letter-spacing: 0.08em;
  text-decoration: none;
}
.account,
.question {
  gap: 9px;
}
#quota,
footer {
  font-size: 13px;
  color: var(--muted);
}
main {
  padding: clamp(34px, 6vh, 78px) 0 58px;
  min-height: 75vh;
}
h1 {
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: clamp(32px, 4vw, 52px);
  font-weight: 500;
  letter-spacing: -0.055em;
  margin: 0 0 32px;
}
.guide-copy {
  max-width: 40em;
  margin-block: 0 16px;
  line-height: 1.8;
  color: var(--muted);
}
.selection-sample {
  margin: 28px 0 36px;
  padding: 14px 20px;
  border-inline-start: 3px solid var(--accent);
}
.selection-sample figcaption {
  color: var(--muted);
  font-size: 13px;
}
.selection-sample p {
  margin: 9px 0 0;
  font: clamp(25px, 4vw, 36px)/1.4 Georgia, serif;
}
.guide-option {
  border-top: 1px solid var(--line);
}
.guide-option summary {
  width: fit-content;
  padding-block: 15px;
  color: var(--accent);
  cursor: pointer;
}
.guide-option summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
h2,
.compose label,
#follow label {
  font-size: 14px;
  letter-spacing: 0.02em;
  font-weight: 650;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(245px, 0.78fr) minmax(0, 1.5fr);
  gap: clamp(24px, 5vw, 65px);
  align-items: start;
}
.compose {
  background: var(--surface);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.compose label,
#follow label {
  display: block;
  color: var(--muted);
  margin-bottom: 12px;
}
textarea,
input {
  font: inherit;
  color: inherit;
  background: transparent;
}
textarea {
  resize: vertical;
  width: 100%;
  min-height: 125px;
  line-height: 1.6;
  font-family: Georgia, "Songti SC", serif;
  font-size: 21px;
  border: 0;
  padding: 0;
}
textarea:focus-visible {
  outline-offset: 4px;
}
.compose-actions {
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}
button {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 7px 14px;
  cursor: pointer;
}
button:disabled {
  opacity: 0.48;
  cursor: default;
}
.primary {
  color: var(--buttonText);
  background: var(--button);
  border-color: var(--button);
  font-weight: 600;
}
.quiet {
  border: 0;
  background: none;
  color: var(--muted);
  padding-inline: 0;
}
.quiet:hover {
  text-decoration: underline;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
#status:not(:empty),
#pair-status:not(:empty),
#login-status:not(:empty) {
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 0;
}
p:empty {
  margin: 0;
}
.reading {
  min-width: 0;
}
.result {
  font-size: clamp(25px, 3vw, 36px);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.035em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0 0 22px;
}
.result[lang="en"] {
  font-family: Georgia, serif;
  font-weight: 400;
}
.lesson-focus {
  margin: 0 0 var(--space-4);
  overflow-wrap: anywhere;
}
.lesson-focus > summary {
  min-height: var(--hit);
  padding-block: var(--space-2);
}
.lesson-focus strong { font: 600 1.125rem/1.5 Georgia, serif; }
.lesson-focus p { margin: 0; line-height: 1.65; }
.map {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  padding: var(--space-4);
  margin: 0 0 var(--space-6);
  overflow-wrap: anywhere;
}
.map-head {
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  min-height: var(--hit);
}
.map h2, .why h2 {
  margin: 0;
}
.map h2 {
  font-size: 1rem;
}
.map-tabs {
  --count: 2;
  --slide: 0%;
  display: inline-grid;
  grid-template-columns: repeat(var(--count), minmax(0, 1fr));
  position: relative;
  align-self: flex-start;
  max-width: 100%;
  padding: var(--space-1);
  border-radius: var(--control-radius);
  background: var(--paper);
}
.map-tabs[data-count="3"] { --count: 3; }
.map-tabs[data-index="1"] { --slide: 100%; }
.map-tabs[data-index="2"] { --slide: 200%; }
.map-tabs::before {
  position: absolute;
  content: "";
  box-sizing: border-box;
  inset-block: var(--space-1);
  inset-inline-start: var(--space-1);
  width: calc((100% - 2 * var(--space-1)) / var(--count));
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--chip-radius);
  transform: translateX(var(--slide));
  pointer-events: none;
}
.mode-tab, .map-action {
  min-height: var(--hit);
  min-width: var(--hit);
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: var(--chip-radius);
  color: var(--muted);
  background: transparent;
  font-size: 0.875rem;
  line-height: 1.45;
}
.map button { -webkit-tap-highlight-color: transparent; }
.map button:not(:disabled):active { opacity: 0.74; }
.mode-tab {
  position: relative;
  padding-inline: var(--space-3);
}
.mode-tab[aria-selected="true"] {
  color: var(--accent);
  font-weight: 650;
}
.map-action.emphasized {
  color: var(--accent);
  background: var(--wash);
  font-weight: 550;
}
.diagram {
  position: relative;
}
.phrase-line, .word-bank, .exercise-actions {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-1);
}
.phrase-line {
  position: relative;
  z-index: 1;
  line-height: 1.35;
}
.phrase-line.zh {
  margin-top: var(--space-6);
  column-gap: 0;
}
.token {
  display: inline-flex;
  align-items: flex-end;
  max-width: 100%;
  min-width: 0;
}
.piece {
  position: relative;
  border: 0;
  border-radius: var(--chip-radius);
  background: transparent;
  padding: var(--space-1);
  text-align: left;
  min-width: var(--hit);
  min-height: var(--hit);
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.piece .word, .unmatched.en, .en-answer, .punctuation {
  font: 1.25rem/1.4 Georgia, serif;
}
.piece .role {
  display: block;
  font: 0.75rem/1.35 system-ui, sans-serif;
  color: var(--muted);
  margin-bottom: var(--space-1);
}
.zh.piece {
  text-align: center;
}
.zh .word, .unmatched.zh, .zh .punctuation {
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
}
.punctuation {
  margin-inline-start: calc(-1 * var(--space-1));
  padding-bottom: var(--space-1);
  color: var(--muted);
}
.unmatched { padding-block: var(--space-1); }
.en.piece::after, .piece[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset-inline: var(--space-1);
  bottom: 0;
  height: 1px;
  background: var(--line);
}
.piece[aria-pressed="true"] {
  color: var(--accent);
  background: var(--wash);
}
.piece[aria-pressed="true"]::after {
  background: var(--accent);
  height: 2px;
}
.piece[aria-pressed="true"] .role {
  color: var(--accent);
}
.connector {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.connector path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
}
.detail, .why p, #answer, dialog p {
  font-size: 0.9375rem;
  line-height: 1.65;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.detail {
  border-top: 1px solid var(--line);
  padding-top: var(--space-3);
}
.diagram + .detail { margin-top: var(--space-3); }
.detail p, .why p { margin: var(--space-1) 0 0; }
.selected-pair {
  color: var(--accent);
  font-size: 0.875rem;
}
.lesson-pane:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: var(--space-1);
  border-radius: var(--chip-radius);
}
.exercise {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
}
.exercise :is(p, textarea) { margin: 0; }
.exercise-prompt {
  font-size: 1.125rem;
  line-height: 1.5;
}
.assembly-well {
  width: 100%;
  min-width: 0;
  padding: var(--space-3);
  background: var(--paper);
  border-radius: var(--control-radius);
}
.progress-label, .placeholder {
  color: var(--muted);
  line-height: 1.5;
}
.progress-label {
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
.exercise .progress-label + p { margin-top: var(--space-1); }
.word-bank { gap: var(--space-2); }
.choice {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--hit);
  max-width: 100%;
  min-width: var(--hit);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--chip-radius);
  border-color: var(--edge);
  text-align: start;
  font: 1.0625rem/1.45 Georgia, serif;
  overflow-wrap: anywhere;
}
.choice-label { min-width: 0; }
.choice-icon {
  flex: none;
  display: inline-grid;
  place-content: center;
  width: 1rem;
  height: 1rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  font: 0.7rem/1 system-ui, sans-serif;
}
.choice[data-state="used"] {
  color: var(--accent);
  background: var(--wash);
  opacity: 1;
}
.choice[data-state="hint"] {
  color: var(--hint);
  border-color: var(--hint);
}
.exercise-feedback {
  color: var(--accent);
  font-size: 0.9375rem;
  line-height: 1.5;
}
.exercise-feedback[data-hint="true"] { color: var(--hint); }
.swap-draft {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--edge);
  border-radius: var(--chip-radius);
  min-height: var(--hit);
  padding: var(--space-2);
  max-height: 12rem;
  font: 1.0625rem/1.45 Georgia, serif;
}
.swap-draft::placeholder { color: var(--muted); opacity: 1; }
.swap-answer {
  border-inline-start: 2px solid var(--accent);
  padding-inline-start: var(--space-3);
}
.swap-answer strong { color: var(--accent); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.why {
  margin: var(--space-4) 0 var(--space-6);
}
#follow {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.question input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 9px 12px;
}
.question button {
  flex: none;
}
footer {
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 17px 0 28px;
}
dialog,
#pairing {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
}
dialog {
  width: min(390px, calc(100% - 32px));
  box-shadow: 0 18px 80px #182a2020;
}
dialog h2,
#pairing h1 {
  font-size: 22px;
  margin: 0 0 14px;
}
dialog::backdrop {
  background: #14271d55;
  backdrop-filter: blur(4px);
}
dialog .close {
  float: right;
  padding: 0 8px;
  border: 0;
  background: none;
  font-size: 22px;
  color: var(--muted);
}
#login > button {
  width: 100%;
  margin: 5px 0;
  padding: 10px;
}
#pairing {
  margin-bottom: 28px;
}
#pair-code {
  font:
    20px ui-monospace,
    monospace;
  letter-spacing: 0.12em;
  margin-right: 18px;
}
[hidden] {
  display: none !important;
}
@media (max-width: 760px) {
  header,
  main,
  footer {
    width: min(590px, calc(100% - 34px));
  }
  header {
    padding: 17px 0;
  }
  main {
    padding-top: 28px;
  }
  h1 {
    margin-bottom: 18px;
  }
  .workspace {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .compose textarea {
    min-height: 70px;
    height: 80px;
  }
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17201c;
    --surface: #202b25;
    --ink: #eff5ec;
    --muted: #acb9ad;
    --line: #38473d;
    --edge: #819586;
    --hint: #e6be85;
    --accent: #a0d9b7;
    --wash: #304b3c;
    --button: #a0d9b7;
    --buttonText: #142a1e;
  }
}
@media (pointer: coarse) {
  :root { --hit: 44px; }
}
@media (prefers-contrast: more) {
  :root { --line: var(--edge); }
}
@media (prefers-reduced-transparency: reduce) {
  dialog::backdrop { backdrop-filter: none; }
}
@media (hover: hover) and (pointer: fine) {
  button:not(:disabled):hover { border-color: var(--accent); }
  .piece:hover { box-shadow: inset 0 0 0 1px var(--accent); }
  .map-action:not(:disabled):hover, .mode-tab:not([aria-selected="true"]):hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .piece, .choice, .map-action {
    transition: background-color var(--motion-feedback) var(--motion-ease),
                color var(--motion-feedback) var(--motion-ease);
  }
  .map[data-input="pointer"] .map-tabs::before {
    transition: transform var(--motion-selection) var(--motion-ease);
  }
  .map[data-input="keyboard"] :is(.piece, .choice, .map-action) { transition: none; }
  .map[data-input="pointer"] :is(.lesson-pane, .swap-answer):not([hidden]) {
    transition: opacity var(--motion-selection) var(--motion-ease),
                transform var(--motion-selection) var(--motion-ease);
    @starting-style {
      opacity: 0;
      transform: translateY(var(--motion-offset));
    }
  }
}
