/* =============================================================
   两个人 · 端到端加密聊天
   styles.css — 全部样式，移动优先，深色模式跟随系统
   无外部依赖、无字体下载、无图片资源（图标全部是内联 SVG）
   ============================================================= */

/* ---------- 1. 设计令牌（亮色为默认） ---------- */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --surface-3: #e2e5eb;
  --text: #14161a;
  --text-2: #5c6169;
  --text-3: #8d939c;
  --line: rgba(18, 20, 24, .10);
  --line-strong: rgba(18, 20, 24, .16);
  --accent: #2f6bff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(47, 107, 255, .10);
  --mine: #2f6bff;
  --mine-text: #ffffff;
  --peer: #ffffff;
  --peer-text: #14161a;
  --bubble-line: transparent;
  --danger: #e5484d;
  --danger-ink: #ffffff;
  --danger-soft: rgba(229, 72, 77, .10);
  --ok: #22a06b;
  --ok-soft: rgba(34, 160, 107, .12);
  --warn: #d98b18;
  --warn-soft: rgba(217, 139, 24, .14);
  --scrim: rgba(10, 12, 16, .45);
  --shadow-bar: 0 -1px 0 var(--line);
  --shadow-card: 0 1px 2px rgba(16, 20, 28, .05), 0 8px 24px rgba(16, 20, 28, .06);
  --radius: 14px;
  --radius-lg: 20px;
  --radius-bubble: 18px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
          "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
          "Liberation Mono", monospace;

  /* 安全区：由 iOS 注入，非 iOS 环境回退 0 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --topbar-h: 54px;
  --input-h: 54px;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --surface-3: #262b34;
    --text: #eef1f6;
    --text-2: #a9b1bd;
    --text-3: #79818e;
    --line: rgba(255, 255, 255, .10);
    --line-strong: rgba(255, 255, 255, .18);
    --accent: #5b8cff;
    --accent-ink: #08101f;
    --accent-soft: rgba(91, 140, 255, .16);
    --mine: #3d6dff;
    --mine-text: #ffffff;
    --peer: #1d2129;
    --peer-text: #eef1f6;
    --bubble-line: rgba(255, 255, 255, .07);
    --danger: #ff5c60;
    --danger-ink: #2a0507;
    --danger-soft: rgba(255, 92, 96, .14);
    --ok: #3ddc97;
    --ok-soft: rgba(61, 220, 151, .14);
    --warn: #ffc061;
    --warn-soft: rgba(255, 192, 97, .16);
    --scrim: rgba(0, 0, 0, .6);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .28);
  }
}

/* ---------- 2. 重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* 防误选（长按选择只在消息气泡与输入框里放开） */
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button, input, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

h1, h2, p, ol, ul, li { margin: 0; padding: 0; }
ol, ul { list-style: none; }

input, textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-appearance: none;
  appearance: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* 图标精灵容器不占位 */
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---------- 3. 图标工具类 ---------- */
.ico {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}
.ico-14 { width: 14px; height: 14px; stroke-width: 1.9; }
.ico-16 { width: 16px; height: 16px; stroke-width: 1.8; }
.ico-18 { width: 18px; height: 18px; }
.ico-20 { width: 20px; height: 20px; }
.ico-32 { width: 32px; height: 32px; stroke-width: 1.5; }
.inline-ico { display: inline-block; vertical-align: -3px; margin: 0 2px; }

/* 火焰用实心填充更清楚（体积小、一眼看懂） */
.ico use[href="#i-fire"] { fill: currentColor; }
.ico-12 { width: 12px; height: 12px; stroke-width: 2; }

/* ---------- 4. App 外壳（iOS 地址栏高度跳变处理） ---------- */

/*
 * 全局兜底：[hidden] 必须真的隐藏。
 * ui.js 统一用 setAttribute('hidden') / removeAttribute('hidden') 控制显隐，
 * 但不少组件自己有 display:flex/grid 这类规则，会盖掉 hidden 的默认样式
 * （曾经导致启动遮罩一直盖在最上面、屏幕切换失效）。
 */
