/* ============================================================
 * OPC · 人生遥控器 — 三主题设计系统
 * TERMINAL 终端场：紧张而强大 · 金融终端 · 扫描线与辉光
 * INK      纸墨账：留白克制 · 纸笔书写 · 零辉光零扫描线
 * ABYSS    深海  ：缓慢呼吸 · 月光水色 · 大圆角柔光
 * ============================================================ */
:root {
  --bg: #05070d; --panel: #0b1120; --panel2: #0d1526;
  --line: #1b2740; --line2: #25355c;
  --text: #d9e2f2; --muted: #64748f;
  --amber: #ffb454; --cyan: #37c8ff; --green: #3ddc84; --red: #ff5d5d;
  --gold: #e8c33c; --pink: #e78ba8; --purple: #9d8ce0;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  /* 衍生色阶（主题层覆盖） */
  --am-bg: rgba(255,180,84,.06); --am-line: rgba(255,180,84,.35); --am-strong: rgba(255,180,84,.55);
  --am-grad2: #e89a2e; --am-ink: #1a1206; --logo-ink: #04121c;
  --cy-bg: rgba(55,200,255,.08); --cy-line: rgba(55,200,255,.35);
  --gr-bg: rgba(61,220,132,.06); --gr-line: rgba(61,220,132,.4);
  --rd-bg: rgba(255,93,93,.09); --rd-line: rgba(255,93,93,.45);
  --pu-bg: rgba(177,140,255,.08); --pu-line: rgba(177,140,255,.25);
  /* 结构语感 */
  --r-s: 3px; --r-m: 5px; --r-l: 8px;
  --halo: rgba(55,200,255,.05);
  --shadow-mod: 0 1px 2px rgba(0,0,0,.5);
  --shadow-key: inset 0 0 0 1px rgba(255,180,84,.3);
  --shadow-logo: 0 0 0 1px rgba(55,200,255,.3);
  --shadow-today: 0 0 0 1px rgba(55,200,255,.32);
  --shadow-toast: 0 8px 24px rgba(0,0,0,.55);
  --shadow-rd: 0 0 0 1px rgba(255,93,93,.4);
  --shadow-m: 0 6px 24px rgba(0,0,0,.45);
}
/* ---------- INK 纸墨账：纸白 · 墨字 · 朱砂 · 衬线 · 零辉光 ---------- */
body[data-theme="ink"] {
  --bg: #f1ede2; --panel: #faf7ef; --panel2: #f5f1e6;
  --line: #d8d0bc; --line2: #c2b697;
  --text: #2c261c; --muted: #8b8069;
  --amber: #b03a2e; --cyan: #20647e; --green: #4a7c59; --red: #bf3b2b;
  --gold: #a8763e; --pink: #c25b6e; --purple: #6b5b95;
  --am-bg: rgba(176,58,46,.06); --am-line: rgba(176,58,46,.35); --am-strong: rgba(176,58,46,.55);
  --am-grad2: #93302a; --am-ink: #fdf9f0; --logo-ink: #fdf9f0;
  --cy-bg: rgba(32,100,126,.07); --cy-line: rgba(32,100,126,.35);
  --gr-bg: rgba(74,124,89,.08); --gr-line: rgba(74,124,89,.4);
  --rd-bg: rgba(191,59,43,.06); --rd-line: rgba(191,59,43,.4);
  --pu-bg: rgba(107,91,149,.08); --pu-line: rgba(107,91,149,.3);
  --r-s: 2px; --r-m: 3px; --r-l: 4px;
  --halo: rgba(176,58,46,.03);
  --shadow-mod: none; --shadow-key: none; --shadow-logo: none;
  --shadow-today: none; --shadow-toast: 0 4px 16px rgba(60,50,30,.18); --shadow-rd: none;
  --shadow-m: 0 4px 14px rgba(60,50,30,.16);
  --sans: "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
}
/* ---------- ABYSS 深海：深水底色 · 月光 · 静谧克制（去霓虹粉紫，靠层次而非发光） ---------- */
body[data-theme="abyss"] {
  --bg: #071318; --panel: #0b1d26; --panel2: #0e2430;
  --line: #163742; --line2: #205064;
  --text: #dceef2; --muted: #5f8494;
  --amber: #ffc98b; --cyan: #43d8c8; --green: #6fe0a8; --red: #ff7f7f;
  --gold: #e6cd8c; --pink: #dd9aa2; --purple: #8fa3c8;
  --am-bg: rgba(255,201,139,.07); --am-line: rgba(255,201,139,.4); --am-strong: rgba(255,201,139,.55);
  --am-grad2: #f2a95c; --am-ink: #12222b; --logo-ink: #04211f;
  --cy-bg: rgba(67,216,200,.08); --cy-line: rgba(67,216,200,.4);
  --gr-bg: rgba(111,224,168,.08); --gr-line: rgba(111,224,168,.4);
  --rd-bg: rgba(255,127,127,.09); --rd-line: rgba(255,127,127,.45);
  --pu-bg: rgba(143,163,200,.09); --pu-line: rgba(143,163,200,.3);
  --r-s: 6px; --r-m: 9px; --r-l: 12px;
  --halo: rgba(67,216,200,.05);
  --shadow-mod: 0 1px 2px rgba(0,0,0,.45);
  --shadow-key: inset 0 0 0 1px rgba(255,201,139,.16);
  --shadow-logo: 0 0 0 1px rgba(67,216,200,.22);
  --shadow-today: 0 0 0 1px rgba(67,216,200,.28);
  --shadow-toast: 0 8px 22px rgba(0,0,0,.5);
  --shadow-rd: 0 0 0 1px rgba(255,127,127,.32);
  --shadow-m: 0 6px 22px rgba(0,0,0,.42);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

/* —— 统一动效节拍：全站共用一套缓动，避免各处「快慢不一」的廉价感 —— */
:root {
  --ease-out: cubic-bezier(.22, 1, .36, 1);   /* 出场：快起慢收 */
  --ease-std: cubic-bezier(.4, 0, .2, 1);     /* 常规：标准 Material 曲线 */
  --t-fast: .12s;
  --t-std: .22s;
}
/* 键盘可达性：焦点永远看得见（触屏不会误触发，因为只在 :focus-visible） */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: var(--r-s);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  padding: 0 12px calc(96px + env(safe-area-inset-bottom));
  max-width: 1360px;
  margin: 0 auto;
  position: relative;
}
/* 扫描线：仅终端场；深海无；纸墨无 */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 200;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.014) 0 1px, transparent 1px 4px);
}
body[data-theme="ink"]::after, body[data-theme="abyss"]::after { content: none; }
/* 纸墨：给纸面一点纹理 */
body[data-theme="ink"] {
  background:
    radial-gradient(1200px 400px at 50% -100px, rgba(176,58,46,.045), transparent 65%),
    #f1ede2;
}
/* 深海：顶部月光光斑 */
body[data-theme="abyss"] {
  background:
    radial-gradient(1100px 480px at 50% -140px, rgba(67,216,200,.1), transparent 62%),
    radial-gradient(700px 300px at 85% -80px, rgba(255,201,139,.05), transparent 60%),
    #071318;
}
.mono { font-family: var(--mono); }
.dim { color: var(--muted); }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: var(--mono); }
body[data-theme="ink"] input, body[data-theme="ink"] select, body[data-theme="ink"] .mono, body[data-theme="ink"] .kv, body[data-theme="ink"] .metric-big { font-family: var(--mono); }

