/* Breezy web client – design tokens from the "Obsidian Kinetic" design reference.
   Fonts are self-hosted (SIL OFL, see fonts/OFL-*.txt); no external requests. */

@font-face {
  font-family: "Space Grotesk"; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url("fonts/space-grotesk.woff2") format("woff2");
}
@font-face {
  font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("fonts/plus-jakarta-sans.woff2") format("woff2");
}
@font-face {
  font-family: "Plus Jakarta Sans"; font-style: italic; font-weight: 200 800; font-display: swap;
  src: url("fonts/plus-jakarta-sans-italic.woff2") format("woff2");
}

:root {
  /* Surfaces: obsidian canvas, cards rise through tonal layers. */
  --canvas: #0a0e16;
  --canvas-base: #0b0f17;
  --card: #111827;
  --card-raised: #161e2e;
  --elevated: #1a2234;
  --surface: #1c2028;
  --surface-high: #262a33;
  --surface-highest: #31353e;
  --border: #1e293b;
  --border-strong: #2b3a52;
  --border-glow: #22c55e40;

  --text: #e6e9f2;
  --text-strong: #f9fafb;
  --muted: #94a3b8;
  --faint: #64748b;

  --primary: #22c55e;
  --primary-bright: #4be277;
  --on-primary: #0b0f17;
  --primary-soft: #22c55e1f;
  --primary-glow: #22c55e66;
  --cobalt: #0066ff;
  --cobalt-text: #8db5ff;
  --cobalt-soft: #0066ff1f;
  --cobalt-border: #0066ff33;
  --sky: #38bdf8;
  --sky-soft: #38bdf81f;
  --warn: #fbbf24;
  --warn-soft: #fbbf241f;
  --danger: #ffb4ab;
  --danger-strong: #ff6b5e;
  --danger-soft: #93000a40;

  /* Security levels */
  --private: var(--primary);
  --private-soft: var(--primary-soft);
  --light: var(--sky);
  --light-soft: var(--sky-soft);
  --pro: var(--cobalt-text);
  --pro-soft: var(--cobalt-soft);

  --font-head: "Space Grotesk", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --font-body: "Plus Jakarta Sans", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-sm: .5rem;
  --r: 1rem;
  --r-md: 1.5rem;
  --r-lg: 2rem;
  --r-xl: 3rem;
  --pill: 9999px;

  --gutter: 1.5rem;
  --margin: 2.5rem;
  --sidebar-w: 18rem;
  --shadow-float: 0 20px 40px -10px rgba(0, 0, 0, .7);
  --bloom: radial-gradient(ellipse at top, #22c55e12 0%, transparent 70%);
  --accent-line: linear-gradient(90deg, transparent, var(--primary), transparent);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--canvas);
  color: var(--text);
  font: 400 15px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: .45; cursor: default; }
