/* Anima UI. Motion is part of the design: every change eases in, nothing jumps.
   Colors are tokens; dark is the default look, light follows the system. */

:root {
  --bg: #0b0b10;
  --bg-2: #111118;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.075);
  --surface-solid: #16161f;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --fg: #ecebf3;
  --fg-2: #b4b3c2;
  --muted: #7d7c8e;
  --accent: #8b7cff;
  --accent-2: #5ec8ff;
  --accent-fg: #0b0b10;
  --user: linear-gradient(135deg, #7a6bff 0%, #5b8cff 100%);
  --ok: #58d68d;
  --warn: #ffb547;
  --danger: #ff6b7a;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, 0.6);
  --glass: blur(18px) saturate(1.4);
  --radius: 16px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.36, 0.5, 1);
  --fast: 160ms;
  --mid: 320ms;
  --slow: 560ms;
  --font: "Inter", "SF Pro Text", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f5fb;
    --bg-2: #efeef7;
    --surface: rgba(20, 16, 60, 0.035);
    --surface-2: rgba(20, 16, 60, 0.06);
    --surface-solid: #ffffff;
    --line: rgba(20, 16, 60, 0.08);
    --line-2: rgba(20, 16, 60, 0.14);
    --fg: #17161f;
    --fg-2: #45435a;
    --muted: #7f7d93;
    --accent: #6a58ff;
    --accent-fg: #ffffff;
    --shadow: 0 12px 40px -16px rgba(30, 20, 90, 0.25);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  letter-spacing: -0.005em;
  color: var(--fg);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(139, 124, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(94, 200, 255, 0.07), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.spacer { flex: 1; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- controls ---------- */

button {
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 14px; cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease), opacity var(--fast);
}
button:hover { background: var(--surface-2); border-color: var(--line-2); }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
button.sm { padding: 5px 11px; font-size: 13px; }
button.wide { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: 9px; background: transparent; border-color: transparent; color: var(--fg-2); }
.icon-btn:hover { color: var(--fg); }
input, select, textarea {
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; outline: none;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast);
}
input:focus, select:focus, textarea:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- agent orbs ----------
   A living gradient sphere per agent. Hue comes from the agent's name.
   States: idle (slow breathing), thinking (fast swirl), tool (orbiting
   spark), waiting (warm pulse for approvals). */

.orb {
  --h: 258;
  --size: 36px;
  --speed: 9s;
  position: relative; flex-shrink: 0;
  width: var(--size); height: var(--size); border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, hsl(calc(var(--h) + 30) 100% 88% / 0.95), transparent 38%),
    radial-gradient(circle at 70% 75%, hsl(calc(var(--h) - 50) 95% 55%), transparent 60%),
    radial-gradient(circle at 50% 50%, hsl(var(--h) 85% 58%), hsl(calc(var(--h) + 25) 80% 32%));
  box-shadow: 0 0 calc(var(--size) * 0.5) calc(var(--size) * -0.12) hsl(var(--h) 90% 62% / 0.55), inset 0 0 calc(var(--size) * 0.2) hsl(calc(var(--h) + 40) 100% 80% / 0.35);
  overflow: hidden; isolation: isolate;
  animation: orb-breathe 4.8s var(--ease) infinite;
  transition: box-shadow var(--slow) var(--ease), filter var(--slow);
}
.orb i, .orb b {
  position: absolute; inset: -30%; border-radius: 45%;
  background: conic-gradient(from 0deg, transparent 0 20%, hsl(calc(var(--h) + 60) 100% 70% / 0.55) 30%, transparent 45% 65%, hsl(calc(var(--h) - 60) 100% 65% / 0.5) 78%, transparent 90%);
  filter: blur(calc(var(--size) * 0.09));
  mix-blend-mode: screen;
  animation: orb-spin var(--speed) linear infinite;
}
.orb b { animation-direction: reverse; animation-duration: calc(var(--speed) * 1.45); border-radius: 40%; opacity: 0.8; }
.orb::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.55), transparent 28%);
  pointer-events: none;
}
.orb.xs { --size: 18px; } .orb.sm { --size: 24px; } .orb.md { --size: 34px; } .orb.lg { --size: 64px; } .orb.xl { --size: 120px; } .orb.hero { --size: 96px; }
.orb.thinking { --speed: 1.6s; animation: orb-think 1.2s var(--ease) infinite; box-shadow: 0 0 calc(var(--size) * 0.9) calc(var(--size) * -0.05) hsl(var(--h) 95% 65% / 0.75), inset 0 0 calc(var(--size) * 0.2) hsl(calc(var(--h) + 40) 100% 80% / 0.45); }
.orb.tool { --speed: 3s; }
.orb.tool::before {
  content: ""; position: absolute; z-index: 2; width: 22%; height: 22%; left: 39%; top: 39%; border-radius: 50%;
  background: #fff; box-shadow: 0 0 8px 2px hsl(var(--h) 100% 80%);
  animation: orb-orbit 1.1s linear infinite;
}
.orb.waiting { --h: 35 !important; animation: orb-wait 1.4s var(--ease) infinite; }
.orb.offline { filter: grayscale(0.9) brightness(0.7); animation: none; }
.orb.offline i, .orb.offline b { animation-play-state: paused; }

