/* Bamboo Island — Parent Documentation
   Single stylesheet for the whole docs site. Calm green/mint palette to
   match the app. Fixed left sidebar, content on the right with step cards.
   Responsive: sidebar collapses to a top bar under 860px. */

:root {
  --bg: #F4F1EC;          /* app's warm paper background */
  --surface: #FFFFFF;
  --ink: #1F3A2E;         /* deep forest green for headings */
  --ink-soft: #4A5D52;    /* body text */
  --teal: #2E7D6F;        /* primary accent (app teal) */
  --teal-soft: #E3F0EC;   /* light teal chip background */
  --mint: #DCEDE6;
  --sand: #F0E6D2;
  --line: #D9D2C5;        /* hairline borders */
  --shadow: 0 1px 3px rgba(31,58,46,.08), 0 8px 24px rgba(31,58,46,.06);
  --radius: 14px;
  --sidebar-w: 268px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-soft);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 28px 22px;
  overflow-y: auto;
  z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 26px;
}
.brand__logo {
  width: 38px; height: 38px; border-radius: 50%;
  overflow: hidden;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.brand__logo img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.brand__name { font-weight: 700; color: var(--ink); font-size: 17px; line-height: 1.2; }
.brand__sub { font-size: 12px; color: var(--ink-soft); }

/* ---------------- Search (anchored to the header box, above it) ---------------- */
/* Anchored to .hero / .page-head (position: relative below) so the search's
   right edge stays locked to the box's right edge when the browser is resized.
   Positioned with a negative top offset so it floats ABOVE the box visually. */
.site-search {
  position: absolute; top: -52px; right: 0; z-index: 30;
  width: 260px; max-width: 60%; margin: 0;
}
.site-search input {
  width: 100%; box-sizing: border-box;
  padding: 8px 12px 8px 32px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.site-search input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}
.site-search__icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: #9AA59E; pointer-events: none;
}
#site-search-results {
  display: none; position: absolute; z-index: 40;
  right: 0; top: calc(100% + 4px);
  width: 320px; max-width: 90vw;
  max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14);
}
.search-result {
  display: block; padding: 8px 12px; text-decoration: none;
  border-bottom: 1px solid #eef0ed; color: inherit;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--teal-soft); }
.search-result__title { font-size: 13px; font-weight: 600; color: var(--ink); }
.search-result__snippet { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.search-result mark, .search-empty mark { background: #fde68a; border-radius: 2px; padding: 0 1px; }
.search-empty { padding: 10px 12px; font-size: 13px; color: var(--ink-soft); }

.nav-group { margin: 22px 0; }
.nav-group__label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: #9AA59E; margin: 0 0 8px 4px;
}
.nav-link {
  display: block;
  padding: 8px 12px; border-radius: 9px;
  color: var(--ink-soft); font-weight: 500; font-size: 15px;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--teal-soft); text-decoration: none; }
.nav-link--active { background: var(--teal-soft); color: var(--teal); font-weight: 600; }
.nav-link .ico { margin-right: 9px; }

/* ---------------- Main content ---------------- */
.main {
  margin-left: var(--sidebar-w);
  padding: 64px 56px 80px;   /* extra top room for the search bar above the header box */
  max-width: 920px;
}

.page-head { position: relative; margin-bottom: 36px; }
.page-head__eyebrow {
  font-size: 13px; font-weight: 600; color: var(--teal);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.page-head h1 {
  font-size: 36px; line-height: 1.15; margin: 0 0 12px;
  color: var(--ink); font-weight: 800;
}
.page-head p.lede {
  font-size: 19px; color: var(--ink-soft); margin: 0; max-width: 60ch;
}

h2 {
  font-size: 26px; color: var(--ink); font-weight: 700;
  margin: 48px 0 16px; padding-top: 8px;
}
h2 .hn { color: var(--teal); }
h3 { font-size: 19px; color: var(--ink); margin: 28px 0 10px; font-weight: 700; }

p { margin: 0 0 16px; }
p:last-child { margin-bottom: 0; }

strong { color: var(--ink); font-weight: 700; }
em { font-style: italic; }

ul, ol { padding-left: 22px; margin: 0 0 16px; }
li { margin-bottom: 6px; }

/* ---------------- Step card (numbered) ---------------- */
.steps { list-style: none; padding: 0; margin: 24px 0; counter-reset: step; }
.step {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  counter-increment: step;
}
.step__num {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--teal-soft); color: var(--teal);
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
}
.step__num::before { content: counter(step); }
.step__title { font-weight: 700; color: var(--ink); margin-bottom: 4px; font-size: 17px; }
.step__body { font-size: 15px; }
.step__body .btnref {
  display: inline-block;
  background: var(--teal-soft); color: var(--teal);
  padding: 1px 8px; border-radius: 6px; font-size: 13px; font-weight: 600;
  white-space: nowrap;
}

/* ---------------- Screenshot ---------------- */
.shot {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}
.shot img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}
/* Phone screenshots are tall portrait — cap height so several fit on screen */
.shot--phone { max-width: 340px; }
/* Inside a shot-row, let phone shots share the row evenly so two always sit
   side by side. Small basis lets them shrink to fit narrower columns; max-width
   still caps them at 340px on wide screens. */
