/* 视觉规范: 参照华为官网 (huawei.com) —— 华为主红 #C7000B, 白底浅灰分区, 细边框卡片, 克制阴影 */
:root {
  --bg: #f5f6f7;
  --bg2: #f2f2f2;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #7a7a7a;
  --line: #ececec;
  --line-2: #dcdcdc;
  --primary: #c7000b;
  --primary-2: #e4353f;
  --primary-soft: #fdf0f1;
  --ok: #3fae4a;
  --bad: #c7000b;
  --warn: #ff7700;
  --shadow: 0 1px 3px rgba(0, 0, 0, .05);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --bg2: #1d1d1d;
    --card: #1a1a1a;
    --text: #f0f0f0;
    --muted: #9a9a9a;
    --line: #2a2a2a;
    --line-2: #3a3a3a;
    --primary: #e4353f;
    --primary-2: #ff5c66;
    --primary-soft: #2a1113;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "HarmonyOS Sans SC", "HarmonyOS Sans", -apple-system, BlinkMacSystemFont,
               "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

.hidden { display: none !important; }
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }

/* ---------------- 登录 ---------------- */
#auth {
  min-height: 100vh;
  padding: max(44px, env(safe-area-inset-top)) 22px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fff;
}
@media (prefers-color-scheme: dark) { #auth { background: var(--bg); } }

.brand { text-align: center; margin-bottom: 24px; }
.brand .logo {
  width: 70px; height: 70px; margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 24px; letter-spacing: .5px;
}
.brand h1 { font-size: 20px; margin: 0 0 6px; font-weight: 700; letter-spacing: 0; }
.brand p { margin: 0; color: var(--muted); font-size: 12.5px; }

.auth-card { background: var(--card); border-radius: 16px; padding: 22px 18px; border: 1px solid var(--line); }
.auth-tabs { display: flex; gap: 24px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.auth-tabs button {
  border: 0; background: transparent; color: var(--muted);
  padding: 0 2px 10px; font-size: 15px; font-weight: 500; position: relative;
}
.auth-tabs button.on { color: var(--text); font-weight: 700; }
.auth-tabs button.on::after {
  content: ""; position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%);
  width: 26px; height: 2px; background: var(--primary); border-radius: 2px;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 13px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--text); font-size: 15px; outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--primary); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 46px; padding: 12px 16px;
  border: 0; border-radius: 8px; font-size: 15.5px; font-weight: 600;
  background: var(--primary); color: #fff; cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn:active { opacity: .85; }
.btn[disabled] { opacity: .45; }
.btn.ghost { background: var(--bg2); color: var(--text); }
.btn.line { background: var(--card); border: 1px solid var(--line-2); color: var(--text); }
.btn.danger { background: var(--primary); }
.btn.sm { width: auto; min-height: 36px; padding: 7px 14px; font-size: 13.5px; border-radius: 6px; }

.tip { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ---------------- 顶部栏 (华为白底 + 红标) ---------------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
#topbar .t-wrap { display: flex; align-items: center; gap: 9px; min-width: 0; }
#topbar .t-mark {
  width: 4px; height: 20px; border-radius: 2px; background: var(--primary); flex: 0 0 auto;
}
#topbar .t-title { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: 0; }
#topbar .t-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
#topbar .t-right { display: flex; align-items: center; gap: 8px; }
.pill {
  background: var(--primary-soft); color: var(--primary);
  padding: 4px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap;
}