@keyframes orb-spin { to { transform: rotate(360deg); } }
@keyframes orb-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045); } }
@keyframes orb-think { 0%, 100% { transform: scale(0.96); } 50% { transform: scale(1.08); } }
@keyframes orb-wait { 0%, 100% { transform: scale(1); filter: brightness(1); } 50% { transform: scale(1.07); filter: brightness(1.25); } }
@keyframes orb-orbit { from { transform: rotate(0deg) translateX(calc(var(--size) * 0.3)) rotate(0deg); } to { transform: rotate(360deg) translateX(calc(var(--size) * 0.3)) rotate(-360deg); } }

/* ---------- login ---------- */

.login { position: fixed; inset: 0; display: grid; place-items: center; align-content: safe center; gap: 28px; padding: 24px; overflow-y: auto; animation: fade-in var(--slow) var(--ease); }
.login-orb { animation: rise var(--slow) var(--spring) both; }
.login-card { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; animation: rise var(--slow) var(--ease) 80ms both; }
.login-card h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; font-weight: 700; }
.login-card p { margin: 0 0 8px; }
.login-card input { text-align: center; padding: 13px; }
.login-card button { padding: 12px; }
.error { color: var(--danger); min-height: 1.4em; margin: 0; font-size: 14px; }
.shake { animation: shake 420ms var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

/* ---------- layout ---------- */

.app { display: flex; height: 100dvh; animation: fade-in var(--slow) var(--ease); }
.sidebar {
  width: 272px; flex-shrink: 0; display: flex; flex-direction: column; gap: 18px;
  padding: 16px 12px 12px; border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-2) 70%, transparent); backdrop-filter: var(--glass);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; font-weight: 700; letter-spacing: -0.02em; font-size: 16px; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-left: auto; transition: background var(--mid), box-shadow var(--mid); }
