/* ========================================================================
   SessionWeave Cockpit · stylesheet
   Inherits visual identity from sessionweave.com (marketing site).
   Production self-hosts Inter + JetBrains Mono in /fonts. This prototype
   uses cached webfonts purely so reviewers see correct metrics.
   ======================================================================== */

/* ---------- 1. Tokens (light) ---------- */
:root {
  /* Surface */
  --bg:          oklch(98.5% 0.004 85);
  --bg-elev:     oklch(96.5% 0.005 85);
  --line:        oklch(89%   0.006 85);
  --line-strong: oklch(82%   0.007 85);

  /* Type */
  --ink:         oklch(18%   0.01  250);
  --ink-soft:    oklch(40%   0.01  250);
  --ink-mute:    oklch(58%   0.008 250);

  /* Accent (cyan/teal, hue 195) */
  --accent:      oklch(58%   0.12  195);
  --accent-ink:  oklch(28%   0.06  195);
  --accent-bg:   oklch(96%   0.025 195);

  /* Destructive (hue ~25, matched chroma) */
  --danger:      oklch(58%   0.12   25);
  --danger-bg:   oklch(96%   0.025  25);

  /* Code (dark in both themes — marketing site signature) */
  --code-bg:     oklch(15%   0.012 250);
  --code-ink:    oklch(92%   0.005 85);
  --code-line:   oklch(24%   0.012 250);
  --code-mute:   oklch(60%   0.01  250);

  --radius: 6px;
  --radius-bubble: 12px;

  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Layout */
  --sidebar-w: 244px;
  --rightpanel-w: 296px;
  --topbar-h: 44px;
  --tab-h: 38px;
  --composer-h: 86px;

  --transition: 0.15s ease;
}

/* ---------- 2. Tokens (dark) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:          oklch(15%   0.012 250);
    --bg-elev:     oklch(18%   0.012 250);
    --line:        oklch(26%   0.012 250);
    --line-strong: oklch(34%   0.014 250);
    --ink:         oklch(94%   0.005 85);
    --ink-soft:    oklch(75%   0.008 85);
    --ink-mute:    oklch(58%   0.01  250);
    --accent:      oklch(72%   0.14  195);
    --accent-ink:  oklch(86%   0.08  195);
    --accent-bg:   oklch(22%   0.03  195);
    --danger:      oklch(72%   0.14   25);
    --danger-bg:   oklch(22%   0.03   25);
  }
}

/* Explicit theme overrides (driven by Tweaks panel) */
:root[data-theme="light"] {
  --bg: oklch(98.5% 0.004 85); --bg-elev: oklch(96.5% 0.005 85);
  --line: oklch(89% 0.006 85); --line-strong: oklch(82% 0.007 85);
  --ink: oklch(18% 0.01 250); --ink-soft: oklch(40% 0.01 250); --ink-mute: oklch(58% 0.008 250);
  --accent: oklch(58% 0.12 195); --accent-ink: oklch(28% 0.06 195); --accent-bg: oklch(96% 0.025 195);
  --danger: oklch(58% 0.12 25); --danger-bg: oklch(96% 0.025 25);
}
:root[data-theme="dark"] {
  --bg: oklch(15% 0.012 250); --bg-elev: oklch(18% 0.012 250);
  --line: oklch(26% 0.012 250); --line-strong: oklch(34% 0.014 250);
  --ink: oklch(94% 0.005 85); --ink-soft: oklch(75% 0.008 85); --ink-mute: oklch(58% 0.01 250);
  --accent: oklch(72% 0.14 195); --accent-ink: oklch(86% 0.08 195); --accent-bg: oklch(22% 0.03 195);
  --danger: oklch(72% 0.14 25); --danger-bg: oklch(22% 0.03 25);
}

/* ---------- 3. Base ---------- */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; font-size: inherit; color: inherit; }
input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
code, pre, .mono { font-family: var(--mono); }
::selection { background: var(--accent-bg); color: var(--accent-ink); }