.shot-row .shot--phone { flex: 1 1 200px; max-width: 340px; }
/* A 2×2 grid of phone shots (e.g. the four ingredient libraries on the Method
   page). Use this INSTEAD of .shot-row (not alongside it) — it replaces the
   flex row with a 2-column grid so all four sit in a clean 2-by-2. */
.shot-row--grid4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-width: 720px; /* two ~340px columns + gap */
  margin: 20px 0;
}
.shot__caption {
  font-size: 13px; color: #8A938B; margin-top: 10px;
  font-style: italic; text-align: center;
}
.shot-row {
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: flex-start;
  margin: 20px 0;
}

/* ---------------- Callout ---------------- */
.callout {
  background: var(--teal-soft);
  border-left: 4px solid var(--teal);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 20px;
  margin: 24px 0;
}
.callout--sand { background: var(--sand); border-left-color: #C9A24B; }
.callout__title { font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.callout p:last-child { margin-bottom: 0; }

/* ---------------- Card grid (mirrors app home) ---------------- */
.island-grid {
  display: grid;
  /* Always exactly 2 columns → Stories/Talks on top, Flashcards/Remember below.
     Falls back to 1 column on narrow phones (see the mobile media query). */
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 24px 0;
  max-width: 560px;
}
.island-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink-soft);
  transition: transform .12s, box-shadow .12s;
}
.island-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(31,58,46,.12); text-decoration: none; }
.island-card__icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--teal-soft);
  display: grid; place-items: center; font-size: 22px; margin-bottom: 12px;
}
.island-card__title { font-weight: 700; color: var(--ink); font-size: 17px; margin-bottom: 4px; }
.island-card__desc { font-size: 14px; }

/* ---------------- Table ---------------- */
.tbl { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 15px; }
.tbl th, .tbl td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.tbl th { background: var(--teal-soft); color: var(--ink); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.tbl tr:last-child td { border-bottom: none; }

/* ---------------- Hero (index) ---------------- */
.hero {
  position: relative;   /* anchor for the absolute-positioned search box */
  background: linear-gradient(135deg, var(--mint), var(--teal-soft));
  border-radius: 22px;
  padding: 48px 44px;
  margin-bottom: 40px;
}
.hero__logo {
  width: 84px; height: 84px; border-radius: 20px;
  object-fit: cover; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(31,58,46,.18);
}
.hero__row {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}
/* Nudge the logo down so it aligns with the title text's cap height. */
.hero__logo { margin-top: 6px; }
.hero__text { flex: 1; min-width: 0; }
.hero h1 { font-size: 44px; margin: 0 0 6px; color: var(--ink); font-weight: 800; line-height: 1.1; }
.hero__zh { font-size: 22px; color: var(--teal); margin-bottom: 14px; }
.hero p { font-size: 19px; max-width: 50ch; }

/* ---------------- Pinyin chart (compact reference) ---------------- */
.pinyin-chart { font-size: 15px; }
.pinyin-chart th { background: var(--teal-soft); }
.pinyin-chart td { text-align: center; font-variant-numeric: tabular-nums; }
.pinyin-chart tr td:first-child { text-align: left; font-weight: 600; color: var(--ink); }

/* ---------------- Footer note ---------------- */
.foot-note {
  margin-top: 48px; padding: 20px; border-top: 1px solid var(--line);
  font-size: 14px; color: #8A938B;
}

/* ---------------- Mobile menu toggle ---------------- */
.menu-btn {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 30;
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 20px; cursor: pointer; box-shadow: var(--shadow);
}

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
  .menu-btn { display: block; }
  /* On mobile, pin the search bar to the top-right so it sits on the SAME
     line as the ☰ menu button (top-left), leaving the header box clean below. */
  .site-search {
    position: fixed; top: 18px; right: 12px; z-index: 30;
    width: calc(100% - 78px);   /* viewport minus menu button + gaps */
    max-width: none; margin: 0;
  }
  /* Tuck the results dropdown under the pinned search, right-aligned. */
  #site-search-results { width: calc(100vw - 24px); right: 0; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s;
    box-shadow: -8px 0 30px rgba(0,0,0,.2);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 64px 20px 60px; }
  .hero { padding: 32px 24px; }
  .hero h1 { font-size: 32px; }
  /* On narrow screens, stack the logo above the hero text. */
  .hero__row { flex-direction: column; gap: 14px; }
  .hero__logo { width: 64px; height: 64px; }
  .page-head h1 { font-size: 28px; }
  .step { grid-template-columns: 48px 1fr; gap: 14px; padding: 16px; }
  /* On narrow phones the 2-column island grid would squeeze each card too
     thin — stack to a single column instead. */
  .island-grid { grid-template-columns: 1fr; max-width: 340px; }
}