.conn.up { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent); }
.conn.down { background: var(--warn); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.side-section { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.side-section.grow { flex: 1; }
.side-title { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0 8px; min-height: 30px; }
.agent-list, .tree, .tree ul, .list { list-style: none; margin: 0; padding: 0; }
.agent-list li {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 12px; cursor: pointer;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.agent-list li:hover { background: var(--surface); }
.agent-list li.active { background: var(--surface-2); }
.agent-list .name { font-weight: 600; font-size: 14px; }
.agent-list .desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-list .meta { min-width: 0; flex: 1; }
.agent-list li.active { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.agent-list .n { font-size: 11px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 18px; text-align: right; }
.agent-list li.active .n { color: var(--fg-2); }
.agent-list .n.bump { animation: pop var(--mid) var(--spring); }
.side-actions { display: flex; align-items: center; gap: 4px; }
.sessions-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sessions-title.swap { animation: drop var(--mid) var(--ease); }
.chip-sm { font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: none; padding: 3px 9px; border-radius: 999px; color: var(--fg-2); background: var(--surface); border-color: var(--line); animation: pop var(--mid) var(--spring); }
.tree-empty { font-size: 13px; color: var(--muted); padding: 10px 8px; line-height: 1.45; animation: fade-in var(--mid) var(--ease); }
.tree { overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.tree ul { margin-left: 18px; padding-left: 8px; border-left: 1px solid var(--line); }
.tree li > .row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; cursor: pointer; font-size: 14px; color: var(--fg-2);
  transition: background var(--fast) var(--ease), color var(--fast);
  animation: slide-in var(--mid) var(--ease) both;
}
.tree li > .row:hover { background: var(--surface); color: var(--fg); }
.tree li > .row.active { background: var(--surface-2); color: var(--fg); }
.tree li { transition: height 240ms var(--ease), opacity 200ms var(--ease); }
.tree li.leaving { height: 0 !important; opacity: 0; overflow: hidden; }
.tree li.leaving > .row { transform: translateX(-24px); transition: transform 240ms var(--ease); }
.tree li > .row { position: relative; transform: translateX(var(--swipe, 0)); }
.tree li > .row { transition: background var(--fast) var(--ease), color var(--fast), transform var(--mid) var(--spring); }
.tree .tick { width: 0; height: 16px; border-radius: 6px; border: 1.5px solid var(--line-2); display: grid; place-items: center; flex-shrink: 0; opacity: 0; margin-right: -8px; overflow: hidden; color: var(--accent-fg); transition: width var(--mid) var(--spring), opacity var(--fast), margin var(--mid) var(--spring), background var(--fast), border-color var(--fast); }
.tree .tick svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; transform: scale(0); transition: transform var(--mid) var(--spring); }
.tree.selecting .tick { width: 16px; opacity: 1; margin-right: 0; }
.tree .row.picked .tick { background: var(--accent); border-color: var(--accent); }
.tree .row.picked .tick svg { transform: scale(1); }
.tree .row.picked { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--fg); }
.row-acts { display: flex; gap: 2px; margin: -4px -4px -4px 0; opacity: 0; transform: translateX(6px); pointer-events: none; transition: opacity var(--fast), transform var(--mid) var(--spring); }
.tree li > .row:hover .row-acts, .tree li > .row:focus-within .row-acts { opacity: 1; transform: none; pointer-events: auto; }
.tree.selecting .row-acts { display: none; }
.row-act { width: 26px; height: 26px; padding: 0; display: grid; place-items: center; border-radius: 8px; background: transparent; border-color: transparent; color: var(--muted); }
.row-act:hover { background: var(--surface-2); color: var(--fg); }
.row-act.del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.row-act svg, .archived-link svg, .confirm-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tree li > .row:hover .live, .tree li > .row:hover .wait { display: none; }
@media (hover: none) {
  .row-acts { position: absolute; right: -92px; top: 0; bottom: 0; margin: 0; align-items: center; gap: 6px; opacity: 1; transform: none; pointer-events: auto; }
  .row-act { width: 40px; height: 32px; border-radius: 10px; background: var(--surface-2); color: var(--fg-2); }
  .row-act.del { background: color-mix(in srgb, var(--danger) 85%, transparent); color: #fff; }
  .tree li > .row { touch-action: pan-y; }
  .tree li > .row.swiped { --swipe: -88px; }
  .tree li { overflow: hidden; }
}
.archived-link { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 7px 10px; border-radius: 10px; background: transparent; border-color: transparent; color: var(--muted); font-size: 13px; animation: fade-in var(--mid) var(--ease); }
.archived-link:hover { color: var(--fg); background: var(--surface); }
.archived-link.back { color: var(--fg-2); }
.tree.archived .row { color: var(--muted); }
.select-bar { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding: 8px 8px 8px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-2); font-size: 13px; color: var(--fg-2); animation: rise var(--mid) var(--spring) both; }
.select-bar .spacer { flex: 1; }
.select-bar button:disabled { opacity: 0.45; }
.chip-sm.ghost-chip { background: transparent; border-color: transparent; color: var(--muted); animation: none; }
.chip-sm.ghost-chip:hover, .chip-sm.on { color: var(--fg); background: var(--surface); border-color: var(--line); }
.tree .title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree .live { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: ping 1.4s var(--ease) infinite; }
.tree .wait { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); animation: ping-warn 1.4s var(--ease) infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 100% { box-shadow: 0 0 0 7px transparent; } }
@keyframes ping-warn { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--warn) 60%, transparent); } 100% { box-shadow: 0 0 0 7px transparent; } }
.kill { display: flex; align-items: center; gap: 8px; justify-content: center; color: var(--danger); background: transparent; border-color: var(--line); font-size: 13px; }
.kill:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.kill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; }
.tabs { position: relative; display: flex; gap: 2px; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); margin-right: auto; }
.tab { position: relative; z-index: 1; background: transparent; border: none; padding: 6px 14px; border-radius: 10px; color: var(--fg-2); font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.tab:hover { background: transparent; color: var(--fg); }
.tab.active { color: var(--fg); }
.tab-pill { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; width: 0; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); transition: left var(--mid) var(--spring), width var(--mid) var(--spring); }
.count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #1a1200; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; animation: pop var(--mid) var(--spring); }
.banner { display: flex; align-items: center; gap: 12px; margin: 0 20px 8px; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 14%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); animation: drop var(--mid) var(--ease); }
.banner span { flex: 1; }

.view { flex: 1; min-height: 0; animation: view-in var(--mid) var(--ease); }
.view.pad { overflow-y: auto; padding: 8px 20px 40px; }
.view-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 18px; flex-wrap: wrap; }
.view-head h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- chat ---------- */