[hidden] { display: none !important; }

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  /* 老 iOS 回退 → 动态视口 → 最终回退 100vh */
  height: 100vh;
  height: -webkit-fill-available;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
/*
 * 显隐以 hidden 属性为唯一依据（ui.js 的 setHidden 就是 set/removeAttribute('hidden')）。
 * 注意：这里必须用 :not([hidden])，不能依赖 .is-active ——
 * 之前样式只认 .is-active 而 JS 只动 hidden，两者从未接上，
 * 结果 5 个屏幕全是 display:none，整站白屏。
 */
.screen:not([hidden]) {
  display: flex;
  animation: screen-in .18s ease-out;
}
/* 兼容：如果 JS 之外有地方加了 .is-active，也让它显示 */
.screen.is-active {
  display: flex;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ---------- 5. 顶栏 / 子页头 ---------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--topbar-h);
  padding: calc(var(--safe-top) + 6px) 10px 6px;
  padding-left: calc(var(--safe-left) + 10px);
  padding-right: calc(var(--safe-right) + 10px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 3;
}

.peer {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.peer-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.presence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 1px;
}
.presence .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  flex: none;
}
.presence.online { color: var(--ok); }
.presence.online .dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.presence.online #presence-text { font-weight: 600; }

.topbar-spacer { width: 38px; flex: none; }

.icon-btn {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-2);
  transition: background .15s;
}
.icon-btn:active { background: var(--surface-2); }

.subbar {
  flex: none;
  padding: calc(var(--safe-top) + 18px) 20px 14px;
  padding-left: calc(var(--safe-left) + 20px);
  padding-right: calc(var(--safe-right) + 20px);
}
.subbar h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.subbar .subtitle { margin-top: 4px; font-size: 13.5px; color: var(--text-2); }

/* ---------- 6. 通用块 ---------- */
.sections {
  padding: 4px calc(var(--safe-right) + 14px) calc(var(--safe-bottom) + 28px) calc(var(--safe-left) + 14px);
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 20px 4px 8px;
}
.danger-label { color: var(--danger); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 14px;
}
.card + .card { margin-top: 10px; }

.field-label {
  font-size: 12.5px;
  color: var(--text-3);
  margin-bottom: 8px;
}

.row-note {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-3);
}
.row-note.center { text-align: center; }
.row-note.is-warn { color: var(--warn); }
.row-note.is-error { color: var(--danger); }

.mono { font-family: var(--mono); letter-spacing: .04em; }

/* ---------- 7. 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  transition: transform .08s, filter .15s, background .15s;
}
.btn:active { transform: scale(.985); }
.btn-block { display: flex; width: 100%; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:active { filter: brightness(1.06); }

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  min-height: 40px;
  font-size: 14.5px;
  font-weight: 500;
  margin-top: 12px;
}
.btn-ghost:active { background: var(--surface-3); }

.btn-danger { background: var(--danger); color: var(--danger-ink); }
.btn-danger:active { filter: brightness(1.06); }
.btn-danger[disabled] { opacity: .45; }

.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:active { transform: none; }

/* ---------- 8. 配对屏 ---------- */
.pair-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 28px) calc(var(--safe-left) + 16px);
}

.qr-wrap { display: flex; justify-content: center; }

.qr-placeholder {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  border: 2px dashed var(--line-strong);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-3);
  box-shadow: var(--shadow-card);
}
.qr-mark { width: 34px; height: 34px; opacity: .75; }
.qr-text { font-size: 14px; font-weight: 600; color: var(--text-2); }
.qr-hint { font-size: 11.5px; color: var(--text-3); padding: 0 16px; text-align: center; }

.pair-code-card { text-align: center; }

.pair-code {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .12em;
  line-height: 1.25;
  padding: 4px 0 2px;
  font-variant-numeric: tabular-nums;
  word-break: keep-all;
}
.pair-code.is-expired { color: var(--text-3); text-decoration: line-through; }

.pair-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.pair-meta-item { display: inline-flex; align-items: center; gap: 5px; }
.pair-meta-item b { font-weight: 600; color: var(--text); }