/* ---------------- FAQ accordion ---------------- */
/* Native <details>/<summary> accordions for the FAQ page. No JS needed; the
   browser handles expand/collapse and keyboard accessibility. Styled to match
   the site's callout/card look. */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}
.faq-list details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.faq-list summary {
  cursor: pointer;
  list-style: none;          /* hide the default disclosure triangle */
  padding: 16px 18px;
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--ink, #1f3a36);
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}
.faq-list summary::-webkit-details-marker { display: none; } /* Safari */
/* Custom +/- indicator that flips to − when open. */
.faq-list summary::before {
  content: "+";
  flex: 0 0 auto;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--teal, #2E7D6F);
  color: #fff;
  font-size: 15px; font-weight: 700;
  line-height: 1;
  transition: transform 0.15s ease;
}
.faq-list details[open] summary::before { content: "−"; }
.faq-list summary:hover { background: rgba(46, 125, 111, 0.06); }
.faq-a {
  padding: 0 18px 18px 50px;  /* indent under the marker */
  color: var(--ink-soft);
  line-height: 1.6;
}
.faq-a p:first-child { margin-top: 0; }
.faq-a p:last-child { margin-bottom: 0; }

/* ── Typing Chinese page: keyboard diagrams ───────────────────────────
   Mirrors the in-app Guide's drawn diagrams: the EN↔中 switch illustration
   and the pinyin→candidate demo. Plain HTML/CSS, no images. */
.kb-switch {
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin: 16px 0;
}
.kb-switch__kb {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 9px 9px 7px;
  text-align: center;
}
.kb-switch__row {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
}
.kb-switch__cands {
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--teal-soft);
  border-radius: 6px;
  padding: 3px 2px;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
}
.kb-switch__bottom {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 5px;
}
.kb-switch__globe {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--teal-soft);
  border-radius: 4px;
  padding: 2px 6px;
}
.kb-switch__space {
  flex: 1 1 auto;
  max-width: 110px;
  font-size: 0.6rem;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 0;
}
.kb-switch__label {
  margin-top: 5px;
  font-size: 0.72rem;
  color: var(--ink-soft);
}
.kb-switch__mid {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  text-align: center;
  min-width: 88px;
}
.kb-switch__arrow {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
}
.kb-switch__hint {
  font-size: 0.72rem;
  color: var(--ink-soft);
}
.kb-demo {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin: 16px auto;
  max-width: 320px;
}
.kb-demo__input {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.3em;
  border-bottom: 2px solid var(--teal, #2E7D6F);
  padding-bottom: 4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
}
.kb-demo__caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--teal, #2E7D6F);
  margin-left: 2px;
  animation: kb-caret 1.1s steps(1) infinite;
}
@keyframes kb-caret { 50% { opacity: 0; } }
.kb-demo__cands {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: baseline;
}
.kb-demo__cand {
  font-size: 1.15rem;
  color: var(--ink-soft);
  padding: 2px 8px;
  border-radius: 6px;
}
.kb-demo__cand--first {
  color: var(--ink);
  background: var(--teal-soft);
  font-weight: 700;
}
@media (max-width: 460px) {
  .kb-switch { flex-direction: column; }
  .kb-switch__mid { flex-direction: row; min-width: 0; }
}