.chat-view { display: flex; flex-direction: column; position: relative; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 4px 24px 12px; border-bottom: 1px solid var(--line); }
.chat-title { font-weight: 650; letter-spacing: -0.01em; }
.chat-sub { font-size: 12px; color: var(--muted); }
.chat-head-text { min-width: 0; flex: 1; }
.chat-head-text > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; transition: opacity var(--mid); }
.stats b { color: var(--fg-2); font-weight: 600; }
.model-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 550; color: var(--fg-2); background: var(--surface); border-color: var(--line); flex-shrink: 0; max-width: 220px; }
.model-chip:hover, .model-chip[aria-expanded="true"] { color: var(--fg); border-color: var(--line-2); background: var(--surface-2); }
.model-chip .model-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-chip .model-name.swap { animation: chunk-in var(--mid) var(--ease); }
.model-chip .chev { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.7; transition: transform var(--mid) var(--spring); }
.model-chip[aria-expanded="true"] .chev { transform: rotate(180deg); }
.model-spark { width: 7px; height: 7px; border-radius: 50%; background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 0 0 0 transparent; transition: box-shadow var(--mid), transform var(--mid) var(--spring); }
.model-chip.custom .model-spark { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); transform: scale(1.15); }

.popover { position: fixed; z-index: 60; width: 320px; max-height: min(460px, calc(100dvh - 24px)); display: flex; flex-direction: column; padding: 6px; border-radius: 18px; background: color-mix(in srgb, var(--surface-solid) 92%, transparent); backdrop-filter: blur(18px) saturate(1.4); border: 1px solid var(--line-2); box-shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(0, 0, 0, 0.2); }
.popover.in { animation: pop-in var(--mid) var(--spring); }
.popover.closing { animation: pop-out 180ms var(--ease) forwards; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.94); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(-4px) scale(0.97); } }
.pop-head { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px 6px; }
.pop-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.pick { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border-radius: 12px; background: transparent; border-color: transparent; animation: slide-in var(--mid) var(--ease) both; }
.pick:hover, .pick:focus-visible { background: var(--surface-2); outline: none; }
.pick-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pick-name { font-size: 14px; font-weight: 550; }
.pick-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-check { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: var(--accent-fg); background: var(--accent); transform: scale(0); opacity: 0; transition: transform var(--mid) var(--spring), opacity var(--fast); }
.pick-check svg { width: 13px; height: 13px; }
.pick.on .pick-check { transform: scale(1); opacity: 1; }
.pick.on .pick-name { color: var(--fg); }
.pop-note { font-size: 12.5px; color: var(--muted); padding: 8px 10px 10px; }
.pop-foot { margin-top: 6px; padding: 10px; border-radius: 12px; font-size: 13px; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 25%, transparent); text-align: center; animation: drop var(--mid) var(--ease) both; }
.pop-foot:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
@media (max-width: 640px) {
  .popover { left: 8px !important; right: 8px; top: auto !important; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; transform-origin: 50% 100% !important; }
  @keyframes pop-in { from { opacity: 0; transform: translateY(24px) scale(0.98); } }
  @keyframes pop-out { to { opacity: 0; transform: translateY(18px); } }
  .model-chip { max-width: 140px; padding: 6px 9px; }
}

.empty.has-recent { padding-top: 5vh; }
.recent { width: min(440px, 100%); margin-top: 22px; display: flex; flex-direction: column; gap: 4px; text-align: left; }
.recent-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--fg-2); padding: 0 10px 4px; }
.recent-head .muted { font-weight: 400; }
.recent-row { text-align: left; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; background: transparent; border-color: transparent; font-size: 14px; color: var(--fg-2); animation: rise var(--mid) var(--ease) both; }
.recent-row:hover { background: var(--surface); border-color: var(--line); color: var(--fg); transform: translateX(2px); }
.recent-row .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-row .when { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.recent-row.live .when::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; animation: ping 1.4s var(--ease) infinite; }
.tag-btn { cursor: pointer; font: inherit; }
.tag-btn:hover { color: var(--fg); border-color: var(--line-2); }
.scroller { flex: 1; overflow-y: auto; scroll-behavior: auto; overscroll-behavior: contain; }
.messages { max-width: 780px; margin: 0 auto; padding: 24px 24px 140px; display: flex; flex-direction: column; gap: 14px; }

.enter { animation: msg-in var(--mid) var(--spring) both; }
.instant, .instant * { animation: none !important; }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } }

