/* ============================================================================
   BotObserver — stylesheet (visual redesign, Powl-inspired, 2026-11-08)
   Design language (taken from the Powl reference screenshots):
   - Near-black canvas, slightly lifted cards with 1 px hairlines and very large radii.
   - One accent (violet) + three status colours (green / amber / red), used sparingly.
   - Big tabular numbers with a small muted caption (stat tiles), pill badges with a dot,
     thin rounded gauges, segmented pill controls, round "orb" avatars with a status dot.
   - One type family (Inter / Segoe UI), monospace only for code and tool calls.
   Accessibility: every text/background pair is >= WCAG AA 4.5:1 in BOTH themes —
   checked by contrast_redesign.py (reads the tokens below), plus the legacy
   contrast_t085*.py scripts (they now read the same tokens).
   Theme: :root = dark (default), [data-theme="light"] = light (set before first paint).
   ============================================================================ */
:root {
  --bg: #0e0e10;             /* page canvas */
  --sidebar: #121214;        /* sidebar */
  --panel: #171719;          /* cards, panels */
  --panel-2: #202023;        /* bubbles, fields, inner blocks */
  --panel-3: #2b2b30;        /* elevation: hover, code, popup */
  --border: #2a2a2f;
  --border-strong: #3d3d45;
  --text: #f4f4f6;
  --text-2: #d3d3db;
  --muted: #a6a6b1;
  --accent: #6a4be0;         /* fills: white on it = 5.7:1 */
  --accent-text: #bba8ff;    /* accent used as TEXT on dark panels */
  --accent-soft: rgba(139, 108, 255, .16);
  --accent-line: rgba(139, 108, 255, .5);
  --ok: #4ade80;
  --warn: #f5b942;
  --low: #fb923c;
  --danger: #ff7b7b;
  --ok-soft: rgba(74, 222, 128, .14);
  --warn-soft: rgba(245, 185, 66, .14);
  --low-soft: rgba(251, 146, 60, .15);
  --danger-soft: rgba(255, 123, 123, .15);
  --track: #2d2d33;          /* gauge track */
  /* Human bubble: violet-tinted (same family as the selected rows in the references). */
  --self-bg: #3a2b78;
  --self-border: #54429f;
  --self-text: #f8f6ff;
  --self-meta: #ddd4ff;
  --self-link: #d9ccff;
  --self-code-bg: rgba(0, 0, 0, .28);
  --self-code-border: rgba(255, 255, 255, .15);
  --badge-bg: rgba(187, 168, 255, .14);
  --shadow: 0 12px 32px rgba(0, 0, 0, .5);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}
/* ---------------------------------------------------------------- Light theme
   Activated by <html data-theme="light"> (set BEFORE rendering by the inline script of
   index.html, persisted in localStorage « bo-theme »). Same structure as the light
   "Token Flex" reference: white cards, soft grey tracks, strong black numbers. */
[data-theme="light"] {
  --bg: #f3f3f6;
  --sidebar: #fbfbfc;
  --panel: #ffffff;
  --panel-2: #f0f0f4;
  --panel-3: #e3e3ea;
  --border: #e2e2e8;
  --border-strong: #c7c7d1;
  --text: #15151a;
  --text-2: #3b3b46;
  --muted: #5c5c69;
  --accent: #5a3fd9;
  --accent-text: #4a2fc2;
  --accent-soft: rgba(90, 63, 217, .1);
  --accent-line: rgba(90, 63, 217, .4);
  --ok: #12743c;
  --warn: #8a5a00;
  --low: #a84300;
  --danger: #b42318;
  --ok-soft: rgba(18, 116, 60, .11);
  --warn-soft: rgba(138, 90, 0, .12);
  --low-soft: rgba(168, 67, 0, .11);
  --danger-soft: rgba(180, 35, 24, .1);
  --track: #e6e6ec;
  --self-bg: #e6e0ff;
  --self-border: #bfb2f5;
  --self-text: #241a5e;
  --self-meta: #4a3a9c;
  --self-link: #3a21b0;
  --self-code-bg: rgba(255, 255, 255, .6);
  --self-code-border: rgba(36, 26, 94, .2);
  --badge-bg: rgba(74, 47, 194, .1);
  --shadow: 0 12px 32px rgba(30, 30, 60, .14);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font-family: inherit; }
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* Discreet scrollbars, consistent with the theme */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* ------------------------------------------------------------ Shared atoms */
/* Orb avatar (generated from the bot name, see botAvatarHtml in app.js). Sizes via font-size. */
.avatar {
  --av-h: 172; position: relative; display: inline-block; flex-shrink: 0; font-size: 26px;
  width: 1em; height: 1em; border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, hsl(var(--av-h) 70% 64%), hsl(var(--av-h) 62% 34%) 78%);
  box-shadow: inset 0 -.06em .12em rgba(0, 0, 0, .25);
}
.avatar::before { /* eyes */
  content: ""; position: absolute; left: .3em; top: .36em; width: .12em; height: .2em; border-radius: 50%;
  background: rgba(10, 10, 20, .62); box-shadow: .26em 0 0 rgba(10, 10, 20, .62); transform: rotate(-6deg);
}
.avatar.lg { font-size: 46px; }
.avatar.md { font-size: 34px; }
.avatar .dot {
  position: absolute; right: -.02em; bottom: -.02em; width: .3em; height: .3em; min-width: 7px; min-height: 7px; border-radius: 50%;
  background: var(--border-strong); border: 2px solid var(--panel); box-sizing: content-box;
}
.avatar .dot.status-working { background: var(--ok); }
.avatar .dot.status-waiting { background: var(--warn); }
.avatar .dot.status-done { background: var(--border-strong); }
.sidebar .avatar .dot { border-color: var(--sidebar); }
.bot-nav-item.active .avatar .dot { border-color: var(--panel-3); }
.hint { color: var(--muted); }
.hint.small { font-size: 12px; margin: 0; }
.hint.small.error, .hint.error { color: var(--danger); }
.hint.small.ok { color: var(--ok); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.small { font-size: 12px; }
.ico { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
/* Pill badge with a status dot (« Au vert » style of the references). */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; line-height: 1;
  padding: 6px 11px; border-radius: 999px; white-space: nowrap; background: var(--panel-3); color: var(--text-2);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.st-working { background: var(--ok-soft); color: var(--ok); }
.pill.st-waiting { background: var(--warn-soft); color: var(--warn); }
.pill.st-done { background: var(--panel-3); color: var(--muted); }
.role-tag {
  display: inline-block; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 999px; background: var(--panel-3); color: var(--muted); margin-right: 6px;
}
.chat-badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--badge-bg); color: var(--accent-text); margin-left: auto; white-space: nowrap;
}
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: var(--text-2);
  text-decoration: none; border: 1px solid var(--border-strong); background: var(--panel); padding: 8px 16px;
  border-radius: 999px; white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.btn-secondary:hover { border-color: var(--accent-line); background: var(--panel-2); color: var(--text); }