/* ================= 状态栏 ================= */
.statusbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 2px 8px;
  background: linear-gradient(180deg, var(--bg) 82%, transparent);
}
.sb-left { display: flex; align-items: center; gap: 9px; }
.logo-mark {
  font-family: var(--mono); font-weight: 800; font-size: 13px; letter-spacing: 1px;
  color: var(--logo-ink); background: linear-gradient(135deg, var(--cyan), var(--purple));
  padding: 4px 8px; border-radius: var(--r-s); box-shadow: var(--shadow-logo);
  display: inline-flex; align-items: center; gap: 5px;
}
.sb-title { font-size: 14px; font-weight: 700; letter-spacing: 1px; }
.sb-title em { font-style: normal; font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 2px; margin-left: 6px; }
.sb-mid { display: flex; gap: 6px; flex: 1; justify-content: center; flex-wrap: wrap; }
.sb-right { text-align: right; font-size: 13px; line-height: 1.35; }
.sb-right .dim { display: block; font-size: 10px; }
.chip {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px;
  border: 1px solid var(--line2); color: var(--cyan);
  padding: 2px 8px; border-radius: var(--r-s); background: var(--cy-bg);
  white-space: nowrap;
}
.chip-live { color: var(--green); border-color: var(--gr-line); background: var(--gr-bg); }
.chip-demo { color: var(--amber); border-color: var(--am-line); background: var(--am-bg); }
.chip-dim { color: var(--muted); }

/* 跑马灯横幅：主行冷知识 + 副行同步态。窄屏两行都折行显示，绝不横向裁切 */
.ticker {
  display: block; font-size: 10px; letter-spacing: 1px; line-height: 1.65;
  color: var(--amber); border: 1px solid var(--am-line);
  border-left: 3px solid var(--amber);
  background: var(--am-bg); padding: 6px 10px; border-radius: var(--r-s);
  margin-bottom: 10px;
  cursor: pointer;
  word-break: break-word; overflow-wrap: anywhere;
}
.ticker .tk-main { display: block; }
.ticker .tk-sub { display: block; margin-top: 1px; color: var(--muted); font-size: 9px; letter-spacing: .6px; }

/* ================= 模块网格 ================= */
.grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 680px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1020px) { .grid { grid-template-columns: repeat(4, 1fr); } .mod-wide { grid-column: span 2; } }