.turn { display: flex; gap: 12px; align-items: flex-start; }
.turn > .orb { margin-top: 2px; }
.turn-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }

.bubble { align-self: flex-end; max-width: 78%; padding: 10px 15px; border-radius: 18px 18px 6px 18px; background: var(--user); color: #fff; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 8px 24px -12px rgba(100, 90, 255, 0.7); }
.bubble.pending { opacity: 0.7; }
.bubble.steer { background: transparent; color: var(--fg); border: 1px dashed var(--accent); box-shadow: none; }
.bubble.steer::before { content: "Steer"; display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.from-agent { align-self: stretch; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; }
.from-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.text { word-wrap: break-word; color: var(--fg); }
.text p { margin: 0 0 10px; } .text p:last-child { margin-bottom: 0; }
.text h1, .text h2, .text h3 { font-size: 16px; margin: 14px 0 6px; letter-spacing: -0.01em; }
.text ul, .text ol { margin: 4px 0 10px; padding-left: 22px; }
.text code { font-family: var(--mono); font-size: 13px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
.text pre { font-family: var(--mono); font-size: 13px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); overflow-x: auto; margin: 6px 0 10px; white-space: pre; }
.text pre code { padding: 0; background: none; }
.text.streaming { white-space: pre-wrap; }
.text.streaming::after { content: ""; display: inline-block; width: 7px; height: 16px; margin-left: 2px; vertical-align: -2px; border-radius: 2px; background: var(--accent); animation: caret 1s steps(1) infinite; }
.text .chunk { animation: chunk-in 380ms var(--ease); }
@keyframes chunk-in { from { opacity: 0; filter: blur(3px); } }
@keyframes caret { 50% { opacity: 0; } }

.thinking-dots { display: inline-flex; gap: 5px; padding: 8px 0; }
.thinking-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1.2s var(--ease) infinite; }
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; } .thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-5px); opacity: 1; } }

.tool { border-radius: 12px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: border-color var(--mid) var(--ease), background var(--mid); }
.tool-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; user-select: none; font-size: 13px; }
.tool-name { font-weight: 600; font-family: var(--mono); font-size: 12.5px; }
.tool-arg { color: var(--muted); font-family: var(--mono); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.tool-state { width: 16px; height: 16px; flex-shrink: 0; display: grid; place-items: center; }
.tool-state .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: orb-spin 700ms linear infinite; }
.tool-state svg { width: 15px; height: 15px; animation: pop var(--mid) var(--spring); }
.tool.ok .tool-state { color: var(--ok); }
.tool.err { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.tool.err .tool-state { color: var(--danger); }
.chev { width: 14px; height: 14px; color: var(--muted); transition: transform var(--mid) var(--ease); }
.tool.open .chev { transform: rotate(90deg); }
.tool-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--mid) var(--ease); }
.tool.open .tool-body { grid-template-rows: 1fr; }
.tool-body > div { overflow: hidden; }
.tool-body pre { margin: 0; padding: 10px 12px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; color: var(--fg-2); }
.tool-body .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 8px 12px 0; }

.approval {
  position: relative; padding: 14px 16px; border-radius: 16px; background: var(--surface-solid);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 10%, transparent), var(--shadow);
  animation: msg-in var(--mid) var(--spring) both, glow 2.4s var(--ease) infinite;
}
.approval.done { animation: none; box-shadow: none; border-color: var(--line); background: var(--surface); }
.approval-title { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.approval-sum { color: var(--fg-2); margin: 6px 0 12px; font-size: 14px; word-break: break-word; }
.approval-actions { display: flex; gap: 8px; }
.approval-result { font-size: 13px; font-weight: 600; animation: pop var(--mid) var(--spring); }
.approval-result.yes { color: var(--ok); } .approval-result.no { color: var(--danger); }
@keyframes glow { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--warn) 6%, transparent), var(--shadow); } }