/* Focus rings — visible on every theme */
:where(button, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* The signature half-height highlighter from the marketing site */
.hl {
  background: linear-gradient(180deg, transparent 62%, var(--accent-bg) 62%);
  padding: 0 2px;
}

/* Eyebrow label — mono, 11px, tracked */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 1px;
  background: var(--line-strong);
}

/* ---------- 4. App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--rightpanel-w);
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "topbar topbar topbar"
    "sidebar central rightpanel";
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}
/* Default >=1100px: panel expanded. */
.app .rightpanel-rail { display: none; }

/* Explicit collapse at any width */
.app[data-rightpanel="collapsed"] {
  grid-template-columns: var(--sidebar-w) 1fr 38px;
}
.app[data-rightpanel="collapsed"] .rightpanel { display: none; }
.app[data-rightpanel="collapsed"] .rightpanel-rail {
  display: flex;
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: 38px;
}

/* ---------- 5. Top bar ---------- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  z-index: 5;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 18px; height: 18px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  transform: rotate(45deg);
}
.brand-name { font-size: 14px; }
.brand-name em {
  font-style: normal;
  color: var(--ink-mute);
  font-weight: 400;
}
.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
}
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  flex: 1;
  min-width: 0;
}
.crumb .kind {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.crumb .sid {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 2px 8px;
  cursor: pointer;
  transition: var(--transition);
}
.crumb .sid:hover { border-style: solid; border-color: var(--accent); color: var(--accent-ink); }
/* Inline copy-icon sitting right next to the session_id in the
   topbar breadcrumb. Replaces the old "Copy SID" button that used
   to live in the session-header bar. */
.crumb-copy {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  padding: 0;
  margin-left: 4px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-mute);
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}
.crumb-copy:hover {
  background: var(--bg-elev);
  color: var(--ink);
  border-color: var(--line);
}
.crumb-copy svg { display: block; }
.crumb .sid-copied {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--accent-ink);
  opacity: 0;
  transition: opacity 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.crumb .sid-copied.show { opacity: 1; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rightpanel-toggle {
  display: none; /* shown on mobile via media query */
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 30px; height: 30px;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
}
.rightpanel-toggle:hover { color: var(--ink); border-color: var(--line-strong); }
.fh-badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  display: inline-flex; align-items: center; gap: 6px;
}
.fh-badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: fh-pulse 2s infinite;
}
@keyframes fh-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 40%, transparent); }
  70%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.fh-badge[data-status="closed"]::before { background: var(--ink-mute); animation: none; }
.fh-badge[data-status="lagged"]::before { background: var(--danger); }

.tweaks-toggle {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--mono);
  letter-spacing: 0.04em;
}
.tweaks-toggle:hover { border-color: var(--line-strong); color: var(--ink); }

/* ---------- 6. Sidebar ---------- */
.sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.sidebar-section {
  padding: 14px 14px 8px;
}
.sidebar-actions {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}
.action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  color: var(--ink);
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
  text-align: left;
}
.action-btn:hover { border-color: var(--line-strong); background: var(--bg-elev); }
.action-btn .icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--ink-soft); }
.action-btn .label { flex: 1; }
.action-btn .kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 3px;
}

/* Inline-input flyout for "open a session" */
.open-input-row {
  display: none;
  margin-top: 8px;
  gap: 6px;
  flex-direction: column;
}
.sidebar[data-open-input="true"] .open-input-row { display: flex; }
.open-input-row input {
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 7px 9px;
  font-family: var(--mono);
  font-size: 12px;
}
.open-input-row input:focus { outline: none; border-color: var(--accent); }
.open-input-row .row {
  display: flex;
  gap: 6px;
}
.open-input-row .row button {
  flex: 1;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 7px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}
.open-input-row .row button.ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.open-input-row .row button:hover { filter: brightness(1.05); }
.open-input-row .err {
  font-size: 11px;
  color: var(--danger);
  font-family: var(--mono);
}