.mod {
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  overflow: hidden; position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.mod:hover { border-color: var(--line2); box-shadow: var(--shadow-mod); }
.mod-head {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 10px; border-bottom: 1px solid var(--line);
  background: var(--am-bg);
  cursor: pointer; user-select: none;
}
.mod-head::before { content: ""; width: 3px; height: 12px; background: var(--ac, var(--cyan)); box-shadow: 0 0 8px var(--ac, var(--cyan)); border-radius: 1px; }
.mod-head .mi { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; color: var(--ac); flex: none; }
.mod-head .mi .ic { width: 100%; height: 100%; }
.mod-head .mt { font-size: 12px; font-weight: 700; letter-spacing: 2px; color: var(--ac, var(--cyan)); }
.mod-head .me { font-family: var(--mono); font-size: 9px; color: var(--muted); letter-spacing: 1px; }
.mod-head .demo-tag { margin-left: auto; font-family: var(--mono); font-size: 9px; color: var(--amber); border: 1px solid var(--am-line); padding: 0 5px; border-radius: 2px; }
.mod-head .ch-tag { margin-left: auto; font-family: var(--mono); font-size: 9px; color: var(--muted); }
.mod-head .demo-tag + .ch-tag { margin-left: 6px; }
.mod-body { padding: 12px; min-height: 128px; }
.mod.clickable:active { transform: scale(0.995); }

/* 终端数字与文本 */
.metric-big { font-family: var(--mono); font-size: clamp(26px, 3.4vw, 34px); font-weight: 700; line-height: 1.05; letter-spacing: -0.5px; }
.metric-big small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.sub-line { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.9; }
.sub-line b { color: var(--text); font-weight: 600; }
.kv { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; padding: 5px 0; border-bottom: 1px dashed var(--line2); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); min-width: 0; word-break: break-word; }
.kv .v { color: var(--text); font-weight: 600; min-width: 0; text-align: right; word-break: break-word; }

.empty {
  border: 1px dashed var(--line2); border-radius: var(--r-m);
  padding: 14px 10px; text-align: center; color: var(--muted);
  font-family: var(--mono); font-size: 11px; line-height: 2;
}
.empty b { color: var(--amber); }

/* 进度条 / 环形 / 迷你图 */
.bar-track { height: 6px; border-radius: 3px; background: var(--cy-bg); overflow: hidden; margin-top: 4px; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--ac, var(--cyan)); box-shadow: 0 0 8px var(--ac, var(--cyan)); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.spark-wrap svg { width: 100%; display: block; }

/* 心情 */
.mood-row { display: flex; gap: 6px; margin-top: 8px; }
.mood-dot { width: 24px; height: 24px; border-radius: var(--r-s); display: flex; align-items: center; justify-content: center; font-size: 13px; background: var(--cy-bg); border: 1px solid transparent; }
.mood-dot.today { border-color: var(--red); box-shadow: var(--shadow-rd); }
/* 无记录日：显示星期首字，让 7 格读成"一周时间轴"（比孤零零的点更好读） */
.mood-dot .wd { font-family: var(--mono); font-size: 11px; color: var(--muted); opacity: .75; }
/* 今日未记录时的空状态：虚线卡，不喧宾夺主，也不留一块巨大空字 */
.mood-empty { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px dashed var(--line2); border-radius: var(--r-m); padding: 14px 16px; }
.mood-empty b { font-size: 15px; letter-spacing: .5px; }
.mood-empty span { font-size: 11px; color: var(--muted); }
.mood-set { display: flex; gap: 6px; margin-top: 10px; }
/* 计时区可能有 2~3 个按钮：与 .form-row 同一套防溢出规则，窄屏平分且不撑破 */
.mood-set .btn-block { width: auto; flex: 1 1 0; min-width: 0; }
.mood-btn {
  flex: 1; font-size: 17px; padding: 6px 0; border-radius: var(--r-s);
  border: 1px solid var(--line); background: var(--cy-bg); transition: all .12s;
}
.mood-btn:active, .mood-btn.on { border-color: var(--red); background: var(--rd-bg); box-shadow: var(--shadow-rd); }

/* 日历 */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; font-family: var(--mono); font-size: 11px; }
.cal .h { color: var(--muted); text-align: center; padding: 3px 0; font-size: 9px; }
.cal .d { text-align: center; padding: 2px 0 3px; border-radius: var(--r-s); line-height: 1.3; border: 1px solid transparent; min-height: 30px; }
.cal .d em { display: block; font-style: normal; font-size: 8px; color: var(--amber); letter-spacing: 0; }
.cal .d.today { border-color: var(--cyan); background: var(--cy-bg); box-shadow: var(--shadow-today); font-weight: 700; }
.cal .d.wek { color: var(--red); }
.cal .d.wek em { color: var(--gold); }
.cal-bar { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }

/* 便签 */
.note-item { display: flex; align-items: flex-start; gap: 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r-m); margin-bottom: 6px; font-size: 12px; line-height: 1.5; background: var(--cy-bg); }
.note-item.done .nt { text-decoration: line-through; color: var(--muted); }
.note-item .nt { flex: 1; word-break: break-word; }
.note-item .nb { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 0 2px; flex: none; }
.note-item .nb:hover { color: var(--cyan); }

/* 急救卡 */
.medcard { border: 1.5px solid var(--rd-line); border-radius: var(--r-l); padding: 18px; background: var(--rd-bg); }
.mc-name { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.mc-blood { font-family: var(--mono); font-size: clamp(44px, 9vw, 64px); font-weight: 800; color: var(--red); text-shadow: 0 0 18px var(--rd-line); margin: 6px 0 12px; line-height: 1.1; }
.mc-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--rd-line); font-size: 13px; }
.mc-row span { color: var(--muted); flex: none; width: 76px; }
.mc-row b { font-weight: 600; word-break: break-all; }
.mc-row a { color: var(--cyan); text-decoration: none; }

