:root {
  --bg: #faf9f6; --card: #ffffff; --surface: #f1efe8; --text: #1d1d1b; --muted: #6b6a65;
  --line: #dedcd3; --line-strong: #b9b7ad; --accent: #2d63b8; --accent-bg: #e6f0fb; --accent-text: #173f78;
  --danger: #b3261e; --ok: #1d7a4f; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --card: #222220; --surface: #2b2b28; --text: #f2f1ec; --muted: #a3a29a;
    --line: #3a3a36; --line-strong: #5a5a54; --accent: #7fb0f0; --accent-bg: #1f3352; --accent-text: #cfe1fb; --ok: #6fcf97;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { padding-bottom: 76px; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; max-width: 560px; margin: 0 auto; }
.brand { font-weight: 600; text-decoration: none; color: var(--text); font-size: 18px; }
.who { color: var(--muted); font-size: 13px; }
.view { max-width: 560px; margin: 0 auto; padding: 0 16px 24px; }
h1 { font-size: 26px; line-height: 1.2; margin: 16px 0 8px; }
h2 { font-size: 20px; margin: 16px 0 8px; }
h3 { font-size: 16px; margin: 20px 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.q { font-size: 17px; font-weight: 600; margin: 12px 0 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card.done { border-color: var(--ok); }
label { display: block; font-size: 14px; margin: 8px 0 12px; }
label input { display: block; width: 100%; margin-top: 6px; font: inherit; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); color: var(--text); min-height: 44px; }
input[type="search"] { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); color: var(--text); min-height: 44px; }
button, .button { font: inherit; font-size: 15px; min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button.primary, .button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
button:active { transform: scale(.98); }
button[disabled] { opacity: .6; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { border-radius: 999px; padding: 10px 14px; min-height: 44px; }
.chip.on { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent); }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.av { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-text); font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.av.big { width: 44px; height: 44px; font-size: 14px; }
.chain { margin: 6px 0; }
.pnode { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.pname { font-weight: 500; }
.hop { display: flex; align-items: center; gap: 12px; }
.hop .line { width: 2px; height: 22px; margin-left: 13px; background: var(--line-strong); flex: none; }
.hoplabel { font-size: 13px; color: var(--muted); }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions button { flex: 1; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.nav a { flex: 1; text-align: center; padding: 12px 4px 14px; font-size: 13px; color: var(--muted); text-decoration: none; }
.nav a.on { color: var(--accent); font-weight: 600; }
.badge { display: inline-block; background: var(--danger); color: #fff; font-size: 11px; border-radius: 999px; padding: 0 6px; line-height: 16px; vertical-align: 2px; }
.toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 10; max-width: 90vw; }
.empty { text-align: center; padding: 40px 8px; }
.bar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.slider { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.slider input { flex: 1; min-width: 0; }
.treewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 8px; -webkit-overflow-scrolling: touch; }
.treewrap svg { display: block; }
.node rect { fill: var(--card); stroke: var(--line-strong); stroke-width: 1; }
.node text { pointer-events: none; }
.n-root rect { fill: var(--accent-bg); stroke: var(--accent); }
.n-hub rect { fill: var(--surface); stroke-dasharray: 4 3; }
.n-person { cursor: pointer; }
.n-person.unconfirmed rect { stroke-dasharray: 2 2; }
.node text.t { font-size: 13px; font-weight: 500; fill: var(--text); }
.node text.s { font-size: 11px; fill: var(--muted); }
.n-root text.t { fill: var(--accent-text); }
.edge { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.future { opacity: .12; }
.node, .edge { transition: opacity .3s; }
.linkbox { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.linkbox input { flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle input { width: 22px; height: 22px; }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.stack { display: grid; gap: 8px; }
.stack .button, .stack button { width: 100%; }
body.screen-mode { padding-bottom: 0; }
.screen-mode .top, .screen-mode .nav { display: none; }
.screen-mode .view { max-width: none; padding: 24px 32px; }
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 16px; }
.screen-head h1 { font-size: 36px; margin: 0; }
.qr { display: flex; align-items: center; gap: 16px; }
.qr svg { width: 128px; height: 128px; background: #fff; border-radius: 8px; }
.qr .url { font-size: 20px; font-weight: 500; word-break: break-all; }
.screen-mode .treewrap svg { width: 100%; height: auto; }
.screen-mode .node text.t { font-size: 14px; }

[hidden] { display: none !important; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.tile { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 24px; font-weight: 600; line-height: 1.2; margin-top: 2px; }
.tile .s { font-size: 12px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.otp input[name="code"] { font-size: 22px; letter-spacing: 6px; text-align: center; }
.pill { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface); color: var(--muted); }
.pill.ok { background: var(--accent-bg); color: var(--accent-text); }
.dev { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--surface); padding: 6px 10px; border-radius: 8px; display: inline-block; }

.value { margin: 12px 0 4px; }
.vrow { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; }
.vicon { width: 34px; height: 34px; border-radius: 17px; background: var(--accent-bg); color: var(--accent-text); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.social { width: 100%; }
.social-slot { display: flex; justify-content: center; min-height: 44px; }
button.on { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-text); }
