/* ==========================================================================
   新概念英语学习系统 · 前台样式
   设计语言：纸张 / 墨色 / 少量金色点缀，衬线正文 + 无衬线界面字
   ========================================================================== */

/* ------------------------------ 1. 设计变量 ------------------------------ */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', 'Songti SC', Georgia,
    'Times New Roman', serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  --paper: #f7f3ea;
  --surface: #fffdf8;
  --surface-2: #f1ebdd;
  --surface-3: #e9e1d0;
  --ink: #1b222b;
  --ink-2: #4b5563;
  --ink-3: #838d9b;
  --line: #e6ddcb;
  --line-2: #d6c9b1;
  --brand: #16324f;
  --brand-2: #2c5d8f;
  --brand-ink: #16324f;
  --accent: #a9762c;
  --accent-2: #d3a250;
  --accent-soft: #f6ead4;
  --accent-ink: #7d5720;
  --ok: #2b7a58;
  --ok-soft: #e2f0e7;
  --warn: #a4621c;
  --danger: #b03a3a;
  --danger-soft: #fbe9e7;
  --topbar-bg: rgba(247, 243, 234, 0.86);
  --focus: rgba(44, 93, 143, 0.35);
  --shadow-xs: 0 1px 2px rgba(35, 28, 15, 0.05);
  --shadow-sm: 0 1px 2px rgba(35, 28, 15, 0.05), 0 4px 14px rgba(35, 28, 15, 0.05);
  --shadow-md: 0 10px 34px rgba(35, 28, 15, 0.1);
  --shadow-lg: 0 24px 60px rgba(35, 28, 15, 0.16);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --sidebar-w: 282px;
  --rail-w: 300px;
  --topbar-h: 66px;
  --maxw: 1560px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme='dark'] {
  --paper: #0d1117;
  --surface: #141a22;
  --surface-2: #1a222c;
  --surface-3: #212b37;
  --ink: #e8e4da;
  --ink-2: #b0b7c2;
  --ink-3: #79828f;
  --line: #232d38;
  --line-2: #33404d;
  --brand: #cfe0f2;
  --brand-2: #8fb8e0;
  --brand-ink: #d6e6f7;
  --accent: #d8a659;
  --accent-2: #b98b3f;
  --accent-soft: #2b2317;
  --accent-ink: #f0cf97;
  --ok: #5cb98c;
  --ok-soft: #16281f;
  --warn: #d3a05c;
  --danger: #e07a72;
  --danger-soft: #2a1a1a;
  --topbar-bg: rgba(13, 17, 23, 0.82);
  --focus: rgba(143, 184, 224, 0.3);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 10px 34px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

/* ------------------------------ 2. 基础重置 ------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-y: scroll;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 520px at 8% -8%, rgba(169, 118, 44, 0.07), transparent 60%),
    radial-gradient(900px 480px at 96% -4%, rgba(22, 50, 79, 0.07), transparent 58%);
}

html[data-theme='dark'] body::before {
  background:
    radial-gradient(1200px 520px at 8% -8%, rgba(216, 166, 89, 0.06), transparent 60%),
    radial-gradient(900px 480px at 96% -4%, rgba(108, 156, 208, 0.07), transparent 58%);
}

h1, h2, h3, h4, h5 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

p { margin: 0 0 0.9em; }
p:last-child { margin-bottom: 0; }
a { color: var(--brand-2); text-decoration: none; transition: color 0.16s var(--ease); }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--accent-soft); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------ 3. 顶栏 ------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--maxw);
  height: 100%;
  margin: 0 auto;
  padding: 0 26px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  min-width: 0;
}
.brand:hover { color: inherit; }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: #fdf8ee;
  background: linear-gradient(145deg, #1d3d5f 0%, #16324f 55%, #0f2438 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 3px 10px rgba(22, 50, 79, 0.28);
  flex: none;
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: auto -30% -60% -30%;
  height: 100%;
  background: radial-gradient(closest-side, rgba(211, 162, 80, 0.55), transparent);
  opacity: 0.85;
}
html[data-theme='dark'] .brand-mark {
  background: linear-gradient(145deg, #2c5d8f 0%, #1c4470 60%, #12314f 100%);
  color: #fff;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}
.brand-tag { font-size: 11px; color: var(--ink-3); letter-spacing: 0.14em; text-transform: uppercase; line-height: 1.2; }

.nav { display: flex; align-items: center; gap: 4px; margin-left: 10px; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); border: 1px solid var(--line); }

.topbar-spacer { flex: 1 1 auto; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  transition: transform 0.25s var(--ease), color 0.2s, border-color 0.2s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--line-2); transform: rotate(-12deg); }

/* 用户菜单 */
.user-menu { position: relative; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 10px 0 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.18s, box-shadow 0.18s;
  max-width: 210px;
}
.user-chip:hover { border-color: var(--line-2); box-shadow: var(--shadow-xs); }
.user-chip-name { font-size: 13.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .chev { color: var(--ink-3); transition: transform 0.2s; }
.user-menu.is-open .user-chip .chev { transform: rotate(180deg); }

.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 224px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 7px;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
  z-index: 70;
}
.user-menu.is-open .dropdown { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-head { padding: 10px 11px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dropdown-name { font-weight: 600; font-size: 14px; }
.dropdown-mail { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-member { font-size: 11px; color: var(--ink-3); margin-top: 5px; line-height: 1.5; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 11px;
  border: 0; background: transparent; border-radius: 8px;
  font-size: 13.5px; color: var(--ink-2); text-align: left;
  transition: background 0.14s, color 0.14s;
}
.dropdown-item:hover { background: var(--surface-2); color: var(--ink); }
.dropdown-item.is-danger { color: var(--danger); }
.dropdown-item.is-danger:hover { background: var(--danger-soft); }
.dropdown-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.badge-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

/* ------------------------------ 4. 布局骨架 ------------------------------ */
.shell {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 26px 56px;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--rail-w);
  align-items: start;
  gap: 26px;
}
.shell.is-focus { grid-template-columns: minmax(0, 1fr); max-width: 860px; padding-top: 46px; }
.shell.is-focus > .sidebar,
.shell.is-focus > .rail { display: none; }

/* 后台关闭右侧栏后：两列布局，正文自动变宽 */
.shell.is-no-rail { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.shell.is-no-rail > .rail { display: none; }

.sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 18px);
  max-height: calc(100vh - var(--topbar-h) - 36px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.rail {
  position: sticky;
  top: calc(var(--topbar-h) + 18px);
  max-height: calc(100vh - var(--topbar-h) - 36px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding-bottom: 6px;
}
.main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }

/* ------------------------------ 5. 目录侧栏 ------------------------------ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-title {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-body { padding: 14px 16px; }

.toc { display: flex; flex-direction: column; min-height: 0; }
.toc-head { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 11px; border-bottom: 1px solid var(--line); }
.toc-title { display: flex; align-items: center; justify-content: space-between; }
.toc-title h2 { font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 650; }
.toc-count { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.book-tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.book-tab {
  flex: 1;
  height: 28px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-2);
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
  white-space: nowrap;
}
.book-tab:hover { color: var(--ink); }
.book-tab.is-active { background: var(--surface); color: var(--brand-2); box-shadow: var(--shadow-xs); }

.search-box { position: relative; }
.search-box .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search-box input {
  width: 100%;
  height: 36px;
  padding: 0 10px 0 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 13px;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.search-box input::placeholder { color: var(--ink-3); }
.search-box input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--focus); background: var(--surface); }

.toc-scroll { overflow-y: auto; padding: 8px; flex: 1; min-height: 0; }

.unit { margin-bottom: 4px; }
.unit-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 9px;
  border: 0;
  background: transparent;
  border-radius: 9px;
  text-align: left;
  color: var(--ink);
  transition: background 0.15s;
}
.unit-head:hover { background: var(--surface-2); }
.unit-head .chev { color: var(--ink-3); transition: transform 0.22s var(--ease); margin-left: auto; }
.unit.is-open .unit-head .chev { transform: rotate(90deg); }
.unit-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 3px 6px;
  border-radius: 6px;
  flex: none;
  line-height: 1.2;
}
html[data-theme='dark'] .unit-badge { color: var(--accent-ink); }
.unit-name { font-size: 13px; font-weight: 550; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.unit-meta { font-size: 11px; color: var(--ink-3); }

.lessons { display: none; padding: 2px 0 6px 0; }
.unit.is-open .lessons { display: block; animation: slideDown 0.24s var(--ease); }
@keyframes slideDown { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.lesson-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px 7px 12px;
  margin-left: 4px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.45;
  transition: background 0.15s, color 0.15s;
}
.lesson-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 0;
  border-radius: 2px;
  background: var(--accent);
  transition: height 0.2s var(--ease);
}
.lesson-item:hover { background: var(--surface-2); color: var(--ink); }
.lesson-item.is-active { background: var(--accent-soft); color: var(--ink); font-weight: 550; }
.lesson-item.is-active::before { height: 62%; }
.lesson-no {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  min-width: 22px;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.lesson-item.is-active .lesson-no { color: var(--accent); }
.lesson-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-flag { flex: none; color: var(--ink-3); display: flex; }
.lesson-flag.is-learned { color: var(--ok); }
.toc-empty { padding: 26px 14px; text-align: center; color: var(--ink-3); font-size: 13px; }

/* 移动端目录折叠 */
.toc-toggle { display: none; }

/* ------------------------------ 6. 右侧栏卡片 ------------------------------ */
.rail-card { padding: 15px 16px; }
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.rail-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--ink); }
.rail-title .icon { color: var(--accent); }
.rail-sub { font-size: 11.5px; color: var(--ink-3); }

.live-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--ok); position: relative; flex: none; }
.live-dot::after {
  content: ''; position: absolute; inset: -3px; border-radius: 99px;
  border: 1px solid var(--ok); opacity: 0.6; animation: ping 2s var(--ease) infinite;
}
@keyframes ping { 0% { transform: scale(0.7); opacity: 0.7; } 80%, 100% { transform: scale(1.6); opacity: 0; } }