/* 目标 */
.goal-item { margin-bottom: 10px; }
.goal-top { display: flex; justify-content: space-between; align-items: center; font-size: 11px; margin-bottom: 2px; gap: 6px; }
.goal-top .gt { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-top .gp { font-family: var(--mono); color: var(--ac); }
.goal-del { border: 0; background: none; color: var(--muted); font-size: 11px; padding: 0 2px; }
.goal-del:hover { color: var(--red); }
.goal-range { width: 100%; accent-color: var(--ac, var(--cyan)); height: 18px; }
.goal-add { display: flex; gap: 6px; margin-top: 8px; }
.goal-add input { flex: 1; min-width: 0; }

/* ================= 按钮 / 表单 ================= */
.btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: 1px;
  border: 1px solid var(--line2); color: var(--text); background: var(--cy-bg);
  padding: 8px 14px; border-radius: var(--r-s); transition: all .15s;
  /* 窄屏不撑破容器：长文案允许换行，绝不出现一字一行的竖排 */
  white-space: normal; word-break: keep-all; line-height: 1.5; min-width: 0;
}
.btn:hover { border-color: var(--cyan); color: var(--cyan); }
.btn-primary { border-color: var(--am-strong); color: var(--am-ink); background: linear-gradient(180deg, var(--amber), var(--am-grad2)); font-weight: 700; }
.btn-primary:hover { filter: brightness(1.08); color: var(--am-ink); }
.btn-danger { border-color: var(--rd-line); color: var(--red); }
.btn-block { width: 100%; }
/* .form-row 内的块按钮：平分宽度 + 允许收缩，杜绝 100%+100% 撑破容器 */
.form-row .btn-block { width: auto; flex: 1 1 0; min-width: 0; }
.btn-mini { padding: 4px 8px; font-size: 10px; }
input.f, textarea.f {
  width: 100%; background: var(--bg); border: 1px solid var(--line2); color: var(--text);
  padding: 9px 10px; border-radius: var(--r-s); font-size: 13px; outline: none;
}
body[data-theme="ink"] input.f, body[data-theme="ink"] textarea.f { background: #fffdf6; }
input.f:focus, textarea.f:focus { border-color: var(--cyan); box-shadow: 0 0 0 2px var(--cy-bg); }
/* —— select 主题化：禁用原生白底下拉 —— */
select.f {
  width: 100%; background: var(--bg); border: 1px solid var(--line2); color: var(--text);
  padding: 9px 26px 9px 10px; border-radius: var(--r-s); font-size: 13px; outline: none;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
select.f:focus { border-color: var(--cyan); box-shadow: 0 0 0 2px var(--cy-bg); }
select.f option { background: var(--bg); color: var(--text); }
body[data-theme="ink"] select.f { background-color: #fffdf6; }
/* —— checkbox / radio 主题化：杜绝原生白块 —— */
input[type="checkbox"], input[type="radio"] {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; border: 1px solid var(--line2); border-radius: 4px;
  background: var(--bg); cursor: pointer; position: relative; vertical-align: middle; flex: none;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:checked, input[type="radio"]:checked { background: var(--cyan); border-color: var(--cyan); }
input[type="checkbox"]:checked::after {
  content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--bg); font-size: 12px; font-weight: 700;
}
input[type="radio"]:checked::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--bg); }
/* —— 权限域复选标签（安全中心） —— */
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); cursor: pointer; user-select: none; }
/* —— 浏览器 autofill 黄底压制（配合 JS 只读拦截） —— */
input.f:-webkit-autofill, textarea.f:-webkit-autofill, select.f:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 100px var(--bg) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  transition: background-color 99999s ease-in-out 0s;
}
.field { margin-bottom: 10px; }
.field label { display: block; font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 1px; margin-bottom: 4px; }
.form-row { display: flex; gap: 8px; }
/* form-row 内的表单控件：占满剩余空间且可收缩到 0，防止 width:100% 撑破 flex 行 */
.form-row input.f, .form-row select.f, .form-row textarea.f { flex: 1 1 auto; min-width: 0; }
/* 全局防横向溢出：长标签、长数字、抽屉与大屏内容一律不撑破视口 */
.kv { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 11px; padding: 5px 0; border-bottom: 1px dashed var(--line2); }
.form-note { font-size: 10px; color: var(--muted); font-family: var(--mono); line-height: 1.8; margin-top: 6px; }
/* 空态：给一句「下一步做什么」，而不是只说「没有数据」——减少用户迷茫 */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 22px 14px; text-align: center;
  border: 1px dashed var(--line2); border-radius: var(--r-m);
  background: var(--cy-bg); margin-top: 8px;
}
.empty-state .ic { width: 26px; height: 26px; color: var(--muted); opacity: .55; }
.empty-state .es-t { font-size: 12px; font-weight: 600; color: var(--text); }
.empty-state .es-d { font-size: 10px; color: var(--muted); line-height: 1.7; max-width: 30em; }
.sect { font-family: var(--mono); font-size: 10px; letter-spacing: 2px; color: var(--amber); margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.sect:first-child { margin-top: 0; }

/* 权益对照（LOCAL / SYNCED） */
.perm { border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; font-family: var(--mono); font-size: 11px; background: var(--cy-bg); }
/* 权益对比表：窄屏三列压缩时文字允许折行，不撑出横向滚动 */
.perm-r span:first-child, .perm-h span:first-child { min-width: 0; word-break: break-word; }
.perm-h, .perm-r { display: grid; grid-template-columns: 1fr 56px 56px; align-items: center; }
.perm-h { background: var(--cy-bg); font-size: 10px; letter-spacing: 1px; color: var(--muted); }
.perm-h span { padding: 6px 0 6px 10px; }
.perm-h b { text-align: center; font-weight: 700; }
.perm-h b.na { color: var(--amber); }
.perm-h b.ac { color: var(--green); }
.perm-r { border-top: 1px dashed var(--line2); }
.perm-r span { color: var(--text); padding: 6px 0 6px 10px; font-family: var(--sans); font-size: 11.5px; }
.perm-r i { text-align: center; font-style: normal; }
.perm-r .ok { color: var(--green); }
.perm-r .no { color: var(--muted); font-size: 10px; }

/* 主题选择 */
.theme-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-card {
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--cy-bg); color: var(--text);
  padding: 10px 6px 9px; text-align: center; display: flex; flex-direction: column; gap: 3px; align-items: center;
  transition: border-color .15s, box-shadow .15s;
}
.theme-card i { width: 26px; height: 26px; border-radius: 50%; }
.theme-card[data-theme="terminal"] i { background: linear-gradient(135deg, #37c8ff, #b18cff); box-shadow: 0 0 10px rgba(55,200,255,.5); }
.theme-card[data-theme="ink"] i { background: linear-gradient(135deg, #f1ede2 55%, #b03a2e); border: 1px solid #c2b697; }
.theme-card[data-theme="abyss"] i { background: linear-gradient(135deg, #0b1d26 40%, #43d8c8 75%, #ffc98b); box-shadow: 0 0 12px rgba(67,216,200,.4); }
.theme-card b { font-size: 12px; letter-spacing: 2px; }
.theme-card .mono { font-size: 8px; color: var(--muted); letter-spacing: 2px; }
.theme-card em { font-style: normal; font-size: 9px; color: var(--muted); }
.theme-card.on { border-color: var(--amber); box-shadow: var(--shadow-key); }

/* 帮助条目 */
.help-i { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line2); font-size: 12px; line-height: 1.7; }
.help-i:last-child { border-bottom: 0; }
.help-i b { flex: none; font-family: var(--mono); font-size: 10px; color: var(--amber); border: 1px solid var(--am-line); border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.help-i span { color: var(--text); }
.help-i span b, .help-i span .mono { color: var(--cyan); }

/* 习惯 */
.habit-row { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r-m); margin-bottom: 6px; font-size: 12.5px; background: var(--cy-bg); }
.habit-row.on { border-color: var(--pink); background: var(--rd-bg); }
.habit-row .hb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.habit-row.on .hb-name { color: var(--muted); text-decoration: line-through; }
.hb-dot { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line2); background: transparent; color: #fff; font-size: 12px; line-height: 1; display: flex; align-items: center; justify-content: center; transition: all .12s; }
.habit-row.on .hb-dot { border-color: var(--pink); background: var(--pink); color: var(--bg); box-shadow: 0 0 8px var(--pu-line); }
.hb-streak { flex: none; font-family: var(--mono); font-size: 10px; color: var(--amber); }

/* 热力图 */
.hm-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; max-width: 260px; }
.hm-line { display: grid; grid-template-columns: repeat(28, minmax(0, 1fr)); gap: 2px; }
.hm-cell { aspect-ratio: 1; border-radius: 3px; background: var(--cy-bg); border: 1px solid transparent; }
.hm-cell.out { background: transparent; }
.hm-cell.lv1 { background: color-mix(in srgb, var(--cyan) 30%, transparent); }
.hm-cell.lv2 { background: color-mix(in srgb, var(--cyan) 60%, transparent); }
.hm-cell.lv3 { background: var(--cyan); box-shadow: 0 0 5px var(--cy-line); }
.hm-heat .hm-head { text-align: center; font-family: var(--mono); font-size: 8px; color: var(--muted); font-style: normal; }
.hm-cell.on { background: var(--pink); box-shadow: 0 0 4px var(--pu-line); }
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .hm-cell.lv1 { background: var(--cy-line); opacity: .4; }
  .hm-cell.lv2 { background: var(--cy-line); opacity: .7; }
}

/* ================= 报告周期切换 / 柱状图 / 色带 / 溯源标签 ================= */
.rpt-chips { display: flex; gap: 6px; margin: 10px 0; }
.rpt-chips .chip {
  flex: 1; padding: 7px 0; font-family: var(--mono); font-size: 11px; letter-spacing: 2px;
  background: transparent; border: 1px solid var(--line2); border-radius: var(--r-s);
  color: var(--muted); cursor: pointer; transition: all .15s;
}
.rpt-chips .chip.on { color: var(--cyan); border-color: var(--cyan); background: var(--cy-bg); box-shadow: 0 0 8px var(--cy-line); }
.mini-bar { display: flex; align-items: flex-end; gap: 6px; height: 92px; padding: 4px 2px 0; }
.mini-bar .mb-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; height: 100%; }
.mini-bar .mb-bar { display: block; width: 70%; max-width: 26px; border-radius: 3px 3px 0 0; background: var(--cyan); opacity: .75; }
.mini-bar .mb-bar.today { opacity: 1; box-shadow: 0 0 8px var(--cy-line); }
.mini-bar .mb-col u { text-decoration: none; font-size: 9px; color: var(--muted); font-family: var(--mono); }
.mini-bar .mb-col em { font-style: normal; font-size: 9px; color: var(--text); font-family: var(--mono); }
.mood-strip { display: flex; gap: 2px; }
.mood-strip .strip-c { flex: 1; height: 16px; border-radius: 3px; border: 1px solid var(--line); opacity: .9; }
.mood-strip .strip-c.now { border-color: var(--cyan); box-shadow: 0 0 6px var(--cy-line); }
.src-tag { display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 3px; font-size: 9px; font-family: var(--mono); border: 1px solid var(--line2); color: var(--muted); vertical-align: 1px; }
.src-tag.api { color: var(--cyan); border-color: var(--cy-line); }
.src-tag.imp { color: var(--gold); border-color: var(--gold); }
/* 记账表单双列网格 */
.fin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.fin-grid .field { margin-bottom: 8px; }
@media (max-width: 420px) { .fin-grid { grid-template-columns: 1fr; } }
/* 演示数据提示条：全屏大屏顶部必须明确声明「非本人数据」 */
.demo-note {
  font-family: var(--mono); font-size: 10px; line-height: 1.8; color: var(--amber);
  border: 1px solid var(--am-line); background: var(--am-bg); border-radius: var(--r-s);
  padding: 7px 10px; margin-bottom: 12px; letter-spacing: .5px;
}
.wkb { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: var(--cy-bg); vertical-align: middle; margin-right: 4px; overflow: hidden; }
.wkb i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--pink), var(--purple)); }

