:root {
  --bg: #0e1218;
  --panel: #171d26;
  --panel2: #1f2732;
  --line: #2b3542;
  --text: #e9eef4;
  --muted: #8d9aab;
  --accent: #ffb020;
  --accent-ink: #1a1200;
  --good: #3ecf8e;
  --warn: #ffb020;
  --bad: #ff5d5d;
  --heard: #6aa7ff;
  --radius: 14px;
  --tap: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f8; --panel: #ffffff; --panel2: #eef1f5; --line: #d8dee6;
    --text: #121820; --muted: #5d6b7c; --accent: #e08a00; --accent-ink: #fff;
    --heard: #2f6fd6;
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(68px + var(--safe-b));
  overscroll-behavior-y: none;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select {
  width: 100%; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; min-height: 48px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.f { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.mono, .call { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; text-decoration: none; font-size: 18px; }
.pill {
  border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 6px 12px; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill[data-state="synced"]::before { background: var(--good); }
.pill[data-state="syncing"]::before { background: var(--warn); animation: pulse 1s infinite; }
.pill[data-state="local"]::before { background: var(--warn); }
.pill[data-state="error"]::before { background: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }

main { padding: 16px; max-width: 720px; margin: 0 auto; outline: none; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
  padding: 0 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel2);
  font-weight: 600; cursor: pointer; text-decoration: none; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.big { min-height: 76px; font-size: 20px; border-radius: 18px; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn.ghost { background: transparent; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 60px; text-decoration: none;
  border-bottom: 1px solid var(--line); cursor: pointer; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left;
}
.item:last-child { border-bottom: 0; }
.item:active { background: var(--panel2); }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .r { font-size: 13px; color: var(--muted); text-align: right; flex: none; }
.empty { padding: 18px; text-align: center; color: var(--muted); }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--panel);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60px;
  text-decoration: none; font-size: 11px; color: var(--muted);
}
.tabbar a .ti { font-size: 18px; line-height: 1.2; }
.tabbar a.on { color: var(--accent); }

/* Session */
.freq {
  width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 64px;
}
.freq .fq { font-size: 22px; font-weight: 700; }
.freq .fn { color: var(--muted); font-size: 14px; }
.freq .chev { margin-left: auto; color: var(--muted); }
.timer { font-variant-numeric: tabular-nums; font-size: 15px; color: var(--muted); }
.timer.live { color: var(--good); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-height: 54px;
  padding: 6px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); cursor: pointer;
}
.chip .call { font-weight: 700; font-size: 16px; }
.chip .nm { font-size: 12px; color: var(--muted); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.heard { border-style: dashed; }
.chip.heard .call { color: var(--heard); }
.chip.sel { border-color: var(--accent); border-style: solid; background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.chip.add { align-items: center; color: var(--accent); border-style: dashed; font-weight: 700; }
.profile .call { font-size: 26px; font-weight: 800; }
.profile .nm { font-size: 20px; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; letter-spacing: 0; }
.stats { display: flex; gap: 8px; margin: 10px 0; }
.stat { flex: 1; background: var(--panel2); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 16px; }
.stat span { font-size: 12px; color: var(--muted); }
.seg { display: flex; background: var(--panel2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 8px; background: transparent; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.3); color: var(--accent); }
.notes-pnl { background: color-mix(in srgb, var(--accent) 10%, var(--panel2)); border-radius: 10px; }
.endbar {
  position: sticky; bottom: calc(68px + var(--safe-b)); padding: 10px 0 0; background: linear-gradient(transparent, var(--bg) 30%);
}
.prev { font-size: 14px; padding: 8px 0; border-top: 1px solid var(--line); }
.prev:first-child { border-top: 0; }
.tag { display: inline-block; font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.tag.heard { color: var(--heard); }
.star { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); min-width: 44px; min-height: 44px; }
.star.on { color: var(--accent); }

/* Sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto; background: var(--panel);
  border-radius: 20px 20px 0 0; padding: 14px 16px calc(18px + var(--safe-b)); max-width: 720px; margin: 0 auto;
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
.sheet h3 { margin: 4px 0 12px; font-size: 18px; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; }
.tabs button { flex: none; min-height: 40px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel2); font-weight: 600; cursor: pointer; }
.tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw;
}
