/* Mirrachat admin workspace — "Teal & Ink" */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --bg: #F2F6F6;
  --surface: #FFFFFF;
  --surface-2: #F7FAFA;
  --surface-3: #EDF2F2;
  --border: #DCE5E5;
  --border-strong: #C6D3D3;
  --text: #0F1A1C;
  --text-2: #475659;
  --text-3: #75878A;
  --accent: #0A7F73;
  --accent-hover: #086A60;
  --accent-soft: #E2F2EF;
  --accent-softer: #F1F9F8;
  --accent-ink: #FFFFFF;
  --focus: rgba(10, 127, 115, .35);

  --danger: #B42318;
  --danger-strong: #C8261B;
  --danger-soft: #FDEDEB;
  --danger-border: #F3C5BF;
  --warn: #9A5B00;
  --warn-soft: #FFF5E1;
  --warn-border: #EFD7A6;
  --ok: #0A7F73;

  --team-bg: #EEF2F4;
  --team-border: #DCE3E7;
  --jp: #5A3EC2;
  --jp-soft: #EEEAFB;
  --tw: #1F5FAF;
  --tw-soft: #E5EEFA;

  --side-bg: #0F1A1C;
  --side-bg-2: #16252A;
  --side-text: #D4E0E1;
  --side-muted: #7E9295;
  --side-border: #203034;
  --side-accent: #2CC4B1;

  --shadow-sm: 0 1px 2px rgba(15, 26, 28, .05);
  --shadow: 0 1px 2px rgba(15, 26, 28, .04), 0 4px 16px rgba(15, 26, 28, .06);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121E21;
  --surface: #172528;
  --surface-2: #1B2B2F;
  --surface-3: #213337;
  --border: #26393D;
  --border-strong: #33494E;
  --text: #E3ECED;
  --text-2: #A9BABC;
  --text-3: #7A8E91;
  --accent: #2CC4B1;
  --accent-hover: #52D6C5;
  --accent-soft: rgba(44, 196, 177, .14);
  --accent-softer: rgba(44, 196, 177, .07);
  --accent-ink: #062723;
  --focus: rgba(44, 196, 177, .4);
  --danger: #FF8A80;
  --danger-strong: #E5484D;
  --danger-soft: rgba(229, 72, 77, .14);
  --danger-border: rgba(229, 72, 77, .42);
  --warn: #F0B860;
  --warn-soft: rgba(240, 184, 96, .12);
  --warn-border: rgba(240, 184, 96, .35);
  --team-bg: #1F2F34;
  --team-border: #2A3E43;
  --jp: #B3A2FF;
  --jp-soft: rgba(150, 126, 255, .16);
  --tw: #86B6FF;
  --tw-soft: rgba(96, 156, 255, .16);
  --side-bg: #0B1416;
  --side-bg-2: #142124;
  --side-border: #1A292C;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121E21;
    --surface: #172528;
    --surface-2: #1B2B2F;
    --surface-3: #213337;
    --border: #26393D;
    --border-strong: #33494E;
    --text: #E3ECED;
    --text-2: #A9BABC;
    --text-3: #7A8E91;
    --accent: #2CC4B1;
    --accent-hover: #52D6C5;
    --accent-soft: rgba(44, 196, 177, .14);
    --accent-softer: rgba(44, 196, 177, .07);
    --accent-ink: #062723;
    --focus: rgba(44, 196, 177, .4);
    --danger: #FF8A80;
    --danger-strong: #E5484D;
    --danger-soft: rgba(229, 72, 77, .14);
    --danger-border: rgba(229, 72, 77, .42);
    --warn: #F0B860;
    --warn-soft: rgba(240, 184, 96, .12);
    --warn-border: rgba(240, 184, 96, .35);
    --team-bg: #1F2F34;
    --team-border: #2A3E43;
    --jp: #B3A2FF;
    --jp-soft: rgba(150, 126, 255, .16);
    --tw: #86B6FF;
    --tw-soft: rgba(96, 156, 255, .16);
    --side-bg: #0B1416;
    --side-bg-2: #142124;
    --side-border: #1A292C;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#app { height: 100%; }