/* 日历心情点 */
.cal .d .mdot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; vertical-align: middle; margin-top: 1px; box-shadow: 0 0 4px currentColor; }

/* ================= 遥控器 ================= */
.remote {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(960px, calc(100% - 20px)); z-index: 80;
  display: flex; gap: 8px; align-items: stretch;
  border: 1px solid var(--line2); border-radius: var(--r-l);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35), inset 0 0 0 1px var(--cy-bg);
  padding: 8px;
}
.key-scroll { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.key-scroll::-webkit-scrollbar { display: none; }
.key {
  flex: none; min-width: 52px; border: 1px solid var(--line2); border-radius: var(--r-l);
  background: var(--cy-bg);
  color: var(--text); padding: 6px 8px 5px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .08s, border-color .15s, box-shadow .15s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.key i { font-style: normal; font-size: 16px; line-height: 1.2; display: flex; align-items: center; justify-content: center; min-height: 20px; }
.key i .ic { width: 17px; height: 17px; color: var(--text); }
.key.on i .ic { color: var(--amber); }
.key u { text-decoration: none; font-family: var(--mono); font-size: 8px; letter-spacing: 1px; color: var(--muted); }
.key:active { transform: scale(0.93); }
.key.on { border-color: var(--amber); box-shadow: var(--shadow-key); }
.key-fn { background: var(--am-bg); }
.key-fn u { color: var(--amber); }

/* ================= 频道大屏 ================= */
.channel {
  position: fixed; inset: 0; z-index: 120;
  background: radial-gradient(1000px 500px at 50% -10%, var(--halo), transparent 60%), var(--bg);
  display: flex; flex-direction: column; padding: 12px max(12px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom));
  touch-action: pan-y;            /* 横向手势交给我们处理，纵向仍走原生滚动 */
}
.channel-head {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line2); border-radius: var(--r-l); padding: 8px 10px;
  background: var(--panel);
}
.ch-btn {
  border: 1px solid var(--line2); background: var(--cy-bg); color: var(--text);
  border-radius: var(--r-s); padding: 8px 14px; font-size: 14px; font-family: var(--mono);
}
.ch-btn:active { transform: scale(0.94); }
.ch-close { margin-left: auto; color: var(--red); border-color: var(--rd-line); }
.ch-title { flex: 1; text-align: center; }
.ch-title b { color: var(--amber); font-size: 14px; margin-right: 10px; letter-spacing: 1px; }
.ch-title span { font-size: 15px; font-weight: 700; letter-spacing: 3px; }
.channel-body { flex: 1; overflow-y: auto; overflow-x: hidden; margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r-l); background: linear-gradient(180deg, var(--panel2), var(--panel)); padding: 18px; }
/* —— 滑屏切换：跟手位移层 —— */
.ch-stage {
  flex: 1; display: flex; align-items: center; margin-top: 10px; min-height: 0; position: relative;
  /* 底层同色衬板：跟手位移时不让背景透出，避免"内容浮空"的廉价感 */
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border-radius: var(--r-l);
}
.ch-slide {
  flex: 1; min-width: 0; max-height: 100%; overflow-y: auto; overflow-x: hidden;
  border: 1px solid var(--line); border-radius: var(--r-l);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  padding: 18px;
  will-change: transform; -webkit-overflow-scrolling: touch;
  box-shadow: 0 0 0 1px transparent;
}
.ch-slide.grabbing { transition: none !important; cursor: grabbing; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.ch-slide.settle { transition: transform .26s cubic-bezier(.22,1,.36,1); }
/* 左右边缘的邻屏预告（滑动时才浮现） */
.ch-hint {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 10px 13px; border-radius: var(--r-m);
  background: var(--panel); border: 1px solid var(--line2);
  box-shadow: var(--shadow-m, 0 6px 24px rgba(0,0,0,.35));
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px; color: var(--muted);
  opacity: 0; pointer-events: none; transition: opacity .16s;
  max-width: 40%; z-index: 3;
}
.ch-hint.l { left: 8px; } .ch-hint.r { right: 8px; }
.ch-hint.on { opacity: 1; }
.ch-hint svg { width: 15px; height: 15px; flex: none; }
.ch-hint b { color: var(--text); font-weight: 600; }
.ch-hint .hn { color: var(--amber); }
/* 频道序号点阵：一眼看清有几个频道、自己在哪 */
.ch-dots { display: flex; gap: 4px; justify-content: center; align-items: center; margin-top: 8px; min-height: 16px; }
.ch-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--line2); transition: all .18s; }
.ch-dots i.on { width: 16px; border-radius: 3px; background: var(--amber); box-shadow: 0 0 6px var(--am-line); }
.ch-dots i.near { background: var(--muted); }
.channel-body .metric-big { font-size: clamp(40px, 8vw, 72px); }
.channel-body .mod-full-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.channel-tip { text-align: center; font-size: 9px; color: var(--muted); letter-spacing: 2px; margin-top: 8px; }
/* 首次进入的一次性滑动引导，之后自动消失（不打扰老用户） */
.ch-coach {
  position: absolute; inset: auto 0 0 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 2px; color: var(--text);
  pointer-events: none; z-index: 4;
}
.ch-coach svg { width: 22px; height: 22px; color: var(--amber); animation: coachSlide 1.5s ease-in-out infinite; }
@keyframes coachSlide { 0%,100% { transform: translateX(-4px); opacity: .5; } 50% { transform: translateX(4px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ch-coach svg { animation: none; } }

/* ================= 抽屉 ================= */
.backdrop { position: fixed; inset: 0; background: rgba(2, 4, 8, 0.6); backdrop-filter: blur(2px); z-index: 90; }
body[data-theme="ink"] .backdrop { background: rgba(60, 50, 30, 0.3); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 100;
  width: min(400px, 100%);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border-left: 1px solid var(--line2);
  display: flex; flex-direction: column;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.35);
  animation: slidein .18s ease-out;
}
body[data-theme="ink"] .drawer { box-shadow: -12px 0 40px rgba(60,50,30,.2); }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-size: 11px; letter-spacing: 3px; color: var(--amber);
}
.drawer-tabs { display: flex; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.drawer-tabs button {
  flex: 1; padding: 9px 4px; font-size: 10px; letter-spacing: 2px;
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap;
}
.drawer-tabs button.on { color: var(--amber); border-bottom-color: var(--amber); }
.drawer-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px; }

