/* ==========================================================================
   汉语学堂 —— 样式表
   手机优先（Android / iOS，含安全区）→ 桌面自适应（≥900px 侧栏布局）
   暗色 / 亮色双主题，用 CSS 变量切换
   字体全部使用系统字体，不依赖任何 CDN（国外可正常访问）
   ========================================================================== */

/* ---------------------------------------------------------------- 主题变量 */
:root {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-2: #f8fafc;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #e2e8f0;
  --border-2: #cbd5e1;
  --primary: #2563eb;
  --primary-2: #3b82f6;
  --primary-soft: #eff6ff;
  --primary-ink: #ffffff;
  --ok: #16a34a;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --gold: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 14px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, .18);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --tab-h: 58px;
  --top-h: 54px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue",
          Roboto, Arial, sans-serif;
  --font-zh: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
             "Songti SC", "SimSun", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0a1120;
  --bg-elev: #101a2e;
  --card: #131f36;
  --card-2: #0e1830;
  --text: #e8effc;
  --text-2: #c3d0e6;
  --muted: #8fa3c0;
  --muted-2: #6b7f9e;
  --border: #22314e;
  --border-2: #2f4162;
  --primary: #4b8dff;
  --primary-2: #6ba2ff;
  --primary-soft: #16233d;
  --primary-ink: #06101f;
  --ok: #34d399;
  --ok-soft: #10261f;
  --warn: #fbbf24;
  --warn-soft: #2a2110;
  --bad: #f87171;
  --bad-soft: #2b1416;
  --gold: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 4px 16px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
}

