/* ============ tokens ============ */
/* Fonts built into the app (see fonts/README.txt): FreeMono for all text, Red Hat Mono for the title. */
@font-face {
  font-family: "FreeMono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/FreeMono.otf") format("opentype");
}
@font-face {
  font-family: "Red Hat Mono";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("../fonts/RedHatMono-Light.woff") format("woff");
}

/* Always dark: #1e1e1e for the background, #2d2d2d for cards, fields and buttons. */
:root {
  --bg: #1e1e1e;
  --bg-soft: #2d2d2d;
  --surface: #2d2d2d;
  --line: #3a3a3a;
  --line-strong: #4d4d4d;
  --text: #dadada;
  --strong: #f2f2f2;
  --muted: #9c9c9c;
  --faint: #6b6b6b;

  --green: #22b77a;
  --green-dark: #148a5a;
  --green-soft: #1d3a2d;
  --green-text: #5ad8a2;
  --red: #ee5d62;
  --red-dark: #b83d43;
  --red-soft: #3d2426;
  --red-text: #ff8d91;
  --blue: #4db4f5;
  --blue-soft: #22323c;
  --blue-line: #2d6f96;
  --gold: #f4b400;
  --gold-dark: #c98f00;
  --orange: #ff8a1f;
  --node-grey: #3a3a3a;
  --node-grey-dark: #262626;
  --cream: #efe8d6;
  --char: #3a3936;

  --font: "FreeMono", "Courier New", monospace;
  --brand: "Red Hat Mono", ui-monospace, Menlo, monospace;
  --flag-red: #ee1c25; /* the red of the Chinese flag */
  --zh: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "Noto Serif CJK SC", serif;
  --zh-serif: var(--zh);
  color-scheme: dark;
}

/* Light theme (Profile → Settings → Light theme, the user's wish 2026-10-12): the same app with dark text on a light
   background. The calendar's study-day colours and the cream word tiles stay as they are. */