.pair-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
  background: var(--warn-soft);
  border-radius: 12px;
  padding: 10px 12px;
}
.warn-ico { color: var(--warn); margin-top: 1px; }

.code-inputs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}
.code-gap { width: 10px; flex: none; }

.code-box {
  width: 100%;
  max-width: 46px;
  height: 54px;
  flex: 1 1 0;
  min-width: 0;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  text-align: center;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}
.code-box:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}
.code-box.is-filled { border-color: var(--accent); }

/* ---------- 9. 聊天屏 ---------- */
.scroll-chat {
  display: flex;
  flex-direction: column;
  padding: 10px calc(var(--safe-right) + 12px) 12px calc(var(--safe-left) + 12px);
}

.msg-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;   /* 消息少时贴底 */
  width: 100%;
}

.no-msg {
  margin: auto;
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
  line-height: 1.7;
  padding: 24px 20px;
}
.no-msg .ico { margin: 0 auto 10px; width: 30px; height: 30px; opacity: .5; }

.day-divider {
  align-self: center;
  margin: 14px 0 10px;
  font-size: 11.5px;
  color: var(--text-3);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px 10px;
}

.msg-row {
  display: flex;
  margin-top: 6px;
  animation: msg-in .16s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(5px) scale(.99); }
  to   { opacity: 1; transform: none; }
}
.msg-row.side-me { justify-content: flex-end; }
.msg-row.side-peer { justify-content: flex-start; }
.msg-row.grouped { margin-top: 1px; }

.msg-col {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  min-width: 0;
}
.side-me .msg-col { align-items: flex-end; }
.side-peer .msg-col { align-items: flex-start; }

.bubble {
  position: relative;
  padding: 9px 13px;
  border-radius: var(--radius-bubble);
  font-size: 16px;
  line-height: 1.42;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
.side-peer .bubble {
  background: var(--peer);
  color: var(--peer-text);
  border: 1px solid var(--bubble-line);
  border-bottom-left-radius: 6px;
}
.side-me .bubble {
  background: var(--mine);
  color: var(--mine-text);
  border-bottom-right-radius: 6px;
}
.msg-row.grouped .bubble { border-radius: var(--radius-bubble); }

/* 阅后即焚：未点开时是一张「点击查看」的遮罩卡片 */
.bubble.burn {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}
.bubble.burn .ico { width: 17px; height: 17px; color: var(--danger); }
.side-me .bubble.burn { border-color: var(--accent); color: var(--accent); }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 3px 4px 0;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.msg-meta .sep { opacity: .5; }
.msg-meta .failed { color: var(--danger); font-weight: 600; }
.msg-meta .pending { opacity: .75; }

.ttl-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--warn);
  font-variant-numeric: tabular-nums;
}
.ttl-tag .ico { width: 12px; height: 12px; }
.ttl-tag.urgent { color: var(--danger); font-weight: 600; }

/* 正在输入 */
.typing-bar {
  flex: none;
  display: none;
  align-items: center;
  gap: 7px;
  padding: 5px calc(var(--safe-right) + 16px) 6px calc(var(--safe-left) + 16px);
  font-size: 12px;
  color: var(--text-3);
  background: var(--bg);
}
.typing-bar.is-on { display: flex; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-bounce 1.1s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* 新消息提示 */
.new-msg-pill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + var(--input-h) + 14px);
  z-index: 5;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
  animation: msg-in .16s ease-out;
}

/* ---------- 10. 底部输入栏 ---------- */
.input-bar {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 7px calc(var(--safe-right) + 8px) calc(var(--safe-bottom) + 7px) calc(var(--safe-left) + 8px);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow-bar);
  z-index: 4;
}

.tool-btn {
  height: 38px;
  min-width: 38px;
  padding: 0 8px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 11px;
  color: var(--text-2);
  background: var(--surface-2);
  transition: background .15s, opacity .15s;
}
.tool-btn:active { background: var(--surface-3); }
.tool-btn.disabled,
.tool-btn:disabled {
  opacity: .35;
  color: var(--text-3);
  cursor: default;
}
.tool-btn:disabled:active { background: var(--surface-2); }

