:root {
  --ink: #1d2933;
  --muted: #66727c;
  --teal: #14635c;
  --teal-dark: #0f4b46;
  --sand: #f6f2ea;
  --paper: #fffdf8;
  --rule: #e3ddd2;
  --mark: #f2e7cf;
}
* { box-sizing: border-box; }
/* 页面用 hidden 切换登录页 / 正文 / 账号面板；.login 等类自带 display，
   没有这条 !important 时 hidden 会被类选择器盖掉，登录卡会一直挂在正文下面。
   与 exam.css 第 29 行保持同一写法。 */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--sand);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-top, 0)) 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0));
  background: var(--teal); color: #fff;
}
.topbar-title { flex: 1; min-width: 0; line-height: 1.25; }
.topbar-title strong { display: block; font-size: 15px; font-weight: 600; }
.topbar-title small {
  display: block; font-size: 12px; opacity: .82;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.14); color: #fff; font-size: 17px;
}
.icon-btn:active { background: rgba(255,255,255,.28); }
.exam-link {
  flex: 0 0 auto; color: #fff; text-decoration: none; font-size: 13px;
  padding: 6px 10px; border-radius: 9px; background: rgba(255,255,255,.16);
  white-space: nowrap;
}
.exam-link:active { background: rgba(255,255,255,.3); }
@media (max-width: 420px) { .topbar .exam-link { font-size: 12px; padding: 5px 8px; } }
/* 品牌标记：与手册封面同一枚「云·水」logo */
.brand-mark { width: 22px; height: 22px; flex: 0 0 auto; border-radius: 50%; }
.login-mark { width: 64px; height: 64px; display: block; margin: 2px auto 14px; }
@media (max-width: 380px) { .topbar .brand-mark { display: none; } }