/* ---------------------------------------------------------------- 基础重置 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 16px; }
p { margin: 0 0 8px; }
a { color: var(--primary); text-decoration: none; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt { margin-top: 12px; }
.mt2 { margin-top: 20px; }
.mb { margin-bottom: 12px; }
.gap { gap: 8px; }
.full { width: 100%; }

/* ---------------------------------------------------------------- 启动遮罩 */
.boot {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; background: var(--bg);
}
.boot-logo {
  width: 76px; height: 76px; border-radius: 22px;
  background: linear-gradient(140deg, var(--primary), #7c3aed);
  color: #fff; font-size: 40px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-zh);
  box-shadow: var(--shadow);
}
.boot-logo.small { width: 52px; height: 52px; border-radius: 15px; font-size: 28px; }
.boot-logo.xs { width: 38px; height: 38px; border-radius: 11px; font-size: 21px; }
.boot-text { font-weight: 700; letter-spacing: 2px; color: var(--text-2); }
.spinner {
  width: 22px; height: 22px; margin-top: 6px; border-radius: 50%;
  border: 2.5px solid var(--border-2); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 通用组件 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); font-weight: 600; font-size: 15px;
  cursor: pointer; transition: .15s; min-height: 44px;
  user-select: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.green { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  border: none; background: transparent; color: var(--text-2);
  font-size: 18px; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; transition: .15s;
}
.icon-btn:active { background: var(--card-2); transform: scale(.94); }
.link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 14px; padding: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--border);
}
.pill.p-blue { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.pill.p-green { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.p-gold { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.p-red { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm);
}
.card.tap { cursor: pointer; transition: .15s; }
.card.tap:active { transform: scale(.985); border-color: var(--border-2); }
.card + .card { margin-top: 10px; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 2px 10px; gap: 8px;
}
.section-title h3 { font-size: 16px; }
.section-title .sub { color: var(--muted); font-size: 12px; }

.empty {
  text-align: center; padding: 40px 18px; color: var(--muted);
}
.empty .big { font-size: 40px; margin-bottom: 8px; }

.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: var(--card); border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; white-space: nowrap; transition: .15s;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip:active { transform: scale(.96); }

/* 进度条 */
.bar { height: 7px; border-radius: 99px; background: var(--card-2); overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 99px; transition: width .35s; }
.bar.green > i { background: linear-gradient(90deg, var(--ok), #4ade80); }

/* ---------------------------------------------------------------- 登录页 */
.auth {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: calc(20px + var(--safe-t)) 18px calc(20px + var(--safe-b));
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(37, 99, 235, .18), transparent 60%),
    radial-gradient(700px 400px at 100% 110%, rgba(124, 58, 237, .16), transparent 60%),
    var(--bg);
  overflow-y: auto;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-brand h1 { font-family: var(--font-zh); letter-spacing: 1px; }
.auth-brand p { margin: 2px 0 0; font-size: 12.5px; }
.tabs { display: flex; background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tabs .tab {
  flex: 1; padding: 9px; border: none; background: transparent; border-radius: 9px;
  font-weight: 600; color: var(--muted); cursor: pointer; transition: .15s; font-size: 14.5px;
}
.tabs .tab.active { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input {
  width: 100%; padding: 12px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev);
  outline: none; transition: .15s; font-size: 16px; /* iOS 上 <16px 会自动放大 */
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.auth-err {
  background: var(--bad-soft); color: var(--bad); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; margin-bottom: 12px;
}
.auth-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.lang-switch { display: flex; gap: 3px; background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.lang-switch button {
  border: none; background: transparent; padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; transition: .15s;
}
.lang-switch button.active { background: var(--primary); color: #fff; }

/* ---------------------------------------------------------------- 应用布局 */
.app { min-height: 100%; }

/* 底部标签栏（手机） */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  padding-left: var(--safe-l); padding-right: var(--safe-r);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar button {
  border: none; background: none; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10.5px; font-weight: 600; padding: 4px 0; transition: .15s;
  position: relative;
}
.tabbar button .ico { font-size: 19px; line-height: 1; }
.tabbar button.active { color: var(--primary); }
.tabbar button.active .ico { transform: translateY(-1px); }

/* 手机顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 35;
  height: calc(var(--top-h) + var(--safe-t));
  padding-top: var(--safe-t);
  padding-left: calc(10px + var(--safe-l)); padding-right: calc(8px + var(--safe-r));
  display: flex; align-items: center; gap: 4px;
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; padding-left: 4px; }
.topbar-title h2 { font-size: 16.5px; }
.topbar-title .tiny { display: block; margin-top: -1px; }
.topbar-actions { display: flex; gap: 2px; }

/* 内容区 */
.view {
  padding: 14px 14px calc(var(--tab-h) + var(--safe-b) + 22px);
  max-width: 100%;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.sidebar, .deskbar { display: none; }

/* ---------------------------------------------------------------- 桌面适配 */
@media (min-width: 900px) {
  body { font-size: 15.5px; }
  .tabbar, .topbar { display: none; }
  /* 桌面：左侧 240px 固定侧栏 + 右侧内容列 */
  .app {
    display: grid; min-height: 100vh;
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    display: flex; flex-direction: column;
    grid-column: 1; grid-row: 1 / span 2;
    width: 240px; height: 100vh; position: sticky; top: 0;
    background: var(--bg-elev); border-right: 1px solid var(--border);
    padding: 18px 12px 14px;
  }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 18px; }
  .side-brand-txt { display: flex; flex-direction: column; line-height: 1.2; }
  .side-brand-txt b { font-family: var(--font-zh); font-size: 16px; }
  .side-brand-txt i { font-style: normal; font-size: 11.5px; color: var(--muted); }
  .side-nav { flex: 1; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
  .side-nav button {
    display: flex; align-items: center; gap: 11px; width: 100%;
    padding: 11px 12px; border: none; border-radius: 11px; background: transparent;
    color: var(--text-2); font-weight: 600; font-size: 14.5px; cursor: pointer;
    text-align: left; transition: .15s;
  }
  .side-nav button:hover { background: var(--card-2); }
  .side-nav button.active { background: var(--primary-soft); color: var(--primary); }
  .side-nav button .ico { font-size: 18px; width: 22px; text-align: center; }
  .side-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border); }

  .deskbar {
    display: flex; align-items: center; justify-content: space-between;
    grid-column: 2; grid-row: 1;
    gap: 12px; padding: 20px 26px 6px;
  }
  .deskbar-title h2 { font-size: 22px; }
  .deskbar-actions { display: flex; align-items: center; gap: 8px; }

  .view {
    grid-column: 2; grid-row: 2;
    padding: 12px 26px 40px; max-width: 1080px; width: 100%;
  }

  /* 桌面网格化 */
  .grid-2, .grid-3, .grid-4 { display: grid; gap: 12px; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card + .card { margin-top: 0; }
  .stack-desktop { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
}

/* 手机端：列表卡片保持纵向堆叠 */
@media (max-width: 899px) {
  .grid-2, .grid-3, .grid-4, .stack-desktop { display: block; }
}

/* ---------------------------------------------------------------- 汉字 / 拼音 */
.zh { font-family: var(--font-zh); }
.hanzi { font-family: var(--font-zh); font-weight: 700; letter-spacing: .5px; }
.py { color: var(--muted); font-family: var(--font); font-size: 12.5px; letter-spacing: .2px; }

/* 注音（ruby） */
ruby.r { ruby-position: over; margin: 0 .5px; cursor: pointer; }
ruby.r rt {
  font-size: .48em; color: var(--muted); font-weight: 500;
  font-family: var(--font); letter-spacing: 0; user-select: none;
}
ruby.r:hover rt, ruby.r:active rt { color: var(--primary); }
.ruby-line { line-height: 2.15; }

/* 可点击朗读 */
[data-speak] { cursor: pointer; }
[data-speak]:active { opacity: .55; }
.spk-hint { position: relative; }
.spk-hint::after {
  content: "🔊"; position: absolute; right: -2px; top: -2px;
  font-size: 9px; opacity: .35; pointer-events: none;
}

/* 词汇行 */
.vrow {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border);
  transition: .15s;
}
.vrow + .vrow { margin-top: 8px; }
.vrow.done { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); background: var(--ok-soft); }
.vrow .vmain { flex: 1; min-width: 0; }
.vrow .vtop { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.vrow .vhanzi { font-family: var(--font-zh); font-size: 22px; font-weight: 700; line-height: 1.35; }
.vrow .vpy { color: var(--primary); font-size: 13px; font-weight: 600; }
.vrow .vvi { color: var(--text-2); font-size: 14px; margin-top: 1px; }
.vrow .ven { color: var(--muted); font-size: 12.5px; }
.vrow .vex {
  margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--border);
  font-size: 13px; color: var(--text-2);
}
.vrow .actions { display: flex; flex-direction: column; gap: 6px; flex: none; }

/* 标记按钮 */
.mark-btn {
  width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--card-2); color: var(--muted); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: .15s;
}
.mark-btn.on { background: var(--ok); border-color: var(--ok); color: #fff; }

/* ---------------------------------------------------------------- 语音 / 音频 */
.speak-fab {
  position: fixed; right: 16px; z-index: 45;
  bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: linear-gradient(140deg, var(--primary), #7c3aed); color: #fff;
  font-size: 22px; cursor: pointer; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center;
  transition: .18s;
}
.speak-fab:active { transform: scale(.92); }
.speak-fab.playing { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 55%, transparent), var(--shadow-lg); }
  50% { box-shadow: 0 0 0 12px transparent, var(--shadow-lg); }
}
@media (min-width: 900px) {
  .speak-fab { bottom: 26px; right: 26px; }
}

/* 麦克风录制态 */
.mic-live { animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); }
  50% { box-shadow: 0 0 0 14px transparent; }
}
.wave { display: flex; align-items: flex-end; gap: 2.5px; height: 20px; }
.wave i {
  width: 3px; background: var(--primary); border-radius: 2px;
  animation: wv .9s ease-in-out infinite;
}
.wave i:nth-child(2) { animation-delay: .12s; }
.wave i:nth-child(3) { animation-delay: .24s; }
.wave i:nth-child(4) { animation-delay: .36s; }
.wave i:nth-child(5) { animation-delay: .48s; }
@keyframes wv { 0%, 100% { height: 5px; } 50% { height: 18px; } }

/* ---------------------------------------------------------------- 聊天 */
.chat-wrap { display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 9px; max-width: 100%; }
.msg .av {
  width: 34px; height: 34px; flex: none; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: var(--card-2); border: 1px solid var(--border);
}
.msg.ai .av { background: linear-gradient(140deg, var(--primary), #7c3aed); color: #fff; border: none; }
.bubble {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 11px 13px; max-width: 100%;
  box-shadow: var(--shadow-sm); overflow-wrap: anywhere;
}
.msg.me { flex-direction: row-reverse; }
.msg.me .bubble { background: var(--primary); border-color: var(--primary); color: #fff; }
.msg.me .bubble .py, .msg.me .bubble .muted { color: rgba(255, 255, 255, .8); }
.bubble .zh-line { font-family: var(--font-zh); font-size: 16.5px; font-weight: 600; line-height: 1.6; }
.bubble .vi-line { color: var(--text-2); font-size: 13.5px; margin-top: 5px; }
.msg.me .bubble .vi-line { color: rgba(255, 255, 255, .85); }
.bubble .fix {
  margin-top: 8px; padding: 7px 10px; border-radius: 9px;
  background: var(--warn-soft); color: var(--warn); font-size: 12.5px;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.bubble .words { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.bubble .words .w {
  padding: 3px 9px; border-radius: 999px; background: var(--primary-soft);
  color: var(--primary); font-size: 12.5px; font-weight: 600;
}
.chat-input {
  position: sticky; bottom: calc(var(--tab-h) + var(--safe-b));
  margin-top: 14px; padding: 10px;
  background: color-mix(in srgb, var(--bg-elev) 94%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius);
  z-index: 30;
}
.chat-input .box { display: flex; align-items: flex-end; gap: 8px; }
.chat-input textarea {
  flex: 1; min-height: 44px; max-height: 130px; resize: none;
  padding: 11px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elev); outline: none; font-size: 16px;
}
.chat-input textarea:focus { border-color: var(--primary); }
.mic-btn {
  width: 46px; height: 46px; flex: none; border-radius: 13px; border: 1px solid var(--border);
  background: var(--card-2); font-size: 19px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: .15s;
}
.mic-btn.rec { background: var(--bad); border-color: var(--bad); color: #fff; }
.live-text {
  margin-top: 8px; padding: 8px 11px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary); font-size: 14px; min-height: 20px;
  font-family: var(--font-zh);
}

/* ---------------------------------------------------------------- 弹层 */
.toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-t) + 13px); z-index: 300;
  display: flex; flex-direction: column; gap: 7px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  background: rgba(15, 23, 42, .93); color: #fff; padding: 10px 15px;
  border-radius: 11px; font-size: 13.5px; box-shadow: var(--shadow-lg);
  animation: toastIn .22s ease; max-width: 92vw; text-align: center;
}
.toast.ok { background: color-mix(in srgb, var(--ok) 92%, #000); }
.toast.err { background: color-mix(in srgb, var(--bad) 92%, #000); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.sheet { position: fixed; inset: 0; z-index: 150; }
.sheet-mask, .modal-mask { position: absolute; inset: 0; background: rgba(2, 6, 23, .5); animation: fadeIn .18s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--bg-elev); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 88vh; display: flex; flex-direction: column;
  padding-bottom: var(--safe-b); animation: sheetUp .26s cubic-bezier(.2, .9, .3, 1);
  box-shadow: var(--shadow-lg);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grip { width: 38px; height: 4px; border-radius: 99px; background: var(--border-2); margin: 8px auto 0; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px 10px; border-bottom: 1px solid var(--border);
}
.sheet-body { padding: 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.modal { position: fixed; inset: 0; z-index: 160; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-panel {
  position: relative; width: 100%; max-width: 400px; background: var(--bg-elev);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-lg);
  animation: fade .2s; max-height: 86vh; overflow-y: auto;
}
.modal-body { margin: 10px 0 16px; color: var(--text-2); font-size: 14.5px; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; }

/* 桌面端弹层改为居中卡片 */
@media (min-width: 900px) {
  .sheet-panel {
    position: absolute; left: 50%; top: 50%; bottom: auto; right: auto;
    transform: translate(-50%, -50%);
    width: 560px; max-width: 92vw; border-radius: var(--radius-lg);
    max-height: 84vh; animation: fade .2s;
  }
  .sheet-grip { display: none; }
}

/* ---------------------------------------------------------------- 表格 / 统计 */
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv b { font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px; text-align: center;
}
.stat .n { font-size: 24px; font-weight: 800; font-family: var(--font); letter-spacing: -.5px; }
.stat .l { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
@media (min-width: 900px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

/* 7 天柱状图 */
.chart7 { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding: 8px 2px 0; }
.chart7 .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.chart7 .col .b {
  width: 100%; max-width: 34px; border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  min-height: 3px; transition: height .4s;
}
.chart7 .col .d { font-size: 10.5px; color: var(--muted); }
.chart7 .col .v { font-size: 11px; font-weight: 700; color: var(--primary); }

/* ---------------------------------------------------------------- 游戏 */
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.game-board { display: grid; gap: 8px; }
.tile {
  aspect-ratio: 1 / .82; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; cursor: pointer; padding: 6px;
  font-family: var(--font-zh); font-weight: 700; transition: .15s; overflow: hidden;
}
.tile:active { transform: scale(.96); }
.tile.sel { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
.tile.gone { opacity: .16; pointer-events: none; }
.tile .t-zh { font-size: 17px; }
.tile .t-py { font-size: 10px; color: var(--muted); font-weight: 500; }
.tile .t-vi { font-size: 11px; color: var(--text-2); }
.tile.good { border-color: var(--ok); background: var(--ok-soft); animation: pop .3s; }
.tile.bad { border-color: var(--bad); background: var(--bad-soft); animation: shake .3s; }
@keyframes pop { 50% { transform: scale(1.07); } }
@keyframes shake { 25%, 75% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }

.opt {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 13px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card); cursor: pointer; transition: .15s; min-height: 50px; font-size: 15px;
}
.opt + .opt { margin-top: 9px; }
.opt .k {
  width: 24px; height: 24px; flex: none; border-radius: 7px; background: var(--card-2);
  color: var(--muted); font-size: 12.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.opt.good { border-color: var(--ok); background: var(--ok-soft); }
.opt.good .k { background: var(--ok); color: #fff; }
.opt.bad { border-color: var(--bad); background: var(--bad-soft); }
.opt.bad .k { background: var(--bad); color: #fff; }
.opt[disabled] { cursor: default; }
.q-prompt { text-align: center; padding: 18px 10px; }
.q-prompt .qzh { font-family: var(--font-zh); font-size: 34px; font-weight: 800; letter-spacing: 2px; }
.q-prompt .qpy { color: var(--primary); font-size: 15px; margin-top: 4px; }
.q-prompt .qdesc { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* 音色卡片 */
.voice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
@media (min-width: 640px) { .voice-grid { grid-template-columns: repeat(3, 1fr); } }
.voice {
  padding: 11px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--card); cursor: pointer; transition: .15s;
}
.voice.active { border-color: var(--primary); background: var(--primary-soft); }
.voice .vn { font-weight: 700; font-size: 14px; }
.voice .vt { font-size: 11px; color: var(--muted); margin-top: 2px; }
.voice .vg { font-size: 11.5px; margin-top: 5px; }

/* 角色扮演 */
.rp-scene { background: var(--card-2); border: 1px dashed var(--border-2); border-radius: var(--radius); padding: 13px; }
.rp-score { font-size: 26px; font-weight: 800; }
.steps { display: flex; gap: 4px; flex-wrap: wrap; }
.steps i { width: 22px; height: 5px; border-radius: 99px; background: var(--border); }
.steps i.on { background: var(--primary); }
.steps i.done { background: var(--ok); }

/* 语文轨道正文 */
.reader { font-family: var(--font-zh); font-size: 18px; line-height: 2.25; letter-spacing: .5px; white-space: pre-wrap; }
.reader-poem { font-family: var(--font-zh); font-size: 19px; line-height: 2.3; text-align: center; letter-spacing: 3px; white-space: pre-wrap; }
.note-item { padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.note-item:last-child { border-bottom: none; }
.note-item .nh { font-family: var(--font-zh); font-weight: 700; font-size: 15px; }

/* 拼音表 */
.py-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.py-cell {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; cursor: pointer; transition: .15s;
}
.py-cell:active { border-color: var(--primary); }
.py-cell .s { font-size: 21px; font-weight: 800; color: var(--primary); font-family: var(--font); }
.py-cell .e { font-family: var(--font-zh); font-size: 15px; margin-top: 3px; }
.py-cell .h { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.35; }
.tone-card { display: flex; align-items: center; gap: 13px; padding: 12px; }
.tone-card .tnum { font-size: 24px; font-weight: 800; color: var(--primary); width: 34px; text-align: center; }
.tone-svg { flex: none; }

/* 词典结果 */
.dict-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.dict-item:last-child { border-bottom: none; }
.dict-item .dh { font-family: var(--font-zh); font-size: 21px; font-weight: 700; }

/* 扫描/搜索输入 */
.search-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.search-bar input {
  flex: 1; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); outline: none; font-size: 16px;
}
.search-bar input:focus { border-color: var(--primary); }

/* 骨架屏 */
.skel { background: linear-gradient(90deg, var(--card-2), var(--border), var(--card-2)); background-size: 200% 100%; animation: sk 1.3s linear infinite; border-radius: 9px; }
@keyframes sk { to { background-position: -200% 0; } }

/* 找错题 / 排字：可点击的汉字 */
.tchar {
  display: inline-block; padding: 1px 3px; margin: 0 1px;
  border-radius: 7px; cursor: pointer; transition: .15s;
  border: 1px solid transparent;
}
.tchar:hover { background: var(--card-2); }
.tchar:active { transform: scale(.93); }
.tchar.hit { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.tchar.ans {
  background: var(--ok-soft); color: var(--ok); border-color: var(--ok);
  font-weight: 800; animation: pop .35s;
}

/* 图卡 */
.emoji-big { font-size: 84px; line-height: 1.15; user-select: none; }
.emoji-opt { font-size: 34px; text-align: center; line-height: 1.2; }
@media (max-width: 380px) { .emoji-big { font-size: 68px; } .emoji-opt { font-size: 28px; } }

/* 积分条 */
.pts-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pts-hero {
  background: linear-gradient(140deg, var(--primary), #7c3aed);
  color: #fff; border-radius: var(--radius); padding: 18px; text-align: center;
  box-shadow: var(--shadow);
}
.pts-hero .big { font-size: 40px; font-weight: 800; line-height: 1.1; letter-spacing: -1px; }
.pts-hero .sub { opacity: .88; font-size: 12.5px; margin-top: 2px; }
.badge-title {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255, 255, 255, .18); padding: 4px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; margin-top: 8px;
}

/* 计划页 */
.plan-hero {
  background: linear-gradient(135deg, var(--primary-soft), transparent 70%);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 15px;
}
.progress-ring { display: flex; align-items: center; gap: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
