/* ==========================================================================
   体悟集 · Insight — base.css
   设计基调：纸质 / 墨色，留白充足，中文优先排版。
   ========================================================================== */

/* ---------- 设计变量 ---------- */
:root {
  --font-ui: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "SimSun", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;

  --bg: #f6f3ec;
  --bg-soft: #efeae0;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --ink: #1c1b19;
  --ink-2: #3d3a35;
  --muted: #7a736a;
  --line: #e3ddd1;
  --line-strong: #cec5b4;
  --accent: #9a5b21;
  --accent-ink: #ffffff;
  --accent-soft: #f6e7d5;
  --jade: #2f6b5f;
  --jade-soft: #dff0ea;
  --danger: #b23c3c;
  --danger-soft: #fbe6e4;
  --warn: #a8791c;
  --warn-soft: #fbf0d6;
  --ok: #2f7d55;
  --ok-soft: #e2f3e9;
  --shadow-1: 0 1px 2px rgba(28, 27, 25, .06), 0 2px 8px rgba(28, 27, 25, .05);
  --shadow-2: 0 6px 24px rgba(28, 27, 25, .12), 0 2px 6px rgba(28, 27, 25, .06);
  --shadow-3: 0 20px 60px rgba(20, 18, 14, .28);
  --radius-s: 8px;
  --radius: 14px;
  --radius-l: 20px;
  --radius-pill: 999px;
  --topbar-h: 60px;
  --content-w: 1160px;
  --read-w: 760px;
  --font-scale: 1;
}

html[data-theme="dark"] {
  --bg: #14131a;
  --bg-soft: #1a1922;
  --surface: #1e1d27;
  --surface-2: #23222c;
  --ink: #ece8e1;
  --ink-2: #cfcac2;
  --muted: #9a938a;
  --line: #302e3a;
  --line-strong: #45424f;
  --accent: #d8a465;
  --accent-ink: #241a0d;
  --accent-soft: #3a2f21;
  --jade: #7ec3b0;
  --jade-soft: #1e3630;
  --danger: #e88b85;
  --danger-soft: #3a2323;
  --warn: #e0b768;
  --warn-soft: #3a3120;
  --ok: #86cfa5;
  --ok-soft: #1e3529;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, .5);
  --shadow-3: 0 24px 70px rgba(0, 0, 0, .65);
}

/* ---------- 基础重置 ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
/* 字号设置：对根元素整体缩放（等价于浏览器缩放），文字、间距、图标一起变化 */
html { zoom: var(--font-scale, 1); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 42%),
                    radial-gradient(circle at 88% 0%, color-mix(in srgb, var(--jade) 6%, transparent), transparent 40%);
}
img, video, svg { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 .5em; font-weight: 650; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 载入动画 ---------- */
.boot-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--bg);
}
.boot-mark {
  width: 74px; height: 74px; border-radius: 22px;
  display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 40px; color: var(--accent-ink);
  background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 62%, var(--jade)));
  box-shadow: var(--shadow-2);
  transform-origin: center bottom;
  animation: bootBounce 1.5s linear infinite;
}
/*
 * 软性变速跳动：每一段单独给缓动函数，而不是全程一个速度 ——
 * 蓄力下压 → 快速起跳后柔缓减速 → 顶点轻轻悬停 → 加速落下并压缩 → 一次衰减小弹 → 停一拍。
 * 只用位移与挤压拉伸，颜色、透明度始终不变（旧版改透明度会被 reduced-motion 压成闪烁）。
 */
@keyframes bootBounce {
  0% { transform: translateY(0) scale(1.03, .96); animation-timing-function: linear; }
  5% { transform: translateY(0) scale(1.03, .96); animation-timing-function: cubic-bezier(.16, .84, .3, 1); }
  26% { transform: translateY(-16px) scale(.998, 1.002); animation-timing-function: cubic-bezier(.5, 0, .8, .5); }
  35% { transform: translateY(-16.6px) scale(1, 1); animation-timing-function: cubic-bezier(.55, 0, .85, .45); }
  55% { transform: translateY(0) scale(1.03, .95); animation-timing-function: cubic-bezier(.16, .84, .3, 1); }
  66% { transform: translateY(-5.5px) scale(1, 1); animation-timing-function: cubic-bezier(.5, 0, .8, .5); }
  78% { transform: translateY(0) scale(1.015, .98); animation-timing-function: cubic-bezier(.2, .7, .4, 1); }
  84%, 100% { transform: translateY(0) scale(1, 1); }
}
.boot-text { color: var(--muted); letter-spacing: .18em; font-size: 13px; }

/* ---------- 布局骨架 ---------- */
.app-root { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; }
.page { flex: 1; width: 100%; max-width: var(--content-w); margin: 0 auto; padding: 22px 18px 90px; }
.page--narrow { max-width: var(--read-w); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.center { display: grid; place-items: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--font-mono); }
.serif { font-family: var(--font-serif); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner { width: 100%; max-width: var(--content-w); margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .04em; }
.brand__mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 19px; color: var(--accent-ink);
  background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--jade)));
}
.brand__text { font-size: 16px; }
.brand__sub { font-size: 11px; color: var(--muted); letter-spacing: .22em; text-transform: uppercase; }
.navtabs { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.navtabs::-webkit-scrollbar { display: none; }
.navtab {
  padding: 7px 13px; border-radius: var(--radius-pill); white-space: nowrap;
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink-2); font-size: 14px;
}
.navtab:hover { background: var(--surface-2); text-decoration: none; }
.navtab.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.topbar__actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; font-size: 14px; font-weight: 500;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn--ink { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 18%, var(--surface)); }
.btn--sm { padding: 5px 11px; font-size: 13px; }
.btn--xs { padding: 3px 8px; font-size: 12px; border-radius: var(--radius-s); }
.btn--lg { padding: 11px 22px; font-size: 15px; }
.btn--block { width: 100%; }
.btn--icon { padding: 8px; width: 36px; height: 36px; border-radius: 50%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; color: var(--muted); font-weight: 500; }
.field__hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
.select {
  appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.checkbox input { accent-color: var(--accent); width: 16px; height: 16px; }
.switch { position: relative; width: 42px; height: 24px; border-radius: 999px; background: var(--line-strong); border: none; cursor: pointer; transition: background .18s ease; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s ease; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- 工具类 ---------- */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.gap-0 { gap: 0; } .gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .gap-3 { gap: 24px; }
.w-full { width: 100%; } .h-full { height: 100%; }
.relative { position: relative; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.scroll-x { overflow-x: auto; }
.sticky-side { position: sticky; top: calc(var(--topbar-h) + 12px); }