.note { align-self: center; font-size: 12.5px; color: var(--muted); padding: 4px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); cursor: default; }
.note.link { cursor: pointer; } .note.link:hover { color: var(--fg); border-color: var(--line-2); }
.err-msg { padding: 10px 14px; border-radius: 12px; color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); font-size: 14px; }
.turnstats { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; opacity: 0.85; animation: fade-in var(--slow) var(--ease); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 12vh 20px 0; color: var(--muted); animation: fade-in var(--slow) var(--ease); }
.empty h3 { margin: 6px 0 0; color: var(--fg); font-size: 22px; letter-spacing: -0.02em; }
.empty.small { padding: 40px 20px; font-size: 14px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.suggestions button { border-radius: 999px; font-size: 13px; color: var(--fg-2); }

.jump { position: absolute; right: 28px; bottom: 120px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; padding: 0; background: var(--surface-solid); box-shadow: var(--shadow); animation: pop var(--mid) var(--spring); }

.composer { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 24px 18px; pointer-events: none; background: linear-gradient(to top, var(--bg) 55%, transparent); }
.composer-inner {
  pointer-events: auto; max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 8px 8px 16px; border-radius: 22px; background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
  border: 1px solid var(--line-2); box-shadow: var(--shadow); backdrop-filter: var(--glass);
  transition: border-color var(--mid) var(--ease), box-shadow var(--mid) var(--ease);
}
.composer-inner:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 12%, transparent), var(--shadow); }
.composer-inner.running { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.composer textarea { flex: 1; resize: none; border: none; background: transparent; box-shadow: none; padding: 8px 0; max-height: 220px; line-height: 1.5; }
.composer textarea:focus { box-shadow: none; }
.composer-actions { display: flex; align-items: center; gap: 6px; }
.send, .stop { width: 38px; height: 38px; padding: 0; border-radius: 50%; display: grid; place-items: center; border: none; animation: pop var(--mid) var(--spring); }
.send { background: var(--accent); color: var(--accent-fg); }
.send:disabled { background: var(--surface-2); color: var(--muted); opacity: 1; }
.stop { background: var(--fg); }
.stop span { width: 12px; height: 12px; border-radius: 3px; background: var(--bg); }
.chip { border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); animation: pop var(--mid) var(--spring); }
.composer-hint { pointer-events: none; max-width: 780px; margin: 6px auto 0; text-align: center; font-size: 11.5px; color: var(--muted); transition: opacity var(--mid); }

/* ---------- memory, approvals, agents ---------- */

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.panel-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 4px 2px; }
.panel-bar { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.mem-grid { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.list li { padding: 7px 10px; border-radius: 10px; cursor: pointer; font-size: 13.5px; transition: background var(--fast) var(--ease); animation: slide-in var(--mid) var(--ease) both; word-break: break-all; }
.list li:hover { background: var(--surface-2); }
.list li.active { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.list li small { display: block; color: var(--muted); font-size: 11.5px; }
.timeline li { position: relative; padding-left: 22px; }
.timeline li::before { content: ""; position: absolute; left: 8px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.editor { min-height: 460px; font-family: var(--mono); font-size: 13px; line-height: 1.6; resize: vertical; animation: fade-in var(--mid) var(--ease); }
.diff { margin: 0; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; padding: 12px 14px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); max-height: 60vh; overflow: auto; animation: fade-in var(--mid) var(--ease); }
.diff .add { color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, transparent); display: block; }
.diff .del { color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); display: block; }
.budget { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); margin-left: auto; }
.budget-bar { width: 140px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.budget-bar span { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width var(--slow) var(--ease); }
.budget-bar span.over { background: var(--danger); }

.stack { display: flex; flex-direction: column; gap: 12px; max-width: 820px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; transition: transform var(--mid) var(--ease), opacity var(--mid) var(--ease), border-color var(--fast); animation: msg-in var(--mid) var(--spring) both; }
.card:hover { border-color: var(--line-2); }
.card.leaving { opacity: 0; transform: translateX(24px) scale(0.98); }
.card-head { display: flex; align-items: center; gap: 12px; }
.card-head .t { font-weight: 650; }
.card-head .s { font-size: 12.5px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--fg-2); }

.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 20px; }
.agent-card { align-items: flex-start; }
.agent-card .orb { margin-bottom: 4px; }
.agent-card .t { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.agent-card .d { color: var(--fg-2); font-size: 14px; min-height: 2.8em; }
.agent-card .usage { font-size: 12px; color: var(--muted); }
.form { max-width: 620px; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 160px; }
.form-row > button { flex: 0 0 auto; min-width: 0; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; max-width: 360px; padding: 11px 15px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 14px; animation: toast-in var(--mid) var(--spring) both; }
.toast.out { animation: toast-out var(--mid) var(--ease) both; }
.toast.error { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.97); } }

@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-6px); } }

.scrim { display: none; }
.only-phone { display: none; }