/* TTS play buttons for inline examples (see the grammar section in
   pages/talks.html). Small round pills after hanzi/pinyin or English glosses;
   speech handled by the browser's Web Speech API with a Chinese voice for
   hanzi and an English voice for glosses. */
.tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: 0 3px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}
.tts-btn:active { transform: scale(0.92); }

/* Copyable prompt boxes ("No AI key? Use any chatbot") — 📋 copies to the
   clipboard; the block itself is select-all friendly. */
.prompt-box { margin: 8px 0 18px; position: relative; }
.prompt-box pre {
  margin: 0; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 0.86rem; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  user-select: all; -webkit-user-select: all;
}
.prompt-copy {
  margin-bottom: 6px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--teal-soft); color: var(--teal);
  font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.prompt-copy:active { transform: scale(0.97); }

/* Download button (sample import files on the Reading page). */
.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary, #0f766e);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 9px 16px;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.12s;
}
.dl-btn:hover { background: var(--primary-dark, #115e59); color: #ffffff; }
.dl-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---- Interactive Pinyin Chart (pages/pinyin-chart.html) ---- */
.chart-scroll {
  overflow-x: auto;
  margin: 18px 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.pc-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
  min-width: 100%;
}
.pc-table th {
  position: sticky;
  top: 0;
  background: var(--mint);
  color: var(--ink);
  font-weight: 700;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  z-index: 2;
}
.pc-table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
}
.pc-table tbody th {
  position: sticky;
  left: 0;
  background: var(--mint);
  font-weight: 700;
  color: var(--teal);
  border-right: 1px solid var(--line);
  z-index: 1;
}
.pc-cell {
  min-width: 44px;
  text-align: center;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid rgba(217, 210, 197, 0.5);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease;
}
.pc-cell:hover, .pc-cell:focus-visible {
  background: var(--teal-soft);
  outline: none;
}
.pc-cell--empty {
  cursor: default;
  color: transparent;
  background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(217,210,197,0.25) 6px 7px);
}
.pc-cell--empty:hover { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(217,210,197,0.25) 6px 7px); }

