:root {
  --bg: #0b0b10; --panel: #15151d; --line: #262633; --text: #ececf3; --muted: #8d8da0;
  --accent: #8b7bff; --live: #ff4d5e; --ok: #3ddc97; --warn: #ffb547;
  --radius: 16px; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.muted { color: var(--muted); } .small { font-size: 13px; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.icon-btn { font-size: 20px; width: 36px; height: 36px; border-radius: 10px; }
.brand { font-weight: 650; display: flex; align-items: center; gap: 8px; flex: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.mode { display: flex; background: var(--panel); border-radius: 10px; padding: 3px; }
.mode button { padding: 6px 14px; border-radius: 8px; font-size: 14px; color: var(--muted); }
.mode button[aria-selected="true"] { background: var(--line); color: var(--text); }

.menu { display: grid; gap: 4px; padding: 8px 16px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.menu a, .menu button { text-align: left; padding: 10px 0; color: var(--text); }

.gate { max-width: 420px; margin: 18vh auto 0; padding: 0 16px; text-align: center; }
.gate form { display: flex; gap: 8px; margin-top: 16px; }
.gate input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 16px; }
.gate button { padding: 12px 16px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; }
.err { color: var(--live); min-height: 1.4em; }

main { max-width: 640px; margin: 0 auto; padding: 0 16px 40px; }
.pane { padding: 22px 0 8px; text-align: center; }
.listen { position: relative; width: 168px; height: 168px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #2a2550, #15151d 70%); border: 1px solid var(--line); display: grid; place-items: center; margin: 0 auto; }
.listen .label { font-weight: 600; z-index: 1; padding: 0 18px; }
.listen .ring { position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--accent); opacity: .35; }
.listen[aria-pressed="true"] { background: radial-gradient(circle at 50% 40%, #5a1f2a, #15151d 70%); }
.listen[aria-pressed="true"] .ring { border-color: var(--live); animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity: .7 } 100% { transform: scale(1.18); opacity: 0 } }
.hint { color: var(--muted); font-size: 14px; margin: 14px auto 0; max-width: 34ch; }

.bridge { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px; }
.step { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.step > span { flex: 1; min-width: 0; }
.step > b:first-child { width: 24px; height: 24px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 13px; flex: none; }
#bridgeNum { font-weight: 650; font-size: 18px; font-variant-numeric: tabular-nums; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; color: var(--text); background: var(--panel); }

body.is-live .pane { display: none; }
body.is-live .live { position: sticky; top: 57px; z-index: 4; }
.live { display: flex; align-items: center; gap: 10px; margin: 16px 0 4px; padding: 10px 14px; border-radius: 12px; background: #2a1218; border: 1px solid #5a1f2a; font-size: 14px; }
.live span#liveText { flex: 1; }
.rec { width: 10px; height: 10px; border-radius: 50%; background: var(--live); animation: blink 1.2s infinite; flex: none; }
@keyframes blink { 50% { opacity: .3 } }

.transcript { margin: 12px 0; max-height: 118px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 14px; color: var(--muted); mask-image: linear-gradient(to bottom, transparent, #000 40%); }
.transcript p { margin: 2px 0; }
.transcript .draft { font-style: italic; opacity: .7; }
.transcript .spk { color: var(--accent); font-size: 12px; margin-right: 6px; }

.cards h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; }
.empty { text-align: center; font-size: 14px; margin-top: 28px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; animation: in .25s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(6px) } }
.card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card h3 { margin: 0; font-size: 18px; line-height: 1.25; }
.identity { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.why { margin: 8px 0 0; font-size: 14px; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--line); color: var(--muted); white-space: nowrap; }
.badge.verified { color: var(--ok); } .badge.ambiguous, .badge.unverified { color: var(--warn); } .badge.failed { color: var(--live); }
.badge.resolving::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; border: 2px solid var(--muted); border-top-color: transparent; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg) } }
.card.resolving .why { color: var(--muted); }
.liminal { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.liminal li { font-size: 14px; padding: 8px 10px; border-radius: 10px; background: #1d1a33; border-left: 3px solid var(--accent); }
.liminal time { display: block; font-size: 12px; color: var(--accent); font-weight: 600; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.links a { font-size: 13px; padding: 6px 11px; border-radius: 999px; background: var(--line); color: var(--text); }
.links a.review { background: #2a2416; }
.more { margin-top: 10px; font-size: 14px; }
.more summary { color: var(--muted); cursor: pointer; font-size: 13px; }
.facts { padding-left: 18px; margin: 8px 0; } .facts li { margin: 4px 0; }
.facts a, .sources a { font-size: 12px; }
.sources { padding-left: 18px; color: var(--muted); font-size: 12px; word-break: break-all; }
.alts p { margin: 6px 0; font-size: 13px; }
.card footer { display: flex; gap: 4px; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.card footer button { font-size: 13px; color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.card footer button:active { background: var(--line); }
.card.pinned { border-color: var(--accent); }
.card.dismissed { display: none; }

#sessionsList .row { display: block; width: 100%; text-align: left; padding: 12px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 380px) { .mode button { padding: 6px 10px; } .listen { width: 148px; height: 148px; } }
.card.faint { opacity: .55; }
