:root {
  --bg: #0d0f14;
  --surface: #151820;
  --surface-2: #1b1f29;
  --surface-3: #232836;
  --border: #2a3040;
  --text: #eef0f5;
  --muted: #9aa3b5;
  --faint: #6d7588;
  --red: #c8102e;
  --red-hover: #e0213f;
  --red-soft: rgba(200, 16, 46, 0.14);
  --green: #3fbf8a;
  --green-soft: rgba(63, 191, 138, 0.14);
  --amber: #e2a93b;
  --amber-soft: rgba(226, 169, 59, 0.14);
  --blue: #6aa6ff;
  --blue-soft: rgba(106, 166, 255, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 19px;
  --text-xl: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--red-hover); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- sign in ---- */
.login-wrap { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 28px;
}
.login-card .brand { margin-bottom: 20px; }
.login-card p { color: var(--muted); font-size: var(--text-sm); margin-bottom: 20px; }

/* ---- shell ---- */
.app { display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(13, 15, 20, 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: var(--text-lg); letter-spacing: -0.01em; }
.brand svg { width: 32px; height: 32px; flex: none; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.bad { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.tabs { display: flex; gap: 4px; margin-left: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; }
.tab {
  border: 0; background: transparent; color: var(--muted); padding: 8px 16px; border-radius: 999px;
  font-size: var(--text-sm); font-weight: 600; white-space: nowrap; min-height: 40px;
}
.tab[aria-selected="true"] { background: var(--red); color: #fff; }
.tab:not([aria-selected="true"]):hover { color: var(--text); background: var(--surface-2); }
.signout { border: 0; background: transparent; color: var(--faint); font-size: var(--text-sm); padding: 8px; min-height: 40px; }
.signout:hover { color: var(--text); }
main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 20px; }
.footer { text-align: center; color: var(--faint); font-size: var(--text-xs); padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }

/* ---- shared bits ---- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-pad { padding: 20px; }
h2 { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 8px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.banner { border-radius: var(--radius-sm); padding: 10px 14px; font-size: var(--text-sm); margin-bottom: 16px; }
.banner.error { background: var(--red-soft); color: #ffb3bf; border: 1px solid rgba(200, 16, 46, 0.4); }
.banner.ok { background: var(--green-soft); color: #9de8c6; border: 1px solid rgba(63, 191, 138, 0.35); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.in { background: var(--blue-soft); color: var(--blue); }
.pill.out { background: var(--green-soft); color: var(--green); }
.pill.fail { background: var(--red-soft); color: #ff8a9c; }
.pill.wait { background: var(--amber-soft); color: var(--amber); }
.pill.plain { background: var(--surface-3); color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: var(--text-sm);
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-hover); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 6px 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: var(--text-sm); font-weight: 600; }
.field .hint { font-size: var(--text-xs); color: var(--faint); }
.input {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: var(--text-base); min-height: 46px;
}
.input:focus { border-color: var(--red); outline: none; box-shadow: 0 0 0 3px var(--red-soft); }
textarea.input { min-height: 150px; resize: vertical; line-height: 1.5; }
select.input { color: var(--text); }
select.input option { background: var(--surface); color: var(--text); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: var(--text-lg); margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- calls ---- */
.calls-layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 20px; align-items: start; }
.call-list-panel { position: sticky; top: 84px; max-height: calc(100dvh - 104px); display: flex; flex-direction: column; overflow: hidden; }
.list-tools { padding: 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 6px; }
.chip { border: 1px solid var(--border); background: transparent; color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: var(--text-xs); font-weight: 600; min-height: 32px; }
.chip[aria-pressed="true"] { background: var(--surface-3); color: var(--text); border-color: var(--faint); }
.call-list { overflow-y: auto; flex: 1; }
.call-item {
  display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; padding: 14px 16px; color: var(--text);
}
.call-item:hover { background: var(--surface-2); }
.call-item[aria-current="true"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--red); }
.call-item .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 4px; }
.call-item .who { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-item .when { font-size: var(--text-xs); color: var(--faint); white-space: nowrap; }
.call-item .snippet { font-size: var(--text-sm); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.call-item .meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: var(--text-xs); color: var(--faint); }

.detail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.detail-head { padding: 20px; }
.detail-head h2 { font-size: var(--text-xl); margin: 8px 0 4px; }
.back { display: none; }
.player { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.player audio { width: 100%; height: 44px; }
.player .note { font-size: var(--text-sm); color: var(--muted); }
.summary { padding: 20px; font-size: var(--text-base); }
.picked { padding: 20px; display: grid; gap: 16px; }
.picked .item p { white-space: pre-wrap; }
.brief { padding: 20px; border-left: 3px solid var(--green); }
.brief p { white-space: pre-wrap; }
.transcript { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.line { display: flex; flex-direction: column; max-width: 82%; }
.line .bubble { padding: 10px 14px; border-radius: 14px; font-size: var(--text-base); line-height: 1.45; white-space: pre-wrap; }
.line .stamp { font-size: var(--text-xs); color: var(--faint); margin: 3px 6px 0; border: 0; background: none; padding: 0; text-align: left; }
.line .stamp:hover { color: var(--text); text-decoration: underline; }
.line.hank { align-self: flex-start; }
.line.hank .bubble { background: var(--surface-3); border-bottom-left-radius: 4px; }
.line.caller { align-self: flex-end; align-items: flex-end; }
.line.caller .bubble { background: var(--red-soft); border: 1px solid rgba(200, 16, 46, 0.35); border-bottom-right-radius: 4px; }
.line.playing .bubble { box-shadow: 0 0 0 2px var(--amber); }
.speaker { font-size: var(--text-xs); color: var(--faint); margin: 0 6px 3px; font-weight: 600; }

/* ---- call someone ---- */
.call-layout { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 20px; align-items: start; }
.campaign { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.campaign:last-child { border-bottom: 0; }
.campaign .top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.campaign .name { font-weight: 650; font-size: var(--text-base); }
.campaign .phone { font-size: var(--text-sm); color: var(--muted); }
.campaign .brief-text { font-size: var(--text-sm); color: var(--muted); white-space: pre-wrap; margin: 6px 0 10px; }
.campaign .result { font-size: var(--text-sm); background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.campaign .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 900px) {
  main { padding: 14px; }
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .tab { flex: 1; }
  .signout { margin-left: auto; }
  .calls-layout, .call-layout { grid-template-columns: 1fr; }
  .call-list-panel { position: static; max-height: none; }
  .calls-layout.has-detail .call-list-panel { display: none; }
  .calls-layout:not(.has-detail) .detail { display: none; }
  .back { display: inline-flex; align-self: flex-start; }
  .line { max-width: 92%; }
}

/* Hank's notebook */
.code-state { display: inline-block; font-size: var(--text-sm); font-weight: 600; border-radius: 999px; padding: 4px 12px; margin-bottom: 16px; }
.code-state.set { background: var(--green-soft); color: #9de8c6; }
.code-state.unset { background: var(--red-soft); color: #ffb3bf; }
.note-item { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.note-item p { margin: 0 0 8px; white-space: pre-wrap; }
.note-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: var(--text-xs); }
.note-meta .faint { margin-right: auto; }
/* Live listen-in bar */
.livebar { width: 100%; max-width: 1280px; margin: 0 auto; padding: 12px 20px 0; }
.livebar .live-inner {
  display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px;
}
.livebar.idle .live-inner { padding: 8px 16px; }
.livebar.on .live-inner { border-color: rgba(200, 16, 46, 0.55); background: linear-gradient(0deg, var(--red-soft), var(--red-soft)), var(--surface); }
.live-quiet { color: var(--faint); font-size: var(--text-sm); }
.live-rows { display: flex; flex-direction: column; gap: 10px; flex: 1 1 420px; min-width: 0; }
.live-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); flex: none; box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.6); animation: livepulse 1.6s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.55); } 70% { box-shadow: 0 0 0 9px rgba(200, 16, 46, 0); } 100% { box-shadow: 0 0 0 0 rgba(200, 16, 46, 0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.live-who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; }
.live-who strong { font-size: var(--text-base); overflow-wrap: anywhere; }
.live-sub { font-size: var(--text-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.live-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.live-vol input { width: 110px; accent-color: var(--red); vertical-align: middle; }
.live-note { font-size: var(--text-sm); color: var(--muted); }
.live-auto { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; font-size: var(--text-sm); color: var(--muted); cursor: pointer; min-height: 36px; }
.live-auto input { width: 18px; height: 18px; accent-color: var(--red); }
@media (max-width: 900px) { .livebar { padding: 10px 14px 0; } }
@media (max-width: 600px) { .live-auto { margin-left: 0; } }
.tab .short { display: none; }
@media (max-width: 600px) {
  .tab .long { display: none; }
  .tab .short { display: inline; }
}
@media (max-width: 600px) {
  .tab { padding: 8px 6px; font-size: 13px; }
  .tabs { gap: 2px; }
}
/* Hank's skills */
.skills-layout { max-width: 880px; margin: 0 auto; }
.skill-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; }
.skill-card h3 { margin-bottom: 6px; font-size: var(--text-lg); font-weight: 700; color: var(--text); text-transform: none; letter-spacing: normal; }
.skill-card p { color: var(--muted); font-size: var(--text-sm); margin-bottom: 12px; line-height: 1.55; }
.skill-card a.btn { text-decoration: none; }
.skill-phrase { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; border-top: 1px dashed var(--border); padding-top: 10px; }
.phrase-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.phrase-text { font-size: var(--text-sm); color: var(--text); font-weight: 600; }
@media (max-width: 560px) { .skill-phrase { flex-direction: column; gap: 4px; } }
@media (max-width: 600px) {
  .tab .long { display: none; }
  .tab .short { display: inline; }
  .tab { padding: 8px 5px; font-size: 12px; }
}