.sidebar-recent {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}
.sidebar-recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.recent-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  padding: 8px 9px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  align-items: center;
}
.recent-row:hover { background: var(--bg-elev); }
.recent-row[aria-current="true"] {
  background: var(--accent-bg);
}
.recent-row[aria-current="true"]::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.recent-row .rsid {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-row[aria-current="true"] .rsid { color: var(--accent-ink); font-weight: 600; }
.recent-row .ago {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  grid-column: 1;
}
.recent-row .remove {
  grid-column: 2;
  grid-row: 1 / span 2;
  background: transparent;
  border: none;
  color: var(--ink-mute);
  font-size: 14px;
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  opacity: 0;
  transition: var(--transition);
}
.recent-row:hover .remove { opacity: 1; }
.recent-row .remove:hover { background: var(--bg); color: var(--danger); }

.recent-empty {
  font-size: 12px;
  color: var(--ink-mute);
  font-family: var(--mono);
  padding: 8px 9px;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  font-size: 11px;
  color: var(--ink-mute);
  font-family: var(--mono);
  line-height: 1.5;
  letter-spacing: 0.02em;
}
.sidebar-footer .link {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px dotted var(--line-strong);
}

/* Supervisor identity row — sticky bottom of left sidebar.
   Hosted: click is a no-op toast. Local-hub: opens popover menu (see system doc). */
.sidebar-identity {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: var(--bg);
  transition: var(--transition);
  position: relative;
}
.sidebar-identity:hover { background: var(--bg-elev); }
.sidebar-identity:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 0; }
.sidebar-identity .id-glyph {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--ink-soft);
}
.sidebar-identity .id-glyph svg { width: 14px; height: 14px; }
.sidebar-identity .id-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar-identity .id-name {
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-identity .id-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.sidebar-identity .caret {
  width: 18px; height: 18px;
  color: var(--ink-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar-identity .caret svg { width: 14px; height: 14px; }

/* ---------- 7. Central pane ---------- */
.central {
  grid-area: central;
  display: grid;
  grid-template-rows: var(--tab-h) 1fr auto auto auto;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.tab-strip {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-strip::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  font-size: 12px;
  color: var(--ink-soft);
  border-right: 1px solid var(--line);
  cursor: pointer;
  background: transparent;
  border-top: none; border-bottom: none; border-left: none;
  position: relative;
  white-space: nowrap;
  transition: var(--transition);
  height: var(--tab-h);
}
.tab[aria-selected="true"] {
  color: var(--ink);
  background: var(--bg);
  font-weight: 500;
}
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--bg);
}
.tab[aria-selected="true"]::before {
  content: "";
  position: absolute;
  left: 14px; right: 14px; top: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}
.tab:hover:not([aria-selected="true"]) {
  color: var(--ink);
  background: var(--bg-elev);
}
.tab .tab-icon { width: 12px; height: 12px; flex-shrink: 0; }
.tab .tab-close {
  border: none; background: transparent; color: var(--ink-mute);
  width: 16px; height: 16px; line-height: 1; font-size: 13px;
  border-radius: 3px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 2px;
}
.tab .tab-close:hover { background: var(--line); color: var(--ink); }
.tab[data-sticky="true"] .tab-close { display: none; }
.tab .tab-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

.tab-strip-pad {
  flex: 1;
  border-bottom: none;
}

/* ---------- 8. Chat stream ---------- */
.chat-wrap {
  position: relative;
  overflow: hidden;
  min-height: 0;
}
.chat-stream {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 28px 12px;
  scroll-behavior: smooth;
}
.chat-stream:focus { outline: none; }

.chat-day-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 12px;
}
.chat-day-divider::before,
.chat-day-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.chat-day-divider span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

/* System rows (joined/left/ended) — centered, no bubble */
.tl-system {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
}
.tl-system .ts { color: var(--line-strong); }
.tl-system .glyph {
  width: 12px; height: 12px;
  flex-shrink: 0;
  color: var(--ink-mute);
}
.tl-system.warning { color: var(--danger); }
.tl-system.warning .glyph { color: var(--danger); }

/* Session-ended sharp rule */
.tl-ended {
  margin: 16px 0;
  padding: 8px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}

/* ---------- Chat bubble ---------- */
.tl-msg {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: 12px;
  margin: 14px 0;
  align-items: start;
}
.tl-msg .avatar {
  width: 32px; height: 32px;
  border-radius: 7px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}
.tl-msg .avatar svg { width: 22px; height: 22px; }

.bubble {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-bubble);
  padding: 9px 13px 11px 16px;
  max-width: min(640px, 70ch);
  min-width: 0;
  overflow: hidden;
}
.bubble::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--p-color, var(--accent));
}
.bubble-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.bubble-pid {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bubble-pid:hover { color: var(--accent-ink); }
.bubble-role {
  font-size: 11px;
  color: var(--ink-mute);
  opacity: 0.85;
}
.bubble-evt {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.bubble-body {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
}
.bubble-body p { margin: 0; }

.bubble-code {
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  margin: 6px 0 2px;
  overflow-x: auto;
  border: 1px solid var(--code-line);
  max-height: 320px;
  overflow-y: auto;
  position: relative;
  max-width: 100%;
  white-space: pre;
}
.bubble-code .k { color: oklch(72% 0.12 195); }
.bubble-code .s { color: oklch(78% 0.13 130); }
.bubble-code .n { color: oklch(78% 0.13 60); }
.bubble-code .p { color: oklch(60% 0.005 250); }

.bubble-code-toggle {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  cursor: pointer;
  margin-top: 6px;
}
.bubble-code-toggle:hover { color: var(--ink); border-color: var(--line-strong); }

.bubble-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  gap: 8px;
}
.bubble-status {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
}
.bubble-status.completed { color: oklch(55% 0.12 145); }
.bubble-status.cancelled { color: var(--danger); }
.bubble-ts {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
}

/* ---------- Supervisor "YOU" interjection ---------- */
.tl-sup {
  margin: 18px auto 18px;
  max-width: 720px;
  display: flex;
  align-items: stretch;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, transparent 62%, var(--accent-bg) 62%);
}
.tl-sup .marker {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tl-sup .you-glyph {
  width: 22px; height: 22px;
  color: var(--accent);
}
.tl-sup .you-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--accent-ink);
  font-weight: 700;
}
.tl-sup .sup-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tl-sup .sup-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.tl-sup .sup-context {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-ink);
}
.tl-sup .sup-ts {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
}
.tl-sup .sup-text {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
}