/* 布局管理 */
.layout-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-m); margin-bottom: 6px; font-size: 12px; background: var(--cy-bg); }
.layout-item .li-name { flex: 1; }
.layout-item.off { opacity: 0.42; }
.layout-item .li-btn { border: 1px solid var(--line2); background: none; color: var(--muted); border-radius: var(--r-s); padding: 3px 8px; font-size: 11px; }
.layout-item .li-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.layout-item .li-btn:disabled { opacity: .28; cursor: default; }
.layout-item .li-btn:disabled:hover { color: var(--muted); border-color: var(--line2); }
.layout-item .li-btn.mv { padding: 3px 7px; }
/* 兼容通道折叠区（数据源页） */
details.compat { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r-m); padding: 8px 12px; background: var(--cy-bg); }
details.compat > summary { cursor: pointer; font-size: 12px; color: var(--muted); letter-spacing: .3px; }
details.compat[open] > summary { color: var(--text); margin-bottom: 6px; }
details.compat > *:not(summary) { margin-top: 8px; }

/* AI 对话 */
.ai-msgs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; max-height: 300px; overflow-y: auto; }
.ai-msg { font-size: 12px; line-height: 1.7; padding: 8px 10px; border-radius: var(--r-m); max-width: 92%; white-space: pre-wrap; word-break: break-word; }
.ai-msg.user { align-self: flex-end; background: var(--cy-bg); border: 1px solid var(--cy-line); }
.ai-msg.assistant { align-self: flex-start; background: var(--pu-bg); border: 1px solid var(--pu-line); }
.ai-msg.err { align-self: stretch; background: var(--rd-bg); border: 1px solid var(--rd-line); color: var(--red); font-family: var(--mono); font-size: 11px; }