.boot { height: 100%; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--text-3); }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 32px; padding: 0; }
.btn-danger { background: var(--danger-strong); border-color: var(--danger-strong); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--danger-strong); }

kbd {
  font-family: var(--mono); font-size: 11px; line-height: 1;
  padding: 2px 5px; border-radius: 4px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  background: var(--surface); color: var(--text-2);
}

/* ----------------------------------------------------------------- login */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 32px 16px;
  background: var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); padding: 32px 28px 26px;
}
.brandmark { display: flex; align-items: center; gap: 12px; }
.brandmark img { width: 40px; height: 40px; border-radius: 10px; }
.brandmark .wm { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.brandmark .sub { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); margin-top: 4px; }
.login-card h1 { font-size: 18px; margin: 26px 0 4px; }
.login-card .lead { color: var(--text-2); margin-bottom: 20px; }
.field { position: relative; display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input, textarea.input {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 84px; padding: 9px 12px; resize: vertical; line-height: 1.45; }
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.login-card .btn-primary { width: 100%; height: 40px; margin-top: 6px; }
.form-error {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 12px; margin-bottom: 14px; border-radius: var(--radius-sm);
  background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--danger);
  font-size: 13px;
}
.form-error.is-info { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.form-error .icon { margin-top: 2px; }
.login-foot { margin-top: 18px; font-size: 12px; color: var(--text-3); text-align: center; }
.mock-pill {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border);
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
}

