/* kb-web:移动优先,系统字体,深浅色跟随系统;代码块恒深底(monokai)。 */
:root {
  --bg: #f7f6f3; --fg: #1f2328; --muted: #6b7280; --panel: #ffffff;
  --line: #e3e1dc; --accent: #0f766e; --accent-fg: #fff;
  --chip: #eceae5; --danger: #b91c1c;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --fg: #e6e4df; --muted: #9aa0a6; --panel: #1d2025;
    --line: #2c3036; --accent: #2dd4bf; --accent-fg: #06251f;
    --chip: #262a31;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.75 -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  overflow-wrap: anywhere;
  padding-top: var(--safe-t);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }

/* ---- 导航(手机:底部固定,拇指可达) ---- */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: var(--fg); }
.nav nav { display: flex; gap: 4px; }
.nav nav a {
  text-decoration: none; color: var(--muted);
  padding: 8px 12px; border-radius: 999px; min-height: 40px; display: inline-flex; align-items: center;
}
.nav nav a:active { background: var(--chip); color: var(--fg); }
@media (max-width: 640px) {
  .nav { position: fixed; left: 0; right: 0; top: auto; bottom: 0;
         padding-bottom: calc(8px + var(--safe-b)); border-top: 1px solid var(--line); border-bottom: none; }
  main { padding-bottom: calc(72px + var(--safe-b)); }
}

main { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 0 calc(24px + var(--safe-b)); }

h1 { font-size: 22px; line-height: 1.4; margin: 8px 0 12px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 12px 0;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* ---- 卡片链接行 ---- */
.cardlink {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 6px; min-height: 44px;
  text-decoration: none; color: var(--fg);
  border-bottom: 1px solid var(--line);
}
.cardlink:last-child { border-bottom: none; }
.state-badge { flex: none; }
.chip {
  border: 1px solid var(--line); background: var(--chip); color: var(--fg);
  border-radius: 999px; padding: 6px 12px; min-height: 36px; font-size: 14px;
}
.chip-on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.inlineform { display: inline-block; margin: 0 2px; }

/* ---- 进度条 ---- */
.bar { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; }
.bar.big { height: 14px; margin: 8px 0 16px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.stagelist { display: grid; gap: 2px; }

/* ---- 表单(输入 ≥16px 防 iOS 缩放;触控 ≥44px) ---- */
textarea, input[type="password"], input[type="text"] {
  width: 100%; font: inherit; font-size: 16px; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin: 6px 0; min-height: 44px;
}
textarea { resize: vertical; }
button {
  font: inherit; font-size: 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: 10px; padding: 10px 20px; min-height: 44px; min-width: 44px;
}
button:disabled { opacity: .5; }
form { margin: 8px 0 0; }

/* ---- 卡片正文(背诵内容主阅读区) ---- */
.cardbody { background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.cardbody h2 { margin-top: 22px; padding-left: 10px; border-left: 3px solid var(--accent); }
.cardbody table { display: block; overflow-x: auto; border-collapse: collapse; width: 100%; }
.cardbody th, .cardbody td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.cardbody blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.cardbody pre { margin: 0; }
.codehilite {
  background: #282c34; color: #abb2bf; border-radius: 10px;
  padding: 12px 14px; overflow-x: auto; margin: 10px 0; font-size: 13.5px; line-height: 1.6;
}
.codehilite code { background: none; padding: 0; white-space: pre; }
code { background: var(--chip); padding: 1px 5px; border-radius: 5px; font-size: .92em; }

/* ---- 问答 ---- */
.msg { border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; max-width: 92%; }
.msg-user { background: var(--chip); margin-left: auto; }
.msg-assistant { background: var(--panel); border: 1px solid var(--line); }
.msg-role { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg-body .codehilite { font-size: 12.5px; }
.askform { position: sticky; bottom: calc(64px + var(--safe-b)); background: var(--bg);
  padding: 6px 0; }
@media (max-width: 640px) { .askform { position: static; } }

/* ---- 登录 ---- */
.login-box { max-width: 360px; margin: 18vh auto 0; text-align: center; }
.login-box input { text-align: center; }
.login-box button { width: 100%; }

/* ---- 回忆检验 ---- */
.question { font-size: 17px; font-weight: 600; margin: 6px 0; }
.recall-item h2 { font-size: 14px; color: var(--muted); font-weight: 500; }