a { color: var(--cobalt-text); }
h1, h2, h3 { font-family: var(--font-head); color: var(--text-strong); margin: 0; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: #22c55e55; }
* { scrollbar-width: thin; scrollbar-color: var(--surface-high) transparent; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--faint); font-size: 12px; font-weight: 400; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 13px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; }
.eyebrow, .section-label {
  font: 600 10px/14px var(--font-head); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.section-label { padding: 4px 12px 8px; }

svg.icon {
  width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.accent-icon { color: var(--primary); }

/* ------------------------------------------------------------------ brand */
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 36px; height: 36px; border-radius: 50%; background: var(--card); border: 1px solid var(--border);
  display: grid; place-items: center; flex: none;
}
.logo::after {
  content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.brand-name { font: 600 14px/1.2 var(--font-head); color: var(--text-strong); letter-spacing: -.01em; }
.brand-sub { font: 500 10px/1.4 var(--font-head); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px;
  border-radius: var(--pill); font: 600 13px/1 var(--font-head); letter-spacing: .01em; white-space: nowrap;
  transition: background-color .15s, box-shadow .15s, transform .15s, color .15s, border-color .15s;
  text-decoration: none;
}
.btn svg.icon { width: 16px; height: 16px; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover:not(:disabled) { transform: scale(1.02); box-shadow: 0 0 20px var(--primary-glow); }
.btn.secondary { background: var(--card); border: 1px solid var(--cobalt); color: var(--cobalt-text); }
.btn.secondary:hover:not(:disabled) { background: var(--cobalt-soft); }
.btn.ghost { color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); background: var(--surface); }
.btn.ghost-border { border: 1px solid var(--border-strong); color: var(--text); }
.btn.ghost-border:hover { border-color: var(--border-glow); background: var(--surface); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: #ffdad6; }
.btn.armed, .icon-btn.armed { background: var(--danger-soft); color: #ffdad6; }
.link-btn { font: 600 12px var(--font-head); color: var(--cobalt-text); text-decoration: none; margin-left: auto; }
.link-btn:hover { text-decoration: underline; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--muted);
  flex: none; transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.round-btn {
  width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  transition: transform .15s, box-shadow .15s, background-color .15s;
}
.round-btn.primary { background: var(--primary); color: var(--on-primary); }
.round-btn.primary:hover:not(:disabled) { transform: scale(1.04); box-shadow: 0 0 20px var(--primary-glow); }
.round-btn.secondary { background: var(--surface-high); color: var(--text); }
.round-btn.secondary:hover { background: var(--surface-highest); }
.round-btn svg.icon { width: 20px; height: 20px; stroke-width: 2.2; }
.round-btn.sm { width: 36px; height: 36px; }
.round-btn.sm svg.icon { width: 16px; height: 16px; }

/* Inputs: pill fields on the obsidian base. */
.field { display: grid; gap: 6px; font: 500 12px/16px var(--font-head); letter-spacing: .02em; color: var(--muted); min-width: 0; }
.field .hint { font-family: var(--font-body); letter-spacing: 0; }
.field input, .field select, .field textarea, .input {
  width: 100%; height: 48px; padding: 0 18px; border-radius: var(--pill); border: 1px solid var(--border);
  background: var(--canvas-base); color: var(--text); font: 400 14px/1.5 var(--font-body); letter-spacing: 0;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; padding: 12px 18px; border-radius: var(--r); resize: vertical; min-height: 72px; }
.field select { appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 21px, calc(100% - 17px) 21px; background-size: 5px 5px; background-repeat: no-repeat; }
.field select:disabled { opacity: .6; cursor: default; }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 4px #22c55e1a;
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: start; }
.check { display: inline-flex; gap: 10px; align-items: center; font-size: 14px; color: var(--text); cursor: pointer; }
input[type="checkbox"] {
  appearance: none; width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--border-strong);
  background: var(--canvas-base); display: inline-grid; place-items: center; cursor: pointer; flex: none; margin: 0;
}
input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary); }
input[type="checkbox"]:checked::after {
  content: ""; width: 5px; height: 9px; border: solid var(--on-primary); border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}
fieldset { border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 16px 12px; margin: 0; display: grid; gap: 12px; }
legend { font: 600 10px/14px var(--font-head); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 0 6px; }

