/* englishgo — shared + shelf styles */
:root {
  --bg: #f5f5f7;
  --fg: #1d1d1f;
  --muted: #86868b;
  --accent: #c2542e;
  --accent-dark: #9c3f1f;
  --card: #ffffff;
  --border: #e5e5ea;
  --highlight: #ffe9b3;
  --shadow: 0 2px 10px rgba(60, 50, 30, 0.08);
  --shadow-lg: 0 12px 32px rgba(29, 29, 31, 0.12);
  --radius: 16px;
  font-size: 17px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, .btn {
  font-family: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 14px;
  cursor: pointer;
  color: var(--fg);
}
button:hover { border-color: var(--accent); color: var(--accent-dark); }
button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- shelf (modern reader app) ---------- */
.shelf { max-width: 980px; margin: 0 auto; padding: 28px 24px 48px; }

.shelf-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 22px;
}
.shelf-topbar h1 {
  margin: 0; font-size: 2rem; font-weight: 700; letter-spacing: -0.02em;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.icon-link {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  color: var(--fg); text-decoration: none;
  border: 1px solid transparent;
  background: none; cursor: pointer;
}
.icon-link:hover { background: var(--card); border-color: var(--border); }
.icon-link .badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--accent); color: #fff;
  font-size: 0.62rem; font-weight: 600; line-height: 16px; text-align: center;
}
.icon-link.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* continue-reading hero card */
.continue-card { margin-bottom: 34px; }
.continue-link {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; text-decoration: none; color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.continue-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.continue-cover {
  flex: none; width: 64px; height: 96px; border-radius: 8px;
  overflow: hidden; background: var(--border);
  box-shadow: 0 3px 10px rgba(29,29,31,0.22);
}
.continue-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.continue-info { flex: 1; min-width: 0; }
.continue-label {
  margin: 0; color: var(--accent); font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.continue-info h2 {
  margin: 2px 0 4px; font-size: 1.25rem; font-weight: 650;
  letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.continue-meta { margin: 0; color: var(--muted); font-size: 0.85rem; }
.continue-progress {
  margin-top: 10px; height: 6px; border-radius: 3px;
  background: var(--border); overflow: hidden;
}
.continue-progress .bar {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), #e07a4f);
  transition: width 0.4s ease;
}
.continue-chapters { margin: 6px 0 0; color: var(--muted); font-size: 0.78rem; }
.continue-arrow { flex: none; color: var(--muted); }
.continue-link:hover .continue-arrow { color: var(--accent); transform: translateX(3px); }
.continue-arrow svg { transition: transform 0.18s ease, color 0.18s ease; }

/* shelf grid */
.shelf-section-title {
  margin: 0 0 16px; font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em;
}
.shelf-section-title .count { color: var(--muted); font-weight: 400; }
.book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 26px 22px; margin-top: 4px;
}
.book-card { display: block; text-decoration: none; color: inherit; }
.book-card .cover {
  position: relative;
  aspect-ratio: 528/973; background: linear-gradient(160deg, #e8e8ed, #dcdce2);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 4px 14px rgba(29, 29, 31, 0.14);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.book-card:hover .cover { transform: translateY(-4px); box-shadow: 0 10px 26px rgba(29,29,31,0.22); }
.book-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book-card .cover-fallback {
  padding: 10px; color: var(--muted); font-size: 0.85rem;
  text-align: center; font-style: italic;
}
.book-card .cover-audio {
  position: absolute; left: 8px; bottom: 8px;
  padding: 2px 8px; border-radius: 99px;
  background: rgba(29,29,31,0.62); backdrop-filter: blur(4px);
  color: #fff; font-size: 0.68rem; font-weight: 500; letter-spacing: 0.02em;
}
.book-card .cover-progress-dot {
  position: absolute; top: 10px; right: 10px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
}
.book-card .cover-done {
  position: absolute; top: 10px; right: 10px;
  padding: 2px 8px; border-radius: 99px;
  background: var(--accent); color: #fff;
  font-size: 0.68rem; font-weight: 500; letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(156, 63, 31, 0.4);
}
.book-card .meta { margin-top: 10px; padding: 0 2px; }
.book-card .t {
  font-size: 0.92rem; font-weight: 550; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-card .a { font-size: 0.78rem; color: var(--muted); margin-top: 1px; }
.book-card .p { font-size: 0.75rem; color: var(--accent); margin-top: 3px; font-weight: 500; }
.shelf-foot {
  margin-top: 44px; padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 0.8rem;
}
.shelf-foot p { margin: 0; }
.shelf-nav { margin-top: 40px; color: var(--muted); }
.shelf-nav a { color: var(--muted); }

/* ---------- review-due reminder banner ---------- */
.review-reminder {
  position: relative;
  margin-bottom: 22px;
}
.review-reminder-link {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #fff4ec, #ffe9db);
  border: 1px solid #f2cdb3;
  border-radius: var(--radius); padding: 14px 44px 14px 16px;
  text-decoration: none; color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.review-reminder-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(194, 84, 46, 0.18);
}
.rr-emoji {
  flex: none; font-size: 1.6rem;
  animation: rr-bounce 2.2s ease-in-out infinite;
}
@keyframes rr-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
.rr-main { flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.rr-title { font-weight: 600; font-size: 0.98rem; }
.rr-title b { color: var(--accent); font-size: 1.1rem; }
.rr-sub { color: #a05c38; font-size: 0.8rem; }
.rr-go {
  flex: none; color: var(--accent); font-weight: 600; font-size: 0.9rem;
  white-space: nowrap;
}
.rr-dismiss {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; padding: 0;
  border: none; background: transparent; border-radius: 8px;
  color: #b07a55; font-size: 0.85rem; cursor: pointer;
}
.rr-dismiss:hover { background: rgba(194, 84, 46, 0.12); color: var(--accent-dark); }

/* book remove-from-shelf button (floats on cover, hover-revealed) */
.book-card .cover { position: relative; }
.book-card .book-del {
  position: absolute; top: 8px; left: 8px;
  width: 28px; height: 28px; padding: 0;
  border-radius: 50%; border: none;
  background: rgba(29, 29, 31, 0.6); backdrop-filter: blur(4px);
  color: #fff; font-size: 0.8rem; line-height: 1;
  cursor: pointer; opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.book-card:hover .book-del { opacity: 1; }
.book-card .book-del:hover { background: var(--accent); }
/* touch devices: always faintly visible */
@media (hover: none) {
  .book-card .book-del { opacity: 0.55; }
}

/* ---------- reader ---------- */
.reader { max-width: 720px; margin: 0 auto; padding: 20px 18px 120px; }
.reader-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.reader-top .home { text-decoration: none; color: var(--muted); }
.reader-top h2 { font-size: 1.15rem; margin: 0 auto 0 0; }
#btn-finish { font-size: 1rem; padding: 3px 10px; }
#btn-finish.done { background: var(--accent); color: #fff; border-color: var(--accent); }
.chap-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.chap-tabs button { padding: 3px 10px; font-size: 0.85rem; }
.chap-tabs .quiz-tab { border-color: var(--border); }
.chap-tabs .quiz-tab:hover { border-color: var(--accent); }

/* ---------- chapter quiz + pronunciation modals ---------- */
#quiz-modal, #pron-modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(29,29,31,0.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#quiz-modal[hidden], #pron-modal[hidden] { display: none; }
.quiz-box, .pron-box {
  background: var(--card); border-radius: 16px; max-width: 520px; width: 100%;
  max-height: 86vh; overflow: auto; padding: 22px 24px;
  box-shadow: var(--shadow-lg);
}
.quiz-head, .pron-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.quiz-head h3, .pron-head h3 { margin: 0; font-size: 1.1rem; }
.quiz-close { border: none; background: none; font-size: 1rem; cursor: pointer; color: var(--muted); }
.quiz-progress { color: var(--muted); font-size: 0.8rem; margin-bottom: 8px; }
.quiz-q { font-size: 1.05rem; font-weight: 600; line-height: 1.5; margin-bottom: 14px; }
.quiz-opts { display: grid; gap: 8px; }
.quiz-opt {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 14px; border-radius: 12px; font-size: 0.95rem;
}
.quiz-letter {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg); display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600; color: var(--muted);
}
.quiz-opt.correct { border-color: #34a853; background: #e9f7ee; }
.quiz-opt.correct .quiz-letter { background: #34a853; color: #fff; }
.quiz-opt.wrong { border-color: var(--accent); background: #fdeeea; }
.quiz-opt.wrong .quiz-letter { background: var(--accent); color: #fff; }
.quiz-fb { margin: 12px 0 0; font-size: 0.9rem; min-height: 1.4em; }
.quiz-fb.ok { color: #2c7a3d; }
.quiz-fb.bad { color: var(--accent-dark); }
.quiz-next {
  margin-top: 16px; width: 100%; padding: 10px;
  background: var(--fg); color: #fff; border: none; border-radius: 12px;
  font-size: 1rem; cursor: pointer;
}
.quiz-done-face { font-size: 3rem; text-align: center; margin: 10px 0; }
.quiz-done-score { text-align: center; font-size: 1.6rem; font-weight: 700; }
.quiz-done-hint { text-align: center; color: var(--muted); font-size: 0.9rem; }

.pron-score {
  text-align: center; font-size: 2.6rem; font-weight: 800; color: var(--accent);
}
.pron-face { text-align: center; font-size: 1.6rem; margin-bottom: 12px; }
.pron-words {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  margin-bottom: 12px;
}
.pw { padding: 2px 8px; border-radius: 6px; background: #e9f7ee; color: #2c7a3d; }
.pw.missing { background: #f0eee8; color: var(--muted); text-decoration: line-through; }
.pron-hint { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 0 0 6px; }
body.listen-mode #chapter .sent { display: none; }
body.listen-mode #chapter .sent.current { display: block; }
body.listen-mode #chapter .sent.current .w { pointer-events: none; }
body.listen-mode .chap-tabs { opacity: 0.35; }
body.listen-mode { --listen-veil: 1; }
#listen-current { text-align: center; color: var(--muted); font-size: 0.85rem; }
#listen-current.hidden { visibility: hidden; }
#ab-listen.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.sent { display: block; padding: 2px 4px; border-radius: 4px; cursor: pointer; }
.sent:hover { background: #f0eee8; }
.sent.current { background: var(--highlight); }
.sent.bookmarked::after { content: "★"; color: var(--accent); font-size: 0.7em; vertical-align: super; margin-left: 2px; }
.sent .w { cursor: pointer; border-bottom: 1px dotted transparent; }
.sent .w:hover { border-bottom-color: var(--accent); color: var(--accent-dark); }
/* words already in the vocab book */
.sent .w.in-vocab {
  background: linear-gradient(transparent 78%, rgba(194, 84, 46, 0.22) 78%);
  border-bottom: 1.5px solid var(--accent);
  border-radius: 1px;
}
.sent .w.in-vocab::before { content: "●"; color: var(--accent); font-size: 0.55em; vertical-align: super; margin-right: 1px; }

/* per-sentence translate button */
.sent { position: relative; }
.sent .tr-btn {
  position: absolute; top: 2px; right: -34px;
  width: 26px; height: 26px; padding: 0;
  border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--muted);
  font-size: 0.72rem; line-height: 1; opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.sent:hover .tr-btn { opacity: 1; }
.sent .tr-btn:hover { background: var(--card); border-color: var(--border); color: var(--accent-dark); }
.sent .tr-btn.done { opacity: 0.65; color: var(--accent); }
@media (max-width: 900px) {
  .sent .tr-btn { right: 2px; top: -14px; }
}

/* word-panel remove state */
#wp-add.remove { background: #fdf1ee; border-color: #e8b8aa; color: #a03d20; }
#wp-add.remove:hover { background: #f9e3dc; }

/* floating word panel */
#word-panel {
  position: fixed; inset: auto 12px 96px 12px; z-index: 20;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(60,50,30,0.18); padding: 14px 16px;
  display: none;
}
#word-panel.open { display: block; }
#word-panel .wp-word { font-size: 1.3rem; font-weight: bold; }
#word-panel .wp-phon { color: var(--muted); margin-left: 8px; font-size: 0.9rem; }
#word-panel .wp-trans { margin: 8px 0; max-height: 24vh; overflow: auto; white-space: pre-wrap; }
#word-panel .wp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#word-panel .wp-close { position: absolute; top: 6px; right: 10px; border: none; background: none; color: var(--muted); font-size: 1rem; cursor: pointer; }

/* word note: single-line 批注：… [移除] */
#word-panel .wp-note-line {
  display: flex; align-items: baseline; gap: 6px;
  margin: 8px 0; padding: 6px 8px;
  background: rgba(250,246,238,0.9); border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.9rem;
}
#word-panel .wp-note-line[hidden] { display: none; }
#word-panel .wp-note-label { color: var(--muted); flex: none; }
#word-panel .wp-note-text { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
#word-panel .wp-note-del { flex: none; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 0.8rem; padding: 0; }
#word-panel .wp-note-del:hover { color: var(--accent); }
#word-panel .has-note { position: relative; }
#word-panel .has-note::before { content: "📝"; font-size: 0.7em; margin-right: 4px; }
#word-panel .wp-notes[hidden] { display: none; }
#word-panel .wp-note-form { display: flex; gap: 6px; align-items: flex-start; margin-top: 4px; }
#word-panel .wp-note-form textarea { flex: 1; resize: vertical; min-height: 2.2em; font: inherit; font-size: 0.85rem; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
#word-panel .wp-note-form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* bottom audio bar */
#audio-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(250,249,247,0.97); border-top: 1px solid var(--border);
  padding: 10px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
#audio-bar .time { color: var(--muted); font-size: 0.8rem; min-width: 88px; text-align: center; }
#audio-bar input[type=range] { accent-color: var(--accent); }
#audio-bar .rate { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.8rem; }
#progress { flex: 1; min-width: 120px; }

/* spell modal */
#spell-modal {
  position: fixed; inset: 0; z-index: 40; background: rgba(40,35,25,0.5);
  display: none; align-items: center; justify-content: center;
}
#spell-modal.open { display: flex; }
#spell-modal .box {
  background: var(--card); border-radius: 16px; padding: 28px 32px;
  text-align: center; max-width: 90vw;
}
#spell-modal .letters { font-size: 2.6rem; letter-spacing: 0.35em; font-family: "Courier New", monospace; margin: 14px 0; }
#spell-modal .letters .lt { opacity: 0.35; transition: opacity 0.15s, color 0.15s; }
#spell-modal .letters .lt.lit { opacity: 1; color: var(--accent); }
#spell-modal .ctl { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 10px; }
#spell-modal .ph { color: var(--muted); }

/* sentence translate block */
.sent .trans { display: block; color: var(--muted); font-size: 0.9em; margin-top: 2px; border-left: 3px solid var(--border); padding-left: 8px; }

/* shadowing recorder states */
#ab-shadow.recording { background: #e5484d; color: #fff; border-color: #e5484d; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.65; } }
.shadow-hint { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 14px; box-shadow: var(--shadow); z-index: 50; color: var(--muted); display: none; }

/* vocab page */
.vocab { max-width: 760px; margin: 0 auto; padding: 28px 20px; }
.vocab table { width: 100%; border-collapse: collapse; background: var(--card); }
.vocab th, .vocab td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.vocab th { color: var(--muted); font-weight: normal; font-size: 0.85rem; }
.vocab .del { color: var(--muted); }
.vocab .head { display: flex; justify-content: space-between; align-items: baseline; }

@media (max-width: 640px) {
  :root { font-size: 16px; }
  .reader { padding-bottom: 140px; }
  #word-panel { inset: auto 8px 130px 8px; }
  #spell-modal .letters { font-size: 1.8rem; }
}

/* ---------- streak / reading-time pill (shelf header) ---------- */
.streak-card { flex: none; order: 3; }
.streak-link {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 5px 14px 5px 10px;
  text-decoration: none; color: inherit; cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.streak-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.streak-flame { font-size: 1.1rem; line-height: 1; }
.streak-main { text-align: left; line-height: 1.25; }
.streak-days { font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.streak-days b { color: var(--accent); font-size: 0.95rem; }
.streak-today { color: var(--muted); font-size: 0.68rem; white-space: nowrap; }
.streak-week { display: flex; gap: 4px; align-items: flex-end; padding-left: 6px; }
.streak-col { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.streak-bar {
  width: 7px; height: 3px; border-radius: 2px;
  background: var(--border); transition: height 0.3s ease;
}
.streak-bar.on { background: linear-gradient(180deg, var(--accent), #e07a4f); }
.streak-col.today .streak-bar { outline: 1.5px solid var(--accent); outline-offset: 1px; }
.streak-label { font-size: 0.54rem; color: var(--muted); }
.streak-col.today .streak-label { color: var(--accent); font-weight: 700; }

/* ---------- stats page ---------- */
.stats { max-width: 760px; margin: 0 auto; padding: 28px 24px 60px; }
.stats .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.stats h2 { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-hero {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 26px;
}
.stat-tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 16px; text-align: center;
}
.stat-tile .v { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-tile .v small { font-size: 0.9rem; color: var(--muted); font-weight: 400; }
.stat-tile .k { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.stat-tile .v.acc { color: var(--accent); }
.stats-section { margin-bottom: 26px; }
.stats-section h3 {
  margin: 0 0 12px; font-size: 1.02rem; font-weight: 600; letter-spacing: -0.01em;
}
.chart {
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 18px 14px; min-height: 150px;
}
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.chart .bar {
  width: 100%; max-width: 34px; border-radius: 4px 4px 2px 2px; min-height: 3px;
  background: linear-gradient(180deg, var(--accent), #e07a4f);
  transition: height 0.35s ease;
}
.chart .bar.empty { background: var(--border); }
.chart .lbl { font-size: 0.66rem; color: var(--muted); white-space: nowrap; }
.chart .val { font-size: 0.66rem; color: var(--muted); white-space: nowrap; }
.chart .col.today .lbl { color: var(--accent); font-weight: 700; }
.chart .col.today .bar { outline: 2px solid var(--accent); outline-offset: 1px; }
.book-rows { display: flex; flex-direction: column; gap: 8px; }
.book-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 16px;
}
.book-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-row .track { width: 130px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; flex: none; }
.book-row .track .fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), #e07a4f); }
.book-row .mins { flex: none; color: var(--muted); font-size: 0.85rem; min-width: 58px; text-align: right; }
.stats-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.stats-empty .big { font-size: 2.4rem; margin-bottom: 8px; }

/* ---------- vocab hard-words tab ---------- */
.vocab-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.vocab-tabs button { padding: 5px 14px; font-size: 0.9rem; border-radius: 20px; }
.vocab-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.vocab-tabs #hard-count { background: rgba(255,255,255,0.25); border-radius: 10px; padding: 0 7px; margin-left: 4px; font-size: 0.8rem; }
table tr.hard td { background: #fdf6f0; }
table td.stat { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
table td.stat.hard-stat { color: #b3261e; }

/* illustrations from the book PDF */
.illo {
  display: block;
  max-width: min(420px, 92%);
  margin: 14px auto 18px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  user-select: none;
}
body.listen-mode .illo { display: none; }

/* ---------- daily goal + month calendar ---------- */
.goal-head { display: flex; align-items: center; justify-content: space-between; }
.goal-sel {
  font: inherit; font-size: 0.85rem; padding: 3px 8px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card);
}
.goal-ring-wrap { display: flex; align-items: center; gap: 18px; margin: 12px 0 4px; }
.goal-ring {
  --pct: 0;
  position: relative; flex: none;
  width: 84px; height: 84px; border-radius: 50%;
  background:
    conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--border) 0);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.goal-ring::before {
  content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--card);
}
.goal-ring.done { background: conic-gradient(#34a853 calc(var(--pct) * 1%), var(--border) 0); }
.goal-ring span { position: relative; }
.goal-ring .goal-num { font-size: 1.25rem; font-weight: 700; }
.goal-ring .goal-sub { font-size: 0.7rem; color: var(--muted); }
.goal-text { margin: 0; color: var(--muted); font-size: 0.9rem; }
.goal-cal {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px;
  max-width: 340px; margin-top: 6px;
}
.cal-hd { text-align: center; color: var(--muted); font-size: 0.72rem; }
.cal-cell, .cal-blank {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 0.78rem; color: var(--muted);
  background: var(--bg);
}
.cal-cell.hit { background: var(--accent); color: #fff; font-weight: 600; }
.cal-cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.stats-section h4 { margin: 14px 0 4px; font-size: 0.9rem; color: var(--muted); }

/* ---------- badge wall ---------- */
.badge-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.badge-tile {
  text-align: center; padding: 12px 8px 10px; border-radius: 14px;
  background: var(--bg); border: 1px solid var(--border);
  filter: grayscale(1); opacity: 0.55;
}
.badge-tile.earned { filter: none; opacity: 1; background: var(--card); box-shadow: var(--shadow); }
.badge-tile.new { border-color: var(--accent); }
.badge-tile.new::after {
  content: "NEW"; display: block; margin-top: 4px;
  color: var(--accent); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em;
}
.badge-emoji { font-size: 1.7rem; }
.badge-title { font-size: 0.8rem; font-weight: 600; margin-top: 4px; }
.badge-desc { font-size: 0.68rem; color: var(--muted); margin-top: 2px; line-height: 1.4; }

/* daily-goal mini line in shelf streak card */
.goal-mini {
  margin-top: 4px; font-size: 0.78rem; color: var(--accent-dark);
}

/* ---------- LLM settings modal (shelf) ---------- */
#settings-modal {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(29,29,31,0.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#settings-modal[hidden] { display: none; }
.settings-box {
  background: var(--card); border-radius: 16px; max-width: 440px; width: 100%;
  padding: 22px 24px; box-shadow: var(--shadow-lg);
}
.settings-tip { color: var(--muted); font-size: 0.85rem; line-height: 1.6; margin: 0 0 14px; }
.settings-field { display: block; margin-bottom: 12px; }
.settings-field span { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.settings-field input {
  width: 100%; font: inherit; font-size: 0.9rem; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.settings-field input:focus { outline: none; border-color: var(--accent); }
.settings-status { font-size: 0.82rem; min-height: 1.2em; margin: 4px 0 10px; }
.settings-status.ok { color: #2c7a3d; }
.settings-status.bad { color: var(--accent-dark); }
.settings-actions { display: flex; gap: 10px; }
.settings-actions button { flex: 1; padding: 9px; }
.settings-actions .primary {
  background: var(--fg); color: #fff; border: none; border-radius: 10px;
  font-weight: 600;
}

/* quiz history items */
.qh-item {
  padding: 10px 14px; border-radius: 12px;
  background: var(--bg); margin-bottom: 8px;
}
.qh-q { font-size: 0.92rem; font-weight: 550; line-height: 1.45; }
.qh-meta { color: var(--muted); font-size: 0.8rem; margin-top: 3px; }

/* quiz head actions (refresh + close) */
.quiz-head-actions { display: flex; align-items: center; gap: 4px; }
.quiz-refresh {
  border: none; background: none; font-size: 1.05rem; cursor: pointer;
  color: var(--muted); padding: 2px 8px; border-radius: 8px;
}
.quiz-refresh:hover { color: var(--accent); background: var(--bg); }
.quiz-refresh.spinning { animation: spin 1s linear infinite; }

/* ---------- admin console ---------- */
.admin-page { background: var(--bg); }
.admin { max-width: 720px; margin: 0 auto; padding: 24px 20px 60px; }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.admin-topbar h1 { font-size: 1.35rem; margin: 0; }
.admin-section {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px 20px; margin-bottom: 16px;
}
.admin-section h2 { font-size: 1.05rem; margin: 0 0 8px; }
.admin-tip { color: var(--muted); font-size: 0.82rem; line-height: 1.6; margin: 0 0 12px; }
.admin-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.admin-actions button { padding: 9px 14px; }

/* zip drop zone */
.upload-drop {
  border: 2px dashed var(--border); border-radius: 14px;
  padding: 22px 16px; text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-drop.over { border-color: var(--accent); background: var(--bg); }
.upload-drop:hover { border-color: var(--accent); }
.upload-emoji { font-size: 1.6rem; display: block; margin-bottom: 6px; }
.upload-hint { margin: 0; font-size: 0.9rem; }
.upload-hint a { color: var(--accent); }
.upload-sub { margin: 4px 0 0; color: var(--muted); font-size: 0.78rem; }

/* upload progress */
.upload-progress { margin-top: 12px; }
.upload-progress .bar {
  height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden;
}
.upload-progress .bar-fill {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 4px; transition: width 0.2s;
}
.upload-status { font-size: 0.82rem; color: var(--muted); margin: 8px 0 0; }

/* background job rows */
.jobs { margin-bottom: 12px; }
.job-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 10px;
  background: var(--bg); margin-bottom: 6px; font-size: 0.86rem;
}
.job-row.err { color: var(--accent-dark); }
.job-title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-detail { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-stage { color: var(--muted); }
.job-stage.done { color: #2c7a3d; }
.job-stage.spinning { display: inline-block; animation: spin 1s linear infinite; color: var(--accent); }

/* book management (search / filter / sort / batch / edit) */
.bm-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.bm-group-toggle { white-space: nowrap; }
.bm-group-toggle:hover { background: var(--highlight); }

/* author grouping: head + collapsible body */
.bm-group-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
  cursor: pointer; user-select: none; margin-bottom: 4px;
}
.bm-group-head .arrow { font-size: 0.8rem; color: var(--muted); transition: transform 0.15s; }
.bm-group-head.collapsed .arrow { transform: rotate(-90deg); }
.bm-group-title { font-weight: 600; font-size: 0.9rem; }
.bm-group-head .gstat { font-size: 0.75rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.bm-group-body {
  margin-left: 18px; display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 10px;
}
.bm-search {
  flex: 1 1 200px; min-width: 160px;
  padding: 9px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 0.9rem; background: var(--card); color: var(--fg);
}
.bm-search:focus { outline: none; border-color: var(--accent); }
.bm-select {
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 0.86rem; background: var(--card); color: var(--fg);
  cursor: pointer;
}

.bm-batch {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; border-radius: 10px; background: var(--highlight);
  margin-bottom: 12px;
}
.bm-batch-count { font-size: 0.85rem; font-weight: 600; }
.bm-batch button { padding: 6px 12px; font-size: 0.82rem; }
.bm-batch button.danger { color: var(--accent-dark); }
.bm-batch button.link {
  border: none; background: none; color: var(--muted);
  text-decoration: underline; cursor: pointer;
}
.bm-count { color: var(--muted); font-size: 0.78rem; margin: 10px 0 0; }

.bm-list { display: flex; flex-direction: column; gap: 8px; }
.bm-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px;
  background: var(--bg); flex-wrap: wrap;
}
.bm-row.hidden { opacity: 0.6; }
.bm-check { flex: 0 0 auto; width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.bm-cover {
  flex: 0 0 auto; width: 34px; height: 50px; border-radius: 6px;
  background: var(--card); border: 1px solid var(--border);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.bm-cover img { width: 100%; height: 100%; object-fit: cover; }
.bm-cover-fallback { font-size: 1.1rem; }
.bm-info { flex: 1 1 240px; min-width: 0; }
.bm-title {
  font-weight: 600; font-size: 0.92rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bm-done {
  margin-left: 8px; font-size: 0.7rem; font-weight: 500;
  color: #2c7a3d; background: #e6f4ea; border-radius: 6px; padding: 1px 6px;
}
.bm-meta {
  color: var(--muted); font-size: 0.78rem; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bm-hidden-tag {
  color: var(--accent-dark); font-size: 0.72rem; margin-top: 3px;
}
.bm-chip {
  flex: 0 0 auto; font-size: 0.72rem; padding: 3px 9px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap;
}
.bm-chip.aligned { color: #2c7a3d; border-color: #cde7d3; background: #eef8f0; }
.bm-chip.text_ready { color: #8a6116; border-color: #ecdcae; background: #fdf6e4; }
.bm-chip.scanned { color: var(--muted); }
.bm-chip.off { color: var(--muted); background: var(--bg); }
.bm-actions { display: flex; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; }
.bm-actions button { padding: 7px 12px; font-size: 0.82rem; }
.bm-actions button.danger { color: var(--accent-dark); }

/* edit dialog */
.bm-edit-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(29, 29, 31, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.bm-edit-box {
  background: var(--card); border-radius: 16px; padding: 22px 24px;
  width: min(360px, 92vw); box-shadow: var(--shadow-lg);
}
.bm-edit-box h3 { margin: 0 0 14px; font-size: 1.05rem; }
.bm-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.bm-field span { font-size: 0.8rem; color: var(--muted); }
.bm-field input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 0.9rem;
}
.bm-field input:focus { outline: none; border-color: var(--accent); }
.bm-edit-hint { color: var(--muted); font-size: 0.76rem; margin: 0 0 14px; }
.bm-edit-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* legacy book ops rows (kept for reference; superseded by bm-*) */
.admin-books { display: flex; flex-direction: column; gap: 8px; }
.book-op-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-radius: 12px;
  background: var(--bg); flex-wrap: wrap;
}
.book-op-info { display: flex; flex-direction: column; min-width: 0; }
.book-op-title { font-weight: 600; font-size: 0.92rem; }
.book-op-meta { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }
.book-op-actions { display: flex; gap: 8px; }
.book-op-actions button { padding: 7px 12px; font-size: 0.82rem; }
.book-op-actions button.danger { color: var(--accent-dark); }

/* backup list */
.backup-list { list-style: none; margin: 8px 0 0; padding: 0; }
.backup-list li {
  padding: 7px 12px; border-radius: 8px; background: var(--bg);
  margin-bottom: 5px; font-size: 0.82rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* flash line under topbar */
.admin-flash { font-size: 0.84rem; color: var(--muted); margin: 0 0 14px; min-height: 1.2em; }
.admin-flash.err { color: var(--accent-dark); }

/* ---------------- login picker (multi-user) ---------------- */

.login-page { background: var(--bg-page, #f6f3ee); }
.login-main {
  max-width: 560px; margin: 10vh auto 0; padding: 0 20px;
  text-align: center;
}
.login-title { font-size: 2rem; margin: 0 0 4px; }
.login-sub { color: var(--muted); margin: 0 0 28px; }
.login-picker { margin-bottom: 24px; }
.login-picker .login-sub { margin: 0 0 14px; }
.login-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}
.login-avatar {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 18px 10px 14px; border-radius: 16px;
  background: var(--card, #fff); border: 1px solid var(--border);
  cursor: pointer; position: relative; font: inherit;
}
.login-avatar:hover { border-color: var(--accent); transform: translateY(-2px); }
.login-avatar .la-emoji { font-size: 2.2rem; line-height: 1; }
.login-avatar .la-name { font-size: 0.9rem; font-weight: 600; }
.login-avatar .la-lock {
  position: absolute; top: 8px; right: 10px; font-size: 0.8rem;
}
.login-error { color: var(--accent-dark); font-size: 0.86rem; }

/* PIN keypad */
.pin-panel {
  max-width: 300px; margin: 0 auto; padding: 18px;
  border-radius: 16px; background: var(--card, #fff);
  border: 1px solid var(--border);
}
.pin-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pin-avatar { font-size: 1.8rem; }
.pin-name { font-weight: 600; flex: 1; text-align: left; }
.pin-back {
  border: none; background: none; font-size: 1.2rem; cursor: pointer;
  color: var(--muted); padding: 4px 8px;
}
.pin-dots { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }
.pin-dots .pin-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid var(--border); background: transparent;
}
.pin-dots .pin-dot.on { background: var(--accent); border-color: var(--accent); }
.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.pin-key {
  padding: 14px 0; font-size: 1.25rem; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg, #f6f3ee);
  cursor: pointer; font: inherit;
}
.pin-key:active { transform: scale(0.96); }
.pin-key.go { background: var(--accent); color: #fff; border-color: var(--accent); }
.pin-error { color: var(--accent-dark); font-size: 0.84rem; margin: 10px 0 0; }

/* ---------------- user chip (all pages) ---------------- */

/* current-user pill: [avatar name | 切换] — one continuous capsule.
   data-user-chip holders are plain <span> (block by default) which
   used to wrap the old separate switch button onto its own line; the
   pill is inline-flex so both zones always share one baseline. */
[data-user-chip] { display: inline-flex; }

.user-chip-pill {
  display: inline-flex; align-items: stretch;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  overflow: hidden;
}
.user-chip-pill:hover { background: var(--card, #fff); border-color: var(--border); }

.user-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 6px;
  border: none; border-radius: 999px;
  background: transparent;
  cursor: pointer; font: inherit;
  text-decoration: none; color: inherit;
}
.user-chip-avatar { font-size: 1.05rem; line-height: 1; }
.user-chip-name { font-size: 0.82rem; font-weight: 600; }

/* switch zone of the pill (only when >1 profile) */
.user-chip-switch {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 11px 0 9px;
  border: none; border-left: 1px solid var(--border);
  border-radius: 0 999px 999px 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer; font: inherit;
  transition: color 0.12s, background 0.12s;
}
.user-chip-switch:hover {
  color: var(--accent);
  background: var(--highlight);
}
.user-chip-switch:active { opacity: 0.7; }
.user-chip-switch svg { display: block; }
.user-chip-switch-label {
  font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.02em;
}
.user-chip-switch-label:hover { color: var(--accent); }

/* ---------------- admin: user profile management ---------------- */

.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px; background: var(--bg, #f6f3ee);
  flex-wrap: wrap; margin-bottom: 8px;
}
.user-row .ur-avatar { font-size: 1.5rem; }
.user-row .ur-name { font-weight: 600; font-size: 0.92rem; }
.user-row .ur-role {
  font-size: 0.72rem; padding: 2px 8px; border-radius: 999px;
  background: var(--card, #fff); border: 1px solid var(--border);
  color: var(--muted);
}
.user-row .ur-role.admin { color: var(--accent-dark); border-color: var(--accent); }
.user-row .ur-pin { font-size: 0.78rem; color: var(--muted); }
.user-row .ur-actions { margin-left: auto; display: flex; gap: 6px; }
.user-row .ur-actions button { padding: 6px 10px; font-size: 0.78rem; }
.user-row.off { opacity: 0.55; }

/* ---------------- admin: series management ---------------- */

.series-mgmt {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--card, #fff);
}
.series-mgmt-head {
  display: flex; align-items: center; gap: 10px;
}
.series-mgmt-head h3 { margin: 0; font-size: 0.95rem; }
.series-mgmt-head button { margin-left: auto; }
.series-list { margin-top: 10px; }
.series-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 10px; background: var(--bg, #f6f3ee);
  margin-bottom: 6px; flex-wrap: wrap;
}
.series-row-name { font-size: 0.9rem; font-weight: 600; }
.series-row-ops { margin-left: auto; display: flex; gap: 6px; }
.series-row-ops button { padding: 5px 10px; font-size: 0.75rem; }

/* ---------------- shelf: series merged card + volume modal ---------------- */

/* merged series card: normal shelf slot, opens a modal on click */
.series-card { text-align: left; cursor: pointer; border: none;
  background: none; padding: 0; font: inherit; color: inherit; position: relative; }
.series-card .cover::after {
  /* stacked edge: hint that multiple volumes hide behind the first */
  content: ""; position: absolute; top: 4px; right: -5px; bottom: -5px; width: 60%;
  background: var(--card, #fff); border: 1px solid var(--border);
  border-radius: 10px; z-index: -1;
  box-shadow: 0 2px 8px rgba(29,29,31,0.08);
}
.series-card:hover .cover { transform: translateY(-3px); }
.series-card .cover-audio { display: none; }

.series-vol-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(29,29,31,0.72); color: #fff;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 2px 8px; border-radius: 999px;
}

.series-open-hint {
  margin-top: 4px; font-size: 0.75rem; font-weight: 700;
  color: var(--accent);
}

/* trailing ungrouped shelf */
.loose-block { grid-column: 1 / -1; }
.loose-label {
  font-size: 0.78rem; color: var(--muted);
  margin: 10px 0 6px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* modal: all volumes of one series */
body.modal-open { overflow: hidden; }

.series-modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(29, 29, 31, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: eg-fade-in 0.16s ease;
}
@keyframes eg-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.series-modal-box {
  background: var(--card, #fff);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(29, 29, 31, 0.3);
  max-width: min(860px, 94vw);
  width: 100%;
  max-height: 86vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: eg-pop 0.18s ease;
}
@keyframes eg-pop {
  from { transform: translateY(10px) scale(0.97); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

.series-modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px 10px;
  border-bottom: 1px solid var(--border);
}
.series-modal-title {
  margin: 0; font-size: 1.05rem; font-weight: 800;
  color: var(--ink, #2b2724);
}
.series-modal-close {
  margin-left: auto; border: none; background: none; cursor: pointer;
  font-size: 1.05rem; color: var(--muted);
  padding: 4px 8px; border-radius: 8px;
}
.series-modal-close:hover { background: var(--bg, #f6f3ee); color: var(--ink, #2b2724); }

.series-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px 16px;
  padding: 18px 20px 22px;
  overflow-y: auto;
}

/* ---------------- login: account / register panel ---------------- */

.account-panel { max-width: 320px; margin: 0 auto; width: 100%; }
.account-tabs {
  display: flex; gap: 4px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.account-tab {
  flex: 1; padding: 8px 0; background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  color: var(--muted); font-size: 0.9rem;
}
.account-tab.active {
  color: var(--ink, #2b2724);
  border-bottom-color: var(--accent);
  font-weight: 700;
}
.account-form { display: flex; flex-direction: column; gap: 12px; }
.account-field { display: flex; flex-direction: column; gap: 4px; }
.account-field span { font-size: 0.78rem; color: var(--muted); }
.account-field input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 1rem; background: var(--card, #fff);
}
.account-field input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.account-submit {
  margin-top: 4px; padding: 11px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 0.95rem; font-weight: 700;
  cursor: pointer;
}
.account-submit:disabled { opacity: 0.6; cursor: wait; }
.account-error {
  color: var(--accent-dark, #b3401f); font-size: 0.82rem; margin: 0;
}

/* ---------------- admin console login wall ---------------- */

.admin-login {
  max-width: 340px; margin: 12vh auto 0; width: 100%;
  background: var(--card, #fff); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px;
}
.admin-login h2 { margin: 0 0 6px; }
.admin-login-form {
  display: flex; flex-direction: column; gap: 12px; margin-top: 14px;
}
.admin-login-form .primary { margin-top: 4px; }

/* ---------------- account page (self-service) ---------------- */

.account { max-width: 560px; margin: 0 auto; padding: 24px 20px 60px; }
.acct-profile {
  display: flex; align-items: center; gap: 16px; margin-bottom: 14px;
}
.acct-avatar {
  font-size: 2.6rem; line-height: 1;
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border);
}
.acct-name-wrap { flex: 1; min-width: 0; }
.acct-name-wrap input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 10px; font: inherit; font-size: 1rem; background: var(--bg);
}
.acct-name-wrap input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.acct-avatar-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.acct-av-opt {
  font-size: 1.3rem; padding: 7px 10px; border-radius: 10px;
  border: 1.5px solid transparent; background: var(--bg);
}
.acct-av-opt.picked { border-color: var(--accent); background: var(--highlight); }
.acct-form { display: flex; flex-direction: column; gap: 4px; }
.settings-field input {
  width: 100%; font: inherit; font-size: 0.9rem; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.settings-field input:focus { outline: none; border-color: var(--accent); }

/* ---------------- unified admin console ---------------- */

.admin-nav {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px;
}
.admin-nav a {
  padding: 5px 12px; border-radius: 999px; text-decoration: none;
  color: var(--muted); font-size: 0.85rem; font-weight: 600;
  background: var(--card); border: 1px solid var(--border);
}
.admin-nav a:hover { color: var(--accent-dark); border-color: var(--accent); }

.user-row .ur-username {
  font-size: 0.78rem; color: var(--muted);
  background: var(--bg); padding: 1px 8px; border-radius: 999px;
}

/* ---------------- profile switch dialog (topbar icon) ---------------- */

.switch-dialog {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(20, 18, 15, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: switch-fade 0.15s ease-out;
}
@keyframes switch-fade { from { opacity: 0; } to { opacity: 1; } }

.switch-card {
  background: var(--bg, #fff);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.22);
  width: min(400px, 100%);
  padding: 22px 22px 18px;
  position: relative;
  animation: switch-pop 0.18s ease-out;
}
@keyframes switch-pop {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.switch-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.switch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.switch-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 14px 6px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card, #f8f6f2);
  cursor: pointer; font: inherit; position: relative;
  transition: border-color 0.12s, transform 0.12s;
}
.switch-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.switch-item.current { opacity: 0.55; cursor: default; }
.switch-item.current:hover { transform: none; border-color: var(--border); }
.switch-item-avatar { font-size: 1.9rem; line-height: 1; }
.switch-item-name { font-size: 0.88rem; font-weight: 600; }
.switch-item-lock {
  position: absolute; top: 7px; right: 9px; font-size: 0.75rem;
}
.switch-item-now {
  position: absolute; top: 6px; left: 8px;
  font-size: 0.68rem; color: var(--accent);
  font-weight: 700;
}

.switch-cancel {
  display: block; margin: 16px auto 0;
  border: none; background: none;
  color: var(--muted); font: inherit; font-size: 0.88rem;
  cursor: pointer; padding: 6px 14px; border-radius: 8px;
}
.switch-cancel:hover { background: var(--card, #f6f6f6); }

/* credential step (inline in the same card) */
.switch-back {
  position: absolute; top: 10px; left: 12px;
  border: none; background: none;
  font-size: 1.15rem; color: var(--muted);
  cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.switch-back:hover { background: var(--card, #f6f6f6); }

.switch-cred-head {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin: 6px 0 4px;
}
.switch-cred-avatar { font-size: 1.8rem; }
.switch-cred-label { font-weight: 600; font-size: 0.95rem; }

.switch-error {
  color: var(--accent-dark); font-size: 0.84rem;
  margin: 8px 0 0; text-align: center; min-height: 1.2em;
}

.switch-pw-form {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 12px;
}
.switch-pw-input {
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card, #f8f6f2);
  font: inherit; text-align: center;
}
.switch-pw-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.switch-pw-submit {
  padding: 12px 0; border-radius: 12px;
  border: none; background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer;
}
.switch-pw-submit:disabled { opacity: 0.6; cursor: wait; }

/* ---------------- family profiles (account page) ---------------- */

.family-profiles {
  display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px;
}
.fp-card {
  border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; background: var(--bg);
}
.fp-card.me { border-color: var(--accent); }
.fp-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.fp-avatar {
  font-size: 1.8rem; line-height: 1;
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--card, #fff); border: 1px solid var(--border);
}
.fp-name-input {
  flex: 1; min-width: 0; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  font: inherit; background: var(--card, #fff);
}
.fp-name-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.fp-name-input:disabled { opacity: 0.6; }
.fp-lock { font-size: 0.9rem; }
.fp-now {
  font-size: 0.7rem; font-weight: 700; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: 2px 8px;
}
.fp-meta { margin-bottom: 10px; }
.fp-avatar-row { display: flex; flex-wrap: wrap; gap: 6px; }
.acct-av-opt.small { font-size: 1.05rem; padding: 4px 7px; border-radius: 8px; }
.fp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.fp-btn {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card, #fff); font: inherit; font-size: 0.85rem;
  padding: 7px 14px; cursor: pointer;
}
.fp-btn:hover { border-color: var(--accent); }
.fp-btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 600;
}
.fp-btn.danger { color: var(--accent-dark, #b3401f); }
.fp-add-form {
  border-top: 1px dashed var(--border); padding-top: 18px;
}
.fp-pin-field { margin-bottom: 14px; }