.presence-list { display: flex; flex-direction: column; gap: 2px; }
.presence-item { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 8px; transition: background 0.15s; }
.presence-item:hover { background: var(--surface-2); }
.presence-info { min-width: 0; flex: 1; }
.presence-name { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.presence-where { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; flex: none;
}

.seg { display: flex; gap: 3px; background: var(--surface-2); padding: 3px; border-radius: 9px; margin-bottom: 12px; }
.seg-btn {
  flex: 1; height: 26px; border: 0; background: transparent; border-radius: 6px;
  font-size: 11.5px; font-weight: 550; color: var(--ink-2); transition: all 0.16s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: var(--surface); color: var(--text-strong, var(--ink)); box-shadow: var(--shadow-xs); }

.rank-list { display: flex; flex-direction: column; gap: 1px; }
.rank-row { display: flex; align-items: center; gap: 9px; padding: 6px 4px; border-radius: 8px; transition: background 0.15s; }
.rank-row:hover { background: var(--surface-2); }
.rank-row.is-me { background: var(--accent-soft); }
.rank-no {
  width: 20px; height: 20px; flex: none; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--ink-3); border-radius: 6px;
}
.rank-no.r1 { background: linear-gradient(140deg, #f6d489, #d9a63c); color: #5a3c00; box-shadow: 0 1px 3px rgba(180, 130, 20, 0.35); }
.rank-no.r2 { background: linear-gradient(140deg, #e2e6eb, #b9c2cc); color: #3c4650; }
.rank-no.r3 { background: linear-gradient(140deg, #ecccae, #c2996f); color: #523117; }
.rank-name { flex: 1; min-width: 0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-time { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; flex: none; }
.rank-row.is-me .rank-name { font-weight: 650; }
.me-rank {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--ink-2);
}
.me-rank strong { color: var(--accent); font-variant-numeric: tabular-nums; }

.progress-track { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 0.6s var(--ease); }
.progress-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-top: 7px; }

.tip-card { background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%); }
.tip-card p { font-size: 12.5px; color: var(--ink-2); line-height: 1.75; }
.tip-kbd { font-family: var(--font-mono); font-size: 11px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line-2); }

/* ------------------------------ 7. 通用组件 ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 17px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease), border-color 0.16s,
    background 0.16s, color 0.16s;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: var(--ink-3); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn--primary { background: linear-gradient(175deg, #1e4066 0%, #16324f 100%); color: #fdfaf3; border-color: #16324f; }
.btn--primary:hover { background: linear-gradient(175deg, #234a75 0%, #193a5c 100%); border-color: #193a5c; }
.btn--accent { background: linear-gradient(175deg, #bd8a3c 0%, #a9762c 100%); color: #fff; border-color: #a9762c; }
.btn--accent:hover { background: linear-gradient(175deg, #c99548 0%, #b17f31 100%); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); box-shadow: none; border-color: transparent; }
.btn--outline { background: transparent; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn--lg { height: 46px; padding: 0 24px; font-size: 15px; border-radius: 12px; }
.btn--block { width: 100%; }
.btn--icon { width: 40px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }
.btn--danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.chip--accent { background: var(--accent-soft); color: var(--accent-ink); }
.chip--ok { background: var(--ok-soft); color: var(--ok); }
.chip--line { background: transparent; border: 1px solid var(--line); }

.avatar {
  border-radius: 50%;
  background: var(--surface-3);
  object-fit: cover;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--ink-2);
  font-weight: 650;
  font-size: 13px;
  border: 1px solid var(--line);
  user-select: none;
}
.avatar-sm { width: 26px; height: 26px; font-size: 11px; }
.avatar-md { width: 34px; height: 34px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }
.avatar-xl { width: 88px; height: 88px; font-size: 30px; border-width: 2px; }
.avatar-ring { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--accent-2); }

.input, .textarea, .select {
  width: 100%;
  min-height: 42px;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--brand-2);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--focus);
}
.input:disabled { opacity: 0.6; cursor: not-allowed; }
.textarea { resize: vertical; min-height: 92px; line-height: 1.7; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }
.field-error { font-size: 12px; color: var(--danger); display: none; }
.field.has-error .field-error { display: block; }
.field.has-error .input { border-color: var(--danger); }

.form-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.divider { height: 1px; background: var(--line); border: 0; margin: 20px 0; }
.divider-text { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12px; margin: 18px 0; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.65;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
}
.alert .icon { margin-top: 2px; flex: none; }
.alert--warn { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent-ink); }
.alert--danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert--ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 44px 20px;
  text-align: center;
  color: var(--ink-3);
}
.empty .icon { width: 34px; height: 34px; opacity: 0.5; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.empty-desc { font-size: 12.5px; max-width: 380px; line-height: 1.7; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ------------------------------ 8. 首页 ------------------------------ */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(720px 320px at 88% -30%, rgba(211, 162, 80, 0.16), transparent 65%),
    linear-gradient(165deg, var(--surface) 0%, var(--surface-2) 100%);
  padding: 42px 40px 38px;
  box-shadow: var(--shadow-sm);
}
html[data-theme='dark'] .hero {
  background:
    radial-gradient(720px 320px at 88% -30%, rgba(216, 166, 89, 0.13), transparent 65%),
    linear-gradient(165deg, #151c25 0%, #10161d 100%);
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(0, 0.78fr);
  gap: 28px;
  align-items: start;
}
.hero-aside { display: flex; justify-content: flex-end; }
.quote-card {
  position: relative;
  margin: 0;
  padding: 22px 20px 18px 26px;
  width: 100%;
  max-width: 330px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.quote-mark {
  position: absolute;
  top: 2px;
  left: 11px;
  font-family: var(--font-serif);
  font-size: 46px;
  line-height: 1;
  color: var(--accent-2);
  opacity: 0.32;
  pointer-events: none;
}
.quote-en {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink);
  margin: 4px 0 9px;
}
.quote-cn { font-size: 12px; color: var(--ink-3); margin: 0 0 10px; line-height: 1.7; }
.quote-by { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }

.hero-eyebrow {  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 650; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
.hero-eyebrow::before { content: ''; width: 26px; height: 1px; background: var(--accent); opacity: 0.7; }
.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(24px, 2.58vw, 36px);
  line-height: 1.32;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 14px;
  max-width: 20em;
}
.hero h1 em {
  font-style: normal;
  color: var(--brand-2);
  background: linear-gradient(transparent 64%, var(--accent-soft) 64%, var(--accent-soft) 94%, transparent 94%);
  padding: 0 2px;
}
.hero-sub { font-size: 14.5px; color: var(--ink-2); max-width: 46ch; line-height: 1.85; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 11px; margin-top: 26px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 30px; margin-top: 32px; padding-top: 22px; border-top: 1px solid var(--line); }
.hero-stat-value { font-family: var(--font-serif); font-size: 24px; font-weight: 600; color: var(--brand-2); line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-stat-label { font-size: 11.5px; color: var(--ink-3); letter-spacing: 0.06em; margin-top: 3px; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 4px 0 16px; }
.section-title { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; }
.section-title .icon { color: var(--accent); }
.section-desc { font-size: 12.5px; color: var(--ink-3); }
.section-link { font-size: 12.5px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 4px; }
.section-link:hover { color: var(--accent); }

.book-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.book-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
}
.book-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--book-color, var(--accent));
  opacity: 0.85;
}
.book-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.book-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.book-no { font-family: var(--font-serif); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.book-name { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.book-en { font-family: var(--font-serif); font-style: italic; font-size: 12.5px; color: var(--ink-3); }
.book-desc { font-size: 12.5px; color: var(--ink-2); line-height: 1.65; }
.book-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 8px; }
.book-meta { font-size: 11.5px; color: var(--ink-3); }

.continue-card {
  display: flex; align-items: center; gap: 18px;
  padding: 20px; border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(120deg, var(--surface) 0%, var(--surface-2) 100%);
  box-shadow: var(--shadow-xs);
}
.continue-icon {
  width: 52px; height: 52px; border-radius: 14px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.continue-body { flex: 1; min-width: 0; }
.continue-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.continue-title { font-size: 16px; font-weight: 650; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-card {
  padding: 15px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.stat-label { font-size: 11.5px; color: var(--ink-3); letter-spacing: 0.04em; display: flex; align-items: center; gap: 6px; }
.stat-value { font-family: var(--font-serif); font-size: 23px; font-weight: 600; margin-top: 6px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-unit { font-family: var(--font-sans); font-size: 12px; font-weight: 500; color: var(--ink-3); margin-left: 3px; }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px dashed var(--accent-2);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
  line-height: 1.7;
}
.notice .icon { flex: none; margin-top: 2px; }

.feature-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.feature {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}
.feature .icon-lg { color: var(--accent); margin-bottom: 9px; }
.feature h3 { font-size: 13.5px; font-weight: 650; margin-bottom: 5px; }
.feature p { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }

.preview-list { display: flex; flex-direction: column; }
.preview-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.preview-row:last-child { border-bottom: 0; }
.preview-no { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); width: 34px; flex: none; }
.preview-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-unit { font-size: 11.5px; color: var(--ink-3); flex: none; }

/* ------------------------------ 9. 课文阅读 ------------------------------ */
.lesson-head { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.lesson-card-head { padding: 30px 34px 22px; }
.lesson-card-body { padding: 0 34px 30px; }
.grow { flex: 1 1 auto; }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; font-size: 12px; color: var(--ink-3); margin-bottom: 14px; }
.breadcrumb a { color: var(--ink-3); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { opacity: 0.5; }
.breadcrumb .current { color: var(--ink-2); font-weight: 550; }

.lesson-eyebrow {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
}
.lesson-title-en {
  font-family: var(--font-serif);
  font-size: clamp(25px, 2.8vw, 34px);
  line-height: 1.24;
  letter-spacing: -0.015em;
  font-weight: 600;
  color: var(--ink);
}
.lesson-title-cn { font-size: 15px; color: var(--ink-2); margin-top: 7px; font-weight: 500; }
.lesson-summary { font-size: 13.5px; color: var(--ink-3); margin-top: 10px; line-height: 1.7; }

.lesson-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 9px;
  margin-top: 20px;
}
.tool-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px; font-weight: 550;
  transition: all 0.16s var(--ease);
}
.tool-btn:hover { color: var(--ink); border-color: var(--ink-3); transform: translateY(-1px); }
.tool-btn.is-on { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent-ink); }
.tool-btn.is-playing { background: var(--brand); border-color: var(--brand); color: #fff; }
html[data-theme='dark'] .tool-btn.is-playing { background: var(--brand-2); border-color: var(--brand-2); color: #0d1117; }
.tool-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.tool-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }

.reading {
  position: relative;
  padding: 34px 0 6px;
  font-family: var(--font-serif);
  font-size: 18.5px;
  line-height: 1.95;
  color: var(--ink);
  letter-spacing: 0.002em;
}
.reading p { margin: 0 0 1.15em; }
.reading.is-dialogue { line-height: 1.85; }
.reading.is-dialogue p { margin-bottom: 0.42em; }
.reading.is-dialogue p:empty { display: none; }
.reading p:last-child { margin-bottom: 0.2em; }
.reading .dialogue { color: var(--ink); }
.reading blockquote {
  margin: 1.2em 0;
  padding-left: 16px;
  border-left: 2px solid var(--line-2);
  color: var(--ink-2);
  font-style: italic;
}
.reading h3 {
  font-family: var(--font-sans);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 1.6em 0 0.6em;
}
.reading ul, .reading ol { margin: 0 0 1.1em 1.1em; list-style: disc; }
.reading li { margin-bottom: 0.35em; }
.reading a { text-decoration: underline; text-underline-offset: 3px; }
.reading-empty {
  padding: 40px 24px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  text-align: center;
  color: var(--ink-3);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.8;
}
.reading-empty strong { display: block; color: var(--ink-2); font-size: 14.5px; margin-bottom: 6px; }

/* 译文区 */
.trans-block { margin-top: 30px; }
.collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.36s var(--ease); }
.collapse > .collapse-inner { overflow: hidden; }
.collapse.is-open { grid-template-rows: 1fr; }

.trans-panel {
  position: relative;
  margin-top: 6px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent-2);
  box-shadow: var(--shadow-xs);
}
.panel-label {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-sans);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.trans-text { font-size: 15.5px; line-height: 1.95; color: var(--ink-2); }
.trans-text p { margin: 0 0 1em; }
.trans-text p:last-child { margin-bottom: 0; }

.notes-panel { padding: 20px 22px; }
.notes-text { font-size: 13.8px; line-height: 1.9; color: var(--ink-2); }
.notes-text strong { color: var(--ink); }

/* 锁屏 */
.lock-panel {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px dashed var(--accent-2);
  background:
    repeating-linear-gradient(135deg, transparent 0 10px, rgba(211, 162, 80, 0.05) 10px 20px),
    var(--surface);
}
.lock-icon {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.lock-body { flex: 1; min-width: 0; }
.lock-title { font-size: 14px; font-weight: 650; color: var(--ink); }
.lock-desc { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.65; }

/* 音频播放器 */
.player { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-xs); overflow: hidden; }
.player-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.player-tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 9px; }
.player-tab {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px;
  border: 0; background: transparent; border-radius: 7px;
  font-size: 12px; font-weight: 550; color: var(--ink-2);
  transition: all 0.16s;
}
.player-tab:hover { color: var(--ink); }
.player-tab.is-active { background: var(--surface); color: var(--brand-2); box-shadow: var(--shadow-xs); }
.player-body { display: flex; align-items: center; gap: 13px; padding: 13px 15px 15px; }
.play-btn {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  border: 0;
  background: linear-gradient(160deg, #1e4066, #16324f);
  color: #fff;
  box-shadow: 0 4px 14px rgba(22, 50, 79, 0.28);
  transition: transform 0.16s, box-shadow 0.16s;
}
.play-btn:hover { transform: scale(1.05); }
.play-btn:disabled { background: var(--surface-3); color: var(--ink-3); box-shadow: none; cursor: not-allowed; }
.player-main { flex: 1; min-width: 0; }
.seek { position: relative; height: 18px; display: flex; align-items: center; cursor: pointer; }
.seek-rail { position: absolute; left: 0; right: 0; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.seek-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.seek-therm { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--surface); left: 0; transform: translateX(-50%); opacity: 0; transition: opacity 0.15s; }
.seek:hover .seek-therm, .seek.is-dragging .seek-therm { opacity: 1; }
.player-time { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-top: 3px; }
.player-extra { display: flex; align-items: center; gap: 6px; }
.speed-btn {
  height: 28px; padding: 0 9px; border-radius: 7px;
  border: 1px solid var(--line); background: transparent;
  font-size: 11.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.speed-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.player-locked { padding: 16px; display: flex; align-items: center; gap: 12px; }

/* 课文底部导航 */
.lesson-foot { display: flex; align-items: stretch; gap: 12px; margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--line); }
.nav-card {
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column; gap: 3px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: all 0.18s var(--ease);
}
.nav-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.nav-card.is-next { text-align: right; align-items: flex-end; }
.nav-card.is-disabled { opacity: 0.45; pointer-events: none; }
.nav-label { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.nav-title { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.nav-sub { font-size: 11.5px; color: var(--ink-3); font-family: var(--font-serif); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lesson-progress-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); }
.lesson-progress-bar .icon { color: var(--ok); }

/* ------------------------------ 10. 我的 ------------------------------ */
.profile-card {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 24px; border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(520px 200px at 90% -40%, rgba(211, 162, 80, 0.16), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}
.profile-avatar-wrap { position: relative; flex: none; }
.avatar-edit {
  position: absolute; right: -3px; bottom: -3px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line-2);
  color: var(--ink-2); box-shadow: var(--shadow-xs);
  transition: all 0.16s;
}
.avatar-edit:hover { color: var(--accent); border-color: var(--accent-2); transform: scale(1.06); }
.profile-info { flex: 1; min-width: 190px; }
.profile-name { font-size: 21px; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.profile-mail { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.profile-bio { font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.profile-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }

.section-card { border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-xs); overflow: hidden; }
.section-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.section-card-title { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 9px; }
.section-card-title .icon { color: var(--accent); }
.section-card-body { padding: 20px; }

.activation-card {
  border-radius: var(--radius);
  border: 1px solid var(--accent-2);
  background:
    radial-gradient(420px 180px at 100% -20%, rgba(211, 162, 80, 0.2), transparent 70%),
    linear-gradient(160deg, var(--surface), var(--surface-2));
  padding: 22px;
}
.activation-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.activation-row .input { flex: 1; min-width: 190px; font-family: var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.activation-status { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ok); font-weight: 550; }
.activation-status.is-locked { color: var(--accent-ink); }

.recent-list { display: flex; flex-direction: column; }
.recent-row { display: flex; align-items: center; gap: 13px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.recent-row:last-child { border-bottom: 0; }
.recent-row:hover .recent-title { color: var(--accent); }
.recent-no {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-3);
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
}
.recent-main { flex: 1; min-width: 0; }
.recent-title { font-size: 13.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color 0.15s; }
.recent-meta { font-size: 11.5px; color: var(--ink-3); }
.recent-time { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; flex: none; }

/* ------------------------------ 11. 认证页 ------------------------------ */
.auth-wrap { display: flex; justify-content: center; padding: 12px 0 40px; }
.auth-card {
  width: 100%;
  max-width: 436px;
  padding: 34px 32px 28px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.auth-mark { display: flex; justify-content: center; margin-bottom: 18px; }
.auth-mark .brand-mark { width: 46px; height: 46px; border-radius: 13px; font-size: 17px; }
.auth-title { text-align: center; font-family: var(--font-serif); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.auth-sub { text-align: center; font-size: 13px; color: var(--ink-3); margin-top: 7px; margin-bottom: 26px; line-height: 1.7; }
.auth-foot { text-align: center; font-size: 13px; color: var(--ink-3); margin-top: 20px; }
.auth-foot a { font-weight: 550; }
.auth-links { display: flex; justify-content: space-between; font-size: 12.5px; margin-top: -6px; margin-bottom: 18px; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 7px; border: 0; background: transparent;
  color: var(--ink-3); display: grid; place-items: center;
}
.pw-toggle:hover { color: var(--ink); background: var(--surface-2); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 42px; }

/* ------------------------------ 12. 页脚 ------------------------------ */
.footer {
  position: relative;
  z-index: 1;
  margin-top: 20px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, transparent, var(--surface-2) 40%);
}
.footer-inner { max-width: 900px; margin: 0 auto; padding: 38px 26px 26px; }
.footer-html { font-size: 13px; color: var(--ink-2); line-height: 1.9; }
.footer-html p { margin: 0 0 0.55em; }
.footer-html a { color: var(--brand-2); text-decoration: underline; text-underline-offset: 3px; }
.footer-html strong { color: var(--ink); }
.footer-html .ft-brand {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
  margin-bottom: 10px;
}
.footer-html .ft-dim { color: var(--ink-3); font-size: 12px; }
.footer-html img { border-radius: 8px; }
.footer-bottom {
  max-width: 900px; margin: 0 auto; padding: 16px 26px 30px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--ink-3);
  border-top: 1px solid var(--line);
}
.footer-links { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ------------------------------ 13. 浮层 ------------------------------ */
.toast-root {
  position: fixed; right: 22px; bottom: 22px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 11px;
  background: #1b222b;
  color: #f4efe4;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.26s var(--ease);
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.09);
}
html[data-theme='dark'] .toast { background: #263040; }
.toast .icon { flex: none; }
.toast--ok .icon { color: #7bd6a8; }
.toast--error .icon { color: #ff9d92; }
.toast--error { background: #3a1f1f; }
.toast.is-leaving { animation: toastOut 0.2s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

.modal-root { position: fixed; inset: 0; z-index: 190; display: none; }
.modal-root.is-open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 20, 26, 0.55); backdrop-filter: blur(3px); animation: fadeIn 0.18s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative;
  z-index: 1;
  width: min(94vw, 480px);
  margin: 10vh auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: modalIn 0.22s var(--ease);
  max-height: 80vh;
  overflow-y: auto;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-title { font-size: 17px; font-weight: 650; margin-bottom: 8px; }
.modal-desc { font-size: 13px; color: var(--ink-2); line-height: 1.75; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* 阅读进度条（顶部） */
.read-progress {
  position: fixed; top: var(--topbar-h); left: 0; right: 0; height: 2px; z-index: 59;
  background: transparent; pointer-events: none;
}
.read-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 0.1s linear; }

/* 返回顶部 */
.to-top {
  position: fixed; right: 22px; bottom: 84px; z-index: 90;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line-2);
  color: var(--ink-2); box-shadow: var(--shadow-sm);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: all 0.2s var(--ease);
}
.to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { color: var(--accent); border-color: var(--accent-2); }

/* ------------------------------ 14. 响应式 ------------------------------ */
@media (max-width: 1360px) {
  :root { --sidebar-w: 258px; --rail-w: 278px; }
  .shell { gap: 20px; padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 1180px) {
  :root { --sidebar-w: 240px; --rail-w: 250px; }
  .reading { font-size: 17.5px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 平板 / 手机：改为自上而下 */
@media (max-width: 1080px) {
  .hero-grid { grid-template-columns: 1fr; gap: 22px; }
  .hero-aside { display: none; }
}

@media (max-width: 1020px) {
  .shell {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 16px 40px;
  }
  .shell > .sidebar { order: 1; width: 100%; position: static; max-height: none; }
  .shell > .main { order: 2; width: 100%; }
  .shell > .rail { order: 3; width: 100%; position: static; max-height: none; overflow: visible; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
  .shell.is-focus { display: block; padding-top: 22px; }

  .toc { max-height: none; }
  .toc-scroll { max-height: 52vh; }
  .toc.is-collapsed .toc-scroll { display: none; }
  .toc.is-collapsed .toc-head .search-box { display: none; }
  .toc-toggle { display: inline-flex; }

  .hero { padding: 30px 24px; }
  .hero h1 { font-size: 27px; }
  .hero-stats { gap: 22px; }
  .book-grid { grid-template-columns: 1fr; }
  .feature-strip { grid-template-columns: 1fr; }
  .lesson-title-en { font-size: 26px; }
  .footer-inner { padding: 30px 18px 22px; }
  .topbar-inner { padding: 0 16px; gap: 10px; }
  .brand-tag { display: none; }
}

@media (max-width: 760px) {
  :root { --topbar-h: 60px; }
  .shell > .rail { grid-template-columns: 1fr; }
  .lesson-card-head { padding: 20px 18px 16px; }
  .lesson-card-body { padding: 0 18px 24px; }
  .lesson-progress-bar { flex-direction: column; align-items: flex-start; gap: 5px; }
  .lesson-progress-bar .grow { display: none; }
  .nav { margin-left: 0; gap: 2px; }
  .nav-link { padding: 0 10px; font-size: 13px; height: 34px; }
  .nav-link span { display: none; }
  .user-chip-name { display: none; }
  .user-chip { padding: 0 6px; width: 40px; justify-content: center; }
  .user-chip .chev { display: none; }
  .brand-name { font-size: 14px; max-width: 34vw; }
  .reading { font-size: 17px; line-height: 1.9; }
  .trans-panel { padding: 18px 16px; }
  .lesson-toolbar { gap: 7px; }
  .tool-btn { height: 34px; padding: 0 11px; font-size: 12.5px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat-card { padding: 12px 13px; }
  .stat-value { font-size: 20px; }
  .hero { padding: 26px 20px; }
  .hero-actions .btn { flex: 1; }
  .profile-card { padding: 18px; gap: 15px; }
  .profile-name { font-size: 18px; }
  .lesson-foot { flex-direction: column; }
  .continue-card { gap: 13px; padding: 16px; }
  .auth-card { padding: 26px 20px 22px; }
  .toast-root { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
  .toast { max-width: none; }
  .to-top { right: 16px; bottom: 76px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 23px; }
  .hero-stats { gap: 16px 20px; }
  .hero-stat-value { font-size: 20px; }
  .lesson-title-en { font-size: 23px; }
  .reading { font-size: 16.5px; }
  .player-body { gap: 10px; padding: 12px; }
  .play-btn { width: 38px; height: 38px; }
  .avatar-xl { width: 72px; height: 72px; font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------ 15. 杂项 ------------------------------ */
.member-title {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  margin-left: 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #5a3c00;
  background: linear-gradient(140deg, #f6d489, #d9a63c);
  box-shadow: 0 1px 3px rgba(180, 130, 20, 0.28);
  vertical-align: 3px;
}
html[data-theme='dark'] .member-title {
  color: #2a1f05;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  opacity: 0.85;
  vertical-align: -2px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.lesson-card {
  background: var(--surface);
  border: 1px solid var(--line);
}
.modal-content .field:last-child {
  margin-bottom: 0;
}
code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

html.is-theming body,
html.is-theming .panel,
html.is-theming .sidebar,
html.is-theming .topbar,
html.is-theming .rail-card,
html.is-theming .hero,
html.is-theming .book-card,
html.is-theming .stat-card {
  transition: background-color 0.3s var(--ease), border-color 0.3s var(--ease), color 0.3s var(--ease);
}

/* ---------------- 登录方式切换（用户名 / 邮箱） ---------------- */
.login-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.login-tab {
  flex: 1;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.login-tab:hover { color: var(--ink); }
.login-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