@media (max-width: 820px) {
  .only-phone { display: inline-grid; }
  .only-wide { display: none; }
  .sidebar { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: 84vw; max-width: 320px; transform: translateX(-104%); transition: transform var(--mid) var(--ease); background: var(--bg-2); box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.45); opacity: 0; pointer-events: none; transition: opacity var(--mid) var(--ease); }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .topbar { padding: 10px 12px; gap: 6px; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tab { padding: 6px 10px; font-size: 13.5px; }
  .chat-head { padding: 2px 16px 10px; }
  .stats { display: none; }
  .messages { padding: 18px 16px 150px; }
  .bubble { max-width: 88%; }
  .composer { padding: 0 10px 12px; }
  .composer-hint { display: none; }
  .view.pad { padding: 4px 16px 40px; }
  .mem-grid { grid-template-columns: 1fr; }
  .budget { margin-left: 0; width: 100%; }
  .jump { right: 16px; bottom: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* ---------- small additions used by app.js ---------- */
.messages.swap { animation: fade-in var(--mid) var(--ease); }
.bubble.queued::after { content: "Queued"; display: block; margin-top: 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-align: right; opacity: 0.75; }
.orb.rest, .orb.rest i, .orb.rest b { animation: none; }
.note .orb, .from-label .orb { display: inline-block; vertical-align: -4px; margin-right: 4px; }
.text a { color: var(--accent-2); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent-2) 40%, transparent); }
.agent-card .row { margin-top: 2px; }
.composer textarea:focus-visible { outline: none; }

/* ---------- system and updates ---------- */
.system-row { display: flex; align-items: center; gap: 10px; background: transparent; border-color: transparent; color: var(--fg-2); font-size: 13px; padding: 8px 10px; text-align: left; }
.system-row:hover { background: var(--surface); }
.system-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0; transition: background var(--mid); }
.sys-dot.avail { background: var(--accent); animation: ping 1.6s var(--ease) infinite; }
.sys-dot.busy { background: var(--accent-2); animation: ping 1s var(--ease) infinite; }
.sys-dot.bad { background: var(--danger); }
.sys-dot.off { background: var(--muted); }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-fg); animation: pop var(--mid) var(--spring); }
.small { font-size: 12.5px; }