/* ----------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: clip; }
.sidebar {
  background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; gap: 18px;
  padding: 18px 12px 14px; min-height: 0; overflow-y: auto;
  border-right: 1px solid var(--side-border);
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; }
.side-brand img { width: 30px; height: 30px; border-radius: 8px; }
.side-brand .wm { font-size: 17px; font-weight: 700; letter-spacing: -0.03em; color: #fff; line-height: 1.1; }
.side-brand .sub { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--side-muted); font-weight: 600; }
.side-label { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--side-muted); padding: 0 10px; margin-bottom: 6px; }
.nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--side-text); text-decoration: none; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--side-bg-2); color: #fff; }
.nav-item[aria-current="page"] { background: var(--side-bg-2); color: #fff; box-shadow: inset 2px 0 0 var(--side-accent); }
.nav-item[aria-current="page"] .icon { color: var(--side-accent); }
.nav-item .icon { color: var(--side-muted); }
.nav-item .label { flex: 1; }
.nav-count {
  min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-grid; place-items: center;
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: #23363A; color: var(--side-text);
}
.nav-count.is-danger { background: #E5484D; color: #fff; }
.nav-count.is-zero { background: transparent; color: var(--side-muted); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; gap: 2px; border-radius: 9px; background: #0A1315; border: 1px solid var(--side-border); }
.seg button {
  height: 28px; border: 0; border-radius: 6px; background: transparent;
  color: var(--side-muted); font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
}
.seg button:hover { color: #fff; }
.seg button[aria-pressed="true"] { background: var(--side-bg-2); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 1px 2px rgba(0,0,0,.3); }
.side-section { padding: 0 2px; }
.side-spacer { flex: 1; }

.live {
  display: flex; align-items: center; gap: 8px; padding: 0 10px;
  font-size: 12.5px; color: var(--side-muted);
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #5B6E71; flex: none; }
.live[data-state="live"] .live-dot { background: #2CC4B1; box-shadow: 0 0 0 3px rgba(44,196,177,.18); }
.live[data-state="live"] { color: var(--side-text); }
.live[data-state="connecting"] .live-dot, .live[data-state="reconnecting"] .live-dot { background: #E9B44C; animation: pulse 1.4s ease-in-out infinite; }
.live[data-state="offline"] .live-dot { background: #8B9A9C; }
@keyframes pulse { 50% { opacity: .35; } }

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 10px; background: var(--side-bg-2); border: 1px solid var(--side-border);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
  background: #1F3A3B; color: #9EE7DC;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { color: #fff; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shift {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 2px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--side-muted);
}
.shift::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #E9B44C; }
.shift[data-shift="night"]::before { background: #8EA2FF; }
.side-btn {
  width: 30px; height: 30px; border-radius: 7px; border: 0; display: grid; place-items: center;
  background: transparent; color: var(--side-muted);
}
.side-btn:hover { background: #22343A; color: #fff; }
.side-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px 0 0; }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: clip; }
.view { flex: 1; min-height: 0; }

/* -------------------------------------------------------- urgent banner */
.urgent-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px 10px 14px;
  background: var(--danger-strong); color: #fff;
  border-bottom: 1px solid rgba(0,0,0,.12);
  animation: banner-in .25s ease-out;
}
.urgent-banner .pulse-ring {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: rgba(255,255,255,.16);
  animation: ring 1.6s ease-out infinite;
}
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.45); } 100% { box-shadow: 0 0 0 10px rgba(255,255,255,0); } }
@keyframes banner-in { from { transform: translateY(-100%); opacity: 0; } }
.urgent-banner .ub-text { flex: 1; min-width: 0; }
.urgent-banner .ub-title { font-weight: 700; }
.urgent-banner .ub-detail { font-size: 13px; opacity: .92; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.urgent-banner .btn { background: #fff; color: var(--danger-strong); border-color: #fff; font-weight: 600; }
.urgent-banner .btn:hover { background: #FFF1F0; }
.urgent-banner .ub-more { font-size: 12.5px; opacity: .9; white-space: nowrap; }

/* ----------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.chip-brand { letter-spacing: .04em; font-size: 11px; height: 19px; padding: 0 6px; }
.chip-brand[data-brand="JP"] { background: var(--jp-soft); color: var(--jp); }
.chip-brand[data-brand="TW"] { background: var(--tw-soft); color: var(--tw); }
.chip-topic { font-weight: 500; background: transparent; border: 1px solid var(--border); color: var(--text-2); }
.chip-safety { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.chip-urgent { background: var(--danger-strong); color: #fff; }
.chip-handover { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
.chip-offer { background: var(--accent-soft); color: var(--accent); }
.chip-verdict { background: var(--accent-soft); color: var(--accent); }
.chip-verdict[data-v="ai_wrong"] { background: var(--warn-soft); color: var(--warn); }
.chip-verdict[data-v="ai_unsafe"] { background: var(--danger-soft); color: var(--danger); }
.chip-verdict[data-v="team_better"], .chip-verdict[data-v="same"] { background: var(--surface-3); color: var(--text-2); }
.chip-warn-soft { background: transparent; color: var(--warn); border: 1px dashed var(--warn-border); font-weight: 500; }
.conf { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.conf-bars { display: inline-flex; gap: 2px; align-items: flex-end; }
.conf-bars i { width: 3px; border-radius: 1px; background: var(--border-strong); display: block; }
.conf-bars i:nth-child(1) { height: 6px; } .conf-bars i:nth-child(2) { height: 9px; } .conf-bars i:nth-child(3) { height: 12px; }
.conf[data-c="high"] .conf-bars i { background: var(--accent); }
.conf[data-c="medium"] .conf-bars i:nth-child(-n+2) { background: var(--warn); }
.conf[data-c="low"] .conf-bars i:nth-child(1) { background: var(--text-3); }

/* ----------------------------------------------------------------- queue */
.queue-layout { display: grid; grid-template-columns: 420px minmax(0, 1fr); height: 100%; min-height: 0; }
.queue-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--surface); }
.pane-head { padding: 16px 16px 0; border-bottom: 1px solid var(--border); }
.pane-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.pane-title h1 { font-size: 17px; flex: 1; }
.pane-title .sub { font-size: 12.5px; color: var(--text-3); font-weight: 400; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 10px; border: 0; background: transparent;
  color: var(--text-2); font-weight: 500; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); font-weight: 600; }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tab .count { font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.tab[data-tab="safety"] .count.has { background: var(--danger-strong); color: #fff; }

.list { flex: 1; min-height: 0; overflow-y: auto; outline: none; }
.row {
  position: relative; display: block; width: 100%; text-align: left;
  padding: 11px 16px 12px 18px; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; color: inherit; cursor: pointer;
}
.row:hover { background: var(--surface-2); }
.row.is-selected { background: var(--accent-softer); }
.row.is-selected::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.row.is-open { background: var(--accent-soft); }
.row.is-urgent::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--danger-strong); }
.row.is-selected.is-urgent::before { left: 3px; }
.row-top { display: flex; align-items: center; gap: 7px; min-width: 0; }
.row-contact { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-contact.anon { color: var(--text-3); font-weight: 500; font-style: italic; }
.row-group { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.row-time { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.row-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 6px 0 7px; }
.snips { display: grid; gap: 2px; }
.snip { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 6px; font-size: 13px; line-height: 1.4; }
.snip .who { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding-top: 2px; }
.snip .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.snip.is-player .txt { color: var(--text); }
.snip.is-ai .who { color: var(--accent); }
.snip.is-none .txt { color: var(--text-3); font-style: italic; }
.list-foot { padding: 12px 16px 16px; display: flex; justify-content: center; }
.kbd-hint { display: flex; gap: 12px; flex-wrap: wrap; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); background: var(--surface-2); }
.kbd-hint span { display: inline-flex; gap: 5px; align-items: center; }

/* skeletons */
.skel { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 5px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); animation: shimmer 1.3s infinite; }
:root[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-row { padding: 14px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.skel-line { height: 10px; }

/* states */
.state {
  display: grid; justify-items: center; text-align: center; gap: 8px;
  padding: 48px 24px; color: var(--text-2);
}
.state .state-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); margin-bottom: 4px; }
.state .state-icon .icon { width: 22px; height: 22px; }
.state h2 { font-size: 15px; color: var(--text); }
.state p { max-width: 340px; font-size: 13px; }
.state.is-error .state-icon { background: var(--warn-soft); color: var(--warn); }
.state .btn { margin-top: 8px; }
.state code { font-family: var(--mono); font-size: 12px; color: var(--text-3); }

