/* ============ ReadWord v2 ============ */
/* Visual language: Readlang-like minimalism — flat, white, airy.
 * Content is the hero; chrome stays quiet. Every color flows through
 * the CSS variables below. `html[data-theme="warm"]` and
 * `html[data-theme="dark"]` override the default values; custom user
 * colors are applied as inline styles on <html> (inline always wins). */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --input-bg: #ffffff;
  --text: #1c2330;
  --muted: #6b7484;
  --border: #e8ebf0;
  --accent: #2f6fed;
  --accent-soft: #e8effe;
  --accent-hover: #265fd4;
  --on-accent: #ffffff;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --danger-border: #f3c2c2;
  --danger-hover: #bd3a3a;
  --on-danger: #ffffff;
  --ok: #1f9d55;
  --ok-soft: #e6f6ec;
  --ok-border: #bfe6cd;
  --badge-bg: #f2f4f8;
  --badge-text: #5b6474;
  --auto-bg: #fff4d6;
  --auto-text: #8a6d00;
  --invert-bg: #1c2330;
  --invert-text: #ffffff;
  --radius: 10px;
  --shadow: none;
  --maxw: 780px;
  --hl1: #fff3c4;
  --hl2: #ffe08a;
  --hl3: #ffc94d;
}

/* Warm eye-care theme (Readlang-like cozy feel, matches gejoylab.com) */
html[data-theme="warm"] {
  --bg: #faf6ec;
  --surface: #fffdf6;
  --input-bg: #fffdf6;
  --text: #2b2b2b;
  --muted: #6b6257;
  --border: #e9e0cc;
  --accent: #2d6a4f;
  --accent-soft: #e3efe7;
  --accent-hover: #245c43;
  --on-accent: #ffffff;
  --danger: #c0504a;
  --danger-soft: #f9e9e4;
  --danger-border: #ecc9bd;
  --danger-hover: #a8433d;
  --on-danger: #ffffff;
  --ok: #4a8f5d;
  --ok-soft: #e9f3e4;
  --ok-border: #c4ddb6;
  --badge-bg: #f0e8d2;
  --badge-text: #6d6046;
  --auto-bg: #f7ecc8;
  --auto-text: #7c6410;
  --invert-bg: #3d3627;
  --invert-text: #fffdf6;
  --shadow: 0 1px 3px rgba(90, 70, 30, 0.10);
  --hl1: #fdf0c0;
  --hl2: #fbe08a;
  --hl3: #f7c948;
}

/* Dark theme (true dark, low contrast) */
html[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1e2126;
  --input-bg: #262a31;
  --text: #e2e6eb;
  --muted: #9aa2ad;
  --border: #33383f;
  --accent: #6ea8ff;
  --accent-soft: #22344f;
  --accent-hover: #5a94f0;
  --on-accent: #0f1420;
  --danger: #e0706a;
  --danger-soft: #3a2226;
  --danger-border: #5c3236;
  --danger-hover: #c85d57;
  --on-danger: #141014;
  --ok: #5fc98a;
  --ok-soft: #1d3327;
  --ok-border: #2f5240;
  --badge-bg: #2a2f36;
  --badge-text: #b9c0ca;
  --auto-bg: #3d3418;
  --auto-text: #e3c76a;
  --invert-bg: #e2e6eb;
  --invert-text: #14161a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  /* word highlights stay readable with light text on dark amber */
  --hl1: #57481c;
  --hl2: #6a5718;
  --hl3: #7d651a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.screen { min-height: 100vh; }

/* hidden attribute must always win over display rules above/below */
[hidden] { display: none !important; }

/* ---------- login ---------- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -0.5px; }
.login-card input { margin: 8px 0; }
.cefr-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

/* ---------- layout ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 20px;
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: -0.3px; white-space: nowrap; }
.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button,
.tabs a {
  border: 0;
  background: transparent;
  padding: 10px 4px;
  margin: 0 10px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
}
.tabs button:hover, .tabs a:hover { background: transparent; color: var(--text); }
.tabs button.active, .tabs a.active { background: transparent; color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }

.main { padding: 28px 20px 80px; }
.tab { display: none; }
.tab.active { display: block; }
.narrow { max-width: var(--maxw); margin: 0 auto; }

/* Readlang-style: sections are separated by whitespace, not boxes */
.card {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 4px 0;
  margin-bottom: 32px;
}
.card h2 { margin: 0 0 14px; font-size: 22px; font-weight: 700; letter-spacing: -0.2px; }
.card h3 { margin: 22px 0 10px; font-size: 16px; }
.card h3:first-child { margin-top: 0; }
.card h4 { margin: 14px 0 6px; font-size: 14px; color: var(--muted); }

/* ---------- controls ---------- */
input[type="text"], input[type="password"], input:not([type]), textarea, select {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
textarea { min-height: 180px; resize: vertical; }
textarea.short { min-height: 90px; }
.block-input { display: block; margin-bottom: 10px; }
.grow { flex: 1; min-width: 0; }

.btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn.danger:hover { background: var(--danger-hover); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg); color: var(--text); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.block { width: 100%; margin-top: 4px; }
.btn:disabled { opacity: 0.55; cursor: default; }

.row { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 14px;
}
.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid var(--ok-border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 14px;
}

.toggle { display: flex; gap: 10px; align-items: center; margin: 12px 0; cursor: pointer; }
.toggle input { width: auto; accent-color: var(--accent); }

/* ---------- reader ---------- */
.article {
  font-size: var(--reader-fs, 18px);
  line-height: 2;
  padding: 28px;
}
.article .w {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 2px;
  margin: 0 -2px;
}
.article .w:hover { background: var(--accent-soft); }
.article .w.hl1 { background: var(--hl1); }
.article .w.hl2 { background: var(--hl2); }
.article .w.hl3 { background: var(--hl3); font-weight: 600; }
.reader-toolbar { justify-content: space-between; }

/* ---------- audio reader (listen + follow-along transcript) ---------- */
.audio-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.audio-bar audio { width: 100%; display: block; }
.seg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 7px 10px;
  border-radius: 8px;
  border-left: 3px solid transparent;
}
.seg.active { background: var(--accent-soft); border-left-color: var(--accent); }
.seg-time {
  flex: none;
  border: 0;
  background: none;
  padding: 5px 2px;
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.seg-time:hover { text-decoration: underline; }
.seg-text { margin: 0; flex: 1; min-width: 0; }

/* import progress line under the YouTube row */
#import-yt-status { margin: 8px 0 0; }

/* ---------- lookup panel (desktop side panel / mobile bottom sheet) ---------- */
#panel-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 22, 40, 0.4);
  z-index: 60;
}
.lookup-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(20, 30, 60, 0.12);
  z-index: 2000;
  display: flex;
  flex-direction: column;
}
.panel-head {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: stretch;
  padding: 2px 14px 6px;
  border-bottom: 1px solid var(--border);
}
.panel-nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-nav-row .btn.small { padding: 2px 8px; font-size: 12px; }
.panel-body { overflow-y: auto; padding: 16px; flex: 1; }
.lookup-word { font-size: 24px; font-weight: 700; margin: 0; }
.lookup-sub { color: var(--muted); font-size: 14px; margin: 2px 0 8px; }

.dict-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.dict-panel > .dp-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
/* chevron collapse toggle on the right of every dictionary panel header */
.dp-chevron {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.dp-chevron:hover { color: var(--text); background: var(--badge-bg); }
.source-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 2px 7px;
}
.dict-panel > .dp-body { padding: 12px 14px; font-size: 15px; }
.dp-body.collapsed { display: none; }
/* line-clamped by default: show ~6 lines, fade out, "show more" expands */
.dp-body.clamped { max-height: 150px; overflow: hidden; position: relative; }
.dp-body.clamped::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0;
  height: 44px; background: linear-gradient(transparent, var(--surface)); pointer-events: none; }
.dp-more { display: block; width: 100%; background: none; border: none;
  border-top: 1px solid var(--border); padding: 8px; font-size: 13px; color: var(--muted);
  cursor: pointer; text-align: center; }
.dp-more:hover { color: var(--accent); background: var(--bg); }
.dp-toggle { margin-left: auto; }
/* custom dictionary definitions: preserve line breaks, wrap long lines */
.custom-def { word-break: break-word; line-height: 1.65; }
.cdef-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 6px; }
.cdef-word { font-size: 19px; font-weight: 800; }
.cdef-pron { color: var(--muted); font-size: 14px; }
.cdef-freq { color: var(--muted); font-size: 12px; }
.cdef-body p { margin: 0 0 8px; }
.cdef-body p:last-child { margin-bottom: 0; }
.cdef-sense { padding-left: 4px; }
.cdef-etym { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--border);
  color: var(--muted); font-size: 13px; font-style: italic; }

.sense { margin-bottom: 12px; }
.sense:last-child { margin-bottom: 0; }
.pos-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--badge-text);
  background: var(--badge-bg);
  border-radius: 4px;
  padding: 1px 8px;
  margin-right: 6px;
}
.example { color: var(--muted); font-style: italic; margin: 4px 0 4px 12px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip {
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
}
.chip.syn { background: var(--ok-soft); border-color: var(--ok-border); }
.chip.ant { background: var(--danger-soft); border-color: var(--danger-border); }

.trans-line { margin: 4px 0; }
.tag-chip {
  display: inline-block;
  font-size: 12px;
  background: var(--badge-bg);
  border-radius: 4px;
  padding: 2px 8px;
  margin: 2px 4px 2px 0;
  color: var(--badge-text);
}
.audio-badge {
  display: inline-block;
  font-size: 14px;
  margin-left: 6px;
  vertical-align: middle;
  cursor: default;
}
.forms-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.forms-table td { border-bottom: 1px solid var(--border); padding: 4px 6px; }
.forms-table td:first-child { color: var(--muted); width: 45%; }

.audio-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  vertical-align: middle;
  margin-left: 6px;
}
.audio-btn:hover { background: var(--accent-soft); }

/* ---------- pronunciation ---------- */
.pron-block {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 8px 0 2px;
}
.ipa-chip {
  font-size: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 9px;
  font-family: "Charis SIL", "Doulos SIL", "Segoe UI", sans-serif;
}
.hyphen {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 1px;
}

/* clickable words inside lookup results */
[data-lookup-word] { cursor: pointer; }
[data-lookup-word]:hover { color: var(--accent); text-decoration: underline; }