/* ---------- 布局 ---------- */
.layout { display: block; min-height: calc(100dvh - 56px); }
.side {
  position: fixed; inset: 56px auto 0 0; z-index: 15;
  width: min(86vw, 320px);
  background: var(--paper); border-right: 1px solid var(--rule);
  display: flex; flex-direction: column;
  transform: translateX(-102%); transition: transform .22s ease;
}
.side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.18); }
.side-head { padding: 12px; border-bottom: 1px solid var(--rule); }
.side-head input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--rule); border-radius: 10px;
  background: #fff; font: inherit; font-size: 14px; color: var(--ink);
}
.side-body { flex: 1; overflow-y: auto; padding: 6px 0 16px; -webkit-overflow-scrolling: touch; }
.side-foot {
  border-top: 1px solid var(--rule); padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.side-foot a { color: var(--teal); font-size: 14px; text-decoration: none; }
.text-btn { border: 0; background: none; color: var(--muted); font-size: 14px; padding: 4px; }

.part {
  padding: 14px 16px 4px; font-size: 12.5px; letter-spacing: .04em;
  color: var(--teal-dark); font-weight: 600;
}
.toc-link {
  display: block; padding: 9px 16px 9px 22px; font-size: 14.5px; line-height: 1.45;
  color: var(--ink); text-decoration: none; border-left: 3px solid transparent;
}
.toc-link:active { background: #f1ece2; }
.toc-link.on { border-left-color: var(--teal); background: var(--mark); font-weight: 600; }
.toc-link small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }

.main { max-width: 760px; margin: 0 auto; padding: 18px 18px 60px; }

/* ---------- 正文 ---------- */
.chapter { background: var(--paper); border-radius: 16px; padding: 22px 20px 26px; box-shadow: 0 1px 3px rgba(29,41,51,.06); }
.chapter h1 { font-size: 22px; line-height: 1.4; margin: 0 0 6px; color: var(--teal-dark); }
.chapter h2 {
  font-size: 18px; margin: 28px 0 8px; padding-top: 14px;
  border-top: 1px solid var(--rule); color: var(--teal-dark);
}
.chapter h3 { font-size: 16px; margin: 20px 0 6px; color: var(--ink); }
.chapter p { margin: 0 0 12px; text-align: justify; }
.chapter ul, .chapter ol { margin: 0 0 12px; padding-left: 1.3em; }
.chapter li { margin: 3px 0; }
.chapter strong { color: var(--ink); }
/* 表格在手机上横向滚动，别把首列挤成竖排字 */
.chapter .tbl { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 6px 0 16px; }
.chapter .tbl::-webkit-scrollbar { height: 6px; }
.chapter .tbl::-webkit-scrollbar-thumb { background: #cfd8d4; border-radius: 3px; }
.chapter table { width: 100%; min-width: 430px; border-collapse: collapse; margin: 0; font-size: 13.5px; }
.chapter th, .chapter td { border: 1px solid var(--rule); padding: 7px 8px; text-align: left; vertical-align: top; }
.chapter th { background: #eef3f1; color: var(--teal-dark); font-weight: 600; }
.chapter figure { margin: 14px 0 18px; }
.chapter figure img, .chapter figure video {
  display: block; width: 100%; height: auto; border-radius: 12px; background: #000;
}
.chapter figcaption { font-size: 12.5px; color: var(--muted); text-align: center; margin-top: 6px; }
.chapter .note {
  background: #f3f7f5; border-left: 4px solid var(--teal); border-radius: 0 10px 10px 0;
  padding: 10px 14px; margin: 6px 0 16px;
}
.chapter .note p { margin: 4px 0; }
.chapter .tag {
  display: inline-block; font-size: 12px; color: var(--muted);
  background: #f1ece2; border-radius: 999px; padding: 2px 10px; margin: 0 0 10px;
}
.chapter .q { margin: 0 0 14px; padding: 10px 12px; background: #fbf8f1; border-radius: 10px; }
.chapter .q .stem { font-weight: 600; margin: 0 0 6px; }
.chapter .q .opt { margin: 2px 0; padding-left: 1.1em; color: #33424e; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin: 18px 0 8px; }
.ghost-btn {
  flex: 1; padding: 11px 12px; border: 1px solid var(--rule); border-radius: 12px;
  background: var(--paper); color: var(--ink); font-size: 14.5px;
}
.ghost-btn:disabled { opacity: .4; }
.foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 26px; }

/* ---------- 登录 ---------- */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--paper); border-radius: 18px;
  padding: 26px 22px 22px; box-shadow: 0 10px 40px rgba(20,99,92,.12);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; color: var(--teal-dark); text-align: center; }
.login-sub { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; text-align: center; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--rule); border-radius: 10px;
  font: inherit; font-size: 16px; background: #fff; color: var(--ink);
}
.primary-btn {
  width: 100%; margin-top: 18px; padding: 12px; border: 0; border-radius: 12px;
  background: var(--teal); color: #fff; font-size: 16px;
}
.primary-btn:disabled { opacity: .6; }
.login-err { min-height: 20px; color: #b3402f; font-size: 13.5px; margin: 10px 0 0; }
.login-tip { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; }

/* ---------- 账号 / 改密码 ---------- */
.account-layer {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  padding: 24px; background: rgba(29,41,51,.42);
}
.account-layer[hidden] { display: none; }
.account-card {
  position: relative; width: 100%; max-width: 360px; background: var(--paper);
  border-radius: 18px; padding: 24px 22px 20px;
  box-shadow: 0 10px 40px rgba(20,99,92,.22);
}
.account-card h2 { font-size: 18px; margin: 0 0 4px; color: var(--teal-dark); }
.account-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
.account-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--rule); border-radius: 10px;
  font: inherit; font-size: 16px; background: #fff; color: var(--ink);
}
.account-card .account-close {
  position: absolute; right: 12px; top: 12px; width: 30px; height: 30px;
  background: #f0ece3; color: var(--ink); font-size: 18px;
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%); z-index: 40;
  background: rgba(29,41,51,.92); color: #fff; font-size: 13.5px;
  padding: 9px 16px; border-radius: 999px; max-width: 86vw;
}

/* ---------- 宽屏：常驻目录 ---------- */
/* 手机上表格先缩字号让常见的 3–4 列表排得下；列数多的表横向滑动 */
@media (max-width: 600px) {
  .chapter table { font-size: 12.5px; min-width: 0; }
  .chapter th, .chapter td { padding: 6px 7px; }
  /* 首列多是短标签（段 / 题 / 版本），别被挤成竖排 */
  .chapter td:first-child, .chapter th:first-child { min-width: 3.2em; }
  .chapter .tbl:has(table th:nth-child(5)) table { min-width: 460px; }
}

@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); }
  .side { position: sticky; top: 56px; height: calc(100dvh - 56px); transform: none; }
  .side.open { box-shadow: none; }
  #btnMenu { visibility: hidden; }
  .main { padding: 26px 28px 80px; }
  .chapter { padding: 30px 34px 34px; }
}

/* iPhone / iPad：输入框小于 16px 会让 Safari 自动放大整页（2026-11-22）。
   iPad 上目录常驻，搜索框一样会触发，所以兜到 1024px。 */
@media (max-width: 1024px) {
  input, textarea, select { font-size: 16px !important; }
}