/* ----------------------------------------------------------- conversation */
.conv-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; container-type: inline-size; container-name: conv; background: var(--bg); }
.conv-empty { flex: 1; display: grid; place-items: center; }
.conv-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.conv-head .back { display: none; }
.conv-title { min-width: 0; flex: 1; }
.conv-title h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.conv-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 5px; font-size: 12.5px; color: var(--text-3); }
.conv-meta span { display: inline-flex; align-items: center; gap: 5px; }
.conv-meta .mono { font-family: var(--mono); font-size: 11.5px; }
.conv-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
@container conv (min-width: 780px) {
  .conv-body { grid-template-columns: minmax(0, 1fr) 360px; overflow: hidden; }
  .conv-body > .thread, .conv-body > .inspector { overflow-y: auto; min-height: 0; }
  .inspector { border-left: 1px solid var(--border); }
}
@container conv (min-width: 1100px) {
  .conv-body { grid-template-columns: minmax(0, 1fr) 380px; }
}

.thread { padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; flex-direction: column; max-width: min(620px, 86%); }
.msg-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin: 0 4px 4px; }
.msg-meta .who { font-weight: 600; color: var(--text-2); }
.bubble {
  padding: 9px 13px; border-radius: 14px;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal;
  font-size: 14px; line-height: 1.5;
}
.msg-player { align-self: flex-start; }
.msg-player .bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 5px; box-shadow: var(--shadow-sm); }
.msg-team, .msg-staff { align-self: flex-end; align-items: flex-end; }
.msg-team .bubble, .msg-staff .bubble { background: var(--team-bg); border: 1px solid var(--team-border); border-top-right-radius: 5px; }
.msg-team .pen { color: var(--text); font-weight: 600; }
.msg-ai { align-self: flex-end; align-items: flex-end; width: min(620px, 86%); }
.draft {
  width: 100%; text-align: left; cursor: pointer;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--accent-softer); color: var(--text);
  border-radius: 14px; border-top-right-radius: 5px; padding: 0;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.draft:hover { border-color: var(--accent); }
.draft.is-active { border-style: solid; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); background: var(--surface); }
.draft-head {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 12px 0; font-size: 11.5px; color: var(--accent); font-weight: 700; letter-spacing: .03em;
}
.draft-head .icon { width: 14px; height: 14px; }
.draft-head .not-sent { color: var(--text-3); font-weight: 500; letter-spacing: 0; }
.draft-head .spacer { flex: 1; }
.draft .bubble { background: none; border: 0; padding-top: 5px; color: var(--text); }
.draft.is-unsafe { border-color: var(--danger-border); }
.msg-system { align-self: center; max-width: 90%; }
.msg-system .bubble { padding: 4px 12px; border-radius: 999px; font-size: 12px; color: var(--text-3); background: var(--surface-3); }
.thread-gap { align-self: center; font-size: 12px; color: var(--text-3); }