.ttl-chip {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .01em;
  max-width: 46px;
  overflow: hidden;
  white-space: nowrap;
}

.composer {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 19px;
  padding: 8px 13px;
  transition: border-color .15s, background .15s;
}
.composer:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}
.composer textarea {
  display: block;
  width: 100%;
  max-height: 116px;
  min-height: 21px;
  border: 0;
  background: none;
  resize: none;
  outline: none;
  font-size: 16px;
  line-height: 1.35;
  overflow-y: auto;
}
.composer textarea::placeholder { color: var(--text-3); }

.send-btn {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  transition: opacity .15s, transform .08s;
}
.send-btn:active { transform: scale(.93); }
.send-btn.is-off { opacity: .35; }

/* ---------- 11. 设置屏 ---------- */
.setting-row {
  display: flex;
  align-items: center;
  gap: 11px;
}
.setting-ico {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
}
.setting-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.setting-title { font-size: 15.5px; font-weight: 500; }
.setting-desc { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.fingerprint {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  flex: none;
}

.switch {
  width: 50px;
  height: 30px;
  flex: none;
  border-radius: 999px;
  background: var(--surface-3);
  padding: 3px;
  display: flex;
  align-items: center;
  transition: background .18s;
}
.switch .switch-knob {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .28);
  transition: transform .18s ease;
}
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(20px); }
.switch[aria-disabled="true"] { opacity: .45; }

/* 销毁时长选项 */
.ttl-card {
  padding: 6px 4px;
}
.ttl-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 10px;
  border-radius: 10px;
  text-align: left;
  transition: background .15s;
}
.ttl-opt:active { background: var(--surface-2); }
.ttl-opt + .ttl-opt { border-top: 1px solid var(--line); }
.ttl-opt-label { flex: 1 1 auto; font-size: 15.5px; }
.ttl-opt-sub { font-size: 12px; color: var(--text-3); }
.ttl-opt-tick { color: var(--accent); opacity: 0; flex: none; }
.ttl-opt[aria-checked="true"] .ttl-opt-label { font-weight: 600; }
.ttl-opt[aria-checked="true"] .ttl-opt-tick { opacity: 1; }

/* 自检 */
.diag-card { padding: 6px 4px; }
.diag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  font-size: 14.5px;
}
.diag-row + .diag-row { border-top: 1px solid var(--line); }
.diag-label { flex: 1 1 auto; color: var(--text-2); }
.diag-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.diag-value.is-ok { color: var(--ok); }
.diag-value.is-warn { color: var(--warn); }
.diag-value.is-bad { color: var(--danger); }
.diag-ico { flex: none; }
.diag-ico.is-ok { color: var(--ok); }
.diag-ico.is-warn { color: var(--warn); }
.diag-ico.is-bad { color: var(--danger); }

/* 危险区 */
.danger-card {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.danger-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 7px;
}
.danger-desc {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
  margin-bottom: 14px;
}
.danger-desc b { color: var(--text); }

.version-note {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  padding: 26px 0 8px;
  font-family: var(--mono);
}

/* ---------- 12. 引导屏 ---------- */
.brand-mark {
  align-self: center;
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 19px;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-card);
  margin: 6px 0 4px;
}

.steps { display: flex; flex-direction: column; }
.step {
  display: flex;
  gap: 12px;
  padding: 12px 2px;
}
.step + .step { border-top: 1px solid var(--line); }
.step-num {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 700;
}
.step-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.step-title { font-size: 16px; font-weight: 600; }
.step-desc { font-size: 13px; color: var(--text-2); }