/* Chips & badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--pill);
  background: var(--surface-high); color: var(--muted); font: 600 10px/1 var(--font-head); letter-spacing: .06em;
  text-transform: uppercase; white-space: nowrap; flex: none;
}
.chip.has-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.mode.private, .chip.ok { background: var(--private-soft); color: var(--primary-bright); }
.chip.mode.light { background: var(--light-soft); color: var(--sky); }
.chip.mode.pro { background: var(--pro-soft); color: var(--cobalt-text); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--danger-soft); color: var(--danger); }
.chip.time { background: var(--surface-high); color: var(--text); font-size: 11px; }
.badge-icon {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--primary-soft); color: var(--primary-bright);
}
.badge-icon.big { width: 56px; height: 56px; }
.badge-icon.big svg.icon { width: 26px; height: 26px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: var(--on-primary);
  display: inline-grid; place-items: center; font: 700 12px var(--font-head); flex: none; letter-spacing: 0;
}
.avatar.muted-av { background: var(--surface-high); color: var(--text); }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: none; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 #22c55e66; } 50% { opacity: .7; box-shadow: 0 0 0 5px #22c55e00; } }

/* Bento cards */
.bento {
  position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 24px; transition: border-color .2s;
}
.bento.accent::before {
  content: ""; position: absolute; top: -1px; left: 12%; right: 12%; height: 1px; background: var(--accent-line);
}
.bento.hoverable:hover { border-color: var(--border-glow); background-image: var(--bloom); }
.card-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card-head h2 { font-size: 15px; font-weight: 600; }
.notice {
  background: var(--card); border: 1px solid var(--cobalt-border); border-radius: var(--r); padding: 12px 16px;
  font-size: 14px; color: var(--text); margin-bottom: var(--gutter);
}
.notice.warn { border-color: #fbbf2455; }

/* ------------------------------------------------------------------ auth views */
.center-view { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; overflow-y: auto;
  background: radial-gradient(ellipse at 50% -10%, #22c55e14, transparent 60%), var(--canvas); }
.auth-card { width: 100%; max-width: 420px; padding: 32px; display: grid; gap: 14px; border-radius: var(--r-xl); }
.auth-title { font-size: 28px; line-height: 36px; margin-top: 8px; }
.auth-card p { margin: 0; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font: 500 11px var(--font-head);
  letter-spacing: .06em; text-transform: uppercase; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ------------------------------------------------------------------ app shell */
body.app { overflow: hidden; }
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }

#sidebar {
  background: var(--canvas); display: flex; flex-direction: column; min-height: 0; padding: 24px 20px 20px; gap: 6px;
}
.sidebar-top { display: grid; gap: 14px; }
.sidebar-top .brand { padding: 0 6px 6px; }
.nav-cta {
  height: 44px; border-radius: var(--pill); background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  font: 600 12px var(--font-head); letter-spacing: .03em; color: var(--text-strong); transition: background-color .15s, border-color .15s;
}
.nav-cta:hover { background: var(--surface); border-color: var(--border-glow); }
.nav-cta svg.icon { transition: transform .2s; }
.nav-cta:hover svg.icon { transform: rotate(90deg); }
.nav-links { display: grid; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px; border-radius: var(--pill); color: var(--muted);
  text-decoration: none; font-size: 13px; transition: background-color .15s, color .15s;
}
.nav-link:hover { background: var(--card); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--surface); color: var(--text-strong); font-weight: 600; }
.nav-link[aria-current="page"] svg.icon { color: var(--primary); }
.search { position: relative; display: block; }
.search svg.icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input {
  width: 100%; height: 40px; border-radius: var(--pill); border: 1px solid transparent; background: var(--card);
  padding: 0 14px 0 40px; font-size: 13px; outline: none;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { border-color: var(--primary); background: var(--surface); }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.conv {
  text-decoration: none;
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 14px;
  border-radius: var(--pill); color: var(--muted); font-size: 13px; transition: background-color .15s, color .15s;
}
.conv:hover { background: var(--card); color: var(--text); }
.conv.active { background: var(--surface); color: var(--text-strong); font-weight: 600; }
.conv .ellipsis { flex: 1; }
.conv .agent-mark { color: var(--cobalt-text); width: 14px; height: 14px; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot.private { background: var(--private); }
.dot.light { background: var(--light); }
.dot.pro { background: var(--cobalt); }
.conv-empty { padding: 10px 14px; color: var(--faint); font-size: 13px; }

.user-card { position: relative; margin-top: 8px; }
.user-card summary {
  list-style: none; display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px; border-radius: var(--pill);
  background: var(--card); border: 1px solid var(--border); cursor: pointer; transition: background-color .15s;
}
.user-card summary::-webkit-details-marker { display: none; }
.user-card summary:hover { background: var(--surface); }
.user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
#me-name { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.user-role { font: 500 10px var(--font-head); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.user-card .chev { transform: rotate(-90deg); color: var(--muted); width: 16px; height: 16px; transition: transform .15s; }
.user-card[open] .chev { transform: rotate(90deg); }
.user-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; right: 0; background: var(--elevated); border: 1px solid var(--cobalt-border);
  border-radius: var(--r-md); padding: 6px; box-shadow: var(--shadow-float); display: grid; gap: 2px; z-index: 5;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--pill); color: var(--text);
  text-decoration: none; font-size: 13px; width: 100%; text-align: left;
}
.menu-item:hover { background: var(--surface-high); }

.main-wrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; height: 100dvh; }
.topbar {
  height: 64px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 2rem;
  background: #0a0e16cc; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); position: relative; z-index: 4;
}
.crumbs { display: flex; align-items: center; gap: 8px; font: 500 12px var(--font-head); color: var(--muted); min-width: 0; flex: 1; }
.crumbs .sep { color: #94a3b866; }
.crumb-current { color: var(--text-strong); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 20px; flex: none; }
.segmented { display: flex; align-items: center; background: var(--card); border: 1px solid var(--border); padding: 4px; border-radius: var(--pill); gap: 2px; }
.segmented button {
  padding: 5px 14px; border-radius: var(--pill); font: 500 11px/16px var(--font-head); letter-spacing: .02em; color: var(--muted);
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"].private { background: var(--primary); color: var(--on-primary); box-shadow: 0 2px 10px #22c55e55; }
.segmented button[aria-checked="true"].light { background: #0ea5e9; color: #fff; box-shadow: 0 2px 10px #0ea5e955; }
.segmented button[aria-checked="true"].pro { background: #0066f5; color: #fff; box-shadow: 0 2px 10px #0066f566; }
.segmented button.other-zone { opacity: .7; }
.status-chip { display: inline-flex; align-items: center; gap: 8px; font: 500 11px var(--font-head); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.status-chip.down .pulse-dot { background: var(--warn); animation: none; }
.status-chip.unknown .pulse-dot { background: var(--faint); animation: none; }

.content { flex: 1; min-height: 0; position: relative; }
.view { height: 100%; }

/* ------------------------------------------------------------------ chat */
.chat-grid {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2rem; padding: 0 2rem;
  max-width: 1720px; margin: 0 auto;
}
.chat-col { grid-column: span 8; display: flex; flex-direction: column; min-height: 0; height: 100%; min-width: 0; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 0 4px; }
.chat-title-row { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.title-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); flex: none; animation: pulse 2.4s infinite; }
.title-dot.light { background: var(--sky); animation: none; }
.title-dot.pro { background: var(--cobalt); animation: none; }
#chat-title { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.chat-actions { display: flex; gap: 4px; }
.rename-form { display: flex; gap: 8px; flex: 1; min-width: 0; }
.rename-form input { flex: 1; min-width: 0; height: 36px; border-radius: var(--pill); border: 1px solid var(--primary); background: var(--canvas-base); padding: 0 14px; outline: none; }

.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1.5rem; padding: 1rem 2px 1.5rem; min-height: 0; }
.msg { border-radius: var(--r-lg); padding: 22px 24px; position: relative; overflow-wrap: anywhere; }
.msg-user { background: var(--card); border: 1px solid var(--border); }
.msg-ai { background: var(--card-raised); border: 1px solid var(--border); padding: 24px 28px; }
.msg-ai::before { content: ""; position: absolute; top: -1px; left: 15%; right: 15%; height: 1px; background: var(--accent-line); opacity: .7; }
.msg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; min-width: 0; }
.msg-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.msg-name { font: 600 13px var(--font-head); color: var(--text-strong); }
.msg-ai .msg-name { font-size: 15px; }
.msg-sub { font: 500 11px var(--font-head); color: var(--muted); letter-spacing: .02em; display: flex; gap: 8px; flex-wrap: wrap; }
.msg-sub .warn { color: var(--danger); }
.msg-user .msg-body { padding-left: 48px; white-space: pre-wrap; font-size: 15px; color: var(--text); }
.msg-body { font-size: 15px; line-height: 1.7; color: var(--text); }
.msg-body p { margin: 0 0 .8em; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body strong { color: var(--text-strong); }
.msg-body ul, .msg-body ol { margin: .3em 0 .8em; padding-left: 1.4em; }
.msg-body pre { background: var(--canvas-base); border: 1px solid var(--border); padding: 14px 16px; border-radius: var(--r); overflow-x: auto; margin: .7em 0; }
.msg-body code { font: 13px/1.5 var(--font-mono); }
.msg-body :not(pre) > code { background: var(--canvas-base); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
.msg.failed, .msg.cancelled { border-color: #ffb4ab55; }
.cursor::after { content: ""; display: inline-block; width: 8px; height: 1.1em; vertical-align: -3px; margin-left: 2px; background: var(--primary); animation: blink 1s steps(2) infinite; border-radius: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.thinking { display: inline-flex; gap: 5px; padding: 6px 0; }
.thinking span { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: bounce 1.2s infinite ease-in-out; }
.thinking span:nth-child(2) { animation-delay: .15s; background: var(--primary-bright); }
.thinking span:nth-child(3) { animation-delay: .3s; background: var(--cobalt); }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

.empty { margin-top: 1rem; padding: 32px; border-radius: var(--r-xl); }
.empty-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.empty h2 { font-size: 28px; line-height: 36px; margin-bottom: 6px; }
.empty > p { margin: 0 0 20px; }
.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.mode-card { background: var(--canvas-base); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px; }
.mode-card p { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.composer-wrap { padding: 4px 0 max(10px, env(safe-area-inset-bottom)); flex: none; }
.composer {
  display: flex; align-items: flex-end; gap: 10px; background: var(--card); border: 1px solid var(--border);
  border-radius: 28px; padding: 6px 6px 6px 22px; transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px #22c55e1a; }
#input {
  flex: 1; resize: none; border: 0; outline: none; background: transparent; padding: 11px 0; max-height: 240px;
  font-size: 15px; line-height: 22px; min-width: 0;
}
#input::placeholder { color: var(--faint); }
.zone-note { text-align: center; font: 500 11px var(--font-head); letter-spacing: .04em; color: var(--faint); margin: 8px 8px 0; min-height: 1em; }
.zone-note kbd { font: inherit; color: var(--muted); }

/* Right rail */
.rail { grid-column: span 4; overflow-y: auto; display: flex; flex-direction: column; gap: 1.5rem; padding: 1rem 2px 2rem; min-height: 0; }
.rail .bento { border-radius: var(--r-xl); padding: 24px; }
.rail-head { display: flex; align-items: center; justify-content: space-between; }
.usage-body { display: grid; gap: 16px; margin-top: 18px; }
.stat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-tile { background: var(--canvas-base); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px; min-width: 0; }
.stat-label { display: flex; align-items: center; justify-content: space-between; gap: 6px; font: 500 11px var(--font-head); color: var(--muted); }
.stat-value { font: 700 24px/1.1 var(--font-head); color: var(--text-strong); margin: 10px 0 2px; letter-spacing: -.02em; }
.stat-value small { font: 500 12px var(--font-head); color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.dots { display: flex; gap: 5px; margin-top: 10px; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-highest); }
.dots span.on { background: var(--primary); }
.dots.cobalt span.on { background: var(--cobalt); }
.mode-rows { display: grid; gap: 8px; }
.mode-row { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 10px; font-size: 12px; }
.mode-row .bar { height: 6px; border-radius: 3px; background: var(--surface-high); overflow: hidden; }
.mode-row .bar span { display: block; height: 100%; border-radius: 3px; }
.mode-row .num { font: 500 12px var(--font-head); color: var(--muted); font-variant-numeric: tabular-nums; }
.bar .private { background: var(--private); }
.bar .light { background: var(--light); }
.bar .pro { background: var(--cobalt); }

.rail-task, .task-card { display: flex; flex-direction: column; gap: 14px; }
.task-top { display: flex; align-items: flex-start; gap: 12px; }
.task-top .badge-icon { margin-top: 2px; }
.task-titles { flex: 1; min-width: 0; display: grid; gap: 3px; }
.task-titles h2, .task-titles h3 { font-size: 16px; font-weight: 600; line-height: 22px; }
.task-desc { margin: 0; font-size: 13px; line-height: 1.6; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.last-run { display: flex; align-items: center; gap: 12px; background: var(--canvas-base); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; }
.last-run .lr-icon { color: var(--primary); }
.last-run.failed .lr-icon { color: var(--danger); }
.last-run.none .lr-icon { color: var(--faint); }
.lr-text { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 12px; }
.lr-text strong { font-weight: 600; color: var(--text); }
.lr-text span { font-size: 11px; color: var(--muted); }
.task-actions { display: flex; align-items: center; gap: 8px; }
.task-actions .btn { flex: 1; background: var(--canvas-base); border: 1px solid var(--border); color: var(--text); }
.task-actions .btn:hover { background: var(--surface); }
.rail-agents { display: grid; gap: 8px; margin-top: 16px; }
.agent-row { display: flex; align-items: center; gap: 10px; background: var(--canvas-base); border: 1px solid var(--border); border-radius: var(--pill); padding: 6px 6px 6px 16px; min-width: 0; }
.agent-row .name { flex: 1; font-size: 13px; color: var(--text); }
.rail-empty { font-size: 13px; color: var(--muted); margin: 0; }

/* ------------------------------------------------------------------ pages (agents, tasks) */
.page { overflow-y: auto; padding: 1.5rem 2rem 3rem; }
.page > * { max-width: 1720px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { font-size: 28px; line-height: 36px; font-weight: 600; }
.page-head p { margin: 4px 0 0; max-width: 680px; font-size: 14px; }
.page-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2rem; align-items: start; }
.list-col { grid-column: span 7; display: grid; gap: 1.5rem; min-width: 0; }
.task-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.editor-col { grid-column: span 5; position: sticky; top: 0; border-radius: var(--r-xl); padding: 28px; min-width: 0; }
.editor-empty { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 32px 8px; }
.editor-empty p { margin: 0; max-width: 260px; }
.empty-list { text-align: center; padding: 40px 24px; border-radius: var(--r-xl); }
.empty-list p { margin: 8px 0 16px; }

.agent-card { display: grid; gap: 14px; }
.agent-card.disabled { opacity: .7; }
.agent-card.selected, .task-card.selected { border-color: var(--border-glow); background-image: var(--bloom); }
.agent-top { display: flex; align-items: flex-start; gap: 14px; }
.agent-top .titles { flex: 1; min-width: 0; display: grid; gap: 6px; }
.agent-top h3 { font-size: 17px; font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.agent-desc { margin: 0; font-size: 13px; color: var(--muted); }
.subagents { position: relative; display: grid; gap: 8px; margin-left: 17px; padding-left: 24px; }
.subagents::before { content: ""; position: absolute; left: 0; top: 0; bottom: 18px; width: 1.5px; background: var(--cobalt); opacity: .7; }
.subagent { position: relative; display: flex; align-items: center; gap: 10px; background: var(--canvas-base); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 10px 10px 16px; min-width: 0; }
.subagent::before { content: ""; position: absolute; left: -24px; top: 50%; width: 24px; height: 1.5px; background: var(--cobalt); opacity: .7; }
.subagent::after { content: ""; position: absolute; left: -4px; top: calc(50% - 3px); width: 7px; height: 7px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 8px var(--primary-glow); }
.subagent .info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.subagent .name { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.subagent .desc { font-size: 12px; color: var(--muted); }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.weekdays label { position: relative; }
.weekdays input { position: absolute; opacity: 0; pointer-events: none; }
.weekdays span {
  display: inline-grid; place-items: center; min-width: 44px; height: 32px; padding: 0 10px; border-radius: var(--pill);
  border: 1px solid var(--border-strong); font: 600 12px var(--font-head); color: var(--muted); cursor: pointer;
}
.weekdays input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.weekdays input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.runs { display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: 14px; }
.run-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--canvas-base); border: 1px solid var(--border); border-radius: var(--pill); font-size: 12px; }
.run-row .when { flex: 1; color: var(--muted); }
.run-row a { font: 600 12px var(--font-head); text-decoration: none; }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--elevated); color: var(--text);
  border: 1px solid var(--cobalt-border); padding: 12px 18px; border-radius: var(--r); font-size: 14px;
  box-shadow: var(--shadow-float); max-width: calc(100% - 32px); z-index: 50;
}

/* ------------------------------------------------------------------ responsive */
.only-narrow, .only-rail-drawer { display: none !important; }
.scrim { position: fixed; inset: 0; background: #0009; z-index: 19; }

/* Tablet & small desktop: the rail becomes a drawer, the chat takes the full width. */
@media (max-width: 1279px) {
  .only-rail-drawer { display: inline-grid !important; }
  .rail-head.only-rail-drawer { display: flex !important; }
  .chat-col { grid-column: 1 / -1; }
  .rail {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(25rem, 92vw); z-index: 20; background: var(--canvas);
    border-left: 1px solid var(--border); padding: 20px; transform: translateX(100%); transition: transform .2s ease;
    box-shadow: var(--shadow-float);
  }
  .rail.open { transform: none; }
  .list-col, .editor-col { grid-column: 1 / -1; }
  .editor-col { position: static; }
  .editor-col.idle { display: none; }
}
/* Narrow: the sidebar becomes a drawer. */
@media (max-width: 899px) {
  :root { --gutter: 1rem; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .only-narrow { display: inline-grid !important; }
  #sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, 20rem); z-index: 20; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-float); border-right: 1px solid var(--border);
  }
  #sidebar.open { transform: none; }
  .sidebar-top .brand .only-narrow { margin-left: auto; }
  .topbar { padding: 0 1.25rem; gap: 10px; }
  .topbar-right { gap: 10px; }
  .chat-grid { padding: 0 1.25rem; gap: 1rem; }
  .page { padding: 1rem 1.25rem 2rem; }
  .page-grid { gap: 1rem; }
  .msg { padding: 18px; }
  .msg-ai { padding: 20px; }
  .msg-user .msg-body { padding-left: 0; }
  #top-avatar { display: none; }
}
@media (max-width: 640px) {
  .crumbs { display: none; }
  .topbar-right { flex: 1; justify-content: flex-end; }
  .status-chip .status-text { display: none; }
  .segmented button { padding: 5px 10px; }
  .empty { padding: 22px; }
  .empty h2 { font-size: 22px; line-height: 30px; }
  .chat-actions .btn span { display: none; }
  .editor-col { padding: 20px; border-radius: var(--r-lg); }
  .rail .bento { border-radius: var(--r-lg); padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