/* ---------- screenshot-style dictionary view ---------- */
.dict-word { font-size: 30px; font-weight: 800; margin: 0; letter-spacing: 0.5px; line-height: 1.15;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* speaker after the word: plays the US pronunciation */
.word-audio {
  background: none; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; padding: 6px; border-radius: 8px; flex-shrink: 0;
}
.word-audio:hover { background: var(--accent-soft); }
/* ONE actions row: icon buttons + tips/forms mini-toggles, always one line */
.dh-actions-row {
  display: flex; align-items: center; gap: 5px;
  flex-wrap: nowrap; overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
  margin: 6px 0 2px; padding-bottom: 2px;
}
.dh-actions-row::-webkit-scrollbar { display: none; }
.dh-actions-row > * { flex-shrink: 0; }
.dh-actions-row .mini-toggle { margin-left: 2px; }
/* inflect note shown at the top of the expanded 时态/词形 section */
.dh-inflect-note { color: var(--muted); font-size: 13.5px; margin-bottom: 6px; }
.icon-btn {
  width: 28px; height: 28px; font-size: 14px; line-height: 1;
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
  color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.icon-btn.done { color: #1a7a4c; border-color: #1a7a4c; background: #e8f7ef; }
.icon-btn.off { opacity: 0.4; }
html[data-theme="dark"] .icon-btn.done { background: #14301f; }
.dh-freq { font-size: 12.5px; color: var(--muted); margin-left: 2px; }
/* small inline toggle buttons (pron tips / word forms) */
.mini-toggle {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  font-size: 13px; color: var(--accent); white-space: nowrap;
  background: var(--accent-soft); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 8px; cursor: pointer;
}
.mini-toggle:hover { border-color: var(--accent); }
.mini-toggle .chev { font-size: 10px; transition: transform 0.15s; }
.mini-toggle.open .chev { transform: rotate(90deg); }
.dh-inflect { font-size: 13.5px; color: var(--muted); margin: 4px 0; }
.dh-forms[hidden] { display: none; }
.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 13px; padding: 2px 6px; border-radius: 6px; white-space: nowrap;
}
.link-btn:hover { background: var(--accent-soft); }
.dh-ipa-extra { margin-top: 2px; }
.dh-tips { margin: 6px 0 0; display: flex; flex-direction: column; gap: 4px; }
.dh-tips[hidden] { display: none; }
.dh-meta {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: nowrap; overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
  margin: 6px 0 2px; padding-bottom: 2px; font-size: 14px;
}
.dh-meta::-webkit-scrollbar { display: none; }
.dh-meta > * { flex-shrink: 0; }
.dh-meta .pos-badge { font-size: 13px; }
/* configurable header rows: pos / freq star / ipa */
.dh-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 4px 0;
}
.dh-row .ipa-text { font-size: 15px; color: var(--link, #1d4ed8); }
/* settings: word-box row layout */
.wb-row-drop {
  min-height: 38px; border: 1.5px dashed var(--border, #e5e7eb); border-radius: 8px;
  padding: 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.wb-row-drop.wb-drop-over { border-color: var(--accent, #2f7d4f); background: rgba(47,125,79,.06); }
.wb-chip {
  background: var(--chip, #eef2ff); border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px; padding: 4px 12px; font-size: 13px; cursor: grab; user-select: none;
}
.wb-chip:active { cursor: grabbing; }
/* single frequency star with 1-5 number, click for details */
.freq-star {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none; line-height: 1;
}
.freq-star .freq-num {
  position: absolute; font-size: 11px; font-weight: 800; color: #7c2d12; line-height: 1;
  text-shadow: 0 0 2px #fff;
}
.freq-star .freq-detail {
  position: absolute; top: 110%; left: 50%; transform: translateX(-50%);
  background: var(--card, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; color: var(--text, #111); white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,.12); z-index: 50; line-height: 1.7;
}
.collins-stars { color: #e6a817; letter-spacing: 2px; font-size: 15px; }
.oxford-badge {
  font-size: 12px; font-weight: 700; color: #b45309;
  border: 1.5px solid #e6a817; border-radius: 4px; padding: 0 6px;
}
.cefr-badge { /* reused in reader stats too */
  font-size: 12px; font-weight: 700; color: #0f766e;
  border: 1.5px solid #0f766e; border-radius: 4px; padding: 0 6px;
}
.dh-ipa { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; margin: 8px 0 2px; }
.dh-ipa .ipa-text { min-width: 0; }
.ipa-tag { font-size: 12px; font-weight: 800; color: #c0392b; }
.ipa-text { font-size: 17px; color: #1d4ed8; }
html[data-theme="dark"] .ipa-text { color: #93c5fd; }
.pron-tip {
  font-size: 13px; line-height: 1.5; color: #6b4e12;
  background: #fef9e7; border: 1px solid #f0d878; border-radius: 6px;
  padding: 5px 9px;
}
html[data-theme="dark"] .pron-tip { background: #3a2f14; color: #fcd34d; border-color: #8a6d1f; }
.dh-inflect { font-size: 13.5px; color: var(--muted); margin: 4px 0; }
.dh-forms { font-size: 14px; margin: 6px 0; line-height: 1.9; }
.dh-forms .flabel { color: var(--muted); font-size: 13px; }
.dh-forms .fval { font-weight: 700; color: var(--text); }

/* numbered definitions grouped by part of speech */
.dict-pos-block { margin: 12px 0 4px; }
.dict-pos-head { font-size: 16px; font-weight: 700; margin: 10px 0 6px; }
.dict-def { display: flex; gap: 8px; margin: 7px 0; font-size: 15px; line-height: 1.55; }
.dict-def-num { font-weight: 800; flex-shrink: 0; min-width: 18px; }
.dict-def-body { flex: 1; }
.dict-zh { color: #2f6b4f; font-size: 14px; margin-top: 2px; }
html[data-theme="dark"] .dict-zh { color: #7fd6a4; }
.dict-ex { margin: 5px 0 5px 26px; font-size: 14px; }
.dict-ex::before { content: "• "; color: var(--muted); }
.dict-ex .ex-en { color: var(--text); }
.dict-group-zh {
  margin: 6px 0 4px 26px; font-size: 14.5px; color: #2f6b4f; font-weight: 600;
}
html[data-theme="dark"] .dict-group-zh { color: #7fd6a4; }
.dict-src-note { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* lookup head tag toggles */
.tag-toggle {
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 20px;
  padding: 3px 11px;
  cursor: pointer;
  color: var(--muted);
}
.tag-toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
/* icon-style tag toggles in the lookup head */
.icon-btn.tag-toggle { border-radius: 8px; padding: 0; font-size: 16px; color: var(--text); }
.icon-btn.tag-toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* desktop: the lookup drawer is a fixed overlay on the right — it never
 * pushes or re-scales the article, so line wraps / page counts stay put */
/* reader: always reserve the right-side word-panel space (desktop), from
 * article open to close, so the lookup drawer never shifts the text */
@media (min-width: 721px) {
  body.reader-open .main { margin-right: 440px; }
}

/* lookup count badges in reader */
.article .w sup.cnt {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 2px;
  line-height: 1;
}

/* wordbook: word as button + notes */
.wb-word {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  font-family: inherit;
  text-decoration: none;
  display: inline;
}
.wb-word:hover { color: var(--accent); text-decoration: underline; }
.wb-notes-snippet { font-size: 13px; color: var(--muted); font-style: italic; margin: 4px 0; }
.notes-editor { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.notes-editor textarea { min-height: 70px; margin-bottom: 8px; }

.panel-error { padding: 12px 14px; font-size: 14px; color: var(--muted); }
.inline-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- history (dictionary tab: recent lookups) ---------- */
.history { display: flex; flex-direction: column; margin-top: 12px; }
.history:empty { display: none; }
.hist-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; border-bottom: 1px solid var(--border);
  padding: 6px 4px;
}
.hist-item:last-child { border-bottom: none; }
.hist-item:hover { background: var(--accent-soft); }
.hist-go {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 16px;
  background: none; border: none; text-align: left; cursor: pointer; padding: 8px 0;
}
.hist-wordrow { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.hist-ipa { font-size: 14px; color: var(--muted); white-space: nowrap; }
.hist-say {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  font-size: 20px; padding: 8px 10px; border-radius: 8px; color: var(--text);
}
.hist-say:hover { background: var(--accent-soft); }
.hist-clock { font-size: 22px; color: var(--muted); flex-shrink: 0; }
.hist-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hist-word { font-size: 20px; font-weight: 700; color: var(--text); }
.hist-snippet {
  font-size: 15px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hist-count {
  flex-shrink: 0; font-size: 13px; color: var(--muted);
  background: var(--surface); border-radius: 6px; padding: 5px 10px;
  white-space: nowrap;
}
/* new-word + sweet-spot badges on article rows */
.newwords-badge {
  font-size: 12px; color: var(--muted); background: var(--badge-bg);
  border-radius: 4px; padding: 2px 8px; white-space: nowrap;
}
.sweetspot-badge {
  font-size: 12px; color: var(--ok); background: var(--ok-soft);
  border-radius: 4px; padding: 2px 8px; font-weight: 700; white-space: nowrap;
}
/* streak banner */
#streak-banner { margin-bottom: 20px; }
.streak-line {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; padding: 4px 0;
}
.streak-fire { font-size: 18px; }
.streak-count { font-weight: 700; }
.streak-bar {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--badge-bg); overflow: hidden; min-width: 60px;
}
.streak-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.streak-goal { color: var(--muted); font-size: 14px; white-space: nowrap; }
/* quiz overlay */
#quiz-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: var(--bg); display: flex; justify-content: center;
  padding: 24px 16px; overflow-y: auto;
}
#quiz-overlay[hidden] { display: none; }
.quiz-box { width: 100%; max-width: 640px; }
.quiz-sentence {
  font-size: 19px; line-height: 1.7; margin: 24px 0;
  padding: 18px; background: var(--surface); border-radius: 10px;
}
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-opt { padding: 12px; font-size: 16px; }
.quiz-opt.correct { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.quiz-opt.wrong { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.quiz-opt:disabled { cursor: default; opacity: 1; }
.quiz-feedback { margin-top: 14px; font-size: 16px; }
.ok-text { color: var(--ok); font-weight: 700; }
.err-text { color: var(--danger); font-weight: 700; }
.quiz-result { text-align: center; margin-top: 40px; }
.quiz-score { font-size: 48px; font-weight: 800; margin-bottom: 8px; }
/* floating phrase-lookup button on text selection */
.sel-lookup-btn {
  position: fixed; z-index: 200; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: sel-pop 0.15s ease-out;
}
@keyframes sel-pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.phrase-save { padding: 2px 8px; font-size: 14px; }
.phrase-save.saved { color: var(--ok); }
/* per-word personal notes at the bottom of the lookup panel */
#word-note-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.note-head { font-weight: 700; font-size: 15px; margin-bottom: 8px; }
.note-preview {
  white-space: pre-wrap; font-size: 15px; line-height: 1.6;
  background: var(--surface); border-radius: 8px; padding: 10px 12px;
}
#word-note-input {
  width: 100%; box-sizing: border-box; font-size: 15px; line-height: 1.6;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  background: var(--bg); color: var(--text); resize: vertical;
}
#word-note-input:focus { outline: none; border-color: var(--accent); }

/* ---------- wordbook ---------- */
.filter-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-btns button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
}
.filter-btns button.active { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }

/* settings accordion groups */
.settings-group { border: 1px solid var(--border); border-radius: var(--radius);
  margin: 8px 0; background: var(--surface); }
.settings-group > summary { cursor: pointer; padding: 12px 14px; font-weight: 600;
  font-size: 15px; list-style: none; display: flex; align-items: center; gap: 8px; }
.settings-group > summary::-webkit-details-marker { display: none; }
.settings-group > summary::before { content: '▸'; color: var(--muted); font-size: 12px;
  transition: transform 0.15s; }
.settings-group[open] > summary::before { transform: rotate(90deg); }
.settings-group > summary:hover { background: rgba(0,0,0,0.03); }
.settings-body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.settings-body > :first-child { margin-top: 10px; }

/* fsrs review */
.fsrs-btns { gap: 6px; flex-wrap: wrap; }
.fsrs-btns .btn { min-width: 70px; }
.quiz-cloze { margin: 12px 0; padding: 12px; background: var(--surface);
  border: 1px dashed var(--border); border-radius: 8px; font-style: italic;
  line-height: 1.6; }
.cloze-blank { font-weight: 700; color: var(--accent); letter-spacing: 2px; }

/* stats */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat-box { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; text-align: center; }
.stat-num { font-size: 24px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
#vocab-chart { margin: 12px 0; }
#vocab-chart svg { width: 100%; height: auto; display: block; }
#vocab-range { margin-bottom: 8px; }
.user-row { display: flex; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-row .grow { flex: 1; }
.user-badge { font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: var(--invert-bg); color: var(--invert-text); }
.user-link { font-size: 15px; }
.spam-box { background: #fef3e2; border: 1px solid #f0c36d; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.user-doc-list { display: flex; flex-direction: column; }
.user-doc-row { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
/* ---- 朗读/短语/激励/周报 ---- */
.sel-toolbar { position: absolute; z-index: 200; display: flex; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.phrase-panel { margin-top: 12px; }
.phrase-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0;
  border-bottom: 1px solid var(--border); }
.phrase-row:last-child { border-bottom: none; }
.phrase-sent { font-style: italic; margin-top: 2px; }
.ai-explain-box { border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px;
  margin: 8px 0; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.ai-explain-text { font-size: 14px; line-height: 1.7; margin: 6px 0; white-space: pre-wrap; }
.streak-cal { display: flex; gap: 3px; margin: 8px 0; }
.streak-week { display: flex; flex-direction: column; gap: 3px; }
.streak-day { width: 12px; height: 12px; border-radius: 3px; background: var(--border); }
.streak-day.on { background: var(--accent); }
.streak-day.future { opacity: .25; }
.streak-num { font-size: 22px; font-weight: 700; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 13px; padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border); }
.badge.earned { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: var(--accent); }
.badge.locked { opacity: .45; filter: grayscale(1); }
.checklist { display: flex; flex-direction: column; gap: 4px; }
.check-item { font-size: 14px; }
.check-item.done { color: var(--muted); text-decoration: line-through; }
.curve-bars { display: flex; align-items: flex-end; gap: 4px; margin: 8px 0; min-height: 80px; }
.curve-bar { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.curve-fill { width: 100%; max-width: 26px; background: var(--accent); border-radius: 3px 3px 0 0; opacity: .85; }
.curve-fill.green { background: #4caf50; }
.curve-x { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.shadowing-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin: 8px 0; }
.shadow-score { font-size: 32px; font-weight: 800; }
.pwa-guide ol { margin: 8px 0 8px 20px; line-height: 1.8; font-size: 14px; }
.user-doc-link { font-size: 14px; text-align: left; }
.user-doc-content { margin: 4px 0 8px; }
.doc-inspect { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.doc-inspect-head { padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.doc-inspect-body { padding: 12px; max-height: 300px; overflow-y: auto; white-space: pre-wrap;
  font-size: 14px; line-height: 1.6; }
.viol-box { background: #fdecea; border-color: #e08080; }
.import-subtab { margin-top: 12px; }
#news-ranges { margin-top: 8px; margin-bottom: 4px; }
#news-ranges button { font-size: 13px; padding: 5px 12px; }
#news-fallback-notice { margin: 8px 0; padding: 8px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; }

.wb-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.wb-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.wb-select { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex: none; align-self: center; }
.wb-audio { background: none; border: none; padding: 2px; font-size: 15px; cursor: pointer; line-height: 1; flex: none; }
.wb-audio:hover { transform: scale(1.15); }
.wb-word { font-size: 18px; font-weight: 700; margin: 0; }
.wb-preview { color: var(--muted); font-size: 14px; margin: 4px 0; }
.wb-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: 13px; }
.src-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border-radius: 4px; padding: 2px 7px; }
.src-badge.auto { background: var(--auto-bg); color: var(--auto-text); }
.src-badge.manual { background: var(--accent-soft); color: var(--accent); }
.src-badge.reader { background: var(--ok-soft); color: var(--ok); }
.wb-article { color: var(--muted); font-size: 13px; margin: 4px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-article-link { background: none; border: none; padding: 0; font: inherit; color: var(--leaf-d); cursor: pointer; text-align: left; text-decoration: none; display: inline; }
.wb-article-link:hover { text-decoration: underline; }
/* <a> used as a button keeps button look */
a.btn { text-decoration: none; display: inline-block; }
/* wordbook "by article" view */
.wb-article-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.wb-article-title { font-size: 16px; font-weight: 600; flex: 1; min-width: 200px; }
.wb-article-words { width: 100%; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.wb-article-word { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border-light); }
.wb-article-word:last-child { border-bottom: none; }
.count-badge { color: var(--muted); }
.wb-actions { margin-left: auto; display: flex; gap: 6px; }
.tag-editor { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.tag-editor label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.tag-editor input { width: auto; accent-color: var(--accent); }
.mastered-btn.on { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok); font-weight: 600; }

/* ---------- review ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { font-size: 13px; color: var(--muted); }
.stat-btn { cursor: pointer; font: inherit; color: inherit; }
.stat-btn:hover { border-color: var(--accent); }
.stat-btn:hover .num { color: var(--accent); }
.stat-words { grid-column: 1 / -1; margin-top: 4px; }
.stat-word-list { display: flex; flex-wrap: wrap; gap: 6px; }
.unit-card { margin-bottom: 0; border: 2px solid var(--border); border-radius: 12px;
  padding: 14px 16px; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
#review-units { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
@media (max-width: 720px) { #review-units { grid-template-columns: 1fr; } }
.unit-card:hover { border-color: var(--accent); }
.unit-priority { border-color: var(--accent); }
.unit-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.unit-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.unit-buckets { display: flex; flex-wrap: wrap; gap: 6px; }
.unit-buckets .bucket { font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 2px 10px; color: var(--muted); }
.unit-buckets .bucket b { color: var(--text); }
.unit-words { margin-top: 8px; }

.quiz-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  margin-top: 16px;
  background: var(--bg);
}
.quiz-word { font-size: 40px; font-weight: 700; margin: 8px 0; }
button.quiz-word-btn {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
}
button.quiz-word-btn:hover { text-decoration: underline; }
.dim-chip[aria-pressed="true"] {
  background: var(--danger, #c0392b);
  color: #fff;
  border-color: var(--danger, #c0392b);
}
.quiz-answer { font-size: 16px; color: var(--muted); margin: 12px 0; min-height: 24px; }
.quiz-progress { font-size: 13px; color: var(--muted); }
.quiz-phon { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0 10px; }
.quiz-ipa { font-size: 17px; color: var(--text); font-family: "Charis SIL", "Doulos SIL", serif; }
.quiz-audio { font-size: 20px; }

/* ---------- library ---------- */
.lib-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--surface);
}
.lib-title { font-weight: 600; margin: 0 0 2px; }
.lib-meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.lib-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* reading progress: slim bar + percent */
.progress-wrap { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  min-width: 60px;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-pct { font-size: 12px; color: var(--muted); min-width: 38px; text-align: right; }

/* article is its own scroll container so reading progress can be tracked */
#article-body { max-height: calc(100vh - 260px); max-height: calc(100dvh - 260px); min-height: 300px; overflow-y: auto; }
/* Readlang-style fullscreen reader: the article spans the viewport width */
#reader-view.reader-full { max-width: none; }
/* reader is a full-height column; the pagebar pins to the viewport bottom */
#reader-view {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 90px);
  min-height: calc(100dvh - 90px);
}
#reader-view .pagebar {
  margin-top: auto;
  padding: 14px 0 18px;
}
/* paged (Readlang-style) mode: fixed-height viewport, pages slide via transform.
   Height uses svh (small viewport = browser UI shown): unlike dvh it never
   changes when the mobile URL bar shows/hides, so the measured line grid
   can't go stale and the bottom line can't get clipped by a shrunken viewport. */
#article-body.paged {
  height: calc(100vh - 330px);
  height: calc(100svh - 330px);
  min-height: 340px;
  max-height: none;
  overflow: hidden;
}
#article-pages { will-change: transform; position: relative; }
/* bookmark marker: tiny superscript flag pinned right after the word */
.bkmk { font-size: 0.62em; vertical-align: super; line-height: 1; margin-left: 2px; }
#bookmark-btn.armed { background: var(--accent); color: var(--on-accent); }
.pagebar { justify-content: center; align-items: center; gap: 10px; margin-top: 10px; }
#page-indicator { min-width: 70px; text-align: center; font-variant-numeric: tabular-nums; }
/* mobile: 8 pagebar buttons must fit — tighten gaps and padding */
@media (max-width: 600px) {
  .pagebar { gap: 6px; }
  .pagebar .btn.small { padding: 7px 9px; font-size: 13px; }
  #page-indicator { min-width: 62px; }
}

/* document editor modal */
.editor-modal { max-width: 680px; }
.editor-modal h3 { margin: 0 0 12px; }
#editor-content { min-height: 280px; }
.import-block { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 10px; }
.import-block:first-of-type { border-top: 0; margin-top: 0; }

/* ---------- settings ---------- */
.panel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--surface);
}
.panel-row .lbl { flex: 1; font-weight: 600; }
.panel-row input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.panel-row .drag-handle {
  cursor: grab;
  color: var(--muted, #999);
  font-size: 14px;
  letter-spacing: 1px;
  user-select: none;
  padding: 4px 2px;
  touch-action: none;
}
.panel-row .drag-handle:active { cursor: grabbing; }
.panel-row.dragging { opacity: 0.45; }
.panel-row.drag-over { box-shadow: 0 -3px 0 0 var(--accent); }
.order-btns { display: flex; gap: 2px; }
.order-btns button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
}
.order-btns button:hover:not(:disabled) { background: var(--bg); }
.order-btns button:disabled { opacity: 0.35; cursor: default; }

/* uploaded-dictionary health warning (dict manager list) */
.dict-warning {
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid #d97706;
  border-left: 4px solid #d97706;
  border-radius: 6px;
  background: #fef3c7;
  color: #92400e;
  font-size: 13px;
  line-height: 1.45;
}
html[data-theme="dark"] .dict-warning,
html[data-theme="warm"] .dict-warning {
  background: #3a2b12;
  color: #fcd34d;
  border-color: #b45309;
}

/* ---------- home ---------- */
.spot-chip { cursor: pointer; font-size: 14px; padding: 5px 14px; font: inherit; color: var(--text); background: var(--bg); }
.spot-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- review (SRS) ---------- */
#srs-area { margin-top: 12px; }

/* ---------- import / collect ---------- */
#collect-results .lib-entry:last-child { margin-bottom: 0; }
#collect-results { margin-top: 12px; }

/* ---------- import / hot news ---------- */
#news-list { margin-top: 12px; }
#news-list .lib-entry:last-child { margin-bottom: 0; }
#news-topics { margin: 10px 0 4px; flex-wrap: wrap; }
.lib-title a { color: var(--text); text-decoration: none; }
.lib-title a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- settings: appearance ---------- */
.color-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
input[type="color"] {
  width: 44px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  cursor: pointer;
}
/* library group tabs sit above the search box */
#library-group-tabs { margin-bottom: 12px; flex-wrap: wrap; }

/* ---------- toast & modal ---------- */
#toast-wrap {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--invert-bg);
  color: var(--invert-text);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: fadeup 0.2s ease-out;
}
.toast.err { background: var(--danger); }
@keyframes fadeup { from { opacity: 0; transform: translateY(8px); } }

.modal-wrap {
  position: fixed;
  inset: 0;
  background: rgba(15, 22, 40, 0.45);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(20, 30, 60, 0.2);
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .main { padding: 14px 10px 90px; }
  .card { padding: 16px; }
  .article { padding: 18px 16px; font-size: 17px; }
  .topbar { padding: 8px 10px; }
  .brand { display: none; }

  /* lookup becomes a bottom sheet */
  .lookup-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 86vh;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    animation: slideup 0.25s ease-out;
  }
  @keyframes slideup { from { transform: translateY(40px); opacity: 0.6; } }

  #article-body { max-height: calc(100vh - 210px); max-height: calc(100dvh - 210px); min-height: 240px; }
  #editor-content { min-height: 40vh; }
}

/* ---- Ren chat (admin direct line) ---- */
.renchat-log {
  max-height: 70vh; max-height: 70dvh; min-height: 120px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.renchat-empty { text-align: center; padding: 28px 10px; font-size: 15px; color: var(--muted); }
.ticket-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); flex-shrink: 0; }
.ticket-card.ticket-open { border-color: var(--accent); }
.ticket-head { display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 12px; background: none; border: none; cursor: pointer; font-size: 14px; text-align: left; }
.ticket-id { font-weight: 700; color: var(--muted); white-space: nowrap; }
.ticket-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-badge { font-size: 12px; white-space: nowrap; }
.ticket-body { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 10px;
  border-top: 1px solid var(--border); }
.ticket-body[hidden] { display: none; }
.renchat-msg { display: flex; flex-direction: column; max-width: 85%; }
.renchat-msg.me { align-self: flex-end; align-items: flex-end; }
.renchat-msg.ren { align-self: flex-start; align-items: flex-start; }
.renchat-bubble {
  padding: 9px 13px; border-radius: 16px; font-size: 15px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.renchat-msg.me .renchat-bubble {
  background: var(--accent); color: var(--on-accent);
  border-bottom-right-radius: 5px;
}
.renchat-msg.ren .renchat-bubble {
  background: var(--accent-soft); color: var(--text);
  border-bottom-left-radius: 5px;
}
.renchat-time { margin-top: 3px; font-size: 11px; }

/* ---- Public library ---- */
.pub-stars { display: inline-flex; gap: 2px; }
.pub-star { background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--border); padding: 2px; line-height: 1; }
.pub-star.on { color: #f5a623; }
.pub-star:hover { transform: scale(1.15); }
.pub-rate-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 6px 0; }
.pub-feel { display: inline-flex; gap: 6px; }
.pub-feel-btn.on { background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600; }
.pub-stats { color: var(--muted); }

/* ---- Admin stat tables ---- */
.stat-table-wrap { overflow-x: auto; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stat-table th, .stat-table td { text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--border); vertical-align: top; }
.stat-table th { font-size: 12px; color: var(--muted); font-weight: 600;
  white-space: nowrap; }
.stat-table td.small { font-size: 12px; color: var(--muted); white-space: nowrap; }
/* pronunciation-tips button in the word head (after the speaker) */
.word-audio.head-tips { position: relative; }
.word-audio.head-tips sup {
  font-size: 10px; font-weight: 700; color: var(--accent);
  margin-left: 1px;
}
/* smooth momentum scrolling for the horizontal head rows on iOS */
.dh-meta, .dh-actions-row { -webkit-overflow-scrolling: touch; }

/* narrow screens: let the word-head meta row wrap instead of clipping */
@media (max-width: 640px) {
  .dh-meta { flex-wrap: wrap; overflow-x: visible; row-gap: 6px; }
  .dh-meta > * { flex-shrink: 1; }
}

/* TTS read-along: sentence being spoken */
.tts-sent { border-radius: 3px; transition: background-color .25s; }
.tts-sent.tts-active { background: rgba(255, 200, 60, .45); }

/* AI Write: pasted-image preview */
#ai-gen-img-preview { display: inline-flex; align-items: center; gap: 6px; }
#ai-gen-img-preview[hidden] { display: none; }
#ai-gen-img-thumb { height: 44px; border-radius: 6px; border: 1px solid var(--border); }
/* Reader: article cover + vocab illustration gallery */
#article-hero { text-align: center; padding: 10px 12px 0; }
#article-hero[hidden] { display: none; }
#article-hero img { max-width: 100%; max-height: 200px; border-radius: 10px; }
#vocab-gallery { padding: 10px 12px 0; }
#vocab-gallery[hidden] { display: none; }
.vg-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.vg-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.vg-card { flex: 0 0 auto; width: 112px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; cursor: pointer; }
.vg-card img { width: 100%; height: 84px; object-fit: cover; border-radius: 6px; display: block; background: var(--badge-bg); }
.vg-cap { display: block; font-size: 13px; font-weight: 600; text-align: center; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Ren real-time chat: floating bubble + dialog (separate from IT Support) ---- */
.ren-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 1200;
  width: 56px; height: 56px; border-radius: 50%;
  font-size: 26px; line-height: 1; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
  border: none; box-shadow: 0 4px 16px rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
}
.ren-fab:hover { background: var(--accent-hover); }
.ren-fab[hidden] { display: none; }
.ren-dialog {
  position: fixed; right: 22px; bottom: 90px; z-index: 1200;
  width: min(380px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 130px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.28); overflow: hidden;
}
.ren-dialog[hidden] { display: none; }
.ren-dialog-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.ren-dialog-title { font-weight: 700; font-size: 15px; flex: 1; }
.ren-dialog-sub { padding: 6px 12px 0; }
.ren-dialog-log {
  flex: 1; min-height: 220px; max-height: 380px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; padding: 12px;
}
.ren-dialog-empty { text-align: center; padding: 30px 12px; font-size: 15px; color: var(--muted); line-height: 1.7; }
.ren-dialog-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }

/* ---- AI word follow-up Q&A thread ---- */
.ai-qa-log {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 300px; overflow-y: auto; padding: 10px 2px 2px;
}
.ai-qa-msg { display: flex; flex-direction: column; max-width: 92%; }
.ai-qa-msg.me { align-self: flex-end; align-items: flex-end; }
.ai-qa-msg.ai { align-self: flex-start; align-items: flex-start; }
.ai-qa-bubble {
  padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.ai-qa-msg.me .ai-qa-bubble { background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.ai-qa-msg.ai .ai-qa-bubble { background: var(--accent-soft); color: var(--text); border-bottom-left-radius: 4px; }

/* ---------- 拼音输入法 (pinyin IME) ---------- */
.pinyin-toggle {
  font: inherit;
  font-size: 13px;
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 8px;
  padding: 9px 10px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
}
.pinyin-toggle:hover { background: var(--bg); color: var(--text); }
.pinyin-toggle.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
.pinyin-toggle.on.eng {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}
#pinyin-popup {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
  padding: 6px 8px;
  font-size: 17px;
  line-height: 1.9;
  max-width: 90vw;
}
#pinyin-popup .pc {
  display: inline-block;
  padding: 0 7px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
#pinyin-popup .pc:hover { background: var(--accent-soft); }
#pinyin-popup .pc b {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-right: 3px;
}
#pinyin-popup .pc-more { color: var(--muted); padding: 0 4px; }
#pinyin-popup .py-comp {
  font-size: 11px;
  color: var(--muted);
  padding: 0 6px 3px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
  white-space: nowrap;
}
#pinyin-popup .pc.pw b { color: var(--accent); font-weight: 700; }

/* ---- AI features list in Settings ---- */
.ai-feature-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.ai-feature-row:last-child { border-bottom: none; }
.ai-feature-info { flex: 1; min-width: 0; }
.ai-feature-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.ai-feature-row label { white-space: nowrap; padding-top: 2px; }

/* audio sync highlight (color configurable in Settings → Reading) */
:root { --audio-hl: #fef08a; }
#article-body .audio-hl {
  background-color: var(--audio-hl);
  border-radius: 3px;
}

/* 口语复述 */
.retell-md {
  background: var(--bg, #fafaf9);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.7;
  white-space: normal;
}

/* 口语复述评价 */
.retell-score {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 0; font-size: 14px;
}
.retell-stars { color: #f5b301; letter-spacing: 2px; }
.retell-compare { margin-top: 6px; }
.retell-trans {
  background: #fff; border: 1px solid var(--border);
  border-radius: 6px; padding: 8px; font-size: 13.5px; line-height: 1.6;
}

/* 听写模式 */
.dict-sentence {
  font-size: 16px; line-height: 2.2;
  background: var(--bg, #fafaf9);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 12px;
}
.dict-blank {
  border: 1.5px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font-size: 15px; text-align: center;
  background: #fff; margin: 0 2px;
}
.dict-blank:focus { outline: none; border-color: var(--accent); }

/* 盲听模式：遮住文章文字 */
#article-body.blind-mode {
  filter: blur(8px);
  user-select: none;
  pointer-events: none;
}

/* 写作：中英对照 */
.writing-cols {
  display: flex; gap: 16px;
}
.writing-col { flex: 1; min-width: 0; }
.writing-sent {
  padding: 8px; margin-bottom: 6px; border-radius: 6px;
  line-height: 1.7; cursor: pointer;
  border: 1px solid transparent;
}
.writing-sent:hover { background: var(--bg, #fafaf9); border-color: var(--border); }
.writing-zh { font-size: 15px; }
.writing-en { font-size: 15px; }
.writing-hl {
  background: #fef08a !important;
  border-color: #facc15 !important;
}
.writing-note {
  font-size: 13px; color: var(--muted);
  background: #f0fdf4; border-left: 3px solid #16a34a;
  padding: 6px 10px; margin: -2px 0 8px 0; border-radius: 0 6px 6px 0;
  line-height: 1.6;
}
@media (max-width: 640px) {
  .writing-cols { flex-direction: column; }
}

/* 作文批改 */
.essay-change {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; margin: 6px 0; font-size: 14px; line-height: 1.6;
  background: #fff;
}
.essay-type {
  display: inline-block; color: #fff; font-size: 12px;
  padding: 1px 8px; border-radius: 10px; margin-right: 4px;
}

/* 作文批改改版（2026-10-19；2026-10-20 改整篇显示）：整篇左右对照 + 分类标注 + 篇内点句联动 + 修改点双排序 */
.essay-legend {
  font-size: 13px; color: var(--muted); line-height: 1.9;
  margin: 4px 0 10px;
}
.essay-mark-spelling {
  text-decoration: underline wavy #dc2626 1.5px;
  text-underline-offset: 3px;
}
.essay-mark-grammar {
  text-decoration: underline solid #d97706 2px;
  text-underline-offset: 3px;
}
.essay-mark-expression, .essay-mark-native {
  background: var(--accent-soft); border-radius: 3px; padding: 0 2px;
}
.essay-pair {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0;
}
.essay-pair-head {
  font-weight: 700; font-size: 14px; margin: 12px 0 0;
}
.essay-cell {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 15px; line-height: 1.7;
  background: var(--surface); overflow-wrap: break-word;
}
.essay-cell-corr { background: var(--ok-soft); }
.essay-cell-tag {
  display: block; font-size: 11px; font-weight: 700; color: var(--muted);
  margin-bottom: 4px;
}
.essay-cell.essay-hl {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
/* 整篇显示（2026-10-20）：整篇块内的段落与句子 */
.essay-para + .essay-para { margin-top: 10px; }
.essay-sent { cursor: pointer; border-radius: 3px; }
.essay-sent.essay-hl {
  background: #fef08a;
  box-shadow: 0 0 0 1px #facc15;
}
.essay-ok { color: var(--ok); font-weight: 700; }
.essay-sent-detail {
  border: 1px dashed var(--border); border-radius: 8px;
  padding: 10px 12px; margin: 10px 0; font-size: 14px; line-height: 1.6;
  background: var(--surface);
}
.essay-changes-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin: 14px 0 4px;
}
.essay-sort-toggle { display: inline-flex; gap: 6px; }
.essay-cat-head {
  display: flex; align-items: center; gap: 6px; margin: 12px 0 2px;
}
.essay-change[data-sent-jump] { cursor: pointer; }
.essay-change[data-sent-jump]:hover { border-color: var(--accent); }
@media (max-width: 700px) {
  .essay-pair { grid-template-columns: 1fr; gap: 6px; }
  .essay-pair-head { display: none; }
  .essay-cell-long { min-height: 0; }
}

/* 背单词统计表 */
.vocab-stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.vocab-stats-table th, .vocab-stats-table td {
  padding: 4px 8px; text-align: left; border-bottom: 1px solid var(--border);
}
.vocab-stats-table th { color: var(--muted); font-weight: 600; }

/* Nursing 刷题 */
.nursing-opt {
  display: block; padding: 8px 12px; margin: 4px 0;
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; font-size: 14px; line-height: 1.6;
  background: #fff;
}
label.nursing-opt:hover { background: var(--bg, #fafaf9); border-color: var(--accent); }
.nursing-opt input { margin-right: 8px; }

/* 中英反向查词候选 */
.dict-zh-candidate {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; margin: 6px 0; cursor: pointer;
  background: #fff; line-height: 1.6;
}
.dict-zh-candidate:hover { border-color: var(--accent); background: var(--bg, #fafaf9); }

/* 🔍 描述找词结果 */
.dict-reverse-best {
  border: 2px solid var(--accent); border-radius: 10px;
  padding: 12px 14px; margin: 8px 0; cursor: pointer;
  background: #fff; line-height: 1.6;
}
.dict-reverse-best:hover { background: var(--bg, #fafaf9); }

/* nursing 练习模式选项按钮 */
.nursing-opt-btn {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; margin: 6px 0; cursor: pointer;
  background: #fff; font-size: 14px; line-height: 1.6;
}
.nursing-opt-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--bg, #fafaf9); }
.nursing-opt-btn:disabled { cursor: default; opacity: 0.85; }
.nursing-opt-picked { border-color: #f59e0b; background: #fef3c7; }
.nursing-opt-right { border-color: #16a34a !important; background: #dcfce7 !important; font-weight: 600; }

/* ===== Nursing 科目网格（2-4列可配） ===== */
#nursing-subjects {
  --nursing-cols: 2;
  display: grid;
  grid-template-columns: repeat(var(--nursing-cols), 1fr);
  gap: 12px;
}
#nursing-subjects .nursing-subject-card {
  margin-bottom: 0;
}
@media (max-width: 600px) {
  #nursing-subjects {
    grid-template-columns: 1fr 1fr;
  }
}
/* 板块顺序拖拽 */
.nursing-order-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--card-bg, #fff);
  cursor: grab;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nursing-order-item:active {
  cursor: grabbing;
}

/* Nursing 题目点词查词 */
.nursing-wlookup {
  cursor: pointer;
  border-bottom: 1px dotted #999;
}
.nursing-wlookup:hover {
  background: #fff3cd;
  border-bottom-color: #333;
}

/* Nursing 刷题新布局：左侧边栏 + 右侧题目 */
.nursing-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 4px;
}
.nursing-nav-box {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
}
.nursing-nav-box.nav-unanswered { background: #e5e7eb; color: #666; }
.nursing-nav-box.nav-correct { background: #16a34a; color: #fff; border-color: #16a34a; }
.nursing-nav-box.nav-wrong { background: #dc2626; color: #fff; border-color: #dc2626; }
.nursing-nav-box.nav-current { outline: 2px solid #6366f1; outline-offset: 1px; }
.nursing-opt-select {
  cursor: pointer;
}
.nursing-opt-select.selected {
  border-color: #6366f1 !important;
  background: #eef2ff !important;
}
.nursing-opt-select.disabled {
  opacity: 0.7;
  cursor: default;
}
.nursing-opt-correct {
  border-color: #16a34a !important;
  background: #dcfce7 !important;
}
@media (max-width: 1000px) {
  .nursing-practice-layout { flex-wrap: wrap; }
  /* 窄屏：解析面板必须是整块自然高度——保留 flex/overflow 会被 flex 压成一行高的小窗（Andy 2026-10-15 报障） */
  .nursing-rationale-panel { width: 100%; position: static; max-height: none; flex: none; overflow: visible; }
}
@media (max-width: 700px) {
  /* 手机端练习布局改普通块级堆叠：flex 竖排会把整屏锁住滑不动（Andy 2026-10-15 两次报障），块级布局下题目+解析自然成一页滚动 */
  .nursing-practice-layout { display: block; }
  .nursing-main { flex: none; width: 100%; }
  .nursing-rationale-panel { flex: none; width: 100%; overflow: visible; }
  /* 手机端整个侧边栏区域隐藏，空间全留给题目（Andy 2026-10-15 要求）；
     计时在后台照常运行，完成/退出入口移到题目区底部（.nursing-finish-mobile），电脑端保持原样 */
  .nursing-sidebar { display: none; }
  .nursing-finish-mobile { display: block; }
}

/* Nursing 全屏刷题 */
.nursing-fullscreen {
  position: fixed;
  inset: 0;
  background: var(--bg, #faf8f3);
  z-index: 1000;
  overflow-y: auto;
}
.nursing-fs-header {
  position: sticky;
  top: 0;
  background: var(--bg, #faf8f3);
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: center;
  z-index: 10;
}
.nursing-fs-practice {
  padding: 16px 24px;
  /* 全屏：不用 max-width，沾满宽度 */
}
/* Nursing 三栏布局：左统计 | 中题目 | 右解析 —— 固定宽度 */
.nursing-practice-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  width: 100%;
}
.nursing-sidebar {
  flex: 0 0 220px;
  position: sticky;
  top: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg, #fff);
}
.nursing-main {
  flex: 1 1 0;
  min-width: 0;
}
/* 题目区底部的手机端结束入口：默认隐藏，只在 ≤700px 显示 */
.nursing-finish-mobile {
  display: none;
  margin-top: 10px;
}
.nursing-rationale-panel {
  flex: 1 1 0;
  position: sticky;
  top: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg, #fff);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.nursing-fs-practice {
  padding: 16px 24px;
  width: 100%;
  max-width: none;
}

/* Nursing 刷题 UI 优化 */
.nursing-q-card {
  padding: 20px 24px;
}
.nursing-q-stem {
  font-size: 16px;
  line-height: 1.8;
  margin: 12px 0 16px;
  color: #1f2937;
}
.nursing-opt {
  padding: 12px 16px;
  margin-bottom: 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  line-height: 1.6;
  transition: all 0.15s;
}
.nursing-opt-select:hover {
  border-color: #6366f1;
  background: #f8faff;
}
.nursing-opt-select.selected {
  border-color: #6366f1 !important;
  background: #eef2ff !important;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.15);
}
.nursing-q-num {
  font-size: 14px;
  margin-bottom: 4px;
}
.nursing-sidebar .nursing-timer div {
  font-size: 20px;
  letter-spacing: 0.5px;
}
.nursing-rationale-panel h4 {
  font-size: 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

/* ===== Nursing 模块 UI 优化 ===== */
.nursing-subject-card {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin: 10px 0;
  background: #fff;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.nursing-subject-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.nursing-subject-title { font-size: 16px; font-weight: 700; }
.nursing-subject-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.nursing-chapter-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin: 8px 0;
  background: var(--bg, #fafaf9);
}
.nursing-chapter-title { font-weight: 700; font-size: 14px; }
.nursing-test-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 4px 10px 20px; margin-top: 6px;
  border-top: 1px dashed var(--border);
}
.nursing-test-row:first-child { border-top: none; margin-top: 2px; }
.nursing-test-name { font-weight: 600; font-size: 14px; }
.nursing-test-meta { color: var(--muted); font-size: 12px; }
.nursing-q-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin: 12px 0;
}
.nursing-q-stem { font-size: 15px; line-height: 1.7; margin-bottom: 10px; }
.nursing-q-num { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.nursing-rationale-box {
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px;
  padding: 10px 12px; margin-top: 8px; font-size: 14px; line-height: 1.7;
  white-space: pre-wrap;
}
.nursing-result-ok { background: #dcfce7; border-radius: 8px; padding: 10px 12px; }
.nursing-result-bad { background: #fee2e2; border-radius: 8px; padding: 10px 12px; }
/* 深入讲解：干净排版 */
.nursing-explain-content {
  font-size: var(--nursing-explain-fs, 14px);
  line-height: 1.8;
  color: var(--text);
}
.nursing-explain-content h3,
.nursing-explain-content h4 {
  margin: 14px 0 8px; font-size: 1.1em; color: #1e40af;
  border-bottom: 2px solid #dbeafe; padding-bottom: 4px;
}
.nursing-explain-content strong { color: #111827; }
.nursing-explain-content ul { margin: 8px 0; padding-left: 20px; }
.nursing-explain-content li { margin-bottom: 6px; }
.nursing-explain-content p { margin: 8px 0; }
.nursing-explain-content code {
  background: #f3f4f6; padding: 2px 6px; border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: 0.9em;
}
.nursing-font-ctrl {
  display: inline-flex; gap: 4px; align-items: center;
  margin-left: 8px; vertical-align: middle;
}
.nursing-font-ctrl button {
  width: 24px; height: 24px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; cursor: pointer;
  font-size: 13px; line-height: 1;
}
.nursing-font-ctrl button:hover { background: #f3f4f6; }
/* markdown 表格 */
.nursing-md-table {
  width: 100%; border-collapse: collapse; margin: 10px 0;
  font-size: 0.95em;
}
.nursing-md-table td, .nursing-md-table th {
  border: 1px solid #d1d5db; padding: 8px 10px; text-align: left;
}
/* 追问 Q&A 卡片 */
.nursing-followup-card {
  margin-top: 10px; padding: 12px 14px;
  background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 10px;
}
.nursing-followup-q {
  font-weight: 700; color: #0369a1; margin-bottom: 8px;
  font-size: 14px; line-height: 1.6;
}
.nursing-followup-a {
  background: #fff; border-radius: 8px; padding: 10px 12px;
  border: 1px solid #e0f2fe;
}
.nursing-followup-a .nursing-explain-content { font-size: 14px; }
.nursing-md-table tr:nth-child(even) { background: #f9fafb; }
.nursing-md-table tr:first-child td { font-weight: 600; background: #eff6ff; }

/* 📅 日历 */
.cal-weekhead { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-weight: 600; color: var(--muted, #6b7280); padding: 8px 0 4px; font-size: 13px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day { border: 1px solid var(--border, #e5e7eb); border-radius: 8px; padding: 4px; min-height: 118px; display: flex; flex-direction: column; background: var(--card, #fff); }
.cal-day.other-month { opacity: .45; }
.cal-day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-date { display: flex; justify-content: space-between; align-items: baseline; padding: 0 2px 2px; }
.cal-solar { font-weight: 700; font-size: 15px; }
.cal-day.today .cal-solar { color: var(--accent); }
.cal-lunar { font-size: 11px; color: var(--muted, #6b7280); }
.cal-lunar.festival { color: #dc2626; font-weight: 600; }
.cal-half { flex: 1; border-top: 1px dashed var(--border, #e5e7eb); padding: 3px 2px; border-radius: 4px; }
.cal-half.has-exclusive { background: #fff7ed; }
.cal-half-label { font-size: 10px; font-weight: 700; color: var(--muted, #9ca3af); letter-spacing: .5px; }
.cal-item { font-size: 12px; line-height: 1.35; background: var(--accent-soft); border: 1px solid transparent; border-radius: 4px; padding: 2px 4px; margin: 2px 0; cursor: pointer; word-break: break-word; }
.cal-item.exclusive { background: #fee2e2; border-color: #fca5a5; color: #991b1b; font-weight: 600; }
.cal-add { display: block; width: 100%; border: none; background: transparent; color: var(--muted, #9ca3af); font-size: 13px; cursor: pointer; padding: 1px 0; border-radius: 4px; }
.cal-add:hover { background: var(--accent-soft); color: var(--accent); }
.cal-editor { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; }
.cal-editor[hidden] { display: none; }
.cal-editor-card { background: var(--card, #fff); border-radius: 12px; padding: 20px; width: min(92vw, 420px); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.cal-check { display: block; margin-top: 10px; font-size: 14px; cursor: pointer; }
.cal-check input { margin-right: 6px; }
@media (max-width: 640px) { .cal-day { min-height: 96px; padding: 2px; } .cal-item { font-size: 11px; } .cal-lunar { font-size: 10px; } }

/* 📅 日历：整半天填色 + 选色（覆盖前面的独占样式） */
.cal-half.has-exclusive { background: transparent; }
.cal-item.exclusive { background: rgba(255,255,255,.55); border-color: rgba(0,0,0,.18); color: inherit; font-weight: 700; }
.cal-color-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.cal-color-row[hidden] { display: none; }
.cal-swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(0,0,0,.15); cursor: pointer; display: inline-block; }
.cal-swatch.selected { border-color: #111827; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #111827; }
.cal-color-row input[type="color"] { width: 34px; height: 28px; border: none; background: none; cursor: pointer; padding: 0; }

/* 🧭 导航分组 */
.nav-group-menu { position: fixed; z-index: 300; background: var(--card, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 6px; min-width: 150px; }
.nav-group-menu[hidden] { display: none; }
.nav-group-menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14px; }
.nav-group-menu a:hover { background: var(--accent-soft); }
.tabs .nav-group-btn { cursor: pointer; }
.tabs .nav-group-btn.active { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }
.navset-label { font-weight: 600; font-size: 13px; margin: 8px 0 4px; }
.navset-list { min-height: 42px; border: 1px dashed var(--border, #d1d5db); border-radius: 8px; padding: 6px; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; align-content: flex-start; }
.navset-item { background: var(--accent-soft); border-radius: 6px; padding: 5px 9px; font-size: 13px; cursor: grab; user-select: none; }
.navset-group { border: 1px solid var(--border, #e5e7eb); border-radius: 8px; padding: 8px; margin-bottom: 8px; }
.navset-group-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.navset-group .navset-list { margin-bottom: 0; }
.navset-group-grip { cursor: grab; }

/* 🧭 导航设置 v2：单列混合列表 + 分组折叠 */
.navset-entries { display: flex; flex-direction: column; gap: 6px; min-height: 42px; border: 1px dashed var(--border, #d1d5db); border-radius: 8px; padding: 6px; }
.navset-entries > .navset-item { display: block; }
.navset-entries > .navset-group { margin-bottom: 0; }
.navset-group.collapsed .navset-list { display: none; }
.navset-collapse { min-width: 30px; }
.cal-swatch-none { background: linear-gradient(to top right, #fff 44%, #ef4444 46%, #ef4444 54%, #fff 56%); }

/* 📊 练习结果弹窗卡（.card 在本应用里是透明无底的，不能当弹窗用） */
.nursing-result-card { background: var(--surface, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 14px; box-shadow: 0 12px 40px rgba(20,30,60,.28); padding: 20px; width: 100%; max-width: 500px; max-height: 80vh; overflow: auto; }
.cal-repeat-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.cal-repeat-row select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border, #d1d5db); background: var(--surface, #fff); font-size: 14px; }

/* ✅ 待办事项 + 日历格待办条 */
.cal-todos { border-top: 1px dashed var(--border, #d1d5db); padding: 2px 4px; cursor: pointer; }
.cal-todo-line { font-size: 10px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-todo-line.done { text-decoration: line-through; opacity: .55; }
.todo-row { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border, #e5e7eb); border-radius: 10px; margin-bottom: 6px; background: var(--surface, #fff); }
.todo-text { cursor: pointer; }
.todo-done-text { text-decoration: line-through; opacity: .55; }
.todo-due { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: #fef3c7; white-space: nowrap; }
.todo-due.overdue { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.todo-group-title { font-weight: 700; margin: 14px 0 6px; }
.todo-edit { border: 1px solid var(--border, #e5e7eb); border-top: none; border-radius: 0 0 10px 10px; padding: 8px 10px; margin: -6px 0 8px; background: var(--surface, #fff); }

/* 生成中 / 失败持久状态卡（题库同款语义） */
.gen-pending-card { background: #fef9c3; border: 1px solid #fde047; color: #713f12; border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.gen-error-card { background: #fee2e2; border: 1px solid #fca5a5; color: #7f1d1d; border-radius: 10px; padding: 12px 14px; font-size: 14px; }

/* ⚠️ 窄屏覆盖必须位于所有护理基础规则之后：CSS 同优先级按书写顺序生效，
   本文件基础规则（.nursing-practice-layout 等）写在媒体查询之后，
   1685-1696 行的旧覆盖因此一直被基础规则压掉、从未生效（2026-10-15 晚定位）。*/
@media (max-width: 1000px) {
  .nursing-practice-layout { flex-wrap: wrap; }
  .nursing-rationale-panel { width: 100%; position: static; max-height: none; flex: none; overflow: visible; }
}
@media (max-width: 700px) {
  .nursing-practice-layout { display: block; }
  .nursing-main { flex: none; width: 100%; }
  .nursing-rationale-panel { flex: none; width: 100%; overflow: visible; }
  .nursing-sidebar { display: none; }
  .nursing-finish-mobile { display: block; }
}

/* 合集列表页：折叠态正文预览（3 行截断，Andy 2026-10-15） */
.collection-preview { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; font-size:13px; color:var(--muted); line-height:1.6; margin-top:6px; }

/* ===== NGN 案例布局 + 矩阵题（2026-10-16） ===== */
.nursing-case-layout { display: flex; gap: 14px; align-items: flex-start; }
.nursing-case-layout .nursing-q-card { flex: 1; min-width: 0; }
.nursing-case-panel { flex: 0 0 44%; background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 12px; padding: 12px 14px; }
.nursing-case-title { font-weight: 700; margin-bottom: 8px; }
.nursing-case-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.nursing-case-tab { border: 1px solid #a5b4fc; background: #fff; color: #3730a3; border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.nursing-case-tab.active { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.nursing-case-body { font-size: 14px; line-height: 1.55; }
@media (min-width: 701px) {
  .nursing-case-body { max-height: 560px; overflow-y: auto; }
}
.nursing-matrix { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 4px; }
.nursing-matrix th, .nursing-matrix td { border: 1px solid var(--border); padding: 7px 8px; }
.nursing-matrix thead th { background: #f1f5f9; text-align: center; }
.nursing-matrix-rowtext { text-align: left; }
.nursing-matrix-cell { text-align: center; width: 104px; }
.nursing-matrix-cell input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.nursing-matrix-should { background: #dcfce7 !important; }
.nursing-matrix-wrongpick { background: #fee2e2 !important; }
@media (max-width: 700px) {
  .nursing-case-layout { flex-direction: column; }
  .nursing-case-panel { flex: none; width: 100%; box-sizing: border-box; }
  .nursing-matrix { font-size: 13px; }
  .nursing-matrix-cell { width: auto; }
}

/* ===== 待办：拖拽手柄 + 具体时间（2026-10-17） ===== */
.todo-drag { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; color: var(--muted, #94a3b8); font-size: 15px; line-height: 1; padding: 3px 1px 0; flex: none; }
.todo-item.todo-dragging { opacity: .55; }
.todo-item.todo-dragging .todo-row { border-color: #6366f1; }

/* ===== 日历格内待办色块（2026-10-17，有时间的待办进 AM/PM 半天） ===== */
.cal-todo-chip { background: #dcfce7; border-color: #86efac; color: #14532d; font-weight: 600; }
.cal-todo-chip.done { opacity: .55; text-decoration: line-through; font-weight: 400; }

/* ===== 工单续聊 + 用户标记完成（2026-10-17） ===== */
.ticket-foot { border-top: 1px dashed var(--border); padding: 8px 10px; }
.ticket-card.ticket-done { opacity: .72; }

/* ===== 拼音输入法 v3：高亮候选 + 翻页箭头（2026-10-17，追加在末尾保证级联生效） ===== */
#pinyin-popup .pc.sel { background: var(--accent); color: var(--on-accent); }
#pinyin-popup .pc.sel b { color: var(--on-accent); }
#pinyin-popup .pc-nav { display: inline-block; padding: 0 5px; border-radius: 6px; cursor: pointer; color: var(--muted); user-select: none; }
#pinyin-popup .pc-nav:hover { background: var(--accent-soft); color: var(--text); }

/* ===== 写作标记 + 记录（2026-10-17） ===== */
.writing-marks { margin-top: 8px; border: 1px dashed var(--border); border-radius: 8px; padding: 8px; }
.writing-marks-preview { font-size: 14px; line-height: 1.7; white-space: normal; word-break: break-word; margin-bottom: 8px; }
.wmark { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 1px; }
.writing-marks-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wmark-chip { display: inline-flex; align-items: center; gap: 4px; background: #fef9c3; border: 1px solid #fde68a; border-radius: 999px; padding: 2px 8px; font-size: 13px; }
.wmark-chip.editing { border-radius: 8px; background: var(--surface); }
.wmark-x { border: none; background: transparent; cursor: pointer; font-size: 12px; padding: 0 2px; color: var(--muted, #64748b); }
.mark-cards { margin-top: 6px; }
.mark-card { border: 1px solid #fde68a; background: #fffbeb; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.mark-card-head { font-weight: 700; }
.mark-verdict { font-size: 12px; background: #fde68a; border-radius: 999px; padding: 1px 8px; font-weight: 600; }
.mark-card-main { font-size: 16px; font-weight: 700; color: #065f46; margin: 2px 0; }
.writing-rec-row { display: flex; gap: 8px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--border); cursor: pointer; }
.writing-rec-row:last-child { border-bottom: none; }
.writing-rec-preview { font-weight: 600; }
.record-source { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; background: var(--surface); }
.record-source-text { line-height: 1.7; margin-top: 4px; word-break: break-word; }

/* ===== 🗣️ 口语话术包 + 练习聊天（2026-10-18） ===== */
.speak-pack-card { cursor: pointer; margin-bottom: 10px; }
.speak-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.speak-item:last-child { border-bottom: none; }
.speak-warn { color: #b45309; font-size: 13px; margin-top: 2px; }
.speak-rate { display: inline-flex; gap: 2px; }
.speak-rate-btn { border: 1px solid var(--border); background: transparent; border-radius: 999px; padding: 0 6px; font-size: 12px; cursor: pointer; opacity: .45; }
.speak-rate-btn.on { opacity: 1; border-color: var(--accent); background: #ecfdf5; }
.speak-rate-btn.on.r-fuzzy { background: #fef9c3; }
.speak-rate-btn.on.r-unknown { background: #fee2e2; }
.speak-line { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--border); }
.speak-line:last-child { border-bottom: none; }
.speak-who { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; text-align: center; line-height: 22px; font-size: 12px; font-weight: 700; color: #fff; }
.speak-who.who-a { background: #2563eb; }
.speak-who.who-b { background: #059669; }
.speak-eval-wrap { margin: 10px 0; }
.speak-eval { border: 1px solid #fde68a; background: #fffbeb; border-radius: 10px; padding: 10px 12px; }
.speak-eval-sec { margin-top: 8px; font-size: 14px; line-height: 1.6; }
.speak-ex-answer b { color: #065f46; }

/* ===== 🗣️ 口语 UI 优化（2026-10-18 二期）：吸顶导航/自评强化/微信式会话列表 ===== */
.speak-packnav { position: sticky; top: 54px; z-index: 20; display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; margin-top: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.speak-packnav button { border: 1px solid var(--border); background: var(--bg); border-radius: 999px; padding: 4px 10px;
  font-size: 13px; cursor: pointer; }
.speak-packnav button:active { background: #ecfdf5; }
.speak-nav-total { margin-left: auto; font-size: 12px; color: var(--muted); }
.speak-sec { scroll-margin-top: 118px; }
.speak-item.rt-known { border-left: 3px solid #22c55e; padding-left: 8px; }
.speak-item.rt-fuzzy { border-left: 3px solid #eab308; padding-left: 8px; }
.speak-item.rt-unknown { border-left: 3px solid #ef4444; padding-left: 8px; }
.speak-rate-btn { padding: 2px 9px; font-size: 12.5px; opacity: .55; }
.speak-rate-btn.on { opacity: 1; font-weight: 600; }
.speak-chat-row { display: flex; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.speak-chat-row:last-child { border-bottom: none; }
.speak-chat-ico { flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; background: #ecfdf5; display: flex;
  align-items: center; justify-content: center; font-size: 19px; }
.speak-chat-title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.speak-chat-preview { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.speak-chat-time { flex-shrink: 0; text-align: right; color: var(--muted); font-size: 12px; }
.speak-topic-chip { display: inline-block; max-width: 100%; padding: 0 7px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; vertical-align: middle; }
.speak-chat-actions { flex-shrink: 0; display: flex; gap: 2px; }
.speak-chat-actions .btn { padding: 2px 7px; }

/* ===== 🗣️ 口语封面卡（2026-10-18 三期）：非直角有机框 + 渐变 + 横向滑动 ===== */
.speak-pack-row { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 8px 4px 16px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.speak-pack-row::-webkit-scrollbar { display: none; }
.speak-cover { flex: 0 0 228px; height: 292px; scroll-snap-align: start; cursor: pointer; color: #fff;
  border-radius: 42px 84px 42px 84px / 84px 42px 84px 42px; padding: 20px 20px 16px; position: relative;
  overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 12px 24px rgba(15,23,42,.18);
  transform: rotate(-1.1deg); transition: transform .18s ease, box-shadow .18s ease; }
.speak-cover.alt { border-radius: 84px 42px 84px 42px / 42px 84px 42px 84px; transform: rotate(1.1deg); }
.speak-cover:active { transform: scale(.97); }
.speak-cover::before { content: ''; position: absolute; width: 190px; height: 190px; border-radius: 50%;
  background: rgba(255,255,255,.16); top: -80px; right: -60px; }
.speak-cover::after { content: ''; position: absolute; width: 110px; height: 110px; border-radius: 50%;
  background: rgba(255,255,255,.12); bottom: 40px; left: -52px; }
.speak-cover-emoji { font-size: 56px; line-height: 1.1; filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); position: relative; z-index: 1; }
.speak-cover-title { font-size: 19px; font-weight: 800; margin-top: 8px; line-height: 1.3; position: relative; z-index: 1; }
.speak-cover-cando { font-size: 12.5px; line-height: 1.55; opacity: .92; margin-top: 6px; position: relative; z-index: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.speak-cover-foot { margin-top: auto; position: relative; z-index: 1; }
.speak-cover-bar { height: 6px; border-radius: 999px; background: rgba(255,255,255,.35); overflow: hidden; }
.speak-cover-bar span { display: block; height: 100%; background: #fff; border-radius: 999px; }
.speak-cover-meta { font-size: 12px; margin-top: 6px; opacity: .95; }
.speak-pack-hero { color: #fff; border: none; border-radius: 28px 56px 28px 56px / 56px 28px 56px 28px;
  position: relative; overflow: hidden; box-shadow: 0 10px 22px rgba(15,23,42,.16); }
.speak-pack-hero::before { content: ''; position: absolute; width: 170px; height: 170px; border-radius: 50%;
  background: rgba(255,255,255,.15); top: -80px; right: -40px; }
.speak-hero-emoji { position: absolute; right: 16px; bottom: 8px; font-size: 52px; opacity: .9;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); }

/* ===== 🗣️ 话术包卡片（2026-10-18 四期，Andy 定：与题库科目卡同款，收敛版） ===== */
.speak-pack-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.speak-pack-block { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  background: var(--surface); cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s; }
.speak-pack-block:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.speak-pack-cando { font-size: 12.5px; line-height: 1.55; color: var(--muted); margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.speak-pack-bar { height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 10px; }
.speak-pack-bar span { display: block; height: 100%; background: #059669; border-radius: 999px; }
@media (max-width: 420px) { .speak-pack-cando { -webkit-line-clamp: 3; } }

/* ===== 🗣️ 话术包生成器（2026-10-18） ===== */
.speak-gen-cand { display: flex; gap: 8px; align-items: flex-start; padding: 9px 10px; margin-top: 8px;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); }
.speak-gen-cand input { margin-top: 3px; }

/* ===== NGN 题布局（2026-10-20 工单#3，追加在末尾保证级联生效） ===== */
/* NGN：解析不再是右侧第三栏，而是题目区内、选项下方整宽展开；普通题保持三栏不变 */
.nursing-practice-layout--ngn .nursing-rationale-panel {
  position: static; flex: none; width: 100%; box-sizing: border-box;
  max-height: none; overflow: visible; margin-top: 14px;
}

/* ===== 工单多行输入框（2026-10-20 工单#4，追加在末尾保证级联生效） ===== */
/* IT 界面输入框改为 textarea：回车换行、到右边缘自动折行，不再横向滚出看不见。
   全局 textarea{min-height:180px} 对聊天框太大，这里按类覆盖。 */
.chat-textarea {
  min-height: 0; margin-bottom: 0; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: break-word; resize: vertical;
}

/* 💬 Ren 聊天页（2026-10-21 新增，置于文件末尾保证级联生效） */
.renlive-card { max-width: 880px; margin: 0 auto; }
.renlive-log {
  height: calc(100vh - 340px); height: calc(100dvh - 340px);
  min-height: 280px; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
@media (max-width: 700px) {
  .renlive-log { height: calc(100vh - 300px); height: calc(100dvh - 300px); min-height: 220px; }
}

/* 💬 Ren 聊天附件（2026-10-21，追加在文件末尾保证级联生效） */
.renchat-attach-img { display: block; max-width: 230px; max-height: 230px; border-radius: 8px; margin-top: 2px; }
.renchat-attach-chip { display: inline-block; margin-top: 2px; padding: 6px 10px; border: 1px solid #d7dce2; border-radius: 8px; background: #f6f8fa; color: #2456a6; text-decoration: none; font-size: 13px; word-break: break-all; }
.ren-attach-preview { display: flex; align-items: center; gap: 8px; padding-top: 6px; font-size: 13px; }
.ren-attach-preview[hidden] { display: none; }
.ren-attach-name { word-break: break-all; }

/* 💬 Ren 聊天多附件预览（2026-10-21 追加，文件末尾保证级联） */
.ren-attach-preview { flex-wrap: wrap; }
.ren-attach-chip-item { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border: 1px solid #d7dce2; border-radius: 999px; background: #f6f8fa; font-size: 13px; word-break: break-all; }
.renchat-attach-chip { margin-right: 6px; margin-bottom: 4px; }

/* 题目配图 + 点图题（2026-10-21，追加在文件末尾保证覆盖顺序） */
.nursing-q-img { display: block; max-width: 100%; height: auto; margin: 10px 0; border: 1px solid var(--border); border-radius: 8px; }
.nursing-hotspot { position: relative; display: inline-block; max-width: 100%; }
.nursing-hotspot-img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; cursor: crosshair; }
.nursing-hotspot-dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: rgba(37, 99, 235, .85); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); pointer-events: none; }
.nursing-hotspot-dot.ok { background: rgba(22, 163, 74, .9); }
.nursing-hotspot-dot.bad { background: rgba(220, 38, 38, .9); }
.nursing-hotspot-region { position: absolute; border: 2px solid rgba(22, 163, 74, .9); background: rgba(22, 163, 74, .15); border-radius: 4px; pointer-events: none; }

/* 题干内嵌表格（化验值等展品，2026-10-21 追加在文件末尾） */
.nursing-stem-table { border-collapse: collapse; margin: 10px 0; font-size: 13.5px; line-height: 1.45; }
.nursing-stem-table th, .nursing-stem-table td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; vertical-align: top; }
.nursing-stem-table th { background: #f1f5f9; font-weight: 600; }

/* 🧭 导航三级子分组（2026-10-22，追加在文件末尾保证级联生效） */
.nav-subgroup-btn { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14px; cursor: pointer; }
.nav-subgroup-btn:hover { background: var(--accent-soft); }
.nav-sub-arrow { float: right; color: var(--muted); }
.nav-submenu { margin: 2px 0 4px 12px; border-left: 2px solid var(--border, #e5e7eb); padding-left: 4px; }
.nav-submenu[hidden] { display: none; }
.navset-subs { display: flex; flex-direction: column; gap: 6px; }
.navset-subs:not(:empty) { margin-top: 6px; }
.navset-subgroup { border: 1px dashed var(--border, #d1d5db); border-radius: 8px; padding: 6px; background: rgba(0,0,0,.015); }
.navset-subgroup-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.navset-subgroup-tag { font-size: 12px; color: var(--muted); white-space: nowrap; }
.navset-subgroup-grip { cursor: grab; }
.navset-subgroup .navset-list { margin-bottom: 0; }
.navset-group.collapsed .navset-subs { display: none; }

/* ---- 🤖 本地模型账本 ---- */
.models-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-top: 10px; }
.model-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.model-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.model-name { font-weight: 700; font-size: 1.02em; word-break: break-all; }
.model-purpose { margin-top: 6px; }
.model-deleted { opacity: .62; }
.model-deleted .model-name { text-decoration: line-through; }
.badge-update { background: #fff4d6; border: 1px solid #e3c566; color: #7a5b00; border-radius: 999px; padding: 0 8px; font-size: .78em; line-height: 1.7; }
.badge-deleted { background: #eee; border: 1px solid #ccc; color: #666; border-radius: 999px; padding: 0 8px; font-size: .78em; line-height: 1.7; }
.model-update-note { color: #7a5b00; margin-top: 4px; }
.models-reqs { display: flex; flex-direction: column; gap: 6px; }
.models-req { border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; background: #fff; }

/* ---- 🤖 本地模型：分组与清单 ---- */
.model-cell { min-width: 0; }
.model-cell-label { font-weight: 700; margin-bottom: 6px; }
.models-cat-label { font-weight: 700; margin: 12px 0 4px; }
.catalog-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; background: #fff; }
.catalog-main { flex: 1; min-width: 0; }
.catalog-name { font-weight: 700; word-break: break-all; }
.catalog-vnote { color: #7a5b00; }
.catalog-right { flex-shrink: 0; }
.badge-v { border-radius: 999px; padding: 0 8px; font-size: .78em; line-height: 1.7; border: 1px solid; white-space: nowrap; }
.badge-v-ok { background: #e7f6e7; border-color: #9ccf9c; color: #256b25; }
.badge-v-caution { background: #fff4d6; border-color: #e3c566; color: #7a5b00; }
.badge-v-no { background: #fdeaea; border-color: #e0a3a3; color: #8a2b2b; }

/* ---- 🤖 本地模型 UI 优化（2026-10-23）：概览条/筛选/能力标签/显存条 ---- */
.models-overview { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; margin: 12px 0 2px; }
.mstat { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 8px 16px; min-width: 92px; }
.mstat-num { font-size: 1.3em; font-weight: 700; line-height: 1.25; }
.mstat-label { font-size: .8em; color: var(--muted); }
.mstat-note { align-self: flex-end; padding-bottom: 4px; }
.models-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.mchip { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 999px; padding: 4px 14px; font-size: .92em; cursor: pointer; }
.mchip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.mpill { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; font-size: .78em; line-height: 1.7; white-space: nowrap; }
.model-speed { margin-left: auto; font-weight: 700; font-size: 1.08em; white-space: nowrap; }
.model-speed small { font-weight: 400; color: var(--muted); font-size: .7em; }
.model-role { font-weight: 600; margin-top: 2px; }
.vram-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.vram-bar { flex: 0 0 104px; height: 6px; background: #eef0f4; border-radius: 3px; overflow: hidden; display: flex; }
.vram-fill { background: #3d9e63; height: 100%; }
.vram-over { background: #e3c566; height: 100%; }
.vram-unmeasured { background: #c9ced6; }
.model-more { margin-top: 6px; }
.model-details { margin-top: 6px; }
.models-req { border-left: 3px solid #ccc; }
.models-req.req-pending { border-left-color: #d9a400; }
.models-req.req-evaluated { border-left-color: var(--accent); }
.models-req.req-ok { border-left-color: #3d9e63; }
.models-req.req-muted { border-left-color: #c9ced6; }
#models-list.hide-deleted .model-deleted { display: none; }
#models-list.hide-deleted .models-cat-block:not(:has(.model-card:not(.model-deleted))) { display: none; }
/* 模型卡片：分类内定宽横向打包（2026-10-23 Andy 要求，覆盖上方 .models-grid 均分规则） */
.models-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 300px)); justify-content: start; }
@media (max-width: 700px) {
  .models-grid { grid-template-columns: 1fr; }
}
/* 分类块横向流动打包（2026-10-23 Andy 要求：下一组接上一组右侧，不留空白） */
.models-flow { display: flex; flex-wrap: wrap; gap: 6px 28px; align-items: flex-start; }
.models-flow > .models-cat-block { flex: 0 1 auto; min-width: 0; }
.models-grid { grid-template-columns: repeat(var(--cols, 4), minmax(250px, 300px)); }
@media (max-width: 700px) {
  .models-grid { grid-template-columns: 1fr; }
  .models-flow > .models-cat-block { flex-basis: 100%; }
}

/* ---- 💰 金融账单总览（2026-10-23 新增，追加在文件末尾） ---- */
.finance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-top: 12px; }
@media (max-width: 700px) {
  .finance-grid { grid-template-columns: 1fr; }
}
.fin-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.fin-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.fin-name { font-weight: 700; font-size: 1.05em; }
.fin-status { background: #fff4d6; border: 1px solid #e3c566; color: #7a5b00; border-radius: 999px; padding: 0 10px; font-size: .8em; line-height: 1.8; white-space: nowrap; }
.fin-amount-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 10px 0 2px; }
.fin-amount { font-size: 1.75em; font-weight: 700; line-height: 1.15; }
.fin-due { font-size: 1.05em; font-weight: 700; }
.fin-rows { margin-top: 8px; }
.fin-row { display: flex; gap: 10px; padding: 6px 0; border-top: 1px solid #eef0f4; }
.fin-row-label { flex: 0 0 96px; color: var(--muted); font-size: .88em; padding-top: 1px; }
.fin-row-val { flex: 1; min-width: 0; }
.fin-note { margin-top: 8px; }

/* ---- 💰 金融板块卡（收入/银行卡/信用卡/利息/Fidelity，2026-10-23 追加在文件末尾） ---- */
.fin-sec-hls { display: flex; gap: 26px; flex-wrap: wrap; margin: 10px 0 2px; }
.fin-sec-hl-val { font-size: 1.5em; font-weight: 700; line-height: 1.15; }
.fin-sec-hl-label { color: var(--muted); font-size: .85em; margin-top: 2px; }
.fin-sec-rows { margin-top: 8px; }
.fin-sec-row { display: flex; gap: 10px; padding: 6px 0; border-top: 1px solid #eef0f4; align-items: baseline; }
.fin-sec-row-label { flex: 1; min-width: 0; color: var(--muted); font-size: .9em; }
.fin-sec-row-val { flex: 0 0 auto; font-weight: 600; text-align: right; }
@media (min-width: 1000px) {
  .fin-sec-card { grid-column: span 2; }
}

/* ---- 💰 金融·账户现状 sub 小字 + 📅 按月查看（2026-10-23 追加在文件末尾） ---- */
.fin-sec-row-sub { color: var(--muted); font-size: .8em; margin-top: 1px; }
.fin-monthly { grid-column: 1 / -1; margin-top: 4px; }
.fin-monthly-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 4px; }
.fin-monthly-title { font-weight: 700; font-size: 1.05em; }
.fin-month-sel { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: .95em; background: #fff; }
.fin-month-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-top: 10px; }
.fin-sec-subhead { margin-top: 12px; font-weight: 600; font-size: .92em; color: var(--muted); }
.fin-sec-date { color: var(--muted); font-size: .85em; margin-right: 6px; white-space: nowrap; }
@media (max-width: 700px) {
  .fin-month-body { grid-template-columns: 1fr; }
}

/* 金融页大额单笔 ✎ 改分类备注按钮（2026-10-23 Andy 要求） */
.fin-note-btn {
  flex: 0 0 auto; margin-left: 8px; padding: 2px 8px;
  font-size: .85em; line-height: 1.5; color: var(--muted);
  background: transparent; border: 1px solid var(--border, #ddd);
  border-radius: 999px; cursor: pointer;
}
.fin-note-btn:hover { color: inherit; border-color: var(--muted); }
.fin-note-btn:disabled { opacity: .5; cursor: wait; }

/* 金融页窗口切换（开销构成/买菜分析：近6个月/近3个月/单月） */
.fin-win-tabs { display: flex; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }
.fin-win-btn {
  padding: 4px 14px; font-size: .9em; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--border, #ddd);
}
.fin-win-btn.active { color: inherit; border-color: currentColor; font-weight: 600; }

/* 月视图布局（Andy 2026-10-23）：进账/结余同列上下叠放成一个大区，开销独占右列 */
.fin-month-body {
  grid-template-columns: 1fr 1fr;
  grid-template-areas: 'inc spend' 'bal spend';
  align-items: start;
}
.fin-m-inc { grid-area: inc; }
.fin-m-spd { grid-area: spend; }
.fin-m-bal { grid-area: bal; }
@media (max-width: 700px) {
  .fin-month-body {
    grid-template-columns: 1fr;
    grid-template-areas: 'inc' 'spend' 'bal';
  }
}

/* 利息+Fidelity 叠放列 与 消费意见 并排（Andy 2026-10-23） */
.fin-pair {
  grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; align-items: start;
}
.fin-pair-stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fin-pair > .fin-sec-card, .fin-pair-stack > .fin-sec-card { grid-column: auto; }
@media (max-width: 700px) {
  .fin-pair { grid-template-columns: 1fr; }
}

/* 月视图三列（Andy 2026-10-23 定版）：进账/结余 | 开销 | 利息/Fidelity 叠放 */
.fin-month-body.has-side {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-areas: 'inc spend side' 'bal spend side';
}
.fin-m-side { grid-area: side; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (max-width: 700px) {
  .fin-month-body.has-side {
    grid-template-columns: 1fr;
    grid-template-areas: 'inc' 'spend' 'bal' 'side';
  }
}

/* 月视图改三列 flex（2026-10-23 晚定版：列内叠放、间距统一、底部自然收尾） */
.fin-month-body { display: flex; gap: 12px; align-items: flex-start; }
.fin-col { display: flex; flex-direction: column; gap: 12px; flex: 1 1 0; min-width: 0; }
.fin-col-spd { flex-grow: 1.3; }
.fin-side-cards { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fin-side-cards .fin-card { padding: 12px 14px; }
.fin-side-cards .fin-sec-hl-val { font-size: 1.2em; }
.fin-side-cards .fin-sec-hls { gap: 18px; }
@media (max-width: 700px) {
  .fin-month-body { flex-direction: column; }
  .fin-col, .fin-col-spd { flex: none; width: 100%; }
}