/* ---------- 13. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 86px);
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(88vw, 420px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(22, 24, 29, .94);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .3);
  animation: toast-in .2s ease-out;
  backdrop-filter: blur(8px);
}
.toast.is-out { animation: toast-out .2s ease-in forwards; }
.toast.is-danger { background: var(--danger); color: var(--danger-ink); }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, 12px); }
}

/* ---------- 14. 底部弹层 ---------- */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sheet-scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  animation: fade-in .18s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: relative;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(var(--safe-bottom) + 16px);
  max-height: 82dvh;
  overflow-y: auto;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .28);
  animation: sheet-up .22s cubic-bezier(.32, .72, 0, 1);
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: none; }
}
.sheet-handle {
  width: 38px;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  margin: 4px auto 12px;
}
.sheet-title {
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
}
.sheet-body { font-size: 14px; color: var(--text-2); line-height: 1.55; }
.sheet-body p + p { margin-top: 8px; }
.sheet-body b { color: var(--text); }
.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.sheet-actions .btn { width: 100%; }
.sheet-field { margin-top: 14px; }
.sheet-field input {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  padding: 0 14px;
  font-size: 17px;
  font-family: var(--mono);
  letter-spacing: .12em;
  text-align: center;
}
.sheet-field input:focus { border-color: var(--danger); outline: none; }

/* ---------- 15. 启动占位 ---------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg);
  color: var(--accent);
}
.boot-text { font-size: 13px; color: var(--text-3); }
.boot.is-hidden { display: none; }

/* ---------- 16. 无障碍 / 降级 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* 横屏（偶尔会碰到）：收紧纵向留白 */
@media (orientation: landscape) and (max-height: 500px) {
  .qr-placeholder { max-width: 170px; }
  .subbar { padding-top: calc(var(--safe-top) + 8px); padding-bottom: 8px; }
  .subbar h1 { font-size: 20px; }
  .pair-stack { gap: 8px; }
}

/* 平板/桌面窗口：居中成手机宽度，避免拉得难看 */
@media (min-width: 620px) {
  body { background: var(--surface-2); }
  .app {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}

/* ---------- 17. 配对码输入框（对应 #pair-input） ---------- */
.pair-input {
  width: 100%;
  height: 58px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  text-align: center;
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .22em;
  text-indent: .22em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}
.pair-input:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}
.pair-input::placeholder {
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: .12em;
  text-indent: .12em;
}

/* ---------- 18. 在线状态（对应 #peer-presence[data-online]） ---------- */
#peer-presence[data-online="1"] { color: var(--ok); }
#peer-presence[data-online="1"] .dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
#peer-presence[data-online="1"] #presence-text { font-weight: 600; }
#peer-presence[data-online="0"] .dot { background: var(--text-3); }

/* 正在输入：默认隐藏，只有 .is-on 才显示 */
.typing-bar { display: none; }
.typing-bar.is-on { display: flex; }

/* ---------- 19. 添加到主屏幕横幅 ---------- */
.install-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--safe-top) + 8px);
  z-index: 55;
  width: calc(100% - 20px);
  max-width: 452px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  color: var(--text-2);
  animation: toast-in .2s ease-out;
}
.install-banner .ico { color: var(--accent); flex: none; }
.install-banner-text {
  flex: 1 1 auto;
  font-size: 13px;
  line-height: 1.4;
  min-width: 0;
}
.install-banner-btn {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--accent-soft);
}

/* ---------- 20. 致命错误红条（不自动消失） ---------- */
.fatal-banner {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: calc(var(--safe-top) + 12px) 14px 12px;
  background: var(--danger);
  color: var(--danger-ink);
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
}
.fatal-banner .ico { color: currentColor; flex: none; }
.fatal-text { flex: 1 1 auto; min-width: 0; }
.fatal-close {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: inherit;
  background: rgba(255, 255, 255, .18);
}

/* ---------- 21. 解锁屏 ---------- */
#screen-unlock .pair-input {
  font-size: 17px;
  letter-spacing: .04em;
  text-indent: 0;
  text-align: left;
  padding: 0 14px;
}
#invite-error.is-error { color: var(--danger); }

/* ---------- 22. 阅后即焚「点击查看」的按压反馈 ---------- */
.bubble.burn:active { background: var(--surface-3); }
.side-me .bubble.burn:active { background: var(--accent-soft); }

/* ---------- 23. 顶栏齿轮 / 返回按钮的触控尺寸 ---------- */
.icon-btn { min-width: 38px; min-height: 38px; }
