﻿/* 设计基座：移动优先、单列、安静配色。views.css 由 UI 负责扩展。 */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e6e9f0;
  --brand: #1d4ed8;
  --brand-2: #0ea5e9;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --violet: #7c3aed;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --tab-h: 60px;
  --top-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC", "Noto Sans CJK SC",
          "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, BlinkMacSystemFont,
          "Segoe UI", "Hiragino Sans GB", sans-serif;
  --font-serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", "STSong", serif;
  --font-kai: "Kaiti SC", "KaiTi", "STKaiti", "KaiTi_GB2312", "FangSong", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16.5px;
  line-height: 1.75;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* 阅读设置：字体/字号切换（由“我的 → 阅读设置”写入 body class） */
body.font-serif { --font: var(--font-serif); }
body.font-kai { --font: var(--font-kai); }
body.fs-large { font-size: 18px; }
body.fs-large #view { --read-size: 18px; }
/* 数字/单位高亮 + 分段工具类 */
.num-hl {
  background: #fff3c4; color: #7c2d12; border-radius: 4px; padding: 0 3px;
  font-weight: 600; font-variant-numeric: tabular-nums;
}
.wall-break { height: 10px; }
#app { min-height: 100vh; padding-bottom: calc(var(--tab-h) + var(--safe-b) + 18px); }
#view { padding: 14px 14px 8px; max-width: 920px; margin: 0 auto; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.2em; }

/* 顶栏 */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  min-height: var(--top-h); padding: calc(8px + var(--safe-t)) 14px 8px;
  background: rgba(246, 247, 251, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
#topbar .titles { flex: 1; min-width: 0; }
#topbar h1 { font-size: 19px; line-height: 1.3; }
#topbar p { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-2); font-size: 17px; cursor: pointer;
}
.iconbtn:active { transform: scale(.96); }

/* 底部导航 */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
#tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--ink-3); font-size: 11px; text-decoration: none;
}
#tabbar a .ic { font-size: 18px; line-height: 1; }
#tabbar a.active { color: var(--brand); font-weight: 600; }

/* 通用组件 */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.6);
}
.card + .card { margin-top: 12px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hr { height: 1px; background: var(--line); margin: 12px 0; border: 0; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 600; font-size: 15px;
  cursor: pointer; user-select: none;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: #fecaca; background: #fff5f5; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  background: #eef2ff; color: #3730a3; white-space: nowrap;
}
.pill.ok { background: #ecfdf5; color: #047857; }
.pill.warn { background: #fffbeb; color: #b45309; }
.pill.bad { background: #fef2f2; color: #b91c1c; }
.pill.gray { background: #f1f5f9; color: #475569; }

.bar { height: 6px; border-radius: 999px; background: #eef1f6; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.bar.ok > i { background: var(--ok); }
.bar.warn > i { background: var(--warn); }

.tabs { display: flex; gap: 6px; padding: 4px; background: #eef1f6; border-radius: 12px; }
.tabs button {
  flex: 1; min-height: 36px; border: 0; border-radius: 9px; background: transparent;
  color: var(--ink-2); font-weight: 600; font-size: 14px; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15,23,42,.1); }

.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; font-size: 15px;
}
.textarea { min-height: 96px; resize: vertical; }
.label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 12px 0 6px; }

.emptystate { text-align: center; color: var(--ink-3); padding: 40px 16px; font-size: 14px; }
.spinner {
  width: 26px; height: 26px; margin: 28px auto; border-radius: 50%;
  border: 3px solid #e2e8f0; border-top-color: var(--brand); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 18px);
  transform: translateX(-50%) translateY(20px); z-index: 90;
  max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 12px;
  background: rgba(15, 23, 42, .92); color: #fff; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#modal-root .mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 80;
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
#modal-root .sheet {
  width: 100%; max-width: 560px; background: #fff; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + var(--safe-b)); max-height: 82vh; overflow: auto;
}
@media (min-width: 720px) {
  #modal-root .mask { align-items: center; }
  #modal-root .sheet { border-radius: 18px; }
}

/* 桌面端：左侧导航 */
@media (min-width: 860px) {
  #app { padding-left: 232px; padding-bottom: 24px; }
  #tabbar {
    top: 0; bottom: auto; right: auto; width: 232px; height: 100vh; padding: 22px 12px;
    grid-template-columns: 1fr; grid-auto-rows: 46px; gap: 4px; align-content: start;
    border-top: 0; border-right: 1px solid var(--line);
  }
  #tabbar a {
    flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px;
    font-size: 14px; border-radius: 10px;
  }
  #tabbar a.active { background: #eef2ff; }
  #topbar { padding-left: 24px; }
  #view { padding: 20px 24px; }
}
@media (prefers-color-scheme: dark) {
  /* 首版保持浅色，避免夜间可读性问题；后续可扩 */
}