:root[data-theme="light"] {
  --bg: #f6f5f1;
  --bg-soft: #ecebe6;
  --surface: #ffffff;
  --line: #dfddd6;
  --line-strong: #c8c5bc;
  --text: #2b2b2b;
  --strong: #111111;
  --muted: #66645f;
  --faint: #9a978f;

  --green-soft: #dcf3e7;
  --green-text: #11804f;
  --red-soft: #fbe3e4;
  --red-text: #c0363c;
  --blue-soft: #e2f1fb;
  --blue-line: #8ac5ea;
  --node-grey: #e3e1db;
  --node-grey-dark: #c8c5bc;
  color-scheme: light;
}
:root[data-theme="light"] .pick-unit.suggested { background: rgba(0, 0, 0, .03); }
:root[data-theme="light"] .kbd-key { background: #fff; box-shadow: 0 2px 0 rgba(0, 0, 0, .18); }

/* unit colours: --u fill, --u-dark 3D edge */
.c-jade { --u: #16a36b; --u-dark: #0f7f53; }
.c-violet { --u: #8b5cf6; --u-dark: #6a3fd6; }
.c-sky { --u: #1a8fd6; --u-dark: #116da6; }
.c-orange { --u: #e8740c; --u-dark: #b95a05; }
.c-rose { --u: #dc3f78; --u-dark: #ad2a5a; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  font-synthesis: none; /* FreeMono Regular only: no made-up bold or italic */
}
body.in-lesson { overflow: hidden; }
/* the page under a lesson or Conversation: out of the Tab order and VoiceOver's reach */
body.in-lesson .app { visibility: hidden; }
[hidden] { display: none !important; }
h1, h2, h3 { color: var(--strong); margin: 0; line-height: 1.2; }
p { margin: 0; }
[lang="zh-CN"] { font-family: var(--zh); }
.muted { color: var(--muted); }
code { font-size: .88em; background: var(--bg-soft); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }

.i { width: 22px; height: 22px; flex: none; }
.flame { color: var(--faint); }
.combo .flame { color: var(--orange); }

/* ============ buttons ============ */
.btn {
  --b-bg: var(--surface);
  --b-edge: var(--line);
  --b-fg: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 800 14px/1 var(--font); letter-spacing: .06em; text-transform: uppercase;
  padding: 13px 20px; min-height: 48px;
  color: var(--b-fg); background: var(--b-bg);
  border: 2px solid var(--b-edge); border-radius: 14px;
  box-shadow: 0 4px 0 var(--b-edge);
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: transform .06s, box-shadow .06s, filter .15s;
}
.btn .i { width: 18px; height: 18px; }
.btn:hover:not(:disabled) { filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--b-edge); }
.btn.primary { --b-bg: var(--green); --b-edge: var(--green-dark); --b-fg: #fff; border-color: var(--green); }
.btn.danger { --b-bg: var(--red); --b-edge: var(--red-dark); --b-fg: #fff; border-color: var(--red); }
.btn.danger-link { background: none; border-color: transparent; box-shadow: none; color: var(--red); margin-right: auto; padding-left: 4px; }
.btn.ghost-left { margin-right: auto; }
.btn:disabled { --b-bg: var(--line); --b-edge: var(--line-strong); --b-fg: var(--faint); border-color: var(--line); cursor: default; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 8px 12px; font-size: 12px; border-radius: 12px; box-shadow: 0 3px 0 var(--b-edge); }
.btn.small:active:not(:disabled) { transform: translateY(3px); }
/* Keyboard focus: every button and link shows where you are (Tab, arrow keys) */
button:focus-visible, a:focus-visible, label.btn:focus-visible, select:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.view:focus { outline: none; }
/* While you use the keyboard (html.kb, set in keynav.js) the focused button always shows the ring */
html.kb button:focus, html.kb a:focus, html.kb label.btn:focus, html.kb .switch:focus { outline: 3px solid var(--blue); outline-offset: 2px; }
html.kb .unit-tile:focus { outline-width: 2px; }
html.kb .btn:focus, html.kb .choice:focus, html.kb .tile:focus, html.kb .nav-btn:focus, html.kb .icon-btn:focus { outline-offset: 3px; }
html.kb input:focus, html.kb select:focus, html.kb textarea:focus { border-color: var(--blue); }
.btn:focus-visible, .choice:focus-visible, .tile:focus-visible, .nav-btn:focus-visible, .icon-btn:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 3px;
}
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--faint); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--blue); font: 700 14px var(--font); cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.link-btn:hover { background: var(--bg-soft); }
.link-btn.danger { color: var(--red); }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row.center { justify-content: center; }

/* ============ layout ============ */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.nav {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 14px; border-right: 2px solid var(--line); background: var(--bg);
}
.nav-brand { padding: 4px 10px 24px; font: 300 19px/1.15 var(--brand); letter-spacing: -.01em; color: var(--flag-red); white-space: nowrap; }
.nav-btn {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 14px; border-radius: 0; border: 2px solid transparent;
  background: none; color: var(--muted); cursor: pointer;
  font: 700 16px var(--font); letter-spacing: .06em; text-transform: uppercase; text-align: left;
}
.nav-btn:hover { background: var(--bg-soft); }
.nav-hint { margin-top: auto; align-self: flex-start; padding: 8px 10px; border: 0; background: none; color: var(--faint); font: 400 12px var(--font); text-align: left; cursor: pointer; }
.nav-hint:hover { color: var(--muted); }
/* keyboard shortcuts: the list (press ?) and the keys shown on the page */
.keys { width: 100%; border-collapse: collapse; font-size: 14px; }
.keys td { padding: 7px 0; border-top: 1px solid var(--line); vertical-align: top; }
.keys tr:first-child td { border-top: 0; }
.keys td:first-child { width: 1%; padding-right: 18px; white-space: nowrap; }
.keys-head { font-size: 16px; margin-top: 10px; }
.keys kbd, .nav-hint kbd { display: inline-block; min-width: 24px; padding: 1px 6px; border: 2px solid var(--line); border-radius: 7px; font: 400 12px/1.4 var(--font); color: var(--muted); text-align: center; }
.key-hint { margin: -20px 0 24px; text-align: center; font-size: 13px; color: var(--faint); }
.key-hint.after-choices { margin: 16px 0 0; }
/* The current page looks like a raised button (like "Add words"), with square corners. */
.nav-btn.active { background: var(--surface); border-color: var(--line); box-shadow: 0 4px 0 var(--line); color: var(--muted); }

.main { width: 100%; max-width: 640px; justify-self: center; padding: 0 24px 96px; }
.card { background: var(--surface); border: 2px solid var(--line); border-radius: 18px; padding: 20px; }

.view { display: none; padding-top: 24px; }
.view.active { display: block; }
.view-head { margin-bottom: 22px; }
/* Pinyin and English only at their Tab step (ui.js) */
html:not([data-reveal="py"]) .rv-py, html:not([data-reveal="en"]) .rv-en { display: none !important; }
.reveal-btn[aria-pressed="true"] { border-color: var(--blue); color: var(--blue); }
.reveal-row { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.section-head:has(> .reveal-btn) { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.view-head h1 { font-size: 28px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.view-head p { color: var(--muted); margin-top: 6px; }
.total-box { font-size: 17px; font-weight: 600; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 4px 12px; white-space: nowrap; margin-left: auto; }
/* Practice's cream squares are 56% of their cell, so the title and box come in 22% of a cell to line up with them (4 cells, 3 gaps) */
#view-practice .view-head h1 { padding-inline: calc((100% - 42px) * .055); }
.count { font-size: 15px; background: var(--bg-soft); border: 2px solid var(--line); color: var(--muted); border-radius: 99px; padding: 2px 10px; }
.count:empty { display: none; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; }
.empty.small { padding: 12px; font-size: 14px; }

/* ============ calendar (the start page) ============ */
/* The calendar page may be wider than the others, for two months side by side (sizes come from
   fitCalendar in calendar.js: --month-w a month's width, --day-h a day's height). */
.main.wide { max-width: none; }
/* Words: a wider page when the window is wide enough (the user's wish); the parts above My words keep the usual
   width until there's room to put them side by side (below) */
.main.words-wide { max-width: 1440px; }
.main.words-wide #view-words > .view-head, .main.words-wide #add-form, .main.words-wide #suggest-area { max-width: 592px; margin-left: auto; margin-right: auto; }
/* My words and word suggestions: only the characters, six squares to a row on every screen (the user's wish, 2026-11-18) */
:is(#word-list, #suggest-area) .wl { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; border: 0; }
:is(#word-list, #suggest-area) .wl-row { display: block; padding: 0; border: 0; container-type: inline-size; }
:is(#word-list, #suggest-area) .wl-word { display: block; padding: 0; background: transparent; }
:is(#word-list, #suggest-area) .wl-word:hover { background: transparent; }
:is(#word-list, #suggest-area) .wl-word:focus-visible, html.kb :is(#word-list, #suggest-area) .wl-word:focus { outline-offset: 2px; }
:is(#word-list, #suggest-area) .zh-tile.word { width: 100%; font-size: 52cqw; }
:is(#word-list, #suggest-area) .zh-tile.word.len-2 { font-size: 40cqw; }
:is(#word-list, #suggest-area) .zh-tile.word.len-3 { font-size: 29cqw; }
:is(#word-list, #suggest-area) .zh-tile.word.len-4 { font-size: 22cqw; }
:is(#word-list, #suggest-area) .zh-tile.word.len-5 { font-size: 18cqw; }
:is(#word-list, #suggest-area) .zh-tile.word.len-6 { font-size: 15cqw; }
/* Words of 3 or 4 characters get a box two squares wide, and of 5 or 6 characters three squares wide, all one square
   tall (the user's wishes, 2026-11-19); dense packing fills the gaps they would leave. 100cqw is the box's width, so one
   square is (100cqw - 8px) / 2 in a double box and (100cqw - 16px) / 3 in a triple one. */
:is(#word-list, #suggest-area) .wl { grid-auto-flow: dense; }
:is(#word-list, #suggest-area) .wl-row.wide { grid-column: span 2; }
:is(#word-list, #suggest-area) .wl-row.wide .zh-tile.word { aspect-ratio: auto; height: calc((100cqw - 8px) / 2); }
:is(#word-list, #suggest-area) .wl-row.wide .zh-tile.word.len-3 { font-size: calc((100cqw - 8px) * .25); }
:is(#word-list, #suggest-area) .wl-row.wide .zh-tile.word.len-4 { font-size: calc((100cqw - 8px) * .21); }
:is(#word-list, #suggest-area) .wl-row.wide .zh-tile.word.len-5 { font-size: calc((100cqw - 8px) * .17); }
:is(#word-list, #suggest-area) .wl-row.wide .zh-tile.word.len-6 { font-size: calc((100cqw - 8px) * .145); }
:is(#word-list, #suggest-area) .wl-row.triple { grid-column: span 3; }
:is(#word-list, #suggest-area) .wl-row.triple .zh-tile.word { height: calc((100cqw - 16px) / 3); }
:is(#word-list, #suggest-area) .wl-row.triple .zh-tile.word.len-5 { font-size: calc((100cqw - 16px) * .17); }
:is(#word-list, #suggest-area) .wl-row.triple .zh-tile.word.len-6 { font-size: calc((100cqw - 16px) * .145); }
.main.words-wide #word-list { max-width: 592px; margin-left: auto; margin-right: auto; }
/* A wide window (the Mac app): Add a word and Word suggestions side by side, and My words fills the whole width with
   as many squares as fit (the user's wish, 2026-11-19) */
@media (min-width: 1150px) {
  .main.words-wide #view-words.active { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 32px; align-items: start; }
  .main.words-wide #view-words > * { grid-column: 1 / -1; }
  .main.words-wide #view-words > .view-head { max-width: none; margin-left: 0; }
  .main.words-wide #view-words > #add-form { grid-column: 1; max-width: none; margin: 0; }
  /* Side by side, Word suggestions is as tall as Add a word and scrolls, so Show more units doesn't push My words down
     (the user's wish, 2026-11-19): height 0 keeps it from making the row taller, min-height fills the row */
  .main.words-wide #view-words > #suggest-area { grid-column: 2; max-width: none; margin: 0; align-self: stretch; height: 0; min-height: 100%; overflow-y: auto; }
  /* Side by side, the two boxes stay at the top while My words scrolls under them (the user's wish, 2026-11-19); the
     page-coloured edge covers the gap between them, so words don't show through */
  .main.words-wide #view-words > :is(#add-form, #suggest-area) { position: sticky; top: 16px; z-index: 5; box-shadow: 0 0 0 16px var(--bg); }
  .main.words-wide #view-words > #suggest-area { background: var(--bg); }
  .main.words-wide #word-list { max-width: none; margin: 0; }
  /* the same square size in both, so suggestions and your words look alike (the user's wish, 2026-11-19) */
  .main.words-wide :is(#word-list, #suggest-area) .wl { grid-template-columns: repeat(auto-fill, 84px); }
}
.cal { position: relative; width: var(--month-w, 100%); margin: 0 auto; }
.cal.side { display: flex; gap: var(--between); width: calc(2 * var(--month-w) + var(--between)); }
.cal.side .cal-month { width: var(--month-w); flex: none; }
.cal.stack .cal-month + .cal-month { margin-top: var(--between); }
.cal.one .cal-month.earlier { display: none; }
.cal-title { height: 44px; margin-bottom: 18px; font-size: 28px; font-weight: 800; line-height: 44px; white-space: nowrap; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-week { margin-bottom: 8px; }
.cal-week span { text-align: center; font-size: 13px; line-height: 19px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
/* A day is a square (on a phone it may be shorter, so two months fit); the numbers scale with it (cqw = 1% of its width). */
.cal-day {
  container-type: inline-size; height: var(--day-h); min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--line); color: var(--muted);
}
.cal-day.out { border: 0; }
.cal-day.future { border-style: dashed; color: var(--faint); }
/* A day you studied: white on a deep red-brown (#58271D, the user's choice) */
.cal-day.used { background: #58271d; color: #fff; border-color: transparent; }
/* Today: a thin brick-red frame (#7A3629, the user's choice), around the red-brown when you've studied */
.cal-day.today { border: 2px solid #7a3629; color: var(--strong); }
.cal-day.used.today { color: #fff; }
/* XP tiers, brick to coral (the user's choice 2026-11-05): 50–99 XP brick red, 100+ coral with dark text */
.cal-day.used.xp-mid { background: #b0442e; }
.cal-day.used.xp-high { background: #f28c6e; color: #3a1810; }
.cal-num { font-size: clamp(13px, 27cqw, 22px); line-height: 1; }
.cal-xp { margin-top: 6cqw; font-size: clamp(9px, 15cqw, 12px); line-height: 1; white-space: nowrap; }

/* a part of a page under its own heading (Lessons on Practice; suggestions and your words on Words) */
.section-head { margin: 34px 0 16px; }
.section-head h2 { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.section-head p { color: var(--muted); margin-top: 6px; }
/* Word suggestions in an outlined box like Add a word's (the user's wish, 2026-11-19) */
.suggest-area { border: 2px solid var(--line); border-radius: 18px; padding: 20px; margin-bottom: 24px; }
.suggest-area .section-head { margin-top: 0; }
.suggest-area .section-head h2 { font-size: 19px; }
.sg-buttons { display: flex; gap: 8px; flex: none; }
/* Lessons on the Practice page: a title as big as the page's own (the user's wish) */
.section-head.big { margin: 40px 0 22px; }
.section-head.big h2 { font-size: 28px; }
.suggest-area .row.center { margin-top: -8px; }

/* ============ learn: unit grid ============ */
.learn-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.learn-head .btn { flex: none; }

/* dragging a unit to another square */
#lessons-grid .unit-tile[data-unit], #practice-grid .unit-tile[data-mode] { user-select: none; -webkit-user-select: none; -webkit-user-drag: none; touch-action: pan-y; }
.unit-tile.dragging { opacity: .25; }
.drag-ghost { position: fixed; z-index: 90; pointer-events: none; transform: translate(-50%, -50%) scale(1.05); opacity: .92; }
.unit-cell.drop-here .unit-tile.empty { border: 1px solid var(--strong); }
.unit-cell.drop-here .unit-tile:not(.empty) .zh-tile { outline: 1px dashed var(--strong); outline-offset: 4px; }
.unit-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
/* The cell sets the square size; everything inside scales with it (cqw = 1% of the cell width). */
.unit-cell { container-type: inline-size; aspect-ratio: 1; min-width: 0; }
.unit-tile {
  position: relative; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3cqw;
  padding: 2cqw 2cqw 3cqw;
  font: inherit; color: var(--strong); text-align: center;
  background: none; border: 0; cursor: pointer;
}
.unit-tile:hover .zh-tile { transform: translateY(-2px); box-shadow: inset 0 0 0 1px rgba(80, 64, 30, .1), 0 6px 14px rgba(0, 0, 0, .12); }
.unit-tile:active .zh-tile { transform: translateY(0); }
.unit-tile:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
/* The unit's topic in Chinese: dark grey characters on a cream square with sharp corners. */
.zh-tile {
  display: grid; place-items: center; flex: none; width: 56cqw; aspect-ratio: 1; border-radius: 0;
  background: var(--cream); color: var(--char); box-shadow: inset 0 0 0 1px rgba(80, 64, 30, .1);
  font: 600 29cqw/1 var(--zh-serif); white-space: nowrap; transition: transform .12s, box-shadow .12s;
  position: relative;
}
/* On Practice: the letter that opens the square from the keyboard, small in its top right corner */
.tile-key { position: absolute; top: 3cqw; right: 3.5cqw; font: 700 max(10px, 8.5cqw)/1 var(--font); color: rgba(40, 32, 16, .85); }
.zh-tile.len-2 { font-size: 22.5cqw; }
.zh-tile.len-3 { font-size: 16.4cqw; }
.zh-tile.len-4 { font-size: 12.4cqw; }
.zh-tile.len-5 { font-size: 9.6cqw; }
.zh-tile.len-6 { font-size: 8cqw; }
.zh-tile.fixed { width: 64px; font-size: 38px; }
.zh-tile.fixed.len-2 { font-size: 27px; }
.zh-tile.fixed.len-3 { font-size: 19px; }
.zh-tile.fixed.len-4 { font-size: 14.5px; }
button.zh-tile { border: 0; padding: 0; cursor: pointer; }
.zh-tile.word { width: 56px; font-size: 30px; }
.zh-tile.word.len-2 { font-size: 23px; }
.zh-tile.word.len-3 { font-size: 16px; }
.zh-tile.word.len-4 { font-size: 12.5px; }
.zh-tile.word.len-5 { font-size: 10px; }
.zh-tile.word.len-6 { font-size: 8.5px; }
.zh-tile.mini { width: 30px; font-size: 15px; }
.zh-tile.mini.len-2 { font-size: 12px; }
.zh-tile.mini.len-3 { font-size: 8.5px; }
.zh-tile.mini.len-4 { font-size: 6.5px; }
/* Room for two lines on every name keeps the squares in a row lined up. */
.tile-name {
  max-width: 100%; min-height: 2.24em; font-weight: 800; font-size: clamp(11px, 10.5cqw, 15px); line-height: 1.12;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.tile-bar { flex: none; width: 56cqw; height: max(3px, 2.5cqw); border-radius: 99px; background: var(--line); overflow: hidden; }
.tile-bar i { display: block; height: 100%; border-radius: 99px; background: var(--bar, var(--u)); }
/* Empty squares (where a unit can go, or the free spot among the practice squares) are invisible
   (the user's wish) until you point at one, reach it with the keyboard or drag something; with no
   units at all the Lessons squares show, to start from. */
.unit-tile.empty { background: none; border: 1px dashed transparent; border-radius: 0; color: var(--muted); font-size: 30px; }
body.dragging-tiles .unit-tile.empty, .lessons-grid.blank .unit-tile.empty { border-color: var(--line-strong); }
.unit-tile.empty:hover, .unit-tile.empty:focus-visible, html.kb .unit-tile.empty:focus { border-color: var(--muted); }
.unit-tile.empty:hover::after, .unit-tile.empty:focus-visible::after, html.kb .unit-tile.empty:focus::after { content: "+"; }
.unit-tile.empty.spot { display: block; pointer-events: none; }

/* the unit's lessons (dialog) */
.sheet-title { display: flex; align-items: center; gap: 14px; }
.sheet-title small { display: block; margin-top: 3px; font-size: 14px; font-weight: 700; color: var(--muted); }
/* one column that is never wider than the dialog (the nowrap words line used to widen it, so the sheet scrolled sideways on a phone) */
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.lesson-sq { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; aspect-ratio: 1; padding: 0; border: 0; border-radius: 12px; color: #fff; background: var(--u); box-shadow: 0 3px 0 var(--u-dark); font: 800 16px/1 var(--font); cursor: pointer; }
.lesson-sq .i { width: 18px; height: 18px; }
.lesson-sq.complete .i { stroke-width: 3.4; }
.lesson-sq.upcoming, .lesson-sq.review { background: var(--node-grey); box-shadow: 0 3px 0 var(--node-grey-dark); color: var(--faint); }
.lesson-sq.mastered, .lesson-sq.review.ready { background: var(--gold); box-shadow: 0 3px 0 var(--gold-dark); color: #fff; }
.lesson-sq.current { outline: 3px solid var(--u); outline-offset: 2px; }
.lesson-sq:focus-visible, html.kb .lesson-sq:focus { outline: 3px solid var(--blue); outline-offset: 2px; }
.lesson-sq .i { flex: none; }
.lesson-sheet .ld-words { font-size: 22px; line-height: 1.5; color: var(--strong); margin: 0 0 6px; }
.zh-edit { display: flex; align-items: flex-start; gap: 14px; }
.zh-edit .f { flex: 1; }
#unit-zh { font-family: var(--zh-serif); font-size: 18px; }

/* ============ practice (same grid as Learn) ============ */
.practice-tile .tile-name { min-height: 0; -webkit-line-clamp: 1; }
.tile-sub { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(10px, 9cqw, 13px); color: var(--muted); }
/* a shorter wording on a phone, where the long one was cut off (the Draw square: see DRAW_SUB in app.js) */
.tile-sub .narrow { display: none; }
.unit-tile:disabled, .unit-tile.locked { cursor: default; opacity: .35; }
.unit-tile:disabled:hover .zh-tile, .unit-tile.locked:hover .zh-tile { transform: none; box-shadow: inset 0 0 0 1px rgba(80, 64, 30, .1); }

/* ============ words ============ */
.add-card { margin-bottom: 24px; }
.add-card h2 { font-size: 19px; font-weight: 800; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-bottom: 18px; }
.span2 { grid-column: span 2; }
.f { display: flex; flex-direction: column; gap: 6px; }
.f > span { font-size: 14px; font-weight: 800; color: var(--strong); }
.f small { color: var(--muted); font-size: 13px; min-height: 1.2em; }
input[type="text"], input:not([type]), input[type="search"], select, textarea {
  width: 100%; font: 600 16px var(--font); color: var(--strong);
  background: var(--bg-soft); border: 2px solid var(--line); border-radius: 12px;
  padding: 11px 14px;
}
textarea { resize: vertical; font-family: var(--zh), var(--font); line-height: 1.6; }
select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue-line); background: var(--surface); }
/* where dragged characters will land (see pressBox in drag.js) */
input.drop-here, textarea.drop-here { border-color: var(--blue); }
.box-mirror { position: absolute; left: -10000px; top: 0; padding: 0; border: 0; visibility: hidden; pointer-events: none; overflow-wrap: break-word; }
#f-hanzi, #e-hanzi { font-family: var(--zh), var(--font); font-size: 18px; }
.small { font-size: 13px; }

/* word lookup while adding */
.readings { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: -6px; }
.readings-label { font-size: 13px; font-weight: 800; color: var(--muted); margin-right: 2px; }
.reading { border: 2px solid var(--line); background: var(--surface); border-radius: 10px; padding: 5px 10px; font: 600 13px var(--font); color: var(--text); cursor: pointer; text-align: left; }
.reading b { color: var(--blue); }
.reading.on { border-color: var(--blue-line); background: var(--blue-soft); }
.example-box { border: 2px dashed var(--line); border-radius: 14px; padding: 12px 14px; background: var(--bg-soft); }
.example-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; font-size: 13px; font-weight: 800; color: var(--muted); }
.ex-zh { font-size: 20px; line-height: 1.4; color: var(--strong); }
.ex-zh b { color: var(--blue); font-weight: 600; }
.ex-py { font-size: 14px; font-weight: 600; color: var(--blue); }
.ex-en { font-size: 14px; color: var(--muted); }
.wl-ex { margin-top: 2px; font-size: 13px; color: var(--muted); }
.wl-ex span { color: var(--text); }
/* the example's Chinese, big enough to read (the user's wish) */
.wl-ex [lang="zh-CN"] { font-size: 18px; line-height: 1.5; }
.credits { margin: 4px 2px 0; font-size: 13px; color: var(--muted); }
.credits a { color: var(--blue); }

.list-tools { margin-bottom: 16px; }
.wl-unit { margin-bottom: 22px; }
.wl-head { display: flex; align-items: center; gap: 10px; padding: 0 2px 10px; }
.wl-head h3 { font-size: 17px; }
.wl-head .muted { font-size: 14px; white-space: nowrap; }
.spacer { flex: 1; }
.wl { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); }
.wl-row { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-top: 1px solid var(--line); }
.wl-row:first-child { border-top: 0; }
.wl-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.wl-py { color: var(--blue); font-size: 14px; }
.wl-en { color: var(--text); overflow-wrap: anywhere; }
.w-bar { width: 56px; height: 3px; margin-top: 6px; }
.wl-row:hover button.zh-tile { box-shadow: inset 0 0 0 1px rgba(80, 64, 30, .1), 0 4px 10px rgba(0, 0, 0, .25); }
/* My words: a word is one button (it opens its menu): the square, then pinyin and meaning, no taller than the square
   (the user's wish): a meaning that doesn't fit ends in … and shows in full in the menu */
.wl-word { display: flex; align-items: center; gap: 14px; width: 100%; padding: 8px 12px; border: 0; border-radius: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.wl-word:hover { background: var(--bg-soft); }
.wl-word:hover .zh-tile { box-shadow: inset 0 0 0 1px rgba(80, 64, 30, .1), 0 4px 10px rgba(0, 0, 0, .25); }
.wl-word:focus-visible, html.kb .wl-word:focus { outline: 3px solid var(--blue); outline-offset: -3px; }
.wl-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; line-height: 18px; }

/* the word's menu (openWordMenu in app.js) */

/* ============ word suggestion ============ */
.sg-unit { margin-bottom: 28px; }
.pick-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); max-height: 45vh; overflow: auto; }
.pick-list li + li { border-top: 1px solid var(--line); }
.pick-unit { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.pick-unit:hover { background: var(--bg-soft); }
.pick-unit.suggested { background: rgba(255, 255, 255, .03); }
.pick-name { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--strong); }
.pick-unit .muted { font-size: 13px; }

/* ============ practice: Sentences (short or long) ============ */
.kind-options { display: grid; gap: 10px; }
.kind-opt { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; text-align: left; border: 1px solid var(--line); background: none; cursor: pointer; font: inherit; color: var(--muted); }
.kind-opt:hover:not(:disabled) { background: var(--bg-soft); }
.kind-opt:disabled { cursor: default; opacity: .55; }
.kind-opt b { color: var(--strong); font-weight: 800; }
.kind-opt span { font-size: 14px; }
.kind-opt .kind-count { color: var(--blue); font-size: 13px; }
.prompt-zh.sentence .prompt-zh-text { flex: 1; }
.prompt-zh.sentence .hz { font-size: 30px; }

/* ============ profile ============ */
#view-profile .card { margin-bottom: 18px; }
#view-profile .card h2 { font-size: 19px; font-weight: 800; margin-bottom: 14px; }
#view-profile .card > .muted { margin-bottom: 16px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 2px solid var(--line); cursor: pointer; }
.toggle-row:first-of-type { border-top: 0; padding-top: 0; }
.toggle-row span { display: flex; flex-direction: column; }
.toggle-row b { color: var(--strong); font-weight: 800; }
.toggle-row small { color: var(--muted); font-size: 14px; }
/* a switch: a round-ended track as high as its round knob (the user's choice) */
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 48px; height: 24px; border-radius: 12px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 0; left: 0; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(24px); }
.switch:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.device-list { list-style: none; margin: 12px 0 16px; padding: 0; border-top: 1px solid var(--line); }
.device { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.device > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.device-tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 1px 6px; }
.device-when { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.view .apple-btn { background: #000; color: #fff; border-color: #000; }
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 2px solid var(--line); font-size: 14px; }


/* ============ square corners and thin lines on the four pages, like the Learn grid ============ */
.view .card, .view .btn, .view input:not(.switch), .view select, .view textarea, .view .count, .view .reading,
.view .example-box, .view .link-btn { border-radius: 0; }
.view .card { border-width: 1px; }
.view .example-box { border-width: 1px; }
.view .toggle-row, .view .danger-zone { border-top-width: 1px; }

/* ============ lesson ============ */
.lesson { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); }
.lesson-top { display: flex; align-items: center; gap: 16px; width: 100%; max-width: 1000px; margin: 0 auto; padding: 20px 20px 8px; padding-top: max(20px, env(safe-area-inset-top)); }
.progress { flex: 1; height: 16px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: var(--green); transition: width .35s ease; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .08), inset 0 4px 0 rgba(255, 255, 255, .25); }
.combo { display: flex; align-items: center; gap: 4px; min-width: 110px; justify-content: flex-end; font-weight: 800; color: var(--orange); font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }
.combo:empty { min-width: 0; }
.lesson-body { flex: 1; overflow-y: auto; padding: 24px 20px 32px; }
.ex { max-width: 600px; margin: 0 auto; animation: ex-in .2s ease-out; }
@keyframes ex-in { from { opacity: 0; transform: translateX(14px); } }
.ex-title { font-size: 26px; font-weight: 800; margin-bottom: 24px; }
.ex-badge { display: inline-block; color: #8b5cf6; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: 14px; margin-bottom: 16px; }
.ex-hint { color: var(--muted); font-size: 14px; margin-top: 10px; }
.ex-hint.kb-hint { color: var(--blue); } /* the wrong keyboard is on (phones can't switch it for you) */

.prompt-zh { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.prompt-zh-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; border: 2px solid var(--line); border-radius: 16px; padding: 12px 18px; position: relative; }
.prompt-zh .hz { font-size: 40px; color: var(--strong); line-height: 1.2; }
.prompt-zh .py { color: var(--muted); font-size: 16px; font-weight: 700; }
.prompt-en { font-size: 24px; font-weight: 800; color: var(--strong); border: 2px solid var(--line); border-radius: 16px; padding: 14px 18px; margin-bottom: 22px; display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.speak-bubble {
  display: grid; place-items: center; width: 64px; height: 64px; flex: none;
  border: 0; border-radius: 18px; background: var(--blue); color: #fff; cursor: pointer;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--blue) 70%, #000);
}
.speak-bubble:active { transform: translateY(4px); box-shadow: none; }
.speak-bubble .i { width: 30px; height: 30px; }
.speak-bubble.big { width: 76px; height: 76px; margin: 0 auto 18px; }

.intro-card { text-align: center; overflow-wrap: anywhere; border: 2px solid var(--line); border-radius: 24px; padding: 32px 20px 28px; box-shadow: 0 4px 0 var(--line); }
.intro-hz { font-size: 72px; color: var(--strong); line-height: 1.15; }
.intro-py { font-size: 24px; color: var(--blue); font-weight: 700; margin-top: 6px; }
.intro-en { font-size: 22px; font-weight: 800; color: var(--strong); margin-top: 10px; }
.intro-ex { max-width: 440px; margin: 20px auto 0; padding-top: 16px; border-top: 2px dashed var(--line); }
.intro-ex .ex-zh { font-size: 22px; }
.intro-ex .link-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; }
.intro-ex .link-btn .i { width: 18px; height: 18px; }

.choices { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; overflow-wrap: anywhere; }
.choices.hz { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
.choice {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 16px; min-height: 58px; text-align: left;
  font: 700 18px var(--font); color: var(--strong);
  background: var(--surface); border: 2px solid var(--line); border-radius: 16px;
  box-shadow: 0 4px 0 var(--line); cursor: pointer;
  transition: transform .06s, box-shadow .06s, background .1s;
}
.choice:hover:not(:disabled) { background: var(--bg-soft); }
.choice:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }
.choice kbd { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border: 2px solid var(--line); border-radius: 9px; font: 800 13px var(--font); color: var(--faint); }
.choices.hz .choice { flex-direction: column; justify-content: center; gap: 4px; padding: 22px 12px 16px; text-align: center; }
.choices.hz .choice kbd { position: absolute; top: 10px; left: 10px; width: 26px; height: 26px; }
.choices.hz .choice-main { max-width: 100%; font-size: 38px; font-weight: 500; line-height: 1.2; }
.choices.hz .choice-main.long { font-size: 28px; }
.choice-sub { font-size: 14px; color: var(--muted); font-weight: 700; }
.choices.py .choice-main { font-size: 20px; }
.choice.selected { background: var(--blue-soft); border-color: var(--blue-line); box-shadow: 0 4px 0 var(--blue-line); color: var(--blue); }
.choice.selected kbd { border-color: var(--blue-line); color: var(--blue); }
.choice.right { background: var(--green-soft); border-color: var(--green); box-shadow: 0 4px 0 var(--green); color: var(--green-text); }
.choice.wrong { background: var(--red-soft); border-color: var(--red); box-shadow: 0 4px 0 var(--red); color: var(--red-text); }
.choice:disabled { cursor: default; }
.choice:disabled:not(.right):not(.wrong) { opacity: .55; }

.listen-row { display: flex; align-items: flex-end; justify-content: center; gap: 18px; margin: 4px 0 32px; }
.listen-btn { display: grid; place-items: center; width: 120px; height: 120px; border: 0; border-radius: 28px; background: var(--blue); color: #fff; cursor: pointer; box-shadow: 0 6px 0 color-mix(in srgb, var(--blue) 70%, #000); }
.listen-btn .i { width: 52px; height: 52px; }
.listen-btn.slow { width: 76px; height: 76px; border-radius: 22px; gap: 0; font: 800 12px var(--font); text-transform: uppercase; letter-spacing: .06em; }
.listen-btn.slow .i { width: 30px; height: 30px; }
.listen-btn:active { transform: translateY(6px); box-shadow: none; }

.answer-input { font-size: 20px !important; padding: 16px 18px !important; border-radius: 16px !important; min-height: 64px; }
.answer-input.right { border-color: var(--green); background: var(--green-soft); color: var(--green-text); }
.answer-input.wrong { border-color: var(--red); background: var(--red-soft); color: var(--red-text); }
/* The answer field has no placeholder; the app draws its cursor, which blinks slowly (user's choice) */
.answer-box { position: relative; }
.answer-box .answer-input { caret-color: transparent; }
.answer-caret {
  position: absolute; left: 0; top: 0; width: 2px; border-radius: 1px; background: var(--strong);
  pointer-events: none; animation: caret-blink 1.6s ease-in-out infinite;
}
.answer-input:disabled ~ .answer-caret { display: none; }
.answer-mirror { position: absolute; left: 0; top: 0; display: block; width: 0; overflow: hidden; visibility: hidden; white-space: pre; pointer-events: none; }
@keyframes caret-blink { 0%, 40% { opacity: 1; } 50%, 90% { opacity: 0; } 100% { opacity: 1; } }

.build-answer {
  display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start;
  min-height: 78px; padding: 10px 4px; margin-bottom: 26px;
  border-top: 2px solid var(--line); border-bottom: 2px solid var(--line);
}
.build-answer.right { border-color: var(--green); }
.build-answer.wrong { border-color: var(--red); }
.build-bank { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.sentence-bank { margin-top: 18px; }
.tile {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-width: 56px; min-height: 56px; padding: 8px 14px;
  font: 500 28px var(--zh); color: var(--strong);
  background: var(--surface); border: 2px solid var(--line); border-radius: 14px;
  box-shadow: 0 4px 0 var(--line); cursor: pointer;
}
.tile kbd { position: absolute; top: 3px; left: 5px; font: 800 10px var(--font); color: var(--faint); }
.tile:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.tile.used { color: transparent; background: var(--line); box-shadow: none; pointer-events: none; }
.tile.used kbd { color: transparent; }
/* a sentence's word tiles can be dragged into the answer field */
.sentence-bank .tile { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y; }
.sentence-bank .tile.dragging, .build-answer .tile.dragging { opacity: .35; }
.build-answer .tile { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
/* a sentence's used tile (an empty box) can be clicked to take its word back out of the field */
.sentence-bank .tile.used { pointer-events: auto; }
.sentence-bank .tile.used kbd { color: var(--faint); }
/* no highlighted text in a sentence's field (user's choice; the app also shrinks any selection) */
.sentence-answer .answer-input::selection { background: transparent; }
.tile.drag-ghost { position: fixed; margin: 0; }
/* moving a word or character about (drag.js): the answer as bubbles over it, the carried one large
   and its neighbours half as large, like the Dock on a Mac */
.bubble-row {
  position: fixed; z-index: 90; box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: center; align-content: center;
  gap: 6px; padding: 6px; background: var(--bg); border: 2px solid var(--blue-line); border-radius: 14px; pointer-events: none;
}
.bubble {
  --m: 1; display: inline-flex; align-items: center; justify-content: center; min-width: 1.4em;
  padding: .12em .3em; font: 500 calc(var(--base, 24px) * var(--m)) var(--zh); line-height: 1.2; color: var(--strong);
  background: var(--surface); border: 2px solid var(--line); border-radius: 12px; transition: font-size .12s ease-out;
}
.bubble.carried { border-color: var(--blue); background: var(--blue-soft); }
.bubble-row.away .bubble.carried { opacity: .35; }
.sentence-answer .answer-input { -webkit-touch-callout: none; }
/* characters from a text box ride above the pointer, so the cursor where they will land stays in sight */
.tile.chars-ghost { transform: translate(-50%, calc(-100% - 12px)); max-width: 60vw; overflow: hidden; white-space: nowrap; }

.match-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.match-col { display: flex; flex-direction: column; gap: 12px; }
.tile.match { width: 100%; justify-content: center; min-height: 64px; font: 700 17px var(--font); text-align: center; overflow-wrap: anywhere; }
.tile.match.hz { font: 500 28px var(--zh); }
.tile.match kbd { top: 6px; left: 8px; }
.tile.selected { background: var(--blue-soft); border-color: var(--blue-line); box-shadow: 0 4px 0 var(--blue-line); color: var(--blue); }
.tile.right { background: var(--green-soft); border-color: var(--green); box-shadow: 0 4px 0 var(--green); color: var(--green-text); animation: matched .45s forwards; }
.tile.wrong { background: var(--red-soft); border-color: var(--red); box-shadow: 0 4px 0 var(--red); color: var(--red-text); animation: shake .35s; }
@keyframes matched { 60% { opacity: 1; } to { opacity: .35; background: var(--surface); border-color: var(--line); box-shadow: 0 4px 0 var(--line); color: var(--faint); } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* rating the word on screen: easy / average / difficult / not interesting */
.lesson-rate {
  max-width: 1000px; margin: 0 auto 14px; padding-bottom: 12px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--strong) 12%, transparent);
}
.rate-label { font-size: 14px; color: var(--muted); }
.rate-label b { color: var(--strong); font-weight: 400; font-size: 17px; }
.rate-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.rate-btn.on { --b-bg: var(--surface); --b-edge: var(--muted); --b-fg: var(--strong); border-color: var(--strong); }
.rate-note { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.wl-tag { flex: none; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wl-row.skipped .zh-tile, .wl-row.skipped .wl-text { opacity: .45; }

/* Draw: writing characters by hand, on a cream square like the tiles, with a 米-shaped guide */
.draw-meaning, .draw-prompt { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 12px; margin: -10px 0 18px; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.draw-prompt { justify-content: flex-start; text-align: left; }
.draw-meaning .speak-bubble, .draw-prompt .speak-bubble { width: 40px; height: 40px; }
.draw-py { color: var(--blue); }
.draw-en { color: var(--strong); font-size: 18px; }
.ex-title .draw-py { color: var(--blue); font-weight: 400; }
.draw-area { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.draw-slots { display: flex; gap: 8px; justify-content: center; }
.draw-slot {
  display: grid; place-items: center; width: 48px; height: 48px; background: var(--cream); color: var(--char);
  font: 600 30px/1 var(--zh-serif); box-shadow: inset 0 0 0 1px rgba(80, 64, 30, .1);
}
.draw-slot.blank { background: transparent; border: 1px dashed var(--muted); box-shadow: none; }
.draw-slot.now { outline: 2px solid #ab9838; outline-offset: 3px; }
.draw-box {
  position: relative; width: min(340px, 100%, 42vh); min-width: 200px; aspect-ratio: 1; max-width: 100%;
  background: var(--cream) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M50 0V100M0 50H100M0 0L100 100M100 0L0 100' stroke='%23c4b798' stroke-width='.45' stroke-dasharray='1.6 1.6' fill='none'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  box-shadow: inset 0 0 0 1px rgba(80, 64, 30, .12);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair;
}
.draw-box svg { display: block; touch-action: none; }
/* Touches always land on the <svg> itself, which Hanzi Writer keeps. It replaces the paths inside
   (on a resize, or the next character), and a touch that began on a removed path was lost. */
.draw-box svg * { pointer-events: none; }
.draw-tools { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 14px; min-height: 36px; }
.draw-note { color: var(--muted); font-size: 14px; }

/* footer: check / feedback */
.lesson-foot { border-top: 2px solid var(--line); background: var(--bg); padding: 18px 20px; padding-bottom: max(18px, env(safe-area-inset-bottom)); transition: background .15s; }
.lesson-foot.correct { background: var(--green-soft); border-top-color: transparent; }
.lesson-foot.wrong { background: var(--red-soft); border-top-color: transparent; }
.foot-inner { max-width: 1000px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 56px; }
.foot-actions { display: flex; gap: 12px; margin-left: auto; }
.foot-actions .btn { min-width: 150px; }
.feedback { display: flex; align-items: center; gap: 16px; min-width: 0; overflow-wrap: anywhere; }
/* On larger windows Skip and Check sit right under the question, in its 600px column, and the
   space that's left goes below them. When a question is taller than the window it scrolls above them. */
@media (min-width: 701px) {
  .lesson-body { flex: 0 1 auto; min-height: 0; padding-bottom: 20px; }
  .lesson::after { content: ""; flex: 1 0 20px; }
  .lesson-foot { width: min(100% - 40px, 640px); margin: 0 auto; border: 2px solid var(--line); }
  .lesson-foot.correct, .lesson-foot.wrong { border-color: transparent; }
  .foot-inner, .lesson-rate { max-width: none; }
  .foot-actions .btn { min-width: 130px; }
}
.feedback:empty { display: none; }
.fb-icon { display: grid; place-items: center; width: 64px; height: 64px; flex: none; border-radius: 50%; background: var(--surface); }
.fb-icon .i { width: 36px; height: 36px; stroke-width: 3.4; }
.correct .fb-icon { color: var(--green); }
.wrong .fb-icon { color: var(--red); }
.fb-title { font-size: 22px; font-weight: 800; }
.correct .fb-title, .correct .fb-text { color: var(--green-text); }
.wrong .fb-title, .wrong .fb-text { color: var(--red-text); }
.fb-answer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 2px; font-size: 17px; }
.fb-label { font-weight: 800; }
.fb-hz { font-size: 24px; font-weight: 600; }
.fb-py { font-weight: 700; }
.fb-note { font-size: 14px; margin-top: 4px; opacity: .9; }

.finish { min-height: 100%; display: grid; place-items: center; animation: ex-in .25s ease-out; }
.done-text { font: 400 clamp(56px, 12vw, 96px)/1 var(--font); color: var(--strong); text-align: center; }
/* under "Done" when the lesson wasn't passed: the score, and the offer to do it again (the Redo button) */
.finish-note { margin-top: 22px; text-align: center; color: var(--muted); font-size: 16px; }

/* ============ loading online (claude.ai) ============ */
.boot { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; background: var(--bg); color: var(--muted); }

/* ============ dialogs & toast ============ */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(10, 16, 20, .45); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
/* (dvh: in Safari on a phone 100vh is taller than what shows between its bars, so a tall dialog's top
   and bottom, with its buttons, were out of reach; where dvh isn't known the line before it counts) */
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; overflow-wrap: anywhere; background: var(--surface); border-radius: 22px; padding: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: pop-in .18s ease-out; }
.modal h2 { font-size: 22px; font-weight: 800; margin-bottom: 16px; }
.word-sheet h2 { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.word-sheet h2 .reveal-btn { flex: none; margin-top: 6px; }
.word-sheet h2 [lang="zh-CN"] { font: 600 44px/1.15 var(--zh-serif); color: var(--strong); }
.word-sheet .wd-line { display: flex; align-items: baseline; gap: 10px; margin: 0; }
.word-sheet h2 .wd-side { flex: 1; min-width: 0; align-self: center; font-weight: 400; }
.word-sheet .wd-py { color: var(--blue); font-size: 18px; }
/* at most two lines, so the header stays as tall as the characters whichever is shown */
.word-sheet .wd-en { font-size: 15px; line-height: 1.25; color: var(--text); overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.word-sheet .w-bar { display: block; width: 120px; height: 5px; margin: 0; }
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.modal-body .form-grid { margin-bottom: 0; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.gb { list-style: none; margin: 0; padding: 0; }
.gb-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 2px solid var(--line); }
.gb-row:first-child { border-top: 0; }
.gb-hz { font-size: 26px; color: var(--strong); min-width: 70px; }
.gb-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.gb-py { color: var(--blue); font-weight: 700; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100; transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--strong); color: var(--bg); font-weight: 700; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ smaller screens ============ */
@media (max-width: 1150px) {
  .app { grid-template-columns: 170px minmax(0, 1fr); }
  .nav { padding: 22px 10px; }
  .nav-brand { padding: 4px 10px 22px; font-size: 18px; white-space: normal; }
  .nav-btn { padding: 10px 12px; }
}

@media (max-width: 700px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 30; height: auto;
    flex-direction: row; justify-content: space-around; padding: 6px 8px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    border-right: 0; border-top: 2px solid var(--line);
  }
  .nav-brand, .nav-hint, .key-hint { display: none; }
  /* four big tabs (the user's wish) */
  .nav { padding: 8px 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); gap: 6px; }
  .nav-btn { flex: 1 1 0; min-width: 0; justify-content: center; min-height: 54px; padding: 10px 2px; font-size: 14px; letter-spacing: .02em; line-height: 1.15; text-align: center; }
  .main { padding: 0 16px 130px; }
  /* two months, one above the other (fitCalendar sets their size) */
  .cal-title { height: 38px; margin-bottom: 14px; font-size: 22px; line-height: 38px; }
  .view { padding-top: max(20px, env(safe-area-inset-top)); }
  .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .unit-grid { gap: 8px; }
  #view-practice .view-head h1 { padding-inline: calc((100% - 24px) * .055); }
  .total-box { font-size: 14px; padding: 3px 9px; border-radius: 10px; }
  .tile-sub .wide { display: none; }
  .tile-sub .narrow { display: inline; }
  .cal-week, .cal-grid { gap: 6px; }
  .cal-week { margin-bottom: 6px; }
  .cal-week span { font-size: 11px; line-height: 16px; letter-spacing: 0; }
  .learn-head { flex-direction: column; align-items: flex-start; }
  /* condensed words (the user's wish): a small square, pinyin and meaning on one line, small buttons below
     (word suggestions); in My words the text stays no taller than the square */
  .wl-row { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 6px 12px; padding: 8px 10px; }
  .wl-row .zh-tile.word { grid-row: span 2; align-self: start; width: 44px; font-size: 24px; }
  .wl-row .zh-tile.word.len-2 { font-size: 18px; }
  .wl-row .zh-tile.word.len-3 { font-size: 13px; }
  .wl-row .zh-tile.word.len-4 { font-size: 10px; }
  .wl-row .zh-tile.word.len-5, .wl-row .zh-tile.word.len-6 { font-size: 8px; }
  .wl-text { flex-direction: row; align-items: baseline; gap: 8px; min-height: 22px; font-size: 14px; }
  .wl-py { order: 1; flex: none; font-size: 13px; }
  .wl-en { order: 3; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wl-word { gap: 12px; padding: 7px 10px; }
  .wl-line { line-height: 16px; }
  .wl-tag { order: 2; flex: none; font-size: 10px; } /* after the pinyin */
  .wl-head { flex-wrap: wrap; row-gap: 4px; }
  .lesson-top { padding: 14px 16px 4px; padding-top: max(14px, env(safe-area-inset-top)); gap: 10px; }
  .combo { min-width: 0; }
  .lesson-body { padding: 18px 16px 24px; }
  .ex-title { font-size: 22px; margin-bottom: 18px; }
  .choice kbd, .tile kbd, .tile-key { display: none; }
  .foot-inner { flex-direction: column; align-items: stretch; gap: 14px; }
  .rate-buttons { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin-left: 0; }
  .foot-actions { margin-left: 0; }
  .foot-actions .btn { flex: 1; min-width: 0; }
  .fb-icon { width: 44px; height: 44px; }
  .fb-icon .i { width: 26px; height: 26px; }
  .fb-title { font-size: 19px; }
  .listen-btn { width: 100px; height: 100px; }
  /* a 4-character word stays on one line in the 2 narrow answer squares (320px-wide phones) */
  .choices.hz .choice { padding-left: 6px; padding-right: 6px; }
}

/* ============ no sideways scrolling on a phone ============ */
/* A word too long for its line breaks instead of sticking out of its box */
body { overflow-wrap: break-word; }
/* Anything still too wide is cut off at the window's edge instead of letting the page pan sideways
   (clip, unlike hidden, makes no scroll box: the sidebar stays sticky and focus() can't scroll it) */
.app { overflow-x: clip; }
/* The lesson, the dialogs and the unit list only ever scroll up and down */
.lesson-body, .modal, .pick-list { overflow-x: hidden; }
/* No double-tap zoom (after which the whole screen pans sideways); pinch-zoom still works. WebKit
   starts afresh at each scroll box, so those get it too. The draw box keeps touch-action: none and the
   draggable squares and word tiles keep pan-y (the strictest value along the way wins). */
html, .lesson-body, .modal, .pick-list { touch-action: manipulation; }

/* Autoscroll (scroll-wheel press): the marker where it started, and the cursor shows the direction.
   z-index: above lessons (50), dialogs (80), the drag ghost (90) and toasts (100); below .boot (120). */
.autoscroll-dot {
  position: fixed; z-index: 110; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  display: grid; place-items: center; border-radius: 50%; pointer-events: none;
  background: var(--surface); color: var(--strong); border: 2px solid var(--line-strong);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
html[data-autoscroll], html[data-autoscroll] * { cursor: ns-resize !important; user-select: none !important; -webkit-user-select: none !important; }
html[data-autoscroll="up"], html[data-autoscroll="up"] * { cursor: n-resize !important; }
html[data-autoscroll="down"], html[data-autoscroll="down"] * { cursor: s-resize !important; }
/* ============ on-screen keyboard (lessons on phones and tablets, js/keyboard.js) ============ */
/* It sits above the footer (Skip / Check), in the lesson's column; the footer keeps the home-bar inset. */
.kbd {
  flex: none; width: 100%; padding: 6px max(3px, env(safe-area-inset-right)) 8px max(3px, env(safe-area-inset-left));
  background: var(--bg-soft); border-top: 2px solid var(--line);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  --key-h: clamp(38px, 6.2vh, 46px);
}
.kbd[hidden] { display: none; }
.kbd-bar { display: flex; align-items: center; gap: 6px; height: 44px; margin: 0 2px 6px; }
.kbd-bar[hidden] { display: none; }
.kbd-typed { flex: none; max-width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--blue); font: 16px var(--font); }
.kbd-typed:empty { display: none; }
.kbd-cands { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; overscroll-behavior: contain; touch-action: pan-x; }
.kbd-cands::-webkit-scrollbar { display: none; }
.kbd-note { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbd-cand {
  flex: none; min-width: 44px; height: 40px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--strong); font: 400 22px var(--zh); cursor: pointer;
}
.kbd-cand.first { background: var(--blue-soft); color: var(--blue); }
.kbd-cand.down { background: var(--line-strong); }
.kbd-more { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.kbd-more svg, .kbd-key svg { width: 22px; height: 22px; }
/* 20 narrow columns: a letter takes 2, so the middle row (9 letters) starts half a key in */
.kbd-keys { display: grid; gap: 9px; }
.kbd-row { display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 0 5px; }
.kbd-row > * { grid-column: span 2; }
.kbd-row.r2 > :first-child { grid-column: 2 / span 2; }
.kbd-row > .w2 { grid-column: span 2; }
.kbd-row > .w3 { grid-column: span 3; }
.kbd-row > .w6 { grid-column: span 6; }
.kbd-row > .w9 { grid-column: span 9; }
.kbd-row > .w11 { grid-column: span 11; }
.kbd-key {
  display: grid; place-items: center; min-width: 0; height: var(--key-h); padding: 0; border: 0; border-radius: 7px;
  background: var(--line-strong); box-shadow: 0 2px 0 rgba(0, 0, 0, .45); color: var(--strong);
  font: 400 21px var(--font); text-transform: none; cursor: pointer;
}
.kbd-key.down { background: var(--faint); transform: translateY(1px); box-shadow: none; }
.kbd-fn { background: var(--line); color: var(--text); }
.kbd-fn.on { background: var(--strong); color: var(--bg); }
.kbd-space { font-size: 15px; color: var(--text); }
.kbd-space span { font: 400 19px var(--zh); color: var(--strong); }
.kbd-enter { background: var(--green); box-shadow: 0 2px 0 var(--green-dark); color: #fff; font: 700 15px var(--font); text-transform: uppercase; letter-spacing: .04em; }
.kbd-enter:disabled { background: var(--line); box-shadow: none; color: var(--faint); }
/* all the candidates, where the keys are */
.kbd-grid { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; height: calc(var(--key-h) * 4 + 27px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.kbd-grid .kbd-cand { background: var(--surface); }
.kbd-grid .kbd-cand.first { background: var(--blue-soft); }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .kbd-key.down { transform: none; } }
/* larger windows (tablets): as wide as the question, right above Skip and Check */
@media (min-width: 701px) {
  .kbd { width: min(100% - 40px, 640px); margin: 0 auto; border: 2px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; }
  .kbd-key { height: 50px; }
}
/* short screens (iPhone SE): less room around the question while the keyboard is up */
@media (max-height: 700px) {
  body.kbd-open .lesson-top { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 2px; }
  body.kbd-open .lesson-body { padding-top: 10px; padding-bottom: 10px; }
  body.kbd-open .ex-title { font-size: 19px; margin-bottom: 10px; }
  body.kbd-open .lesson-foot { padding-top: 10px; }
}

/* ============ Conversation (js/talk.js) ============ */
/* A full-screen chat like a lesson: the partner's lines on the left, yours on the right, and the text field
   at the bottom. On a phone the field uses the phone's own keyboard (dictation). */
.talk { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; height: 100dvh; background: var(--bg); }
.talk-top { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px 20px 8px; padding-top: max(16px, env(safe-area-inset-top)); }
.talk-title { flex: 1; margin: 0; font: 600 18px var(--font); color: var(--strong); }
.talk-en-btn { padding: 6px 12px; font-size: 13px; }
.talk-en-btn[aria-pressed="true"] { border-color: var(--blue); color: var(--blue); }
.talk-body { flex: 1; min-height: 0; overflow-y: auto; }
.talk-note, .talk-list { max-width: 760px; margin-left: auto; margin-right: auto; }
.talk-note { margin-top: 4px; margin-bottom: 0; padding: 10px 20px 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.talk-list { list-style: none; padding: 12px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.talk-msg { display: flex; flex-direction: column; max-width: 85%; }
.talk-msg.you { align-self: flex-start; }
.talk-msg.me { align-self: flex-end; align-items: flex-end; }
.talk-bubble { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); }
.talk-msg.you .talk-bubble { padding-right: 46px; }
.talk-msg.me .talk-bubble { background: var(--blue-soft); border-color: var(--blue-line); }
.talk-zh { font: 500 29px/1.4 var(--zh); color: var(--strong); } /* 30% bigger (user's wish, 2026-10-12) */
.talk-py { font-size: 14px; color: var(--blue); }
.talk-en { font-size: 13px; color: var(--muted); }
.talk .speak-btn { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--blue); cursor: pointer; }
.talk .speak-btn .i { width: 20px; height: 20px; }
.talk .speak-btn:hover, .talk .speak-btn:focus-visible { background: var(--line); }
.talk-fix { position: relative; display: flex; flex-direction: column; gap: 2px; margin-top: 6px; padding: 8px 46px 8px 12px; border-left: 3px solid var(--green); background: var(--green-soft); border-radius: 0 10px 10px 0; text-align: left; }
.talk-fix .talk-zh { font-size: 23px; }
.talk-fix-label { font-size: 12px; color: var(--green-text); }
.talk-typing { color: var(--muted); letter-spacing: .2em; }
.talk-foot { border-top: 2px solid var(--line); padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.talk-form { display: flex; gap: 8px; max-width: 728px; margin: 0 auto; }
.talk-form input { flex: 1; min-width: 0; font: 500 18px var(--zh), var(--font); }
.talk-form .btn { flex: none; }
/* Chat (chat.ts): the same screen as Conversation, with a home page of your code, chats and friends */
.chat-home { display: flex; flex-direction: column; gap: 16px; max-width: 760px; margin: 0 auto; padding: 12px 20px 24px; }
.chat-card { border: 2px solid var(--line); border-radius: 18px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.chat-card h3 { font-size: 17px; font-weight: 800; }
.chat-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-code { font-family: var(--font); letter-spacing: .12em; color: var(--strong); }
.chat-add { display: flex; gap: 8px; }
.chat-add input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .1em; }
.chat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.chat-row:hover { border-color: var(--line-strong); }
.chat-friend { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; }
.chat-pick { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.chat-pick legend { font-weight: 700; margin-bottom: 4px; }
.chat-pick label { display: flex; align-items: center; gap: 8px; }
.chat-who { font-size: 12px; color: var(--muted); margin: 0 4px 2px; }
/* the chat's text size, from its Settings (Medium is a bit bigger than the first size, 22px: user's wish) */
.chat { --chat-zh: 26px; }
.chat[data-size="s"] { --chat-zh: 21px; }
.chat[data-size="l"] { --chat-zh: 32px; }
.chat[data-size="xl"] { --chat-zh: 40px; }
.chat .talk-zh.chat-zh { font-size: var(--chat-zh); }
.chat .chat-msgs .talk-py, .chat .chat-msgs .talk-en { font-size: calc(var(--chat-zh) * .58); }
.chat #chat-input { font-size: calc(var(--chat-zh) * .8); }
.chat .talk-top .narrow { display: none; }
/* Chat's Dictionary: a panel beside the chat when the window is wide, over it on a phone (the user's wish, 2026-11-19) */
.chat-dict { position: absolute; z-index: 2; top: var(--chat-top, 64px); right: 0; bottom: var(--chat-foot, 0px); width: 360px; display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-left: 2px solid var(--line); background: var(--bg); box-shadow: -12px 0 24px rgba(0, 0, 0, .25); }
/* The conversation never moves for the panel (user's wish, 2026-11-19). Where there's room (1320px and up) the panel
   sits right next to it, starting at its right edge (it is 760px wide, centred); in a narrower window it lies over the
   conversation's right side, and on a phone under the message box. */
@media (min-width: 1320px) {
  .chat-dict { right: auto; left: calc(50% + 380px); width: min(360px, calc(50% - 380px)); border-right: 2px solid var(--line); box-shadow: none; }
}
.chat-dict-head { display: flex; align-items: center; justify-content: space-between; }
.chat-dict-head h3 { font-size: 17px; font-weight: 800; }
.chat-dict-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.chat-dict-word { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: baseline; width: 100%; padding: 8px 10px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.chat-dict-word[aria-expanded="true"] { border-color: var(--blue-line); }
.chat-dict-zh { grid-row: span 2; font: 500 26px/1.2 var(--zh); color: var(--strong); }
.chat-dict-py { color: var(--blue); font-size: 14px; }
.chat-dict-en { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.chat-dict-more { display: flex; flex-direction: column; gap: 8px; padding: 8px 4px 4px; }
.chat-dict-ex { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.chat-dict-ex [lang] { font: 500 18px var(--zh); }
.chat-dict-ex .rv-py { color: var(--blue); font-size: 13px; }
.chat-dict-ex .rv-en { color: var(--muted); font-size: 13px; }
.chat-dict-more .row { display: flex; flex-wrap: wrap; gap: 6px; }
/* On a phone it fits under the message box, and the chat above gets shorter (user's wish, 2026-11-19) */
@media (max-width: 900px) {
  .chat-dict { position: static; flex: none; height: 45dvh; width: auto; border-left: 0; border-right: 0; border-top: 2px solid var(--line); box-shadow: none; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .chat.dict-open .talk-foot { padding-bottom: 10px; }
}
@media (max-width: 700px) {
  .chat .talk-top .wide { display: none; }
  .chat .talk-top .narrow { display: inline; }
}
.chat .talk-top { gap: 8px; }
.chat .talk-top .btn.small { flex: none; padding: 6px 10px; }
.chat .talk-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) {
  .talk-top { padding: 12px 16px 4px; padding-top: max(12px, env(safe-area-inset-top)); }
  .talk-list { padding: 10px 16px 16px; }
  .talk-note { padding: 8px 16px 0; }
  .talk-msg { max-width: 92%; }
}

/* Profile → Different voices: one row per voice (hear it, its name, on or off) */
.voice-list { margin: 0 0 8px; }
.voice-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.voice-row .icon-btn { flex: none; color: var(--blue); }
.voice-name { flex: 1; display: flex; flex-direction: column; min-width: 0; cursor: pointer; }
.voice-name small { color: var(--muted); font-size: 13px; }
.voice-more { margin: 8px 0 0; font-size: 13px; }