/* ---- 安装引导 / 离线提示条 ---- */
.install-bar, .offline-bar {
  position: fixed; left: 12px; right: 12px; z-index: 150;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-m);
  background: var(--panel); border: 1px solid var(--am-line);
  box-shadow: var(--shadow-m);
  opacity: 0; transform: translateY(12px);
  transition: opacity var(--t-std) var(--ease-std), transform var(--t-std) var(--ease-out);
}
.install-bar { bottom: calc(84px + env(safe-area-inset-bottom)); }
.offline-bar { bottom: calc(12px + env(safe-area-inset-bottom)); border-color: var(--rd-line); color: var(--red); font-size: 11px; justify-content: center; }
.install-bar.on, .offline-bar.on { opacity: 1; transform: translateY(0); }
.install-bar .ib-ic { flex: none; }
.install-bar .ib-ic .ic { width: 20px; height: 20px; color: var(--amber); }
.install-bar .ib-tx { flex: 1; font-size: 11px; line-height: 1.5; min-width: 0; }
.install-bar .ib-tx b { color: var(--text); }
.install-bar .ib-x {
  flex: none; border: 0; background: none; color: var(--muted);
  font-size: 14px; padding: 4px 6px; min-width: 32px; min-height: 32px;
}
/* 已作为独立应用运行时（standalone）不需要安装入口 */
@media (display-mode: standalone) { .install-bar { display: none !important; } }

