:root {
  --bg: #f2f5f4;
  --panel: #ffffff;
  --text: #182522;
  --muted: #687773;
  --line: #dbe4e1;
  --accent: #1f7a68;
  --accent-soft: #e8f5f1;
  --bad: #ba3b34;
  --warn: #b86a00;
  --good: #1f7a68;
  --shadow: 0 4px 16px rgba(23,42,36,.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; height: 100vh; display: flex; flex-direction: column; }

/* ── top bar ── */
.topbar { background: var(--accent); color: #fff; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.topbar h1 { font-size: 16px; font-weight: 600; }
.topbar .sub { font-size: 12px; opacity: .75; }
.topbar-left { display: flex; flex-direction: column; gap: 2px; }
.topbar-nav { display: flex; gap: 8px; align-items: center; }
.topbar-nav a { color: rgba(255,255,255,.8); text-decoration: none; font-size: 13px; padding: 4px 12px; border-radius: 6px; transition: background .15s; }
.topbar-nav a:hover { background: rgba(255,255,255,.15); }
.topbar-nav a.active { background: rgba(255,255,255,.22); color: #fff; font-weight: 600; }

/* ── layout ── */
.layout { display: flex; flex: 1; overflow: hidden; }
.sidebar { width: 320px; flex-shrink: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--panel); }
.main { flex: 1; overflow-y: auto; padding: 20px; }

/* ── session list ── */
.sidebar-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.sidebar-head h2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sessions { overflow-y: auto; flex: 1; }
.session-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.session-item:hover { background: var(--accent-soft); }
.session-item.active { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.session-item .meta { display: flex; gap: 8px; align-items: baseline; }
.session-item .sid { font-size: 12px; font-family: monospace; color: var(--accent); font-weight: 600; }
.session-item .day { font-size: 11px; color: var(--muted); }
.session-item .dur { font-size: 11px; color: var(--muted); margin-left: auto; }
.session-item .texts { font-size: 12px; color: var(--text); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item .badges { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.badge { padding: 1px 6px; border-radius: 999px; font-size: 10px; font-weight: 500; }
.badge.ws   { background: #d4f0e8; color: #1a6e57; }
.badge.seg  { background: #e8eaf6; color: #3949ab; }
.badge.leg  { background: #f5f5f5; color: #757575; }
.badge.bp   { background: #fff8e1; color: #b86a00; }
.badge.pi   { background: #e8f5e9; color: #2e7d32; }
.badge.cnt          { background: var(--accent-soft); color: var(--accent); }
.badge.golden-exec  { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge.ci-test      { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }

/* ── detail panels ── */
.detail-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 15px; }
.card { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-head .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.meta-cell { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.meta-cell .k { font-size: 10px; color: var(--muted); text-transform: uppercase; margin-bottom: 3px; }
.meta-cell .v { font-size: 13px; font-weight: 600; word-break: break-all; }

/* ── audio player ── */
audio { width: 100%; margin-top: 8px; }

/* ── VAD timeline ── */
.timeline-wrap { position: relative; height: 32px; background: var(--bg); border-radius: 6px; overflow: hidden; margin: 10px 0; }
.timeline-seg { position: absolute; top: 4px; height: 24px; border-radius: 4px; cursor: pointer; }
.timeline-seg.sleeping { background: #90a4ae; }
.timeline-seg.awake    { background: var(--accent); }
.timeline-seg.wake_word { background: #26a69a; }
.timeline-cursor { position: absolute; top: 0; width: 2px; height: 100%; background: var(--bad); opacity: .7; pointer-events: none; }

/* ── utterance table ── */
.utbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.utbl th { text-align: left; padding: 6px 8px; font-size: 11px; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--line); letter-spacing: .04em; }
.utbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.utbl tr:hover td { background: var(--accent-soft); }
.utbl tr.clickable { cursor: pointer; }
.vad-range { font-size: 11px; font-family: monospace; color: var(--muted); white-space: nowrap; }
.asr-text { font-weight: 500; }
.wake-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.wake-pill.sleeping    { background: #eceff1; color: #607d8b; }
.wake-pill.awake       { background: var(--accent-soft); color: var(--accent); }
.wake-pill.wake_word   { background: #e0f2f1; color: #00796b; }
.skill-tag { font-size: 11px; font-family: monospace; background: var(--accent-soft); color: var(--accent); padding: 2px 6px; border-radius: 4px; }
.status-ok   { color: var(--good); font-weight: 600; }
.status-err  { color: var(--bad); }
.status-wait { color: var(--muted); }
.tts-text { font-size: 12px; color: var(--muted); font-style: italic; max-width: 200px; }
.action-info { font-size: 11px; color: var(--muted); }
.chain-arrow { color: var(--line); margin: 0 2px; }

/* ── sandbox section ── */
.sandbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; font-size: 12px; }
.sandbox-cell { background: var(--bg); border-radius: 6px; padding: 6px 10px; }
.sandbox-cell .k { font-size: 10px; color: var(--muted); margin-bottom: 2px; }

/* ── loading / empty ── */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-note { color: var(--muted); font-size: 13px; padding: 20px 0; text-align: center; }

/* ── waterfall chart ── */
.wf-legend { display: flex; gap: 14px; align-items: center; font-size: 11px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.wf-legend span { display: flex; align-items: center; gap: 4px; }
.wf-legend-note { margin-left: auto; font-size: 10px; color: var(--muted); font-style: italic; }
.wf-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.wf-vad-dot   { background: #90a4ae; }
.wf-asr-dot   { background: #26a69a; }
.wf-route-dot { background: #7e57c2; }
.wf-tts-dot   { background: #ef6c00; }

.wf-chart { display: flex; flex-direction: column; gap: 8px; }
.wf-row { display: flex; align-items: flex-start; gap: 10px; }
.wf-label { width: 108px; flex-shrink: 0; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-top: 5px; }
.wf-col { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.wf-track { display: flex; height: 24px; border-radius: 4px; overflow: hidden; background: var(--bg); }
.wf-seg { height: 100%; min-width: 0; flex-shrink: 0; }
.wf-seg:hover { opacity: .8; cursor: default; }
.wf-gap   { background: transparent; }
.wf-vad   { background: #90a4ae; }
.wf-asr   { background: #26a69a; }
.wf-route { background: #7e57c2; }
.wf-tts   { background: #ef6c00; }
.wf-stats { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-chain-total { font-weight: 600; color: var(--text); }

.wf-ruler { display: flex; gap: 10px; margin-top: 2px; }
.wf-ruler-inner { flex: 1; position: relative; height: 16px; }
.wf-tick { position: absolute; font-size: 9px; color: var(--muted); transform: translateX(-50%); white-space: nowrap; }
.wf-tick:first-child { transform: none; }
.wf-tick:last-child  { transform: translateX(-100%); }

.wf-legacy-note { font-size: 12px; color: var(--muted); font-style: italic; padding: 8px 0; }

@media (max-width: 700px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: 240px; border-right: none; border-bottom: 1px solid var(--line); }
}

/* ── barge-in (full-duplex) ──────────────────────────────────── */
.bi-list { display: flex; flex-direction: column; gap: 10px; }
.bi-case { background: var(--bg); border-radius: 8px; padding: 10px 12px; border-left: 3px solid var(--warn); }
.bi-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.bi-idx { font-weight: 600; color: var(--warn); font-size: 13px; }
.bi-tts { font-family: monospace; font-size: 11px; background: #fff3e0; color: #ef6c00; padding: 2px 6px; border-radius: 4px; }
.bi-cut { font-size: 11px; color: var(--muted); }
.bi-line { font-size: 12px; color: var(--text); margin-top: 3px; line-height: 1.5; }
.bi-clk { display: inline-block; width: 48px; font-size: 10px; color: #fff; background: var(--accent); border-radius: 3px; text-align: center; padding: 1px 0; margin-right: 8px; }
.bi-clk.edge { background: #7e57c2; }
.bi-metric { font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.bi-metric.bi-good { color: var(--good); background: var(--accent-soft); }
.bi-metric.bi-warn { color: var(--warn); background: #fff3e0; }
.bi-metric.bi-bad  { color: var(--bad); background: #fdecea; }
.bi-target { font-size: 10px; color: var(--muted); margin-left: 4px; }
.bi-na { color: var(--muted); font-style: italic; font-size: 11px; }
.bi-tag { font-size: 10px; font-weight: 600; color: var(--warn); background: #fff3e0; padding: 1px 5px; border-radius: 4px; white-space: nowrap; }
.bi-clk.comp { background: var(--warn); }