/* ---------- 9. Composer ---------- */
.composer-wrap {
  border-top: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  padding: 12px 20px 6px;
}
.composer textarea {
  resize: none;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  min-height: 40px;
  max-height: 160px;
  line-height: 1.5;
  width: 100%;
  transition: var(--transition);
  font-family: var(--sans);
}
.composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.composer .send {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  height: 40px;
}
.composer .send:hover { filter: brightness(1.08); }
.composer .send:active { transform: translateY(1px); }
.composer .send .kbd {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  opacity: 0.6;
  border: 1px solid color-mix(in oklab, var(--bg) 40%, transparent);
  padding: 1px 4px;
  border-radius: 3px;
}
.composer-hint {
  padding: 0 20px 12px 20px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
  display: flex;
  gap: 14px;
  align-items: center;
}
.composer-hint .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: inline-block; }
.composer-hint[data-mode="dm"] .dot { background: var(--p-color, var(--accent)); }

/* Scroll-pause pill */
.scroll-pill {
  position: absolute;
  bottom: calc(var(--composer-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  cursor: pointer;
  border: none;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 4;
  box-shadow: 0 4px 14px color-mix(in oklab, var(--ink) 20%, transparent);
}
.scroll-pill.show {
  display: inline-flex;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Welcome state (no session) */
.welcome {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 40px;
}
.welcome-inner {
  max-width: 480px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.welcome svg.illo { width: 88px; height: 88px; color: var(--ink-mute); }
.welcome h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.welcome p { color: var(--ink-soft); margin: 0; font-size: 14px; line-height: 1.6; }
.welcome blockquote {
  margin: 12px 0 0;
  padding: 14px 16px;
  border-left: 2px solid var(--accent);
  background: var(--bg-elev);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  text-align: left;
  line-height: 1.6;
}
.welcome blockquote em {
  display: block;
  font-style: normal;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin-top: 8px;
}

/* ---------- 10. Right panel · Participants ---------- */
.rightpanel {
  grid-area: rightpanel;
  border-left: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.rp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px;
  border-bottom: 1px solid var(--line);
}
.rp-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.rp-head .count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
}
.rp-head .iconbtn {
  background: transparent;
  border: 1px solid transparent;
  width: 26px; height: 26px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center;
}
.rp-head .iconbtn:hover { background: var(--bg-elev); border-color: var(--line); color: var(--ink); }
.rp-head .iconbtn[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-bg); }
.rp-head .iconbtn svg { width: 14px; height: 14px; }

.rp-list {
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.participant-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  padding: 9px 9px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  align-items: center;
}
.participant-row:hover { background: var(--bg-elev); }
.participant-row[aria-selected="true"] {
  background: var(--bg-elev);
  outline: 1px solid var(--line-strong);
}
.participant-row .avatar {
  grid-row: 1 / span 2;
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  display: grid;
  place-items: center;
  overflow: visible;
  position: relative;
}
.participant-row .avatar svg { width: 24px; height: 24px; }
.participant-row .status-dot {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--ink-mute);
}
.participant-row .status-dot.online { background: var(--p-color, var(--accent)); }
.participant-row .name-line {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.participant-row .pid {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.participant-row .role {
  font-size: 11px;
  color: var(--ink-mute);
}
.participant-row .caps {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.participant-row .cap {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-bg);
  color: var(--accent-ink);
}
.participant-row .cap.muted {
  background: var(--bg-elev);
  color: var(--ink-mute);
  border: 1px solid var(--line);
}
.participant-row .actions {
  grid-column: 3;
  grid-row: 1 / span 2;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: var(--transition);
}
.participant-row:hover .actions,
.participant-row[aria-selected="true"] .actions { opacity: 1; }
.p-act {
  width: 26px; height: 26px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
  transition: var(--transition);
}
.p-act:hover { color: var(--ink); border-color: var(--line-strong); background: var(--bg-elev); }
.p-act svg { width: 12px; height: 12px; }
.p-act.danger:hover { color: var(--danger); border-color: var(--danger); }

/* Inline redirect form */
.redirect-form {
  grid-column: 1 / -1;
  grid-row: 3;
  display: none;
  margin-top: 8px;
  gap: 6px;
}
.participant-row[data-redirect="true"] .redirect-form { display: flex; }
.redirect-form input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 5px 9px;
  font-size: 12px;
}
.redirect-form input:focus { outline: none; }
.redirect-form button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  cursor: pointer;
}
.redirect-form button.cancel { background: transparent; color: var(--ink-mute); border: 1px solid var(--line); }

/* Local-hub-only sub-row preview (commented out for hosted; included as preview when [data-show-localhub-preview]) */
.lh-subrow {
  grid-column: 1 / -1;
  grid-row: 3;
  display: none;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  margin-top: 6px;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
}
.app[data-localhub-preview="true"] .participant-row[data-localhub] .lh-subrow {
  display: flex;
}
.lh-subrow .model { color: var(--ink); }
.lh-subrow .stop {
  margin-left: auto;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 10px;
  cursor: pointer;
}
.lh-subrow .stop:hover { background: var(--danger-bg); border-color: var(--danger); }
.lh-tag {
  position: absolute;
  top: 4px;
  right: 4px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 1px 4px;
  border-radius: 3px;
  display: none;
}
.app[data-localhub-preview="true"] .participant-row[data-localhub] .lh-tag { display: inline-block; }

.rp-foot {
  border-top: 1px solid var(--line);
  padding: 12px;
}
.end-session-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  border-radius: var(--radius);
  padding: 9px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}