/* Tone panel (modal) */
.pc-panel { position: fixed; inset: 0; z-index: 200; }
.pc-panel[hidden] { display: none; }
.pc-panel__backdrop {
  position: absolute; inset: 0;
  background: rgba(31, 58, 46, 0.45);
}
.pc-panel__card {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(430px, calc(100vw - 28px));
  max-height: min(560px, calc(100vh - 40px));
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(31, 58, 46, 0.25);
  padding: 18px 18px 14px;
}
.pc-panel__close {
  position: absolute; top: 10px; right: 10px;
  border: none; background: var(--mint); color: var(--ink);
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 0.9rem; cursor: pointer;
}
.pc-panel__syl {
  text-align: center;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--teal);
  margin-bottom: 10px;
}
.pc-tone {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 6px;
  border-top: 1px solid var(--line);
}
.pc-ladder { flex: 0 0 auto; }
.pc-ladder__level { stroke: var(--ink-soft); stroke-width: 1; opacity: 0.25; }
.pc-ladder__contour { fill: none; stroke: var(--teal); stroke-width: 3; stroke-linecap: round; }
.pc-tone__main { flex: 1 1 auto; min-width: 0; }
.pc-tone__pinyin { font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.pc-tone__name { font-size: 0.72rem; font-weight: 500; color: var(--ink-soft); margin-left: 8px; }
.pc-tone__word { font-size: 1rem; color: var(--ink); margin-top: 2px; }
.pc-tone__gloss { font-size: 0.78rem; color: var(--ink-soft); }
.pc-tone__play {
  flex: 0 0 auto;
  border: none;
  background: var(--teal);
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 0.85rem;
  cursor: pointer;
}
.pc-tone__play:hover { background: #256a5e; }
.chart-loading { padding: 24px; text-align: center; color: var(--ink-soft); }
/* Sticky headers must never swallow cell clicks when they overlap a
   partially-scrolled cell (headers are labels, not interactive). */
.pc-table th { pointer-events: none; }
.pc-table thead th:first-child { pointer-events: none; }

/* ---- Remember web libraries (families on the chart page + radicals grid) ---- */
.rw-group { margin: 22px 0 6px; }
.rw-group h3 { margin: 0 0 4px; color: var(--ink); font-size: 1.15rem; }
.rw-group h3 em { color: var(--teal); font-style: normal; }
.rw-group__desc { color: var(--ink-soft); font-size: 0.9rem; margin: 0 0 12px; }
.rw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 10px;
}
.rw-grid--tones { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.rw-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(31,58,46,0.05);
}
.rw-card img {
  width: 74px; height: 74px;
  object-fit: contain;
  border-radius: 10px;
  background: var(--mint);
}
.rw-card--tone { text-align: left; }
.rw-card--tone img.rw-card__tone-img {
  width: 54px; height: 54px; border-radius: 50%;
  float: left; margin-right: 10px;
}
.rw-card--tone .pc-ladder { float: right; }
.rw-card__key { font-weight: 800; color: var(--teal); margin-top: 6px; font-size: 1.05rem; }
.rw-card__name { font-weight: 600; color: var(--ink); font-size: 0.82rem; line-height: 1.3; margin-top: 2px; }
.rw-card__desc { color: var(--ink-soft); font-size: 0.75rem; margin-top: 2px; }
.rw-card__play {
  clear: both;
  display: inline-block;
  margin-top: 8px;
  border: none;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 1rem;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.rw-card__play:hover { background: var(--teal); color: #fff; }

/* Radicals grid */
.rw-rgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  margin: 18px 0 8px;
}
.rw-rtile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 6px 8px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.rw-rtile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.rw-rtile img {
  width: 64px; height: 64px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--mint);
}
.rw-rtile__glyph {
  font-size: 1.5rem;
  line-height: 1.1;
  color: var(--ink);
}
.rw-rtile__name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  line-height: 1.25;
}
.rw-rtile--variant { border-style: dashed; }
.rw-rtile__tag {
  display: block;
  font-style: normal;
  font-weight: 400;
  color: var(--ink-soft);
  font-size: 0.66rem;
}
/* Radical detail modal content (inside .pc-panel__card) */
.rw-detail { text-align: center; padding-top: 6px; }
.rw-detail__img {
  width: 150px; height: 150px;
  object-fit: contain;
  border-radius: 16px;
  background: var(--mint);
}
.rw-detail__glyph { font-size: 3rem; color: var(--ink); margin-top: 8px; line-height: 1.2; }
.rw-detail__name { font-size: 1.25rem; font-weight: 800; color: var(--teal); margin-top: 4px; }
.rw-detail__meta { color: var(--ink-soft); font-size: 0.85rem; margin-top: 6px; }