/* inspector */
.inspector { position: relative; background: var(--surface); padding: 16px 18px 28px; display: flex; flex-direction: column; gap: 16px; }
.inspector > *, .thread > * { flex-shrink: 0; }
.insp-head { display: flex; align-items: center; gap: 8px; }
.insp-head h3 { font-size: 14px; flex: 1; }
.turn-pick { display: flex; flex-wrap: wrap; gap: 4px; }
.turn-pick button {
  height: 26px; padding: 0 9px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: 12px; font-weight: 500;
}
.turn-pick button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-softer); font-weight: 600; }
.turn-pick button .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; background: var(--border-strong); vertical-align: middle; }
.turn-pick button .dot.done { background: var(--accent); }
.box { border-radius: 10px; padding: 11px 12px; border: 1px solid var(--border); background: var(--surface-2); display: grid; gap: 5px; }
.box-title { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; }
.box-body { font-size: 13px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.box-safety { background: var(--danger-soft); border-color: var(--danger-border); }
.box-safety .box-title { color: var(--danger); }
.box-handover { background: var(--warn-soft); border-color: var(--warn-border); }
.box-handover .box-title { color: var(--warn); }
.box-offer { background: var(--accent-softer); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.box-offer .box-title { color: var(--accent); }
.box .chips { display: flex; flex-wrap: wrap; gap: 4px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.fact { background: var(--surface); padding: 8px 11px; min-width: 0; }
.fact dt { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.fact dd { margin: 2px 0 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fact dd.num { font-variant-numeric: tabular-nums; }
.section-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; margin-bottom: 6px; }
.tools { display: grid; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.tool { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 10px; font-size: 13px; border-top: 1px solid var(--border); }
.tool:first-child { border-top: 0; }
.tool .name { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.tool .ms { font-variant-numeric: tabular-nums; color: var(--text-3); font-size: 12px; }
.tool .ok { color: var(--accent); }
.tool .fail { color: var(--warn); }
.tool .err { grid-column: 2 / -1; font-size: 12px; color: var(--warn); }
.tools-empty { font-size: 13px; color: var(--text-3); }

.decision { border-top: 1px solid var(--border); padding-top: 16px; display: grid; gap: 10px; }
.decision-head { display: flex; align-items: center; gap: 8px; }
.decision-head h3 { font-size: 14px; flex: 1; }
.mode-pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.verdicts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.vbtn:nth-child(-n+3) { grid-column: span 2; }
.vbtn:nth-child(n+4) { grid-column: span 3; }
.vbtn {
  display: flex; align-items: center; justify-content: center; gap: 5px; height: 36px; padding: 0 4px;
  border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--text-2); line-height: 1.15; text-align: center; white-space: nowrap;
  transition: border-color .12s, background .12s, color .12s;
}
.vbtn:hover { border-color: var(--text-3); color: var(--text); }
.vbtn kbd { font-size: 10px; padding: 1px 4px; }
.vbtn[aria-pressed="true"] { color: #fff; border-color: transparent; }
.vbtn[aria-pressed="true"] kbd { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.3); color: #fff; }
.vbtn[data-v="ai_better"][aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.vbtn[data-v="ai_better"][aria-pressed="true"] kbd { color: var(--accent-ink); }
.vbtn[data-v="same"][aria-pressed="true"] { background: #4D5F63; }
.vbtn[data-v="team_better"][aria-pressed="true"] { background: #2C4C6E; }
.vbtn[data-v="ai_wrong"][aria-pressed="true"] { background: #B26A00; }
.vbtn[data-v="ai_unsafe"] { color: var(--danger); }
.vbtn[data-v="ai_unsafe"][aria-pressed="true"] { background: var(--danger-strong); color: #fff; }
.vbtn:disabled { opacity: .6; cursor: progress; }
.decision .field { margin: 0; }
.decision-actions { display: flex; align-items: center; gap: 10px; }
.decision-actions .status { font-size: 12.5px; color: var(--text-3); flex: 1; }
.decision-actions .status.ok { color: var(--accent); }
.decision-actions .status.err { color: var(--danger); }
.reviews { display: grid; gap: 8px; }
.review { border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; display: grid; gap: 5px; }
.review-top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.review-top .name { font-weight: 600; }
.review-top .when { margin-left: auto; color: var(--text-3); font-size: 12px; }
.review .edited { font-size: 13px; border-left: 2px solid var(--accent); padding: 2px 0 2px 9px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.review .note { font-size: 13px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ----------------------------------------------------------------- stats */
.stats { height: 100%; overflow-y: auto; padding: 22px 28px 48px; }
.stats-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stats-head h1 { font-size: 20px; }
.stats-head .note { font-size: 12.5px; color: var(--text-3); flex: 1; }
.seg-light { display: inline-grid; grid-auto-flow: column; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-3); border: 1px solid var(--border); }
.seg-light button { height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.seg-light button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpi .k-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.kpi .k-value { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi.is-danger .k-value { color: var(--danger); }
.shadow-card .k-value { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.shadow-card .status-pill { align-self: center; }
.status-pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.status-pill.off { background: var(--surface-3); color: var(--text-2); }
.meter { height: 6px; border-radius: 3px; background: var(--surface-3); margin-top: 10px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.near i { background: var(--warn); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card h2 { font-size: 14px; display: flex; align-items: center; gap: 10px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { flex: 1; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

.chart { display: grid; gap: 4px; }
.chart-vals, .chart-days { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); text-align: center; font-size: 11.5px; }
.chart-vals { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-days { color: var(--text-3); font-variant-numeric: tabular-nums; }
.chart-days .today { color: var(--text); font-weight: 600; }
.chart svg { width: 100%; height: 140px; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .base-line { stroke: var(--border-strong); stroke-width: 1; }
.bar-accent { fill: var(--accent); }
.bar-accent-soft { fill: color-mix(in srgb, var(--accent) 30%, transparent); }
.bar-danger { fill: var(--danger-strong); }
.bar-warn { fill: var(--warn); }
.bar-ink { fill: #3E6A70; }
:root[data-theme="dark"] .bar-ink { fill: #7FA9AE; }
.sw-accent { background: var(--accent); } .sw-accent-soft { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.sw-danger { background: var(--danger-strong); } .sw-warn { background: var(--warn); } .sw-ink { background: #3E6A70; }
:root[data-theme="dark"] .sw-ink { background: #7FA9AE; }

.stack { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.stack i { display: block; height: 100%; min-width: 2px; }
.v-ai_better { background: var(--accent); }
.v-same { background: #8AA0A4; }
.v-team_better { background: #3B5F86; }
.v-ai_wrong { background: #D08A1C; }
.v-ai_unsafe { background: var(--danger-strong); }
.vlist { display: grid; gap: 6px; margin-top: 14px; }
.vline { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 48px; gap: 8px; align-items: center; font-size: 13px; }
.vline i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.vline .n, .vline .pct { text-align: right; font-variant-numeric: tabular-nums; }
.vline .pct { color: var(--text-3); }
.hbars { display: grid; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; font-size: 13px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .n { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.hbar .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.hbars.warn .track i { background: var(--warn); }
.card .state { padding: 28px 12px; }

/* -------------------------------------------------------------- toasts */
.toast-host { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast {
  padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--bg);
  font-size: 13px; box-shadow: var(--shadow); max-width: 360px; animation: banner-in .2s ease-out;
}
.toast.is-error { background: var(--danger-strong); color: #fff; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1379px) {
  .queue-layout { grid-template-columns: 370px minmax(0, 1fr); }
}
@media (max-width: 1099px) {
  .queue-layout { grid-template-columns: minmax(0, 1fr); }
  .queue-layout.has-open .queue-pane { display: none; }
  .queue-layout:not(.has-open) .conv-pane { display: none; }
  .queue-pane { border-right: 0; }
  .conv-head .back { display: inline-flex; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 899px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .sidebar {
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 10px;
    padding: 8px 10px; overflow: visible; border-right: 0; border-bottom: 1px solid var(--side-border);
  }
  .side-brand { padding: 0; }
  .side-brand .sub, .side-label, .side-spacer, .user-meta, .live .live-text { display: none; }
  .side-brand img { width: 26px; height: 26px; }
  .side-brand .wm { font-size: 15px; }
  .navsec { order: 10; flex-basis: 100%; padding: 0; }
  .nav { display: flex; justify-content: space-between; overflow-x: auto; gap: 2px; scrollbar-width: none; }
  .nav-item { height: 32px; padding: 0 7px; gap: 5px; justify-content: center; font-size: 13px; flex: none; }
  .nav-item .icon { display: none; }
  .tab { padding: 0 7px; }
  .nav-item[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--side-accent); }
  .nav-count { min-width: 18px; height: 17px; font-size: 10.5px; padding: 0 5px; }
  .side-section.brand { margin-left: auto; }
  .seg button { height: 24px; padding: 0 8px; font-size: 12px; }
  .live { padding: 0; }
  .user-card { padding: 0; background: none; border: 0; gap: 2px; }
  .avatar { width: 26px; height: 26px; font-size: 11px; }
  .side-foot { display: flex; align-items: center; gap: 8px; }
  .side-row { padding: 0; }
  .pane-head { padding: 12px 12px 0; }
  .row { padding: 10px 12px 11px 14px; }
  .kbd-hint { display: none; }
  .conv-head { padding: 10px 12px; }
  .thread { padding: 14px 12px 28px; }
  .msg, .msg-ai { max-width: 94%; }
  .msg-ai { width: 94%; }
  .inspector { padding: 14px 12px 28px; border-top: 1px solid var(--border); }
  .vbtn { font-size: 12.5px; gap: 5px; }
  .stats { padding: 16px 12px 36px; }
  .stats-head .note { flex-basis: 100%; order: 5; }
  .stats-head h1 { flex: 1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi .k-value { font-size: 20px; }
  .urgent-banner { padding: 8px 10px; gap: 8px; }
  .urgent-banner .pulse-ring { display: none; }
  .urgent-banner .ub-more { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Team */
.team-body { display: grid; gap: 16px; }
.team-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
.team-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.team-inline .input { flex: 1 1 160px; min-width: 0; }
.team-add .input, .team-add select { flex: 1 1 150px; }
.team-scroll { overflow-x: auto; }
.team-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.team-table th { text-align: left; font-weight: 500; color: var(--text-3, var(--text-2)); font-size: 12px; padding: 0 8px 8px; white-space: nowrap; }
.team-table td { padding: 6px 8px; vertical-align: middle; border-top: 1px solid var(--border); }
.team-table td .input { height: 32px; min-width: 120px; }
.team-table tr.is-off td { opacity: .55; }
.team-table tr.team-out-row td { border-top: 0; padding: 0 8px; }
.team-center { text-align: center; }
.team-muted { color: var(--text-2); font-size: 12px; white-space: nowrap; }
.team-actions { white-space: nowrap; text-align: right; }
.team-secret { margin: 8px 0; border-color: var(--accent); }
.team-secret p { margin: 0 0 8px; color: var(--text-2); }
.team-secret-row { display: flex; gap: 8px; align-items: center; }
.team-secret-value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; padding: 6px 10px; border-radius: 8px; background: var(--surface-3); user-select: all; }
@media (max-width: 760px) { .team-grid { grid-template-columns: 1fr; } }

/* Two-step sign-in */
.mfa-setup { display: flex; gap: 16px; align-items: center; margin: 6px 0 16px; flex-wrap: wrap; }
.mfa-qr { border-radius: 10px; border: 1px solid var(--border); background: #fff; flex: none; }
.mfa-key { display: grid; gap: 6px; min-width: 0; }
.mfa-key-label { font-size: 12px; color: var(--text-2); }
.mfa-key code, .mfa-backup code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; padding: 6px 8px; border-radius: 8px; background: var(--surface-3); user-select: all; word-break: break-all; }
.mfa-code { font-size: 20px; letter-spacing: .18em; text-align: center; font-variant-numeric: tabular-nums; }
.mfa-backup { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 0 16px; }
.mfa-actions { display: flex; gap: 8px; justify-content: flex-end; }