.end-session-btn:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

/* Rail when collapsed */
.rightpanel-rail {
  display: none;
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: 38px;
  border-left: 1px solid var(--line);
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 10px;
  z-index: 2;
}
.rightpanel-rail .rail-toggle {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  width: 26px; height: 26px;
  cursor: pointer;
  color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center;
}
.rightpanel-rail .rail-toggle:hover { color: var(--ink); border-color: var(--line-strong); }
.rightpanel-rail .rail-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mute);
  writing-mode: vertical-rl;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------- 11. Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in oklab, var(--ink) 35%, transparent);
  z-index: 50;
  display: grid;
  place-items: center;
  animation: fade-in 0.18s ease both;
}
.modal {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 24px 18px;
  width: min(420px, 90vw);
  box-shadow: 0 24px 60px color-mix(in oklab, var(--ink) 25%, transparent);
  animation: pop-in 0.2s cubic-bezier(0.22,0.9,0.34,1) both;
}
.modal h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.modal p { margin: 0 0 18px; color: var(--ink-soft); font-size: 13.5px; line-height: 1.55; }
.modal .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.modal .btn {
  border-radius: var(--radius);
  padding: 8px 16px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}
.modal .btn:hover { background: var(--bg-elev); border-color: var(--line-strong); }
.modal .btn.primary {
  background: var(--danger);
  color: var(--bg);
  border-color: var(--danger);
}
.modal .btn.primary:hover { filter: brightness(1.05); background: var(--danger); }
/* Modal scope was overriding .btn--primary with transparent bg + faint border,
   leaving submit buttons with light text on a near-white modal background —
   they looked disabled. Restore the accent fill + dark text inside modals
   too so the CTA reads correctly. */
