/* ============ 中级会计师学习平台 样式（双主题） ============ */

/* ---------- 清新白天主题（默认） ---------- */
:root {
  color-scheme: light;
  --primary: #0891b2;
  --primary-dark: #067a96;
  --primary-light: #ddf3f9;
  --accent: #0e9f6e;
  --accent-light: #e3f6ee;
  --danger: #e02424;
  --danger-light: #fdefef;
  --warn: #c27803;
  --warn-light: #fdf4de;
  --bg: #f0f8f7;
  --card: #ffffff;
  --surface: #ffffff;      /* 选项/输入框/答题卡格子 */
  --soft: #f4fafb;         /* 解析块等浅色衬底 */
  --track: #e2eef0;        /* 进度条轨道 */
  --chip: #e8f1f2;         /* 灰色徽标 */
  --text: #1d2b33;
  --text-2: #526975;
  --text-3: #8ba0aa;
  --border: #dfeaec;
  --hero-grad: linear-gradient(120deg, #0891b2 0%, #10b3c9 55%, #4fd1a5 100%);
  --mask: rgba(15, 35, 45, .45);
  --toast-bg: rgba(23, 42, 51, .92);
  --toast-text: #fff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 60, 70, .06), 0 4px 14px rgba(16, 60, 70, .05);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- 纯黑暗夜主题 ---------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --primary: #23b6d6;
  --primary-dark: #4cc9e4;
  --primary-light: #0b2b33;
  --accent: #34d399;
  --accent-light: #0b2b1f;
  --danger: #f87171;
  --danger-light: #2d1517;
  --warn: #fbbf24;
  --warn-light: #2d250e;
  --bg: #000000;
  --card: #101216;
  --surface: #16191f;
  --soft: #0c0e12;
  --track: #1d2128;
  --chip: #1b1f26;
  --text: #e7eaf0;
  --text-2: #9aa4b2;
  --text-3: #667080;
  --border: #262b34;
  --hero-grad: linear-gradient(120deg, #06333f 0%, #0a4d5f 55%, #0e6b56 100%);
  --mask: rgba(0, 0, 0, .62);
  --toast-bg: rgba(40, 46, 56, .96);
  --toast-text: #eef1f6;
  --shadow: 0 0 0 1px #1a1e25;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.65;
  overscroll-behavior-y: none;
  transition: background-color .25s, color .25s;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; border: none; cursor: pointer; background: none; font-size: 1rem; color: inherit; }
/* 触屏优化：对可点击元素关闭“双击缩放”判定，避免单击被延迟/吞掉导致需双击 */
a, button, .opt, .entry-card, .subj-card, .list-item, .back-btn, .chip, input, textarea, select, .theme-btn, .topnav a, .tabbar a { touch-action: manipulation; }

/* ---------- 顶部导航（桌面） ---------- */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--card); border-bottom: 1px solid var(--border); transition: background-color .25s; }
.topbar-inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.brand-logo { font-size: 1.5rem; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topnav { display: flex; gap: 6px; }
.topnav a { padding: 8px 18px; border-radius: 10px; color: var(--text-2); font-weight: 500; transition: .15s; }
@media (hover: hover) and (pointer: fine) {
  .topnav a:hover { background: var(--primary-light); color: var(--primary); }
}
.topnav a.active { background: var(--primary); color: #fff; }
html[data-theme="dark"] .topnav a.active { color: #04141a; }

/* 主题切换按钮 */
.theme-btn {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; background: var(--chip); transition: .15s;
}
@media (hover: hover) and (pointer: fine) {
  .theme-btn:hover { background: var(--primary-light); }
}
.theme-btn:active { transform: scale(.9); }

/* ---------- 云同步按钮状态点 ---------- */
.sync-btn { position: relative; }
.sync-btn::after {
  content: ""; position: absolute; right: 4px; top: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3); opacity: 0; transition: .2s;
}
.sync-btn.sync-ok::after { background: var(--accent); opacity: 1; }
.sync-btn.sync-err::after { background: var(--danger); opacity: 1; }
.sync-btn.sync-run::after { background: var(--warn); opacity: 1; animation: syncblink 1s infinite; }
@keyframes syncblink { 50% { opacity: .25; } }

/* ---------- 表单行（云同步弹窗等） ---------- */
.form-row { margin: 12px 0; }
.form-row label { display: block; font-size: .85rem; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }

/* ---------- 底部标签栏（移动端） ---------- */
.tabbar { display: none; }

/* ---------- 主内容 ---------- */
.view { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--text-2); margin-bottom: 20px; font-size: .95rem; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 22px; border-radius: 12px;
  font-size: 1rem; font-weight: 600; transition: .15s; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--primary-dark); }
}
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost { background: var(--primary-light); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-o { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-success { background: var(--accent); color: #fff; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: .9rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] .btn-success { color: #04141a; }

/* ---------- 徽标 ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--accent-light); color: var(--accent); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-warn { background: var(--warn-light); color: var(--warn); }
.badge-gray { background: var(--chip); color: var(--text-2); }

/* ---------- 首页 ---------- */
.hero { background: var(--hero-grad); border-radius: 18px; color: #fff; padding: 32px 28px; margin-bottom: 22px; position: relative; overflow: hidden; }
.hero h1 { font-size: 1.6rem; margin-bottom: 6px; }
.hero p { opacity: .92; font-size: .95rem; max-width: 560px; }
.hero-stats { display: flex; gap: 28px; margin-top: 18px; flex-wrap: wrap; }
.hero-stat b { font-size: 1.5rem; display: block; }
.hero-stat span { font-size: .82rem; opacity: .85; }

.entry-card { display: flex; flex-direction: column; gap: 10px; padding: 22px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); transition: .18s; border: 1.5px solid transparent; }
@media (hover: hover) and (pointer: fine) {
  .entry-card:hover { transform: translateY(-3px); border-color: var(--primary); }
}
.entry-ico { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; }
.entry-card h3 { font-size: 1.12rem; }
.entry-card p { color: var(--text-2); font-size: .88rem; flex: 1; }
.entry-meta { color: var(--text-3); font-size: .82rem; }

.section-title { font-size: 1.15rem; font-weight: 700; margin: 26px 0 14px; display: flex; align-items: center; gap: 8px; }

/* 科目卡片 */
.subj-card { padding: 22px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); cursor: pointer; transition: .18s; border: 1.5px solid transparent; }
@media (hover: hover) and (pointer: fine) {
  .subj-card:hover { transform: translateY(-3px); border-color: var(--primary); }
}
.subj-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.subj-ico { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.subj-card h3 { font-size: 1.1rem; }
.subj-tag { font-size: .8rem; color: var(--text-3); }
.subj-info { display: flex; gap: 16px; color: var(--text-2); font-size: .86rem; flex-wrap: wrap; }
.progress-bar { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 99px; transition: width .4s; }

/* ---------- 列表 ---------- */
.list-item { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; transition: .15s; }
@media (hover: hover) and (pointer: fine) {
  .list-item:hover { transform: translateX(3px); }
}
.list-body { flex: 1; min-width: 0; }
.list-body h4 { font-size: 1rem; margin-bottom: 3px; }
.list-body .meta { color: var(--text-3); font-size: .82rem; display: flex; gap: 12px; flex-wrap: wrap; }
.list-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ---------- 面包屑/返回 ---------- */
.back-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.back-btn { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: .92rem; padding: 8px 14px; border-radius: 10px; background: var(--card); box-shadow: var(--shadow); }
@media (hover: hover) and (pointer: fine) {
  .back-btn:hover { color: var(--primary); }
}

/* ---------- 答题界面 ---------- */
.quiz-top { position: sticky; top: 60px; z-index: 40; background: var(--bg); padding: 8px 0 10px; transition: background-color .25s; }
.quiz-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 16px; }
.quiz-timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; color: var(--primary); display: flex; align-items: center; gap: 6px; }
.quiz-timer.warn { color: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .45; } }
.quiz-progress { color: var(--text-2); font-size: .9rem; }

