/* 浅色、高对比、大字号。尽量少动画，并尊重系统「减弱动态效果」设置。 */
:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-2: #eceef1;
  --line: #dcdfe4;
  --text: #16181d;
  --muted: #646c78;
  --accent: #1a7fc4;
  --ok: #1f9d55;
  --warn: #c27c0e;
  --bad: #d93636;
  --important: #d98a00;
  --hl: rgba(26, 127, 196, .10);
  --t-private: #1f6fb2;
  --t-channel: #7b4cc2;
  --t-group: #1f8a55;
  --fs: 1;
  --radius: 14px;
  color-scheme: light;
}
/* 夜间：暖色、低对比的米色调，降低亮度刺激，但不用黑底 */
:root.night {
  --bg: #e6dfd1;
  --surface: #efe8da;
  --surface-2: #e0d7c5;
  --line: #d2c7b2;
  --text: #3d3427;
  --muted: #7a6d59;
  --accent: #8a5a1c;
  --ok: #4f7a3a;
  --important: #b0661a;
  --hl: rgba(138, 90, 28, .10);
  --t-private: #5d5a8a;
  --t-channel: #7a4f7a;
  --t-group: #4f7a3a;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- 看板 ---------- */
.board { min-height: 100vh; padding: 0 max(12px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.board { -webkit-user-select: none; user-select: none; }
.top {
  position: sticky; top: 0; z-index: 5;
  margin: 0 calc(-1 * max(12px, env(safe-area-inset-left)));
  padding: calc(env(safe-area-inset-top) + 10px) max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top-row + .top-row { margin-top: 6px; }
.brand { margin: 0; font-size: calc(15px * var(--fs)); letter-spacing: .18em; font-weight: 800; color: var(--accent); }
.clock { line-height: 1.05; }
.time { font-size: calc(46px * var(--fs)); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.date { margin-top: 4px; font-size: calc(15px * var(--fs)); color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; background: var(--surface-2); font-size: calc(13px * var(--fs)); white-space: nowrap; }
.pill i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.pill b { font-weight: 600; }
.pill[data-tone="ok"] i { background: var(--ok); }
.pill[data-tone="warn"] i { background: var(--warn); }
.pill[data-tone="bad"] i { background: var(--bad); }
.pill[data-tone="bad"] { color: var(--bad); }

.count { display: flex; flex-direction: column; align-items: center; min-width: 76px; padding: 8px 12px; border: 0; border-radius: var(--radius); background: var(--surface-2); line-height: 1.1; }
.count b { font-size: calc(30px * var(--fs)); font-variant-numeric: tabular-nums; }
.count span { font-size: calc(12px * var(--fs)); color: var(--muted); }
.count.has b { color: var(--accent); }

.list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.msg {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px 13px;
  transition: background-color 1.2s ease;
}
.msg.new { background: var(--hl); border-left-color: var(--accent); }
.msg.important { border-left-color: var(--important); }
.msg.important .chat::before { content: "★ "; color: var(--important); }
.msg-head { display: flex; align-items: baseline; gap: 8px; font-size: calc(14px * var(--fs)); color: var(--muted); }
.chat { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text); opacity: .85; }
.when { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sender { margin-top: 3px; font-size: calc(15px * var(--fs)); font-weight: 700; color: var(--accent); }
.body { margin-top: 5px; font-size: calc(21px * var(--fs)); line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.body.placeholder { color: var(--muted); font-style: italic; }
.body.clamp { display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.msg-media { display: block; width: auto; max-width: 100%; max-height: 58vh; margin-top: 10px; border-radius: 10px; object-fit: contain; background: var(--surface-2); }
.tags { display: flex; gap: 6px; margin-top: 8px; }
.tag { font-size: calc(11.5px * var(--fs)); padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag.t-private { color: var(--t-private); }
.tag.t-channel { color: var(--t-channel); }
.tag.t-group, .tag.t-supergroup { color: var(--t-group); }

.empty { margin: 18vh 0 0; text-align: center; font-size: calc(20px * var(--fs)); color: var(--muted); }
.empty small { font-size: calc(14px * var(--fs)); }
.more { display: block; width: 100%; margin: 14px 0 0; padding: 14px; border: 1px dashed var(--line); border-radius: var(--radius); background: transparent; color: var(--muted); }

.resume {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 128px * var(--fs)); z-index: 6;
  padding: 10px 18px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.chip-float { position: fixed; left: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 6; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }

/* 底部操作栏：按钮间距留足，减少误触 */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 10px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-top: 1px solid var(--line);
}
.dock button { height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font-size: 14px; white-space: nowrap; }
.dock #onlineBtn { margin-right: auto; }
.dock .dock-toggle.on { background: var(--ok); color: #fff; border-color: var(--ok); }
.dock .dock-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.dock .gear { width: 44px; padding: 0; font-size: 22px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 7;
  display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg); box-shadow: 0 6px 20px rgba(0,0,0,.18); white-space: nowrap;
}
.toast button { border: 0; border-radius: 999px; padding: 6px 12px; background: var(--accent); color: #fff; font-weight: 700; }

/* 强提醒：全屏覆盖，必须点「知道了」才关闭 */
.alert { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 20px; background: color-mix(in srgb, var(--important) 30%, var(--bg)); }
.alert.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { background: color-mix(in srgb, var(--important) 55%, var(--bg)); } }
.alert-card { width: min(560px, 100%); padding: 24px 22px 20px; border-radius: 22px; background: var(--surface); border: 3px solid var(--important); box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.alert-tag { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--important); color: #fff; font-weight: 800; letter-spacing: .1em; font-size: 14px; }
.alert-chat { margin-top: 14px; font-size: calc(26px * var(--fs)); font-weight: 800; }
.alert-sender { margin-top: 4px; font-size: calc(17px * var(--fs)); color: var(--accent); font-weight: 700; }
.alert-text { margin-top: 12px; font-size: calc(24px * var(--fs)); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 45vh; overflow: auto; }
.alert-more { margin-top: 10px; color: var(--muted); font-size: 14px; }
.alert .primary { margin-top: 18px; padding: 16px; font-size: 19px; background: var(--important); }

.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.btn { padding: 10px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.danger { padding: 10px 18px; border: 0; border-radius: 10px; background: var(--bad); color: #fff; font-weight: 700; }
.danger:disabled, button:disabled { opacity: .5; cursor: not-allowed; }
.steps { margin: 14px 0 0; padding-left: 22px; line-height: 1.7; }
.steps .fail { color: var(--bad); }
.steps small { color: var(--muted); }
.steps .final { list-style: none; margin-left: -22px; margin-top: 8px; font-weight: 700; }
.flash { position: fixed; inset: 0; z-index: 20; pointer-events: none; background: var(--accent); opacity: 0; }
.flash.on { animation: flash .7s ease-out; }
@keyframes flash { 0% { opacity: .35; } 100% { opacity: 0; } }

/* ---------- 设置面板 ---------- */
.sheet { width: min(520px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); }
.sheet::backdrop { background: rgba(0,0,0,.3); }
.sheet form { padding: 18px; }
.sheet h2 { margin: 0 0 12px; font-size: 18px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.seg { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button, .toggle { min-width: 46px; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; }
.seg button.on { background: var(--accent); color: #fff; }
.seg output { min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
.toggle { background: var(--surface-2); }
.toggle.on { background: var(--accent); color: #fff; }
select { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }
.hint { font-size: 13px; color: var(--muted); line-height: 1.5; }
.primary { width: 100%; margin-top: 8px; padding: 12px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; }

/* ---------- 配对 ---------- */
.pair { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.pair-card { width: min(420px, 100%); }
.pair-card h2 { margin: 0 0 6px; }
.pair-card p { color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.pair-card input { width: 100%; padding: 14px; font-size: 24px; letter-spacing: .2em; text-align: center; text-transform: uppercase; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.err { color: var(--bad); min-height: 1.2em; margin: 10px 0 0 !important; }

@media (min-width: 700px) {
  .list { grid-template-columns: 1fr; max-width: 900px; margin-left: auto; margin-right: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .msg { transition: none; }
  .flash.on, .alert.pulse { animation: none; }
}