.modal .btn--primary {
  background: var(--accent);
  color: oklch(15% 0.01 250);
  border-color: var(--accent-ink);
}
.modal .btn--primary:hover {
  background: color-mix(in oklab, var(--accent) 88%, var(--ink) 12%);
  border-color: var(--ink);
}
.modal .btn--primary[disabled],
.modal .btn--primary[disabled]:hover {
  background: var(--bg-elev);
  color: var(--ink-mute);
  border-color: var(--line);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--composer-h) + 24px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ---------- 13. Density variants ---------- */
:root[data-density="cozy"] { /* default */ }
:root[data-density="compact"] {
  --tab-h: 32px;
}
:root[data-density="compact"] .chat-stream { padding: 16px 22px 8px; }
:root[data-density="compact"] .tl-msg { margin: 8px 0; }
:root[data-density="compact"] .bubble { padding: 7px 12px 9px 14px; }

/* ---------- 14. Motion ---------- */
.tl-msg, .tl-sup, .tl-system {
  animation: msg-in 0.18s cubic-bezier(0.22, 0.9, 0.34, 1) both;
  animation-delay: var(--stagger, 0ms);
}
@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.tl-msg.flash::after,
.tl-sup.flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent-bg);
  border-radius: var(--radius-bubble);
  opacity: 0.25;
  pointer-events: none;
  animation: flash-out 0.18s ease forwards;
  animation-delay: var(--stagger, 0ms);
}
.tl-msg { position: relative; }
.tl-msg.flash { isolation: isolate; }
.tl-msg.flash > .bubble::after,
.tl-sup.flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent-bg);
  opacity: 0.35;
  pointer-events: none;
  animation: flash-out 0.36s ease forwards;
  border-radius: inherit;
  animation-delay: var(--stagger, 0ms);
}
@keyframes flash-out {
  from { opacity: 0.35; }
  to   { opacity: 0; }
}