/* ---- Remember Libraries page (rich cards) ---- */
.rw-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
/* Chip nav styled as real buttons: border, shadow, hover lift, press. */
.rw-chips a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 16px;
  border: 2px solid var(--teal);
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(31, 58, 46, 0.18);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease, color 0.12s ease;
}
.rw-chips a::after { content: "↓"; font-size: 0.75rem; color: var(--teal); }
.rw-chips a:hover {
  background: var(--teal);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 3px 0 rgba(31, 58, 46, 0.25);
}
.rw-chips a:hover::after { color: #fff; }
.rw-chips a:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(31, 58, 46, 0.18);
}
.rw-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 3px 10px;
  vertical-align: middle;
  margin-left: 8px;
}
.rw-grid--wide { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.rw-card--full { text-align: left; }
.rw-card--full img { float: left; margin-right: 10px; }
.rw-card__head { display: flex; align-items: baseline; gap: 8px; padding-top: 2px; }
.rw-card__tip { clear: none; color: var(--ink-soft); font-size: 0.74rem; margin-top: 4px; line-height: 1.35; }
.rw-card__sample {
  clear: both;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed var(--line);
}
.rw-card__hanzi { font-size: 1.35rem; color: var(--ink); line-height: 1; }
.rw-card__py { font-size: 0.8rem; color: var(--teal); font-weight: 600; }
.rw-card__py em { font-style: normal; color: var(--ink-soft); font-weight: 400; }
.rw-card__sample .rw-card__play {
  margin: 0 0 0 auto;
  width: 32px; height: 32px; min-width: 32px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
}
.rw-rtile__py {
  font-size: 0.68rem;
  color: var(--teal);
  font-weight: 600;
}
.rw-detail__play {
  display: inline-block;
  margin-top: 12px;
  border: none;
  background: var(--teal);
  color: #fff;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}
.rw-detail__play:hover { background: #256a5e; }
/* Picker cards: pull-down + listen + one-line name at the bottom. */
.rw-card--full { display: flex; flex-direction: column; }
.rw-card--full .rw-card__foot {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-weight: 700;
  color: var(--ink);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rw-card__picker {
  clear: both;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.rw-select {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--mint);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
  cursor: pointer;
}
.rw-card__picker .rw-card__play {
  margin: 0;
  width: 30px; height: 30px; min-width: 30px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
}
.rw-card__picker .rw-card__py { flex: 1 1 100%; order: 3; }
/* Section summary note (replaces per-card tips) + clamped desc lines. */
.rw-note {
  background: var(--sand);
  border-left: 4px solid var(--teal);
  border-radius: 0 10px 10px 0;
  padding: 10px 14px;
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 10px 0 14px;
}
.rw-note strong { color: var(--ink); }
.rw-note em { font-style: italic; }
.rw-card__tip--clamp {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Initials/Finals cards = the app's mnem-slot grid (read-only twin). */
/* The name row spans the FULL card width (under the key tile too) so long
   names ("Mia the Magnificent", "Charlie the Cheerful") never truncate. */
.rw-slot {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  grid-template-areas:
    "key pic"
    "key audio"
    "name name";
  align-items: start;
  gap: 6px 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(31,58,46,0.05);
}
.rw-slot__key {
  grid-area: key;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  background: var(--mint);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 800;
  font-size: 1.1rem;
  word-break: break-all;
}
/* Picture frame: white with a light border (was mint — distracting next to
   the mint key tile). TO REVERT: set --rw-pic-bg back to var(--mint) and
   --rw-pic-border to none in the :root block above. */
:root {
  --rw-pic-bg: #ffffff;
  --rw-pic-border: 1px solid var(--line);
}
.rw-slot__pic img {
  display: block;
  width: 100%;
  height: 104px;
  object-fit: contain;
  border-radius: 10px;
  background: var(--rw-pic-bg);
  border: var(--rw-pic-border);
}
.rw-slot__audio {
  grid-area: audio;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 6px;
  min-width: 0;
}
/* The pull-down is COMPACT (it only ever shows hanzi + pinyin, e.g. "双
   shuāng") so the ▶ Listen button always has room for its full label. */
.rw-slot__audio .rw-select { flex: 0 0 auto; width: 92px; }
.rw-slot__audio .rw-listen { flex: 1 1 auto; }
.rw-slot__audio .rw-slot__py { flex: 1 1 100%; order: 3; }
.rw-listen {
  flex: 0 0 auto;
  border: none;
  background: var(--teal);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.rw-listen:hover { background: #256a5e; }
.rw-slot__py {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.74rem;
  color: var(--teal);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rw-slot__py em { font-style: normal; color: var(--ink-soft); font-weight: 400; }
.rw-slot__name {
  grid-area: name;
  border-top: 1px dashed var(--line);
  padding-top: 7px;
  min-width: 0;
}
/* Place + description are ONE label ("Apple Tree — red apples…"): same font
   size throughout (place bolded), allowed to wrap instead of truncating. */
.rw-slot__nm {
  display: block;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.35;
  overflow-wrap: break-word;
}
.rw-slot__nm b { font-weight: 700; }
.rw-slot__desc {
  display: block;
  color: var(--ink-soft);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ★ slot explainer (app's InfoPopup text) fills the empty audio row. */
.rw-slot__audio--empty {
  font-size: 0.74rem;
  color: var(--ink-soft);
  line-height: 1.45;
  padding-top: 2px;
}
/* Tones in the slot design: tone number tile + family icon + chip/Listen +
   ladder, and the bold one-line voice name at the bottom. */
.rw-slot__key--tone { font-size: 1.3rem; }
.rw-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--mint);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  white-space: nowrap;
}
.rw-slot__audio .pc-ladder { flex: 0 0 auto; margin-left: auto; }
/* The tone's key tile IS its 5-line ladder (tone 5 = number). */
.rw-slot__key--ladder { padding: 2px 0; }
.rw-slot__key--ladder .pc-ladder__level { opacity: 0.35; }
.rw-slot__key--ladder .pc-ladder__contour { stroke: var(--teal); }
/* Radical slot: the GLYPH is the key tile (big hanzi); variants tagged. */
.rw-slot__key--glyph { font-size: 1.7rem; font-family: "Noto Serif SC", "Songti SC", serif; }
.rw-slot--variant { border-style: dashed; }
.rw-slot__vtag { font-weight: 400; font-size: 0.72rem; color: var(--ink-soft); white-space: nowrap; }