#views { padding: 12px 12px calc(80px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.on { display: block; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.view.on { animation: fade .18s ease; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  border: 1px solid var(--line); box-shadow: var(--shadow); margin-bottom: 10px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; }
.card h3 small { color: var(--muted); font-weight: 400; font-size: 12px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.hero {
  background: var(--primary); color: #fff; border-radius: var(--radius);
  padding: 18px; margin-bottom: 10px; position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -46px; top: -56px;
  width: 170px; height: 170px; border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.hero h2 { margin: 0; font-size: 19px; font-weight: 700; }
.hero p { margin: 5px 0 0; opacity: .9; font-size: 12.5px; }
.hero .hero-stats { display: flex; gap: 18px; margin-top: 14px; }
.hero .hero-stats div { font-size: 22px; font-weight: 700; line-height: 1.1; }
.hero .hero-stats span { display: block; font-size: 11px; opacity: .85; font-weight: 400; margin-top: 3px; }

.ring { width: 76px; height: 76px; position: relative; flex: 0 0 auto; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-txt {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 17px; font-weight: 700;
}
.ring .ring-txt small { font-size: 9.5px; font-weight: 400; color: var(--muted); }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.quick button {
  background: transparent; border: 0; border-radius: 10px; padding: 10px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  color: var(--text); font-size: 12px;
}
.quick button .qi { font-size: 21px; line-height: 1; }
.quick button:active { background: var(--bg2); }

.chapter-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.chapter-row:last-child { border-bottom: 0; padding-bottom: 0; }
.chapter-row .cr-top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 7px; gap: 8px; }
.bar { height: 4px; background: var(--bg2); border-radius: 0; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); transition: width .3s; }
.bar.ok > i { background: var(--ok); }
.bar.bad > i { background: var(--warn); }

/* ---------------- 底部导航 ---------------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 560px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 5px 0 calc(5px + env(safe-area-inset-bottom));
}
#tabbar button {
  border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; padding: 4px 0; min-height: 44px;
}
#tabbar button .ti { font-size: 18px; line-height: 1.15; }
#tabbar button.on { color: var(--primary); font-weight: 700; }

/* ---------------- 练习 / 考试 ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 13px; border-radius: 6px; background: var(--bg2);
  border: 1px solid transparent; font-size: 13px; color: var(--text);
}
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }

.q-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 4px; background: var(--bg2); color: var(--muted); }
.badge.single { background: var(--primary-soft); color: var(--primary); }
.badge.multi { background: rgba(255, 119, 0, .1); color: #c25b00; }
.badge.judge { background: rgba(63, 174, 74, .12); color: #2e8b3a; }

.stem { font-size: 16px; line-height: 1.7; margin: 2px 0 14px; font-weight: 500; }

.opt {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 13px 14px; border: 1px solid var(--line-2); border-radius: 8px;
  margin-bottom: 8px; background: var(--card); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.opt .k {
  flex: 0 0 22px; height: 22px; border-radius: 50%;
  background: var(--bg2); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.opt .v { flex: 1; font-size: 14.5px; line-height: 1.55; }
.opt.on { border-color: var(--primary); background: var(--primary-soft); }
.opt.on .k { background: var(--primary); color: #fff; }
.opt.right { border-color: var(--ok); background: rgba(63, 174, 74, .06); }
.opt.right .k { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--primary); background: var(--primary-soft); }
.opt.wrong .k { background: var(--primary); color: #fff; }
.opt.dim { opacity: .6; }

.explain {
  margin-top: 12px; padding: 12px 14px; border-radius: 6px;
  background: var(--bg2); font-size: 13.5px; line-height: 1.7;
  border-left: 3px solid var(--primary);
}
.explain b { color: var(--primary); }
.explain.ok { border-left-color: var(--ok); }
.explain.bad { border-left-color: var(--primary); }

.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.timer.warn { color: #fff; background: var(--primary); padding: 3px 10px; border-radius: 4px; }

.sheet { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.sheet button {
  aspect-ratio: 1; border-radius: 6px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--text); font-size: 13px;
}
.sheet button.done { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.sheet button.cur { outline: 2px solid var(--primary); outline-offset: 1px; }

.score-ring { display: flex; align-items: center; justify-content: center; padding: 6px 0 2px; }
.score-big { font-size: 48px; font-weight: 800; letter-spacing: -1.5px; }
.tag-pass { color: var(--ok); font-weight: 700; }
.tag-fail { color: var(--primary); font-weight: 700; }

.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .li-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.list-item .li-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.stat-box { background: var(--bg2); border-radius: 8px; padding: 12px 8px; text-align: center; }
.stat-box b { display: block; font-size: 20px; font-weight: 700; }
.stat-box span { font-size: 11.5px; color: var(--muted); }

/* ---------------- 资源监控 ---------------- */
.mon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mon-item { background: var(--bg2); border-radius: 8px; padding: 12px; }
.mon-item .mi-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.mon-item .mi-val { font-size: 20px; font-weight: 700; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.mon-item .mi-sub { font-size: 11px; color: var(--muted); margin-top: 5px; }
.cores { display: flex; gap: 2px; align-items: flex-end; height: 24px; margin-top: 4px; }
.cores i { flex: 1; background: var(--primary); border-radius: 0; min-height: 2px; opacity: .85; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }

/* ---------------- 资料库 ---------------- */
.seg {
  display: flex; gap: 26px; padding: 0 2px 10px; margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.seg button {
  border: 0; background: transparent; padding: 0 0 9px; font-size: 14.5px;
  color: var(--muted); position: relative; font-weight: 500;
}
.seg button.on { color: var(--text); font-weight: 700; }
.seg button.on::after {
  content: ""; position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%);
  width: 24px; height: 2px; background: var(--primary);
}

.lib-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.lib-item:last-child { border-bottom: 0; }
.lib-ico {
  flex: 0 0 40px; height: 40px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.lib-body { flex: 1; min-width: 0; }
.lib-title { font-size: 14.5px; font-weight: 600; line-height: 1.45; }
.lib-desc { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.lib-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.lib-meta span {
  font-size: 10.5px; padding: 2px 7px; border-radius: 3px;
  background: var(--bg2); color: var(--muted);
}
.lib-meta span.brand { background: var(--primary-soft); color: var(--primary); }

/* 阅读器 */
#reader {
  position: fixed; inset: 0; z-index: 70; background: var(--card);
  display: flex; flex-direction: column;
}
#reader .r-head {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--line); background: var(--card);
}
#reader .r-title { flex: 1; font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#reader .r-close {
  border: 1px solid var(--line-2); background: var(--card); color: var(--text);
  border-radius: 6px; padding: 6px 12px; font-size: 13px;
}
#reader .r-body { flex: 1; overflow: auto; padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
#reader .r-body iframe { width: 100%; height: calc(100vh - 120px); border: 0; }

.md { font-size: 15px; line-height: 1.8; color: var(--text); word-break: break-word; }
.md h1 { font-size: 21px; margin: 6px 0 14px; font-weight: 700; line-height: 1.4; }
.md h2 { font-size: 17px; margin: 26px 0 10px; font-weight: 700; padding-left: 9px; border-left: 3px solid var(--primary); }
.md h3 { font-size: 15.5px; margin: 18px 0 8px; font-weight: 700; }
.md p { margin: 10px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 22px; }
.md li { margin: 5px 0; }
.md code {
  background: var(--bg2); padding: 1px 5px; border-radius: 3px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 13px;
}
.md pre {
  background: #fafafa; border: 1px solid var(--line); border-left: 3px solid var(--primary);
  border-radius: 6px; padding: 12px 13px; overflow-x: auto; margin: 12px 0;
}
@media (prefers-color-scheme: dark) { .md pre { background: #151515; } }
.md pre code { background: transparent; padding: 0; font-size: 12.5px; line-height: 1.7; }
.md blockquote {
  margin: 12px 0; padding: 10px 14px; background: var(--primary-soft);
  border-left: 3px solid var(--primary); color: var(--text); font-size: 13.5px;
}
.md a { color: var(--primary); text-decoration: none; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.md strong { font-weight: 700; }

/* ---------------- 弹层 / 提示 ---------------- */
#modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .45); }
#modal .sheet-wrap {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: 14px 14px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 82vh; overflow: auto;
}
#modal .sheet-wrap h3 { margin: 0 0 12px; font-size: 16px; }

#toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  background: rgba(26, 26, 26, .92); color: #fff;
  padding: 10px 18px; border-radius: 6px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .22s; z-index: 80;
  max-width: 84vw; text-align: center;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 10px; }
.empty .e-ico { font-size: 32px; display: block; margin-bottom: 8px; opacity: .5; }