/* Toast */
#toast {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -10px);
  z-index: 300; font-size: 12px; letter-spacing: 1px;
  background: var(--panel); border: 1px solid var(--cy-line);
  color: var(--text); padding: 9px 18px; border-radius: var(--r-s);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-std) var(--ease-std), transform var(--t-std) var(--ease-out);
  box-shadow: var(--shadow-toast);
  max-width: calc(100% - 32px);
  text-align: center; line-height: 1.5; word-break: break-word;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: var(--rd-line); color: var(--red); }
/* 成功态：左侧一道绿色竖条，扫一眼就知道结果 */
#toast.ok { border-left: 3px solid var(--green); }

.foot { text-align: center; font-size: 9px; color: var(--muted); opacity: .55; letter-spacing: 2px; margin-top: 18px; }
code.inline { font-family: var(--mono); font-size: 10px; color: var(--cyan); word-break: break-all; }

/* 可点状态徽章 / 访客登录键高亮 */
#mode-chip, #banner { cursor: pointer; }
.key.guest-glow { border-color: var(--amber); box-shadow: var(--shadow-key); }
.key.guest-glow u { color: var(--amber); font-weight: 700; }

/* ================= 移动端优化 ================= */
button, .key, .ch-btn, .mod-head { touch-action: manipulation; }
@media (max-width: 680px) {
  input.f, textarea.f, select.f { font-size: 16px; } /* 防 iOS 聚焦缩放 */
  .channel-body { padding: 14px 12px; }
  .ch-btn { padding: 10px 16px; min-width: 44px; min-height: 40px; }
  .sb-title { font-size: 13px; }
  .sb-title em { display: none; }
  .key { min-width: 50px; }
  .key-fn { min-width: 58px; }
  .mod-body { padding: 11px; min-height: 118px; }
  .drawer { width: 100%; }
  .mod-head .me { display: none; }   /* 英文小标仅大屏展示 */
  #sync-chip { display: none; }     /* 同步态并入账户徽章，减一层噪音 */
  .sb-mid { justify-content: flex-start; }
  .ticker { font-size: 9px; }
  .theme-row { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  /* —— 移动端手感打磨 —— */
  /* 触摸目标不小于 44px（Apple HIG / Material 基准） */
  .ch-btn { min-width: 44px; min-height: 40px; padding: 8px 12px; }
  .ch-close { min-width: 48px; }
  /* 手指按下立刻反馈，不等hover */
  .ch-btn, .btn, .key, .chip, .key-fn, .layout-item .li-btn { transition: transform .08s, opacity .12s, border-color .15s, box-shadow .15s, background .15s; }
  .ch-btn:active, .btn:active, .key:active { transform: scale(.93); }
  .key:active { transform: scale(.9) translateY(1px); }
  /* 大屏：内容左右留出更宽的呼吸位，滑动观感更好 */
  .ch-stage { margin-top: 8px; }
  .ch-slide { padding: 14px 12px; border-radius: var(--r-m); }
  .channel-head { padding: 7px 8px; gap: 7px; }
  .ch-title span { font-size: 14px; letter-spacing: 2px; }
  .ch-title b { font-size: 12px; margin-right: 7px; }
  /* 提示语在触屏上换行说人话 */
  .channel-tip { letter-spacing: .5px; line-height: 1.6; font-size: 10px; }
  .ch-dots { margin-top: 6px; }
  .ch-hint { max-width: 46%; padding: 8px 10px; }
}

/* 触屏设备：去掉 hover 依赖的残留样式，避免「点了没反应」的错觉 */
@media (hover: none) {
  .key:hover, .btn:hover, .ch-btn:hover { border-color: var(--line2); color: var(--text); }
  .btn-primary:hover { filter: none; }
}
/* color-mix 不支持时的兜底（老浏览器：遥控器背景退为不透明面板色） */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .remote { background: var(--panel); }
}