.sheet { width: min(560px, calc(100vw - 32px)); max-height: min(720px, calc(100dvh - 48px)); padding: 0; border: 1px solid var(--line-2); border-radius: 22px; background: var(--surface-solid); color: var(--fg); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7); overflow: hidden; }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in var(--slow) var(--spring); }
.sheet.closing { animation: sheet-out var(--mid) var(--ease) forwards; }
.sheet::backdrop { background: rgba(5, 5, 12, 0.5); backdrop-filter: blur(6px); animation: fade-in var(--mid) var(--ease); }
.sheet.closing::backdrop { animation: fade-out var(--mid) var(--ease) forwards; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px) scale(0.97); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes fade-out { to { opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 10px; }
.sheet-title { flex: 1; min-width: 0; }
.sheet-title h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.sheet-title .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { padding: 4px 18px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.sheet-actions { display: flex; align-items: center; gap: 8px; padding: 12px 18px 18px; border-top: 1px solid var(--line); }
.upd-headline { font-size: 15px; font-weight: 600; }
.upd-headline .muted { font-weight: 400; }
.upd-progress { display: flex; flex-direction: column; gap: 8px; padding: 14px 14px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); animation: drop var(--mid) var(--ease); }
.upd-progress-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.upd-pct { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.upd-elapsed { font-size: 13px; font-variant-numeric: tabular-nums; }
.upd-bar { position: relative; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.upd-bar span { position: relative; display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 900ms var(--ease), background var(--mid); overflow: hidden; }
.upd-progress.running .upd-bar span::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent); transform: translateX(-100%); animation: shimmer 1.6s var(--ease) infinite; }
.upd-progress.stalled .upd-bar span::after { animation: none; opacity: 0; }
.upd-progress.done .upd-bar span { background: var(--ok); }
.upd-progress.failed .upd-bar span { background: var(--danger); }
@keyframes shimmer { to { transform: translateX(100%); } }
.upd-pulse { display: flex; align-items: center; gap: 8px; min-height: 18px; transition: color var(--mid); }
.upd-pulse:empty { display: none; }
.upd-pulse.live::before, .upd-pulse.warn::before, .upd-pulse.bad::before { content: ""; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.upd-pulse.live { color: var(--muted); }
.upd-pulse.live::before { background: var(--ok); animation: heartbeat 1s var(--ease) infinite; }
.upd-pulse.warn { color: var(--warn); }
.upd-pulse.warn::before { background: var(--warn); animation: ping-warn 1.4s var(--ease) infinite; }
.upd-pulse.bad { color: var(--danger); }
.upd-pulse.bad::before { background: var(--danger); }
@keyframes heartbeat { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 70%, 100% { box-shadow: 0 0 0 6px transparent; } }
.upd-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.upd-steps li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; color: var(--muted); font-size: 14px; transition: color var(--mid), background var(--mid); animation: slide-in var(--mid) var(--ease) both; }
.upd-steps li.running { color: var(--fg); background: var(--surface); }
.upd-steps li.done { color: var(--fg-2); }
.upd-steps li.failed { color: var(--danger); }
.upd-steps .tool-state { color: var(--muted); }
.upd-steps li.done .tool-state { color: var(--ok); }
.upd-steps li.failed .tool-state { color: var(--danger); }
.upd-steps .step-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.upd-steps .step-detail { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: 0; opacity: 0; transition: max-height var(--mid) var(--ease), opacity var(--mid), margin var(--mid); }
.upd-steps .step-detail:not(:empty) { max-height: 18px; opacity: 1; margin-top: 2px; }
.upd-steps .step-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.upd-steps li.running .step-time { color: var(--fg-2); }
.upd-steps li.quiet { background: color-mix(in srgb, var(--warn) 10%, transparent); }
.upd-steps li.quiet .spin { border-top-color: var(--warn); }
.upd-steps li.quiet .step-time { color: var(--warn); }
.upd-steps .ring { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2); }
.upd-changes { display: flex; flex-direction: column; gap: 10px; }
.upd-changes .list li { cursor: default; font-size: 13.5px; display: flex; gap: 10px; }
.upd-changes .list li code { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.upd-log summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.upd-log pre { margin: 8px 0 0; max-height: 220px; overflow: auto; font-family: var(--mono); font-size: 12px; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
@media (max-width: 820px) {
  .sheet { width: 100vw; max-width: 100vw; max-height: 88dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  @keyframes sheet-out { to { transform: translateY(100%); } }
}

/* ---------- confirm ---------- */
.sheet.confirm { width: min(400px, calc(100vw - 32px)); }
.confirm-body { padding: 24px 22px 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.confirm-body h2 { margin: 6px 0 0; font-size: 18px; letter-spacing: -0.02em; line-height: 1.3; overflow-wrap: anywhere; }
.confirm-body p { margin: 0; font-size: 14px; line-height: 1.5; }
.confirm-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); animation: pop var(--slow) var(--spring) both; }
.confirm-icon svg { width: 20px; height: 20px; }
.sheet.confirm .sheet-actions { border-top: none; }
button.danger-solid { background: var(--danger); color: #fff; border-color: transparent; font-weight: 600; }
button.danger-solid:hover { background: color-mix(in srgb, var(--danger) 88%, white); }
.toast.has-action { display: flex; align-items: center; gap: 14px; }
.toast-action { padding: 4px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: transparent; }

/* ---- sign-in, passkeys, security ---- */
.login-stack { display: flex; flex-direction: column; gap: 12px; }
.login-card .setup-text { margin: 0; color: var(--fg-2); font-size: 14px; line-height: 1.45; text-align: left; }
.linkish { background: transparent; border-color: transparent; color: var(--muted); font-size: 13px; padding: 4px; }
.linkish:hover { color: var(--fg); }
.codes { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font: 14px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; text-align: left; white-space: pre-wrap; user-select: all; }
.row.center { justify-content: center; }
.row-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sec-body { gap: 18px; }
.sec { display: flex; flex-direction: column; gap: 8px; }
.sec-head { display: flex; align-items: center; gap: 8px; }
.sec-head h3 { margin: 0; flex: 1; font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.sec p { margin: 0; }
.sec-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.sec-list:empty { display: none; }
.sec-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.sec-list li + li { border-top: 1px solid var(--line); }
.sec-item { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sec-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-meta { font-size: 12px; color: var(--muted); }
.sec-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pair { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0 4px; }
.pair img { width: 232px; height: 232px; border-radius: 14px; background: #fff; padding: 8px; }

/* ---- auto-review decisions on tool cards ---- */
.review-note { display: flex; gap: 8px; align-items: baseline; padding: 7px 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--fg-2); }
.review-verdict { flex: none; font-weight: 600; font-size: 11px; letter-spacing: 0.02em; padding: 1px 8px; border-radius: 999px; }
.review-note.approve .review-verdict { color: var(--ok, #2f9e6b); background: color-mix(in srgb, var(--ok, #2f9e6b) 14%, transparent); }
.review-note.deny .review-verdict { color: var(--err, #d64545); background: color-mix(in srgb, var(--err, #d64545) 14%, transparent); }
.review-note.ask .review-verdict { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.review-reason { min-width: 0; overflow-wrap: anywhere; }