/* Historical entries don't animate */
.tl-msg[data-historical], .tl-sup[data-historical], .tl-system[data-historical] {
  animation: none;
}
.tl-msg[data-historical].flash::after,
.tl-sup[data-historical].flash::after { display: none; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tl-msg, .tl-sup, .tl-system {
    animation: fade-only 0.12s ease both;
    transform: none !important;
  }
  .tl-msg.flash > .bubble::after,
  .tl-sup.flash::after { display: none; }
  @keyframes fade-only {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}

/* ---------- 15. Responsive ---------- */
@media (max-width: 1099px) {
  /* Default at narrow widths: collapsed (rail visible, full panel hidden). */
  .app:not([data-rightpanel="expanded"]) {
    grid-template-columns: var(--sidebar-w) 1fr 38px;
  }
  .app:not([data-rightpanel="expanded"]) .rightpanel { display: none; }
  .app:not([data-rightpanel="expanded"]) .rightpanel-rail {
    display: flex;
    position: static;
    width: 38px;
    height: auto;
  }
  /* User-overridden expanded at narrow widths still shows the panel. */
  .app[data-rightpanel="expanded"] {
    grid-template-columns: var(--sidebar-w) 1fr var(--rightpanel-w);
  }
  .app[data-rightpanel="expanded"] .rightpanel { display: flex; }
  .app[data-rightpanel="expanded"] .rightpanel-rail { display: none; }
}
@media (max-width: 719px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 0 1fr 0; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0; bottom: 0;
    width: min(280px, 86vw);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    border-right: 1px solid var(--line);
    box-shadow: 0 0 0 100vmax transparent;
  }
  .app[data-sidebar="open"] .sidebar {
    transform: translateX(0);
    box-shadow: 0 0 0 100vmax color-mix(in oklab, var(--ink) 35%, transparent);
  }

  /* Right panel slides in from the right on mobile (rail itself stays hidden). */
  .rightpanel-rail { display: none !important; }
  .rightpanel {
    display: flex !important;
    position: fixed;
    top: var(--topbar-h);
    right: 0; bottom: 0;
    width: min(320px, 90vw);
    z-index: 30;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    border-left: 1px solid var(--line);
    box-shadow: 0 0 0 100vmax transparent;
  }
  .app[data-rightpanel-mobile="open"] .rightpanel {
    transform: translateX(0);
    box-shadow: 0 0 0 100vmax color-mix(in oklab, var(--ink) 35%, transparent);
  }

  .hamburger { display: inline-flex !important; }
  .rightpanel-toggle { display: inline-flex !important; }
  .chat-stream { padding: 16px 14px 8px; }
  .bubble { max-width: 100%; }
  .composer { padding: 10px 14px 4px; }
  .composer-hint { padding: 0 14px 10px; }
  .tl-sup { margin: 14px 6px; padding: 12px 14px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar-divider { display: none; }
  .crumb .kind { display: none; }
  .crumb .sid {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .fh-badge .fh-text { display: none; }
  .topbar-right { gap: 8px; }
}
.hamburger {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 30px; height: 30px;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  cursor: pointer;
}
.hamburger:hover { color: var(--ink); border-color: var(--line-strong); }

/* Scrollbars */
.chat-stream::-webkit-scrollbar,
.rp-list::-webkit-scrollbar,
.sidebar-recent::-webkit-scrollbar { width: 8px; }
.chat-stream::-webkit-scrollbar-thumb,
.rp-list::-webkit-scrollbar-thumb,
.sidebar-recent::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--line-strong) 60%, transparent);
  border-radius: 4px;
}
.chat-stream::-webkit-scrollbar-track,
.rp-list::-webkit-scrollbar-track,
.sidebar-recent::-webkit-scrollbar-track { background: transparent; }


/* ========================================================================
   16. DM tab (supervisor ⇄ agent only)
   ======================================================================== */
.dm-header {
  display: flex;
  align-items: stretch;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 10px;
  margin: 0 0 18px;
}
.dm-header-avatar {
  width: 6px;
  border-radius: 3px;
  background: var(--p-color, var(--accent));
  flex-shrink: 0;
}
.dm-header-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dm-header-sub {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  max-width: 60ch;
}