/* ---------------------------------------------------------------- Sidebar */
.sidebar {
  width: 292px; flex-shrink: 0; background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 0 0; min-height: 0;
}
.brand {
  display: flex; align-items: center; justify-content: center; padding: 8px 14px; margin: 0 16px 12px;
  background: #fff; border-radius: 14px; min-height: 46px; border: 1px solid var(--border);
}
.mim-logo { height: 28px; object-fit: contain; }
.nav-group { padding: 6px 10px 10px; }
.nav-group.grow { flex: 1; min-height: 120px; display: flex; flex-direction: column; overflow: hidden; }
.nav-group.grow .nav-scroll { flex: 1; min-height: 0; max-height: none; }
.nav-label { font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 10px 8px; letter-spacing: .01em; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  color: var(--text-2); padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; margin-bottom: 1px;
  transition: background .15s, border-color .15s, color .15s;
}
.nav-item .ico { color: var(--muted); transition: color .15s; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item:hover .ico { color: var(--text-2); }
.nav-item.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); font-weight: 600; }
.nav-item.active .ico { color: var(--accent-text); }
.nav-scroll { max-height: 280px; overflow-y: auto; }
.bot-nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  color: var(--text); padding: 5px 10px 5px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; margin-bottom: 1px;
  transition: background .15s, border-color .15s;
}
.bot-nav-item:hover { background: var(--panel-2); }
.bot-nav-item.active { background: var(--panel-3); border-color: var(--border-strong); }
.bot-nav-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.bot-nav-item .last-time { font-size: 11px; color: var(--muted); flex-shrink: 0; cursor: help; font-variant-numeric: tabular-nums; }
.bot-nav-item.stale { opacity: .62; }
.bot-nav-item.stale:hover { opacity: 1; }
.bot-nav-item .room-ico { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; background: var(--panel-2); color: var(--accent-text); flex-shrink: 0; }
.bot-nav-item .room-ico .ico { width: 15px; height: 15px; }

/* Credit lanes mini panel (sidebar), fed by credits.js */
.sb-credits {
  display: block; margin: 0 14px 8px; padding: 10px 14px 9px; border-radius: var(--radius-sm); background: var(--panel);
  border: 1px solid var(--border); text-decoration: none; color: inherit; transition: border-color .15s, background .15s;
}
.sb-credits:hover { border-color: var(--accent-line); background: var(--panel-2); }
.sb-credits-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.sb-credits-head .more { font-weight: 500; color: var(--accent-text); }
.sb-lane { margin-bottom: 6px; }
.sb-lane:last-child { margin-bottom: 0; }
.sb-lane .row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sb-lane .row .nm { flex: 1; color: var(--text); }
.sb-lane .row .pc { font-weight: 600; color: var(--lvl, var(--text)); font-variant-numeric: tabular-nums; }
.sb-lane .bar { height: 5px; border-radius: 999px; background: var(--track); margin-top: 5px; overflow: hidden; }
.sb-lane .bar i { display: block; height: 100%; border-radius: 999px; background: var(--lvl, var(--muted)); }
.sb-credits-empty { font-size: 12px; color: var(--muted); }

