:root {
  --bg: #070D12; --panel: rgba(14, 26, 35, .9); --line: #1B2A36; --line2: #22313F;
  --ink: #F2F6F8; --text: #DCE6EC; --muted: #A9B8C3; --dim: #8A9BA8;
  --copper: #C8693A; --copper-text: #D9804F; --ice: #8FC3D9; --ice-text: #CFE7F2;
  --accent: var(--copper); --accent-text: var(--copper-text);
}
body[data-persona="marshall"] { --accent: var(--ice); --accent-text: var(--ice); }
body[data-persona="pepper"] { --accent: #B9A3E3; --accent-text: #CDBDF0; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; }
body {
  background-image: linear-gradient(rgba(143,195,217,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(143,195,217,.045) 1px, transparent 1px);
  background-size: 32px 32px; overscroll-behavior: none;
}
.mono { font-family: 'JetBrains Mono', monospace; letter-spacing: .1em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.dim { color: var(--dim); font-size: 10px; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* login */
.screen { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.login-box h1 { font: 600 28px 'Chakra Petch', sans-serif; letter-spacing: .24em; color: var(--ink); margin: 12px 0 0; }
.login-box p.mono { font-size: 10px; color: var(--muted); margin: 0 0 24px; }
.login-box form { width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.login-box label { font-size: 13px; color: var(--muted); }
input { width: 100%; min-height: 48px; padding: 0 14px; background: #0A141B; border: 1px solid var(--line2); color: var(--ink); font: 16px Inter, sans-serif; border-radius: 0; }
input:focus { outline: 2px solid var(--copper); outline-offset: 0; }
.primary { min-height: 48px; border: 0; background: var(--copper); color: #070D12; font-weight: 600; letter-spacing: .04em; }
.primary.small { min-height: 44px; padding: 0 16px; }
.note { font-size: 14px; color: var(--muted); line-height: 1.5; min-height: 1.5em; }

/* frame */
#app { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; padding: max(16px, env(safe-area-inset-top)) 18px 12px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font: 600 19px 'Chakra Petch', sans-serif; letter-spacing: .22em; color: var(--ink); }
.brand .sub { font-size: 9.5px; color: var(--muted); }
.logo { width: 56px; height: 56px; border: 2px solid var(--copper); transform: rotate(45deg); display: flex; align-items: center; justify-content: center; }
.logo span { transform: rotate(-45deg); font: 700 24px 'Chakra Petch', sans-serif; color: var(--copper-text); }
.logo.small { width: 32px; height: 32px; border-width: 1.5px; }
.logo.small span { font-size: 14px; }
.chip { font-size: 11px; color: var(--ice); border: 1px solid var(--line2); padding: 6px 8px; }
main { flex: 1; min-height: 0; overflow: hidden; display: flex; }
.tab { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
#tab-teams, #tab-calls { padding: 14px 16px 20px; gap: 10px; }

/* talk */
.core-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0 4px; flex: none; }
.core { position: relative; width: 168px; height: 168px; }
.core svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.core circle { fill: none; transform-origin: 95px 95px; }
.ring-dash { stroke: var(--line2); stroke-width: 1; stroke-dasharray: 2 4; }
.ring-a { stroke: var(--accent); stroke-width: 3; stroke-dasharray: 70 30 90 40 60 187; animation: spin 18s linear infinite; }
.ring-b { stroke: var(--ice); stroke-width: 1.5; stroke-dasharray: 40 120 30 200; animation: spin 26s linear infinite reverse; }
.ring-c { fill: #0E1A23 !important; stroke: var(--accent); stroke-width: 1.5; }
body[data-state="listening"] .ring-a { animation-duration: 3s; }
body[data-state="thinking"] .ring-a, body[data-state="thinking"] .ring-b { animation-duration: 1.4s; }
body[data-state="speaking"] .ring-c { animation: pulse 1s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { stroke-width: 5; } }
#core-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding-left: 4px; font: 600 15px 'Chakra Petch', sans-serif; letter-spacing: .24em; color: var(--ink); }
body[data-persona="marshall"] #core-label { color: var(--ice-text); font-size: 14px; }
body[data-persona="pepper"] #core-label { color: #E4DAF8; }
.state { font-size: 11px; letter-spacing: .3em; color: var(--accent-text); }
.hint { font-size: 13px; color: var(--muted); text-align: center; padding: 0 20px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 8px 16px; flex: none; }
.stats div { border: 1px solid var(--line); background: var(--panel); padding: 9px 10px; display: flex; flex-direction: column; gap: 2px; }
.stats span { font-size: 9.5px; color: var(--muted); }
.stats b { font: 500 21px 'Chakra Petch', sans-serif; color: var(--ink); }
.stats b.ice { color: var(--ice); } .stats b.copper { color: var(--copper-text); }
.convo { flex: 1; min-height: 80px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px 16px; }
.msg { max-width: 88%; display: flex; flex-direction: column; gap: 4px; }
.msg .who { font: 10px 'JetBrains Mono', monospace; letter-spacing: .14em; }
.msg p { margin: 0; padding: 10px 12px; font-size: 15px; line-height: 1.45; color: var(--ink); white-space: pre-line; }
.msg.you { align-self: flex-end; }
.msg.you p { background: #0E1A23; border: 1px solid var(--line2); }
.msg.jarvis .who { color: var(--copper-text); }
.msg.jarvis p { background: rgba(200,105,58,.08); border: 1px solid rgba(200,105,58,.45); }
.msg.marshall .who { color: var(--ice); }
.msg.marshall p { background: rgba(143,195,217,.08); border: 1px solid rgba(143,195,217,.45); }
.msg.pepper .who { color: #CDBDF0; }
.msg.pepper p { background: rgba(185,163,227,.08); border: 1px solid rgba(185,163,227,.45); }
.msg.sys p { color: var(--muted); font-size: 13px; border: 1px dashed var(--line2); }
.type-row { display: flex; gap: 8px; padding: 6px 16px; flex: none; }
.controls { display: flex; align-items: center; justify-content: space-between; padding: 10px 32px 14px; flex: none; }
.round { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line2); background: #0E1A23; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.round svg { width: 22px; height: 22px; }
.persona-btns { display: flex; flex-direction: column; gap: 8px; }
.persona-btns .round { width: 46px; height: 46px; }
.persona-btn { font: 600 16px 'Chakra Petch', sans-serif; }
.persona-btn[data-to="marshall"] { color: var(--ice); }
.persona-btn[data-to="pepper"] { color: #CDBDF0; }
.persona-btn[data-to="jarvis"] { color: var(--copper-text); }
.mic { width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--copper); color: #070D12; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 0 0 8px rgba(200,105,58,.16), 0 0 0 18px rgba(200,105,58,.06); transition: transform .1s; }
.mic:active { transform: scale(.96); }
.mic svg { width: 38px; height: 38px; stroke-width: 2; }
.mic .i-stop { display: none; fill: currentColor; stroke: none; width: 28px; height: 28px; }
.mic-label { font-size: 10px; letter-spacing: .16em; }
body[data-state="listening"] .mic { background: #E0794A; animation: ring 1.2s ease-out infinite; }
body[data-state="speaking"] .mic, body[data-state="thinking"] .mic { background: #0E1A23; color: var(--ice-text); border: 2px solid var(--accent); }
body[data-state="speaking"] .mic .i-mic, body[data-state="thinking"] .mic .i-mic, body[data-state="listening"] .mic .i-mic { display: none; }
body[data-state="speaking"] .mic .i-stop, body[data-state="thinking"] .mic .i-stop, body[data-state="listening"] .mic .i-stop { display: block; }
body[data-state="listening"] .mic .i-stop { color: #070D12; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(224,121,74,.5); } 100% { box-shadow: 0 0 0 26px rgba(224,121,74,0); } }

/* tabs */
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); background: #0A141B; padding-bottom: env(safe-area-inset-bottom); }
.tabs button { position: relative; background: none; border: 0; border-top: 2px solid transparent; padding: 10px 0 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px; font: 10px 'JetBrains Mono', monospace; letter-spacing: .1em; min-height: 56px; }
.tabs button svg { width: 20px; height: 20px; }
.tabs button.on { color: var(--copper-text); border-top-color: var(--copper); }
.badge { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--copper); color: #070D12; font: 600 11px Inter, sans-serif; display: flex; align-items: center; justify-content: center; }

/* teams */
.card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); background: var(--panel); padding: 10px 12px; }
.card.indent { margin-left: 16px; }
.card.chief { border-color: var(--copper); background: rgba(200,105,58,.08); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3A4A57; margin-top: 6px; flex: none; }
.dot.working { background: var(--copper); } .dot.idle { background: var(--ice); } .dot.needs_you { background: #E9A23B; }
.card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card .head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card .nm { font-size: 15px; font-weight: 600; color: var(--ink); }
.card .rl { font-size: 12px; font-weight: 400; color: var(--muted); }
.card .st { font-size: 10px; color: var(--muted); }
.card .st.working, .card .st.needs_you { color: var(--copper-text); }
.card .tk { font-size: 13px; line-height: 1.35; color: var(--dim); }
.card .tk.live { color: var(--text); }
.team-head { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 12px 0 4px; min-height: 44px; text-align: left; color: var(--ink); }
.team-head .chev { color: var(--copper-text); font-size: 12px; width: 12px; }
.team-head .tn { flex: 1; font: 12px 'JetBrains Mono', monospace; letter-spacing: .14em; }
.team-head .tc { font: 11px 'JetBrains Mono', monospace; color: var(--muted); }
.team-head .nb { font: 10px 'JetBrains Mono', monospace; color: #070D12; background: #E9A23B; padding: 2px 6px; }
.offline-line { margin-left: 16px; border: 1px dashed var(--line2); padding: 9px 12px; font-size: 13px; color: var(--muted); }

/* calls */
.panel { border: 1px solid var(--line); background: var(--panel); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; justify-content: space-between; align-items: baseline; }
.row.pad { padding-top: 6px; }
h2 { margin: 0; font-size: 11px; letter-spacing: .16em; color: var(--ink); font-weight: 500; }
.funnel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.bar { display: flex; flex-direction: column; gap: 4px; }
.bar .l { display: flex; justify-content: space-between; font-size: 13px; }
.bar .l b { font: 400 13px 'JetBrains Mono', monospace; color: var(--ink); }
.bar .t { height: 4px; background: var(--line); }
.bar .f { height: 4px; background: var(--ice); }
.bar.c .f { background: var(--copper); }
.call { border: 1px solid var(--line); background: var(--panel); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.call .top2 { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.call .nm { font-size: 15px; font-weight: 600; color: var(--ink); }
.call .sub { font-size: 13px; color: var(--muted); }
.call .why { font-size: 12px; color: var(--dim); }
.dial { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--copper); color: #070D12; display: flex; align-items: center; justify-content: center; }
.dial svg { width: 20px; height: 20px; stroke-width: 2; }
.outs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.outs button { min-height: 44px; border: 1px solid var(--line2); background: #0A141B; color: var(--text); font-size: 12px; padding: 0 2px; }
.outs button.on { background: var(--ice); color: #070D12; border-color: var(--ice); }
.done-tag { font: 10px 'JetBrains Mono', monospace; color: var(--ice); letter-spacing: .12em; }
.appr { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.appr:first-child { border-top: 0; padding-top: 0; }
.appr .ag { font: 10px 'JetBrains Mono', monospace; letter-spacing: .12em; color: var(--dim); text-transform: uppercase; }
.appr .ti { font-size: 14px; font-weight: 600; color: var(--ink); }
.appr .de { font-size: 13px; line-height: 1.45; color: var(--muted); white-space: pre-line; max-height: 8.7em; overflow: hidden; }
.appr .de.open { max-height: none; }
.appr .more { align-self: flex-start; background: none; border: 0; padding: 4px 0; color: var(--copper-text); font: 11px 'JetBrains Mono', monospace; letter-spacing: .1em; min-height: 32px; }
.appr .acts { display: flex; gap: 8px; margin-top: 4px; }
.appr .acts button { flex: 1; min-height: 44px; border: 1px solid var(--line2); background: transparent; color: var(--text); font-size: 13px; letter-spacing: .08em; }
.appr .acts button.go { border: 0; background: var(--copper); color: #070D12; font-weight: 600; }
.brief { border-left: 2px solid var(--ice); padding: 8px 12px; font-size: 13px; line-height: 1.5; color: var(--muted); white-space: pre-line; }
.brief b { display: block; font: 10px 'JetBrains Mono', monospace; letter-spacing: .14em; color: var(--ice); margin-bottom: 4px; }
.empty { font-size: 13px; color: var(--dim); padding: 6px 0; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); background: #0E1A23; border: 1px solid var(--copper); color: var(--ink); padding: 12px 14px; font-size: 14px; z-index: 10; }