/* DM tab labels in the tab strip */
.tab .tab-prefix {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.tab[aria-selected="true"] .tab-prefix { color: var(--ink-soft); }
.tab .tab-pid {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
}
.tab .tab-role {
  font-size: 11px;
  color: var(--ink-mute);
}
.tab[aria-selected="true"] .tab-role { color: var(--ink-soft); }

/* Two-lane DM layout: supervisor right, agent left.
   Both treatments inherit from the main-timeline rendering so the visual
   language is identical — only the alignment changes. */
.chat-stream[data-mode="dm"] .tl-msg {
  max-width: min(78%, 600px);
  margin-right: auto;
}
.chat-stream[data-mode="dm"] .tl-sup {
  max-width: min(78%, 600px);
  margin-left: auto;
  margin-right: 0;
  /* Flip marker to the right side */
  flex-direction: row-reverse;
}
.chat-stream[data-mode="dm"] .tl-sup .sup-body { text-align: left; }
.chat-stream[data-mode="dm"] .tl-sup .sup-meta { flex-direction: row-reverse; }
.chat-stream[data-mode="dm"] .tl-sup .sup-meta .sup-ts {
  margin-left: 0; margin-right: auto;
}

/* In DM mode, hide system rows entirely (joined/left/lagged are scoped out). */
.chat-stream[data-mode="dm"] .tl-system { display: none; }

/* ========================================================================
   17. Composer attachments
   ======================================================================== */
.composer {
  grid-template-columns: auto 1fr auto;
  gap: 8px;
}
.paperclip-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  transition: var(--transition);
  align-self: end;
}
.paperclip-btn:hover {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent-bg);
}
.paperclip-btn svg { width: 16px; height: 16px; }

.composer-attachments {
  padding: 0 20px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.composer-attachments[hidden] { display: none; }

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  font-size: 12px;
  animation: chip-in 0.12s ease both;
  max-width: 260px;
}
@keyframes chip-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}
.attachment-chip .fname {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.attachment-chip .fsize {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
}
.attachment-chip .rm {
  background: transparent;
  border: none;
  color: var(--ink-mute);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.attachment-chip .rm:hover {
  color: var(--danger);
  background: var(--bg);
}

/* Drag overlay */
.drag-overlay {
  position: absolute;
  inset: 8px;
  border: 2px dashed var(--accent);
  background: color-mix(in oklab, var(--accent-bg) 60%, transparent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 10px;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.drag-overlay.show { opacity: 1; }

/* Supervisor-band attachments (rendered inline after the sup-text) */
.sup-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.sup-att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 11.5px;
}
.sup-att-chip svg { width: 11px; height: 11px; color: var(--ink-mute); }
.sup-att-chip .fname {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sup-att-chip .fsize {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
}

/* Send-pressed flash */
.composer .send.sending {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  animation: send-flash 0.22s ease;
}
@keyframes send-flash {
  0% { transform: scale(1); }
  50% { transform: scale(0.98); }
  100% { transform: scale(1); }
}

/* ========================================================================
   18. Typing / processing indicator
   ======================================================================== */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.typing-dots .td {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--td-color, var(--accent));
  opacity: 0.3;
  animation: td-cycle 1.2s ease-in-out infinite;
}
.typing-dots .td:nth-child(2) { animation-delay: 0.2s; }
.typing-dots .td:nth-child(3) { animation-delay: 0.4s; }
@keyframes td-cycle {
  0%, 100% { opacity: 0.3; }
  40%, 60% { opacity: 1; }
}

/* Right-panel participant row: replace status dot with 3-dot pill while processing */
.participant-row .processing-indicator {
  position: absolute;
  bottom: -2px; right: -4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 5px;
  display: none;
  align-items: center;
  height: 14px;
  box-shadow: 0 1px 0 var(--bg-elev);
}
.participant-row[data-processing="true"] .status-dot { display: none; }
.participant-row[data-processing="true"] .processing-indicator { display: inline-flex; }

/* Bottom-of-chat processing slot (fixed-height) */
.processing-slot {
  height: 32px;
  min-height: 32px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-soft);
  border-top: 1px solid transparent;
  background: var(--bg);
}
.processing-slot:not(:empty) {
  border-top-color: var(--line);
}
.processing-slot .typing-dots .td { background: var(--ink-soft); }
.processing-slot .ps-label { color: var(--ink-soft); }
.processing-slot .ps-fallback { display: none; }

/* Reduced motion: static dots, fallback "Processing" label visible */
@media (prefers-reduced-motion: reduce) {
  .typing-dots .td {
    animation: none;
    opacity: 0.7;
  }
  .processing-slot .ps-label { display: none; }
  .processing-slot .ps-fallback {
    display: inline;
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-mute);
  }
}