.q-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-top: 14px; }
.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.q-type { font-size: .8rem; font-weight: 700; padding: 3px 12px; border-radius: 999px; background: var(--primary-light); color: var(--primary); }
.q-no { color: var(--text-3); font-size: .86rem; }
.q-stem { font-size: 1.02rem; white-space: pre-wrap; word-break: break-word; }

.opts { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px;
  border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer;
  transition: .13s; font-size: .98rem; min-height: 48px; background: var(--surface);
}
@media (hover: hover) and (pointer: fine) {
  .opt:hover { border-color: var(--primary); background: var(--primary-light); }
}
.opt-key {
  width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .88rem;
  flex-shrink: 0; transition: .13s; background: var(--card);
}
.opt.sel { border-color: var(--primary); background: var(--primary-light); }
.opt.sel .opt-key { background: var(--primary); border-color: var(--primary); color: #fff; }
.opt.right { border-color: var(--accent); background: var(--accent-light); }
.opt.right .opt-key { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt.wrong { border-color: var(--danger); background: var(--danger-light); }
.opt.wrong .opt-key { background: var(--danger); border-color: var(--danger); color: #fff; }
html[data-theme="dark"] .opt.sel .opt-key,
html[data-theme="dark"] .opt.right .opt-key,
html[data-theme="dark"] .opt.wrong .opt-key { color: #04141a; }
.opt-text { flex: 1; word-break: break-word; }

.quiz-actions { display: flex; gap: 10px; margin-top: 18px; }
.quiz-actions .btn { flex: 1; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
.quiz-actions .btn-primary { flex: 1.25; }
.quiz-actions .btn[disabled] { opacity: .45; cursor: default; }
@media (max-width: 400px) { .quiz-actions .btn { font-size: .9rem; } }

/* 解析块 */
.explain { margin-top: 18px; border-radius: 12px; padding: 16px; background: var(--soft); border: 1px solid var(--border); }
.explain .verdict { font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.verdict.ok { color: var(--accent); }
.verdict.no { color: var(--danger); }
.explain .ans-line { font-size: .95rem; margin-bottom: 8px; }
.explain .ana { color: var(--text-2); font-size: .93rem; white-space: pre-wrap; word-break: break-word; }
.explain .ref { white-space: pre-wrap; word-break: break-word; font-size: .95rem; color: var(--text); background: var(--card); border: 1px dashed var(--border); border-radius: 10px; padding: 12px; margin-top: 8px; }

/* 答题卡 */
.sheet-mask { position: fixed; inset: 0; background: var(--mask); z-index: 90; opacity: 0; pointer-events: none; transition: .2s; }
.sheet-mask.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; z-index: 95; background: var(--card); transition: .25s; box-shadow: 0 -8px 30px rgba(0,0,0,.15); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 700; }
.sheet-legend { display: flex; gap: 14px; padding: 10px 20px 0; font-size: .8rem; color: var(--text-2); flex-wrap: wrap; }
.sheet-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 4px; vertical-align: -1px; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 10px; padding: 16px 20px; overflow-y: auto; }
.sheet-cell {
  height: 44px; border-radius: 10px; border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-weight: 600; cursor: pointer; background: var(--surface);
  font-size: .92rem;
}
.sheet-cell.done { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.sheet-cell.mark { border-color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn-light); }
.sheet-cell.cur { outline: 2.5px solid var(--primary); }
.sheet-cell.ok { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.sheet-cell.bad { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
@media (min-width: 769px) {
  .sheet { top: 0; right: -400px; width: 380px; height: 100vh; display: flex; flex-direction: column; }
  .sheet.open { right: 0; }
}
@media (max-width: 768px) {
  .sheet { left: 0; right: 0; bottom: 0; transform: translateY(105%); border-radius: 20px 20px 0 0; max-height: 72vh; display: flex; flex-direction: column; padding-bottom: var(--safe-bottom); }
  .sheet.open { transform: translateY(0); }
}

/* ---------- 成绩页 ---------- */
.score-hero { text-align: center; padding: 34px 20px 26px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.score-ring { width: 150px; height: 150px; margin: 0 auto 14px; position: relative; }
.score-ring svg { transform: rotate(-90deg); }
.score-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-num b { font-size: 2.1rem; color: var(--primary); line-height: 1.15; }
.score-num span { font-size: .8rem; color: var(--text-3); }
.score-meta { display: flex; justify-content: center; gap: 26px; margin-top: 10px; color: var(--text-2); font-size: .9rem; flex-wrap: wrap; }
.score-meta b { color: var(--text); }

/* ---------- 章节/知识点 ---------- */
.chap-item { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.chap-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; cursor: pointer; min-height: 56px; }
.chap-head h4 { flex: 1; font-size: 1rem; }
.chap-arrow { color: var(--text-3); transition: .2s; }
.chap-item.open .chap-arrow { transform: rotate(90deg); }
.chap-body { display: none; border-top: 1px solid var(--border); }
.chap-item.open .chap-body { display: block; }
.point { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.point:last-child { border-bottom: none; }
.point-head { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.point-check { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .8rem; color: #fff; margin-top: 2px; }
.point.learned .point-check { background: var(--accent); border-color: var(--accent); }
html[data-theme="dark"] .point.learned .point-check { color: #04141a; }
.point-head b { flex: 1; font-size: .97rem; }
.point-c { color: var(--text-2); font-size: .92rem; margin: 8px 0 0 32px; white-space: pre-wrap; }

/* ---------- 笔记 ---------- */
.note-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 12px; }
.note-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.note-head h4 { flex: 1; font-size: 1rem; }
.note-time { color: var(--text-3); font-size: .78rem; }
.note-content { color: var(--text-2); font-size: .92rem; white-space: pre-wrap; word-break: break-word; }
.note-ops { display: flex; gap: 10px; margin-top: 10px; }

textarea.input, input.input, select.input {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 14px;
  font-size: 1rem; font-family: inherit; background: var(--surface); color: var(--text); outline: none;
}
textarea.input:focus, input.input:focus, select.input:focus { border-color: var(--primary); }
textarea.input { min-height: 110px; resize: vertical; }

/* ---------- 模态框 ---------- */
.modal-mask { position: fixed; inset: 0; background: var(--mask); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--card); border-radius: 16px; width: 100%; max-width: 460px; max-height: 86vh; overflow-y: auto; padding: 22px; animation: pop .18s; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.modal h3 { margin-bottom: 14px; font-size: 1.12rem; }
.modal-btns { display: flex; gap: 10px; margin-top: 18px; }
.modal-btns .btn { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--toast-bg); color: var(--toast-text); padding: 10px 22px; border-radius: 99px;
  font-size: .92rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 120; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 筛选行 ---------- */
.filter-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.chip { padding: 8px 16px; border-radius: 999px; background: var(--card); color: var(--text-2); font-size: .88rem; font-weight: 500; cursor: pointer; box-shadow: var(--shadow); border: 1.5px solid transparent; min-height: 38px; }
.chip.active { background: var(--primary); color: #fff; }
html[data-theme="dark"] .chip.active { color: #04141a; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty .e-ico { font-size: 3rem; margin-bottom: 12px; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 768px) {
  html { font-size: 15px; }
  .topbar-inner { height: 52px; padding: 0 14px; }
  .topnav { display: none; }
  .brand-name { font-size: 1rem; }
  .view { padding: 14px 14px calc(78px + var(--safe-bottom)); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .hero { padding: 24px 20px; border-radius: 16px; }
  .hero h1 { font-size: 1.3rem; }
  .hero-stats { gap: 18px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--card); border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: .72rem; color: var(--text-3); min-height: 54px; }
  .tabbar a.active { color: var(--primary); font-weight: 600; }
  .tab-ico { font-size: 1.35rem; line-height: 1.2; }
  .quiz-top { top: 52px; }
  .q-card { padding: 16px; }
  .quiz-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 55; background: var(--card); padding: 10px 14px calc(10px + var(--safe-bottom)); margin: 0; border-top: 1px solid var(--border); }
  .quiz-mode .tabbar { display: none; }
  .quiz-mode .view { padding-bottom: calc(96px + var(--safe-bottom)); }
  .list-item { flex-wrap: wrap; }
  .list-right { width: 100%; justify-content: flex-end; }
  .score-meta { gap: 16px; }
  .modal { border-radius: 16px; }
}
@media (min-width: 769px) {
  .tabbar { display: none !important; }
}

/* ---------- 触屏按压反馈（替代 hover，保持点击手感） ---------- */
.opt:active { background: var(--primary-light); border-color: var(--primary); }
.entry-card:active, .subj-card:active, .list-item:active, .back-btn:active, .chip:active, .btn-ghost:active { background: var(--chip); }