.sidebar-footer {
  padding: 10px 18px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted);
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
}
.status-dot { color: var(--ok); }
.status-dot.stale { color: var(--danger); }
.version-info { width: 100%; font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* Language switcher: segmented pill (FR/EN/中文/ES), persisted in localStorage. */
.lang-switcher { display: flex; gap: 2px; margin: 0 14px 10px; padding: 3px; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; }
.lang-btn {
  flex: 1; font-size: 12px; font-weight: 600; padding: 6px 4px; white-space: nowrap; border-radius: 999px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active { background: var(--panel-3); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong) inset; }

/* ---------------------------------------------------------------- Content */
.content { flex: 1; overflow-y: auto; padding: 18px 30px 22px; display: flex; flex-direction: column; min-width: 0; }
.view { display: none; }
.view.active { display: flex; flex-direction: column; flex: 1; min-height: 0; animation: view-in .28s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view-header { margin-bottom: 16px; }
.view-header h1 { margin: 0 0 4px; font-size: 28px; font-weight: 600; letter-spacing: -.025em; line-height: 1.15; }
.view-header p { margin: 0; color: var(--muted); font-size: 13.5px; }
.view-header p a { color: var(--accent-text); }
.view-header code, .hint code, .version-links code { font-family: var(--mono); font-size: 12px; background: var(--panel-3); padding: 1px 6px; border-radius: 6px; }
.chat-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.chat-title-block { display: flex; align-items: center; gap: 14px; min-width: 0; }
.chat-title-block h1 { font-size: 22px; }

/* ------------------------------------------------ Top bar: stat tiles + theme */
.topbar-row { display: flex; align-items: stretch; gap: 12px; margin: 0 0 18px; flex-shrink: 0; }
.status-counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.status-counters.topbar { display: flex; gap: 12px; margin: 0; flex: 1; min-width: 0; padding: 0; background: transparent; border: 0; overflow-x: auto; flex-wrap: nowrap; }
.status-counter {
  position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 20px;
  cursor: pointer; min-width: 138px; display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; transition: border-color .15s, background .15s;
}
.status-counters:not(.topbar) .status-counter { flex-shrink: 1; }
.status-counter[data-status]:hover { border-color: var(--accent-line); }
.status-counter .num { font-size: 28px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.status-counter .lbl { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-counter.working .num { color: var(--ok); }
.status-counter.waiting .num { color: var(--warn); }
.status-counter.done .num { color: var(--text-2); }
.status-counter .help {
  font-size: 10px; color: var(--muted); cursor: help; border: 1px solid var(--border-strong); border-radius: 50%;
  width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle {
  flex-shrink: 0; align-self: center; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; background: var(--panel);
  border: 1px solid var(--border-strong); color: var(--text-2); border-radius: 999px; padding: 9px 16px; font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--accent-line); color: var(--text); background: var(--panel-2); }
.theme-toggle .icon { font-size: 15px; line-height: 1; }
/* Shared popup (position:fixed, positioned in JS — see renderStatusCounters). */
#status-popup-shared .popup-item { cursor: pointer; border-radius: 8px; padding-left: 8px; padding-right: 8px; }
#status-popup-shared .popup-item:hover { background: var(--panel-2); color: var(--accent-text); }
#status-popup-shared {
  display: none; position: fixed; z-index: 200; background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; min-width: 240px; max-width: 340px; max-height: 280px; overflow-y: auto; box-shadow: var(--shadow);
}
#status-popup-shared.visible { display: block; }
.status-popup .popup-title, #status-popup-shared .popup-title { font-size: 12px; font-weight: 600; color: var(--muted); margin: 2px 0 6px; padding: 0 8px; }
.status-popup .popup-item, #status-popup-shared .popup-item { font-size: 13px; padding: 5px 8px; }
.status-popup .popup-empty, #status-popup-shared .popup-empty { font-size: 12.5px; color: var(--muted); font-style: italic; padding: 0 8px; }

/* ----------------------------------------------------------------- Roster */
.roster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.bot-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; cursor: pointer;
  display: flex; flex-direction: column; gap: 10px; min-width: 0; transition: border-color .15s, background .15s, transform .15s;
}
.bot-card:hover { border-color: var(--accent-line); background: var(--panel-2); transform: translateY(-1px); }
.bot-card .bc-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.bot-card .bc-id { min-width: 0; flex: 1; }
.bot-card .title { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 7px; min-width: 0; line-height: 1.25; }
.bot-card .title .t { min-width: 0; flex: 1 1 0; overflow-wrap: anywhere; }
.bot-card .badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 4px 0 2px; }
.bot-card .badges:empty { display: none; }
.bot-card .badges .chat-badge { margin-left: 0; }
.bot-card .meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-card .last-msg-time { font-size: 12.5px; color: var(--text-2); cursor: help; }
.bot-card .last-msg-time strong { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.bot-card .last-msg-time .rel { color: var(--muted); font-size: 12px; }
.bot-card.stale { opacity: .68; }
.bot-card.stale:hover { opacity: 1; }
.bot-card .last-msg-time.stale strong { color: var(--danger); }
.bot-card .preview {
  font-size: 13px; color: var(--text-2); background: var(--panel-2); border-radius: var(--radius-sm); padding: 9px 12px;
  max-height: 72px; overflow: hidden; line-height: 1.45;
}
[data-theme="light"] .bot-card .preview { background: var(--panel-2); }
/* 30-day usage line of a bot card (tokens + cost) with a share bar relative to the busiest bot */
.bot-card .bc-usage { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.bot-card .bc-usage .row { display: flex; justify-content: space-between; gap: 10px; }
.bot-card .bc-usage b { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.bot-card .bc-usage .bar { height: 5px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bot-card .bc-usage .bar i { display: block; height: 100%; background: var(--accent-text); border-radius: 999px; }
.fleet-filter { display: flex; gap: 6px; align-items: center; margin: 0 0 14px; flex-wrap: wrap; padding: 3px; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; width: fit-content; }
.fleet-filter .fleet-filter-btn {
  font-size: 12.5px; font-weight: 600; padding: 6px 14px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.fleet-filter .fleet-filter-btn:hover { color: var(--text); }
.fleet-filter .fleet-filter-btn.active { background: var(--panel-3); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong) inset; }

/* Status dots outside avatars (generic .dot, kept for compatibility) */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; display: inline-block; }
.dot.status-working { background: var(--ok); }
.dot.status-waiting { background: var(--warn); }

/* ---------------------------------------------------- Fleet badge (T-090) */
.fleet-badge {
  display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px; border: 1px solid transparent; line-height: 1.2; flex-shrink: 0; white-space: nowrap;
}
.fleet-badge.fleet-chaud { background: var(--ok-soft); color: var(--ok); border-color: rgba(74, 222, 128, .3); }
[data-theme="light"] .fleet-badge.fleet-chaud { border-color: rgba(18, 116, 60, .3); }
.fleet-badge.fleet-pause { background: var(--panel-3); color: var(--muted); border-color: var(--border-strong); }
.fleet-badge.fleet-archive { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.fleet-badge.fleet-unknown { background: transparent; color: var(--muted); border-color: var(--border); opacity: .7; }
/* "Live session" pulse: a Hermes process is really writing in the profile WAL right now (< 15 min). */
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #22c55e; display: inline-block; flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: live-pulse 1.6s ease-out infinite;
}
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); } 70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.live-label { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; color: var(--ok); text-transform: uppercase; letter-spacing: .04em; }

/* --------------------------------------------------- Chat (1:1 and rooms) */
.chat-body { display: flex; gap: 12px; flex: 1; min-height: 0; }
.chat-header-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.session-picker { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.session-picker select {
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--text); padding: 8px 14px; border-radius: 999px;
  font-size: 13px; max-width: 340px; cursor: pointer;
}
.session-picker select:focus { outline: none; border-color: var(--accent-line); }
.session-picker.single select { opacity: .75; }
.refresh-ind { width: 12px; height: 12px; display: inline-block; flex-shrink: 0; }
.refresh-ind.on { border: 2px solid var(--border-strong); border-top-color: var(--accent-text); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton-wrap { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.skeleton-wrap .loading-label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.sk { border-radius: var(--radius); background: var(--panel-3); animation: pulse 1.2s ease-in-out infinite; }
.sk.bubble { height: 38px; width: 55%; }
.sk.bubble.right { align-self: flex-end; width: 40%; }
.sk.bubble.long { height: 64px; width: 70%; }
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.chat-main { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
.chat-window {
  flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 26px; padding: 16px 18px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; min-height: 0;
}

/* Bubbles: no pre-wrap on .msg (template whitespace would render as blank lines). */
.msg { max-width: 74%; padding: 9px 14px 10px; border-radius: 20px; white-space: normal; word-break: break-word; line-height: 1.5; font-size: 14px; }
.msg .meta {
  display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.msg .meta .who { font-weight: 600; color: var(--accent-text); }
.msg .meta .extra { color: var(--text-2); }
.msg .meta .extra::before { content: "·"; margin-right: 6px; color: var(--muted); }
.msg .meta .when { font-variant-numeric: tabular-nums; }
.msg .meta .when::before { content: "·"; margin-right: 6px; }
/* WhatsApp-style alignment (T-080): ONLY the real human author (isHuman) goes right, tinted. */
.msg.msg-self { align-self: flex-end; background: var(--self-bg); border: 1px solid var(--self-border); color: var(--self-text); border-bottom-right-radius: 6px; }
.msg.msg-self .meta { color: var(--self-meta); }
.msg.msg-self .meta .who { color: var(--self-text); }
.msg.msg-self code, .msg.msg-self .md-code { background: var(--self-code-bg); border-color: var(--self-code-border); color: var(--self-text); }
.msg.msg-self a { color: var(--self-link); }
.msg.msg-other { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-style: italic; font-size: 12.5px; padding: 2px 8px; }
.msg.pass-line { align-self: stretch; max-width: 100%; background: transparent; border: none; padding: 1px 6px; display: flex; align-items: baseline; gap: 6px; opacity: .75; font-size: 12px; }
.msg.pass-line .meta { margin-bottom: 0; }
.msg.pass-line .pass-tag { font-style: italic; color: var(--muted); }
.msg.pending { opacity: .8; border-style: dashed; }
.msg .pending-note { font-size: 12px; color: var(--self-meta); margin-top: 3px; font-style: italic; }

/* T-083: ultra-compact tool calls / results (no full bubble). */
.tool-call-compact, .tool-result-compact { margin: 0; padding: 0 2px; font-size: 12.5px; line-height: 1.3; display: block; }
.tool-call-line {
  display: inline-block; margin: 1px 6px 1px 0; font-family: var(--mono); font-size: 12px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px; color: var(--text-2); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.tool-call-line strong { color: var(--accent-text); font-weight: 600; }
.tool-result-compact details { display: inline-block; margin-right: 6px; max-width: 100%; }
.tool-result-compact summary { display: list-item; cursor: pointer; color: var(--muted); font-size: 12px; user-select: none; }
.tool-result-compact summary:hover { color: var(--text); }
.tool-result-compact pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin: 4px 0 0; overflow-x: auto;
  font-size: 11.5px; white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow-y: auto;
}
.msg.tool-call, .msg.tool-result { align-self: stretch; max-width: 100%; background: var(--panel-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); opacity: .9; white-space: normal; }
.tool-badge { font-size: 12.5px; padding: 2px 0; font-family: var(--mono); color: var(--text-2); }
.tool-badge strong { color: var(--accent-text); }
.tool-raw { margin-top: 3px; font-size: 12px; }
.tool-raw summary { cursor: pointer; color: var(--muted); user-select: none; }
.tool-raw summary:hover { color: var(--text); }
.tool-raw pre, .tool-result-content {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin: 4px 0 0; overflow-x: auto;
  font-size: 12px; font-family: var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 340px; overflow-y: auto;
}
.tool-meta { color: var(--muted); font-weight: 400; }
.tool-inline { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border-strong); }

/* ------------------------------------------------ Markdown (bubble text) */
.md-body { white-space: normal; }
.md-body p { margin: 0 0 5px; }
.md-body p:last-child { margin-bottom: 0; }
.md-body .md-h { margin: 8px 0 4px; font-size: 15px; font-weight: 650; }
.md-body .md-h:first-child { margin-top: 0; }
.md-body .md-list { margin: 3px 0 5px; padding-left: 20px; }
.md-body .md-list:last-child { margin-bottom: 0; }
.md-body .md-list li { margin-bottom: 2px; }
.md-body code { background: var(--panel-3); border: 1px solid var(--border); padding: 0 5px; border-radius: 6px; font-size: 12.5px; font-family: var(--mono); }
.md-body .md-code { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; overflow-x: auto; font-size: 12.5px; margin: 6px 0; white-space: pre-wrap; }
.md-body .md-code code { background: none; border: none; padding: 0; }
.md-body a { color: var(--accent-text); }
.md-body .md-table { border-collapse: collapse; margin: 6px 0; font-size: 13px; }
.md-body .md-table th, .md-body .md-table td { border: 1px solid var(--border-strong); padding: 4px 9px; text-align: left; }
.md-body .md-table th { background: var(--panel-3); }
.tools-toggle { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; cursor: pointer; white-space: nowrap; }
.tools-toggle input { cursor: pointer; accent-color: var(--accent); }

/* --------------------------------------------------------- Composer pill */
.chat-composer {
  display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 28px; padding: 8px 8px 8px 20px; transition: border-color .15s;
}
.chat-composer:focus-within { border-color: var(--accent-line); }
.chat-composer textarea, .chat-composer select { background: transparent; border: 0; color: var(--text); padding: 8px 0; font-size: 14px; resize: none; line-height: 1.45; }
.chat-composer select { background: var(--panel-2); border-radius: 999px; padding: 9px 14px; flex-shrink: 0; max-width: 200px; font-size: 13px; }
.chat-composer textarea::placeholder { color: var(--muted); }
.chat-composer textarea:focus, .chat-composer select:focus { outline: none; }
.chat-composer textarea { flex: 1; }
.chat-composer button {
  background: var(--accent); color: #fff; border: none; height: 42px; padding: 0 22px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 600;
  flex-shrink: 0; transition: filter .15s;
}
.chat-composer button:hover { filter: brightness(1.12); }
.chat-composer button:disabled { opacity: .5; cursor: not-allowed; }

/* --------------------------------------------------------- Timeline / filters */
.timeline-controls { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }
.timeline-controls input, .timeline-controls select {
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--text); padding: 10px 16px; border-radius: 999px; font-size: 13.5px;
}
.timeline-controls input::placeholder { color: var(--muted); }
.timeline-controls input:focus, .timeline-controls select:focus { outline: none; border-color: var(--accent-line); }
.timeline-controls input#timeline-search { flex: 1; min-width: 200px; }
.timeline-controls button { background: var(--accent); color: #fff; border: none; padding: 10px 20px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.timeline-controls button:hover { filter: brightness(1.12); }
.timeline-list { display: flex; flex-direction: column; gap: 0; flex: 1; min-height: 0; overflow-y: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.tl-row { padding: 11px 18px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.tl-row:last-child { border-bottom: none; }
.tl-row:hover { background: var(--panel-2); }
.tl-row .tl-head { display: flex; gap: 8px; align-items: center; margin-bottom: 3px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.tl-row .tl-bot { color: var(--accent-text); font-weight: 600; cursor: pointer; }
.tl-row .tl-bot:hover { text-decoration: underline; }
.tl-row .tl-role { padding: 2px 8px; border-radius: 999px; background: var(--panel-3); text-transform: uppercase; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; }
.tl-row.tl-tool { opacity: .82; }
.tl-row.tl-tool .tl-content { font-family: var(--mono); font-size: 12px; color: var(--muted); max-height: 60px; }
.tl-row .tl-content { white-space: pre-wrap; word-break: break-word; max-height: 112px; overflow: hidden; color: var(--text-2); line-height: 1.45; }

/* ------------------------------------------------------------ Tables */
.usage-err { color: var(--danger); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usage-err.small { font-size: 12px; margin-top: 4px; }
.usage-empty { color: var(--muted); font-size: 13px; padding: 12px 6px; }
.usage-empty.error { color: var(--danger); }
.usage-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.usage-table th, .usage-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.usage-table th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-size: 12px; font-weight: 500; z-index: 1; }
.usage-table td.num, .usage-table th.num { text-align: right; }
.usage-table tbody tr { transition: background .12s; }
.usage-table tbody tr:hover { background: var(--panel-2); }
.usage-table tr.dim { opacity: .55; }
.usage-table tfoot td { font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: none; background: var(--panel-2); }
.usage-table-wrap { max-height: calc(100vh - 360px); overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; }
.usage-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; border: 1px solid var(--border-strong); box-sizing: content-box; }
.usage-share { display: inline-block; width: 80px; height: 6px; background: var(--track); border-radius: 999px; margin-right: 8px; vertical-align: middle; overflow: hidden; }
.usage-share-fill { height: 100%; background: var(--accent-text); border-radius: 999px; }

/* Tickets (T-117) */
.tickets-controls { margin-bottom: 14px; }
.tickets-controls select, .tickets-controls input { background: var(--panel); color: var(--text); border: 1px solid var(--border-strong); border-radius: 999px; padding: 10px 16px; font-size: 13.5px; }
.tickets-controls input { flex: 1; min-width: 220px; }
/* A select grows to its longest option (owner lines can be very long): cap it so the row never overflows. */
.timeline-controls select, .tickets-controls select { max-width: 260px; min-width: 0; text-overflow: ellipsis; }
.tickets-table .tickets-title-cell { white-space: normal; max-width: 360px; min-width: 200px; }
.tickets-table .tickets-deps-cell { white-space: normal; max-width: 260px; color: var(--muted); font-size: 12px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; cursor: help; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.st-ouvert { background: rgba(96, 165, 250, .16); color: #7db8fb; }
.status-badge.st-en-cours { background: var(--warn-soft); color: var(--warn); }
.status-badge.st-a-verifier { background: var(--accent-soft); color: var(--accent-text); }
.status-badge.st-resolu { background: var(--ok-soft); color: var(--ok); }
[data-theme="light"] .status-badge.st-ouvert { background: rgba(37, 99, 235, .1); color: #1d4ed8; }
.status-counter.st-ouvert .num { color: #7db8fb; }
.status-counter.st-en-cours .num { color: var(--warn); }
.status-counter.st-a-verifier .num { color: var(--accent-text); }
.status-counter.st-resolu .num { color: var(--ok); }
[data-theme="light"] .status-counter.st-ouvert .num { color: #1d4ed8; }
.prio-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid var(--border-strong); }
.prio-badge.prio-p0 { color: var(--danger); border-color: rgba(248, 113, 113, .45); background: var(--danger-soft); }
.prio-badge.prio-p1 { color: var(--low); border-color: rgba(251, 146, 60, .45); background: var(--low-soft); }
.prio-badge.prio-p2 { color: var(--muted); }
.prio-badge.prio-p3 { color: var(--muted); opacity: .75; }

/* ---------- Version / Commits views (T-087) ---------- */
.version-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 26px; max-width: 680px; display: flex; flex-direction: column; gap: 10px; }
.version-big { font-size: 26px; letter-spacing: -.02em; margin-bottom: 6px; }
.version-row { display: flex; gap: 14px; font-size: 14px; align-items: baseline; }
.version-row .lbl { width: 90px; color: var(--muted); font-size: 12px; flex-shrink: 0; }
.version-links { margin-top: 22px; max-width: 960px; }
.version-links h2 { font-size: 16px; margin: 0 0 6px; font-weight: 600; }
.version-links .usage-table { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.version-links .usage-table td { white-space: normal; }
.commits-list { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; overflow: auto; max-height: calc(100vh - 190px); }
.commits-table td:last-child { white-space: normal; max-width: 900px; }
.commits-table td.nowrap { white-space: nowrap; }
.commits-table code, .usage-table code { font-family: var(--mono); font-size: 12px; background: var(--panel-3); padding: 1px 6px; border-radius: 6px; }

/* ------------------------------------------------- Usages: shared building blocks
   (page layout details live in usage-polish.css, scoped to #view-usage) */
.usage-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding-top: 2px; }
.usage-health { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.usage-health.ok { color: var(--ok); }
.usage-health.error { color: var(--danger); }
.usage-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; flex-shrink: 0; }
.usage-freshness { border-radius: var(--radius); padding: 8px 14px; margin-bottom: 10px; font-size: 12.5px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); flex-shrink: 0; }
.usage-freshness.stale { border-color: var(--low); background: var(--low-soft); color: var(--text); }
.usage-freshness.stale strong { color: var(--low); letter-spacing: .04em; }
.usage-freshness.fresh { border-color: var(--ok); color: var(--muted); }
.usage-kpi.unknown .num { color: var(--low); font-style: italic; }
.usage-kpi-note { grid-column: 1 / -1; font-size: 12px; color: var(--muted); padding: 0 2px; }
.usage-quotas-hint { font-size: 12px; margin: 2px 0 6px; max-width: 1100px; }
.usage-kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
.usage-kpi .lbl { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.usage-kpi .num { font-size: 30px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--text); margin: 2px 0; line-height: 1.15; }
.usage-kpi .sub { font-size: 12.5px; color: var(--muted); }
.usage-tabs { display: flex; gap: 2px; align-items: center; margin-bottom: 10px; flex-shrink: 0; padding: 3px; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; }
.usage-tab { background: transparent; border: 0; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 999px; cursor: pointer; transition: background .15s, color .15s; }
.usage-tab:hover { color: var(--text); }
.usage-tab.active { background: var(--panel-3); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong) inset; }
.usage-tab-spacer { flex: 1; }
.usage-days { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.usage-days select { background: var(--panel); border: 1px solid var(--border-strong); color: var(--text); padding: 8px 14px; border-radius: 999px; font-size: 13px; }
.usage-pane { display: none; }
.usage-pane.active { display: block; }
.usage-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.usage-card-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.usage-card-title code { font-family: var(--mono); font-size: 12px; background: var(--panel-3); padding: 0 5px; border-radius: 6px; }
.usage-split { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(320px, 1fr); gap: 14px; }
@media (max-width: 1100px) { .usage-split { grid-template-columns: 1fr; } }
/* Per-bot expandable rows */
.usage-bots tr.usage-bot { cursor: pointer; }
.usage-caret { display: inline-block; width: 12px; color: var(--muted); transition: transform .12s; font-size: 11px; }
.usage-bot.open .usage-caret { transform: rotate(90deg); }
.usage-sub { display: none; background: var(--bg); }
.usage-sub.visible { display: table-row; }
.usage-sub td { border-bottom: 1px dashed var(--border); font-size: 12.5px; color: var(--text-2); }
.usage-sub-name { padding-left: 28px !important; }
/* Quota windows (legacy monitor cards): thin rounded gauges coloured by the shared thresholds */
.usage-quotas { margin-bottom: 14px; flex-shrink: 0; }
.usage-quotas-head { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.usage-quota-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.usage-quota-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.usage-quota-card.error { border-color: rgba(255, 123, 123, .5); }
.usage-quota-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; }
.usage-win { margin-top: 8px; }
.usage-win-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); gap: 10px; }
.usage-win-head strong { color: var(--text); font-variant-numeric: tabular-nums; }
.usage-bar { height: 10px; background: var(--track); border-radius: 999px; overflow: hidden; margin: 7px 0; }
.usage-bar-fill { height: 100%; background: var(--accent-text); border-radius: 999px; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.usage-bar-fill.mid { background: var(--warn); }
.usage-bar-fill.low { background: var(--low); }
.usage-bar-fill.block { background: var(--danger); }
.usage-win-reset { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.usage-win-reset .rel { color: var(--text-2); }
/* Daily stacked bars (pure CSS, no canvas) */
.usage-chart { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding: 4px 0 0; border-bottom: 1px solid var(--border); }
.usage-daybar { flex: 1; display: flex; flex-direction: column-reverse; height: 100%; min-width: 3px; border-radius: 4px 4px 0 0; overflow: hidden; }
.usage-daybar:hover { outline: 1px solid var(--accent-text); }
.usage-daybar .seg { width: 100%; }
.usage-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.usage-chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 3px; }

/* ================================================================ Credit lanes
   (credits.js — CreditGate state, read-only). Level colours come from --lvl,
   set per element by .lvl-ok / .lvl-warn / .lvl-low / .lvl-block / .lvl-unknown. */
.lvl-ok { --lvl: var(--ok); --lvl-soft: var(--ok-soft); }
.lvl-warn { --lvl: var(--warn); --lvl-soft: var(--warn-soft); }
.lvl-low { --lvl: var(--low); --lvl-soft: var(--low-soft); }
.lvl-block { --lvl: var(--danger); --lvl-soft: var(--danger-soft); }
.lvl-unknown { --lvl: var(--muted); --lvl-soft: var(--panel-3); }
.cg-section { margin: 0 0 24px; }
.cg-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 24px; margin: 0 0 14px; }
.cg-head h2 { font-size: 19px; margin: 0 0 3px; font-weight: 600; letter-spacing: -.015em; }
.cg-head p { margin: 0; color: var(--muted); font-size: 13px; max-width: 660px; }
.cg-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cg-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.cg-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--lvl, var(--muted)); display: inline-block; }
.cg-chip.stale { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.cg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.cg-lane { background: var(--panel); border: 1px solid var(--border); border-radius: 26px; padding: 20px 22px 18px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cg-lane.lvl-warn, .cg-lane.lvl-low, .cg-lane.lvl-block { border-color: var(--lvl); }
.cg-lane-head { display: flex; align-items: center; gap: 12px; }
.cg-ico { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: var(--panel-2); color: var(--text); flex-shrink: 0; }
.cg-ico svg { width: 22px; height: 22px; }
.cg-lane-id { flex: 1; min-width: 0; }
.cg-lane-name { font-size: 17px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.cg-lane-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--lvl-soft); color: var(--lvl); font-size: 12px; font-weight: 700; white-space: nowrap; }
.cg-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cg-win { border-top: 1px solid var(--border); padding-top: 16px; }
.cg-win:first-of-type { border-top: 0; padding-top: 0; }
.cg-win-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cg-win-label { font-size: 14px; font-weight: 600; color: var(--text); }
.cg-free { font-size: 12.5px; padding: 5px 12px; border-radius: 999px; background: var(--panel-2); color: var(--text-2); white-space: nowrap; }
.cg-big { display: flex; align-items: baseline; gap: 6px; margin: 10px 0 0; flex-wrap: wrap; }
.cg-big .n { font-size: 46px; font-weight: 600; letter-spacing: -.04em; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.cg-big .u { font-size: 22px; font-weight: 500; color: var(--text-2); }
.cg-big .t { font-size: 13.5px; color: var(--muted); margin-left: 4px; }
.cg-reset { font-size: 13px; color: var(--muted); margin-top: 4px; }
.cg-reset strong { color: var(--text-2); font-weight: 600; }
.cg-gauge { position: relative; height: 14px; background: var(--track); border-radius: 999px; margin: 16px 0 4px; }
.cg-gauge .fill { position: absolute; left: 0; top: 0; bottom: 0; min-width: 14px; border-radius: 999px; background: var(--lvl); transition: width .7s cubic-bezier(.2, .8, .2, 1); }
.cg-gauge .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--panel); }
.cg-scale { position: relative; height: 16px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cg-scale span { position: absolute; transform: translateX(-50%); top: 2px; }
.cg-legend { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--text-2); margin-top: 6px; }
.cg-legend .k { display: inline-flex; align-items: center; gap: 7px; }
.cg-legend .k i { width: 11px; height: 11px; border-radius: 4px; background: var(--lvl); display: inline-block; }
.cg-legend .k.free i { background: var(--track); border: 1px solid var(--border-strong); }
.cg-legend b { font-weight: 600; color: var(--text); margin-left: 4px; }
.cg-extras { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.cg-extra .row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--text-2); }
.cg-extra .row b { color: var(--text); font-weight: 600; }
.cg-extra .bar { height: 6px; border-radius: 999px; background: var(--track); margin-top: 7px; overflow: hidden; }
.cg-extra .bar i { display: block; height: 100%; background: var(--lvl, var(--accent-text)); border-radius: 999px; }
.cg-note { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
/* Projection block (time to reach each threshold). Text stays on neutral tokens; the level shows through the dot. */
.cg-eta { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.cg-eta-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.cg-eta-head .ttl { font-size: 14px; font-weight: 600; color: var(--text); }
.cg-eta-head .win { font-size: 12.5px; color: var(--text-2); padding: 2px 10px; border-radius: 999px; background: var(--panel-2); }
.cg-eta-head .trend { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; }
.cg-eta-rows { display: flex; flex-direction: column; gap: 2px; }
.cg-eta-row { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--text-2); padding: 4px 0; border-top: 1px dashed var(--border); }
.cg-eta-row:first-child { border-top: 0; }
.cg-eta-row i { width: 9px; height: 9px; border-radius: 50%; background: var(--lvl); display: inline-block; flex: none; align-self: center; }
.cg-eta-row .th { font-weight: 600; color: var(--text); min-width: 42px; font-variant-numeric: tabular-nums; }
.cg-eta-row .nm { color: var(--muted); }
.cg-eta-row .when { margin-left: auto; text-align: right; min-width: 0; }
.cg-eta-row .when b { color: var(--text); font-weight: 600; }
.cg-eta-row .when em { font-style: normal; color: var(--muted); }
.cg-eta-row.done .when b { color: var(--text-2); }
.cg-eta-row.done i { opacity: .55; }
.cg-eta-verdict { font-size: 13px; color: var(--text-2); line-height: 1.45; border-left: 3px solid var(--border-strong); padding-left: 10px; }
.cg-eta-verdict.bad { color: var(--text); font-weight: 600; border-left-color: var(--danger); }
.cg-eta-note { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
/* Consumption curve (credits.js): the SVG is stretched to the card with non-scaling strokes; axis labels, end dots and
   the tooltip are HTML so they stay sharp. Line colours = lane brand tints (3:1+ on both panels). */
.cg-curve { --c-claude: #e8896a; --c-chatgpt: #3ed6a6; --c-kimi: #6fb0ff; --c-other: #c4b5fd; margin-top: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 26px; padding: 20px 22px 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
[data-theme="light"] .cg-curve { --c-claude: #b8502d; --c-chatgpt: #0b7a5d; --c-kimi: #1d63c9; --c-other: #5b3fd9; }
.cg-curve .lc-claude, .cg-curve.lc-claude { --c: var(--c-claude); }
.cg-curve .lc-chatgpt { --c: var(--c-chatgpt); }
.cg-curve .lc-kimi { --c: var(--c-kimi); }
.cg-curve .lc-other { --c: var(--c-other); }
.cg-curve-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px 24px; }
.cg-curve-top h2 { font-size: 19px; margin: 0 0 3px; font-weight: 600; letter-spacing: -.015em; }
.cg-curve-top p { margin: 0; color: var(--muted); font-size: 13px; max-width: 660px; }
.cg-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); }
.cg-seg button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.cg-seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.cg-seg button:focus-visible, .cg-lg:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.cg-lgrow { display: flex; flex-wrap: wrap; gap: 8px; }
.cg-lg { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); color: var(--text-2); font: inherit; font-size: 12.5px; cursor: pointer; }
.cg-lg i { width: 16px; height: 4px; border-radius: 2px; background: var(--c); }
.cg-lg b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.cg-lg[aria-pressed="false"] { opacity: .5; }
.cg-lg[aria-pressed="false"] i { background: var(--border-strong); }
.cg-plotwrap { display: grid; grid-template-columns: 38px minmax(0, 1fr); column-gap: 6px; }
.cg-yax { position: relative; height: 260px; }
.cg-yax span { position: absolute; right: 0; transform: translateY(-50%); display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cg-yax span i { width: 6px; height: 6px; border-radius: 50%; background: var(--lvl); }
.cg-plot { position: relative; height: 260px; touch-action: pan-y; cursor: crosshair; }
.cg-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.cg-plot .zone { fill: var(--danger-soft); }
.cg-plot .fut { fill: var(--panel-2); opacity: .55; }
.cg-plot .g { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cg-plot .th { stroke: var(--lvl); stroke-width: 1; stroke-dasharray: 5 5; opacity: .8; vector-effect: non-scaling-stroke; }
.cg-plot .nowl { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 2 4; vector-effect: non-scaling-stroke; }
.cg-plot .ln { fill: none; stroke: var(--c); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.cg-plot .pj { fill: none; stroke: var(--c); stroke-width: 2.4; stroke-dasharray: 3 6; stroke-linecap: round; opacity: .9; vector-effect: non-scaling-stroke; }
.cg-dot { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--c); border: 2px solid var(--panel); transform: translate(-50%, -50%); pointer-events: none; }
.cg-futlbl { position: absolute; right: 8px; top: 6px; font-size: 11px; color: var(--muted); pointer-events: none; }
.cg-hover { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border-strong); pointer-events: none; }
.cg-tip { position: absolute; top: 8px; z-index: 2; transform: translateX(12px); min-width: 150px; padding: 8px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border-strong); font-size: 12.5px; color: var(--text-2); pointer-events: none; white-space: nowrap; }
.cg-tip.flip { transform: translateX(calc(-100% - 12px)); }
.cg-tip .when { color: var(--text); font-weight: 600; margin-bottom: 4px; }
.cg-tip .r { display: flex; align-items: center; gap: 7px; }
.cg-tip .r i { width: 10px; height: 4px; border-radius: 2px; background: var(--c); }
.cg-tip .r b { margin-left: auto; padding-left: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.cg-hover[hidden], .cg-tip[hidden] { display: none; }
.cg-xax { position: relative; height: 20px; margin-top: 6px; }
.cg-xax span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cg-curve-note { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.cg-curve-empty { font-size: 13.5px; color: var(--muted); padding: 18px 0; }
@media (max-width: 560px) { .cg-yax, .cg-plot { height: 210px; } .cg-curve { padding: 16px 14px 14px; } }
/* In-page OpenCode sign-in window (remote-login.js) */
body.rl-lock { overflow: hidden; }
.rl-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .62); }
.rl-box { background: var(--panel); border: 1px solid var(--border-strong); border-radius: 26px; padding: 18px 20px 16px; width: min(1060px, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.rl-head { display: flex; align-items: center; gap: 12px; }
.rl-head h3 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; letter-spacing: -.01em; }
.rl-left { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rl-cancel { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.rl-cancel:hover { background: var(--panel-2); }
.rl-cancel:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.rl-hint, .rl-note { margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.45; }
.rl-note { font-size: 12px; color: var(--muted); }
.rl-stage { position: relative; background: #111; border-radius: 14px; overflow: hidden; line-height: 0; }
.rl-stage canvas { width: 100%; height: auto; aspect-ratio: 1000 / 700; display: block; touch-action: none; }
.rl-field { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; resize: none; }
.rl-state { position: absolute; inset: 0; display: grid; place-items: center; color: #ddd; font-size: 14px; line-height: 1.4; background: rgba(0, 0, 0, .35); }
.rl-state[hidden] { display: none; }

/* OpenCode reconnect (console session expired): button + progress message, filled by credits.js */
.cg-reconnect { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.cg-rc-btn { align-self: flex-start; padding: 10px 18px; border-radius: 999px; border: 0; background: var(--accent); color: #fff; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: filter .15s; }
.cg-rc-btn:hover:not(:disabled) { filter: brightness(1.12); }
.cg-rc-btn:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.cg-rc-btn:disabled { opacity: .65; cursor: progress; }
.cg-rc-msg { font-size: 13px; line-height: 1.45; color: var(--text-2); }
.cg-rc-help { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.cg-reconnect.busy .cg-rc-msg { border-left: 3px solid var(--accent); padding-left: 10px; color: var(--text); }
.cg-reconnect.good .cg-rc-msg { border-left: 3px solid var(--ok); padding-left: 10px; color: var(--text); }
.cg-reconnect.bad .cg-rc-msg { border-left: 3px solid var(--danger); padding-left: 10px; color: var(--text); }
.cg-empty { background: var(--panel); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 22px; color: var(--muted); font-size: 13.5px; }
.cg-empty strong { color: var(--text); display: block; margin-bottom: 4px; font-size: 15px; }

/* Lane brand tints (icon only; text colours stay on the neutral tokens) */
.cg-ico.claude { color: #e8896a; }
.cg-ico.chatgpt { color: #3ed6a6; }
.cg-ico.kimi { color: #6fb0ff; }
.cg-ico.opencode { color: #c4b5fd; }
[data-theme="light"] .cg-ico.opencode { color: #5b3fd9; }
[data-theme="light"] .cg-ico.claude { color: #b8502d; }
[data-theme="light"] .cg-ico.chatgpt { color: #0b7a5d; }
[data-theme="light"] .cg-ico.kimi { color: #1d63c9; }
/* Gauges grow from 0 on first paint only (class removed by credits.js after ~1.4 s). */
.cg-section.animate .cg-gauge .fill { animation: cg-grow .9s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes cg-grow { from { width: 0; } }

/* Signed-in user chip (sidebar footer, filled by auth.js) */
.auth-chip { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.auth-chip[hidden] { display: none; }
.auth-user { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.auth-chip.setup .auth-user { color: var(--warn); white-space: normal; }
.auth-logout {
  flex-shrink: 0; font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px; background: transparent; color: var(--text-2);
  border: 1px solid var(--border-strong); cursor: pointer; transition: background .15s, border-color .15s;
}
.auth-logout:hover { background: var(--panel-2); border-color: var(--accent-line); color: var(--text); }
.auth-logout[hidden] { display: none; }

/* ------------------------------------------------------------- Responsive */
@media (max-width: 980px) {
  .sidebar { width: 236px; }
  .content { padding: 16px 18px 20px; }
  .view-header h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---- Hand-entered window (Kimi monthly total) + cycle projection ---- */
.cg-win.cycle { border-top: 1px dashed var(--border); padding-top: 14px; margin-top: 2px; }
.cg-man-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.cg-man-badge { padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text-2); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.cg-man-meta .warn { color: var(--warn); font-weight: 600; }
.cg-cycle { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.cg-cycle-pace { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cg-man-add { padding: 4px 0; }
.cg-man-link { align-self: flex-start; background: none; border: 0; padding: 6px 0; margin-top: 6px; color: var(--accent-text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.cg-man-link:hover:not(:disabled) { filter: brightness(1.15); }
.cg-man-link:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; border-radius: 4px; }
.cg-man-link:disabled { opacity: .5; cursor: progress; }
.cg-man-link.danger { color: var(--danger); }
.cg-man-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.cg-man-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.cg-man-form input { font: inherit; font-size: 14px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text); font-variant-numeric: tabular-nums; min-width: 0; }
.cg-man-form input:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.cg-man-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.cg-man-actions .cg-man-link { margin-top: 0; }
.cg-man-err { font-size: 12.5px; color: var(--danger); font-weight: 600; }
.cg-man-help { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ---- Kimi automatic reading block (KimiWebService) ---- */
.cg-kimiweb { margin-top: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-2); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.cg-kimiweb.good { border-color: rgba(52, 199, 123, .45); }
.cg-kimiweb.bad { border-color: var(--danger); }
.cg-kw-title { font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--text-2); }
.cg-kimiweb .cg-rc-msg { font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.cg-kimiweb .cg-man-link { margin-top: 0; }
.cg-ico.nous { color: #5eead4; }
[data-theme="light"] .cg-ico.nous { color: #0f766e; }
