/* Lark: black, monochrome, quiet. */
:root {
  --bg: #000000;
  --panel: #0a0a0a;
  --panel-2: #111111;
  --text: #f4f4f5;
  --muted: #8b8b90;
  --faint: #5a5a60;
  --border: #1d1d20;
  --border-strong: #2e2e33;
  --accent: #ffffff;
  --accent-text: #000000;
  --ok: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --code-bg: #0d0d0f;
  --radius: 14px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ink: 255 255 255;
  --hi: #ffffff;
  --lo: #000000;
  --bg-deep: #050505;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; letter-spacing: -0.005em; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--hi); }
::selection { background: var(--hi); color: var(--lo); }
h1, h2, h3 { margin: 0 0 8px; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* Top bar */
.top { display: flex; align-items: center; gap: 32px; padding: 14px 28px; border-bottom: 1px solid var(--border); background: rgb(0 0 0 / .85); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 2; }
.brand { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 10px; letter-spacing: 0.32em; text-transform: uppercase; color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--hi); display: inline-block; box-shadow: 0 0 12px rgb(var(--ink) / .6); }
nav { display: flex; gap: 26px; flex: 1; }
nav a { color: var(--muted); padding: 4px 0; border-bottom: 1px solid transparent; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500; }
nav a:hover { color: var(--text); }
nav a.active { color: var(--text); border-color: var(--text); }
main { max-width: 1180px; margin: 0 auto; padding: 32px 20px 80px; }

/* Dashboard shell: a left sidebar, content to its right. */
.side { position: fixed; inset: 0 auto 0 0; width: 232px; display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; border-right: 1px solid var(--border); background: var(--bg-deep); z-index: 3; }
.side .brand { padding: 4px 10px 14px; }
.side nav { flex-direction: column; gap: 2px; flex: 1; }
.side nav a { padding: 9px 12px; border-radius: 10px; border: 0; font-size: 13px; letter-spacing: 0; text-transform: none; }
.side nav a:hover { background: var(--panel); }
.side nav a.active { background: var(--panel-2, #111); color: var(--text); }
.new-chat { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--border-strong); border-radius: 12px; color: var(--text); font-size: 13px; font-weight: 500; }
.new-chat:hover { background: var(--panel); }
.new-chat span { font-size: 16px; line-height: 1; }
.side-foot { justify-content: space-between; padding: 10px 4px 0; border-top: 1px solid var(--border); }
.side-foot select { flex: 1; min-width: 0; }
.side .menu-body { top: auto; bottom: 42px; left: 0; right: auto; }
body:has(> .side) > main { margin-left: 232px; }
@media (max-width: 820px) {
  .side { position: sticky; top: 0; inset: auto; width: auto; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .side .brand { padding: 0 6px 0 0; }
  .side nav { flex-direction: row; flex: 1; }
  .side nav a { padding: 6px 10px; white-space: nowrap; }
  .new-chat { margin: 0; padding: 6px 10px; white-space: nowrap; }
  .side-foot { border: 0; padding: 0; }
  .side .menu-body { top: 42px; bottom: auto; right: 0; left: auto; }
  body:has(> .side) > main { margin-left: 0; }
}

/* Surfaces */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
a.panel:hover { border-color: var(--border-strong); background: var(--panel-2); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .two { grid-template-columns: 1fr; } .top { gap: 14px; padding: 12px 16px; } nav { gap: 14px; overflow-x: auto; } }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Controls */
button, .button { display: inline-block; background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); border-radius: 999px; padding: 8px 18px; font: inherit; font-weight: 600; font-size: 13px; letter-spacing: 0.01em; cursor: pointer; transition: opacity .15s, background .15s, border-color .15s; }
button:hover, .button:hover { opacity: .88; color: var(--accent-text); }
button.ghost, .button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border-strong); font-weight: 500; }
button.ghost:hover, .button.ghost:hover { border-color: var(--text); opacity: 1; color: var(--text); }
button.danger { background: transparent; color: var(--bad); border: 1px solid #3a1c1c; font-weight: 500; }
button.danger:hover { border-color: var(--bad); opacity: 1; }
button:disabled { opacity: .4; cursor: default; }
input, select, textarea { width: 100%; background: var(--code-bg); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 12px; font: inherit; transition: border-color .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--hi); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 96px; resize: vertical; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 10px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }
label.check input { width: auto; accent-color: var(--hi); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
legend { padding: 0 8px; font-weight: 600; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }

/* Status */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 11px; border: 1px solid var(--border-strong); white-space: nowrap; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-succeeded { color: var(--ok); border-color: rgb(74 222 128 / .3); }
.s-failed { color: var(--bad); border-color: rgb(248 113 113 / .3); }
.s-running { color: var(--hi); border-color: rgb(var(--ink) / .35); }
.s-running::before { animation: pulse 1.4s ease-in-out infinite; }
.s-queued, .s-cancelled { color: var(--muted); }
@keyframes pulse { 50% { opacity: .25; } }
.pill { font-size: 11px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; color: var(--muted); }

/* Run log */
.log { background: var(--code-bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; max-height: 70vh; overflow: auto; white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.ev { padding: 4px 0; border-bottom: 1px solid #141416; }
.ev:last-child { border-bottom: 0; }
.ev .t { color: var(--faint); margin-right: 10px; }
.ev.assistant { color: var(--text); }
.ev.tool-call { color: #c7d2fe; }
.ev.error { color: var(--bad); }
.ev.out { color: var(--muted); }
.result { white-space: pre-wrap; }
.error-box { color: var(--bad); white-space: pre-wrap; }

/* Overlays */
dialog { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--panel); color: var(--text); max-width: 440px; width: calc(100% - 32px); }
dialog::backdrop { background: rgb(0 0 0 / .7); }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--hi); color: var(--lo); padding: 11px 16px; border-radius: 12px; max-width: 420px; white-space: pre-wrap; z-index: 5; font-weight: 500; box-shadow: 0 12px 40px rgb(0 0 0 / .6); }
.empty { text-align: center; padding: 48px 16px; }
[hidden] { display: none !important; }

/* Header right side */
.top-right { gap: 10px; flex-wrap: nowrap; }
.top-right select { width: auto; max-width: 200px; padding: 6px 10px; border-radius: 999px; font-size: 12px; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; width: 32px; height: 32px; border-radius: 50%; background: var(--hi); color: var(--lo); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; top: 42px; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 12px; padding: 14px; min-width: 230px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 20px 50px rgb(0 0 0 / .7); z-index: 4; }
.menu-body a { color: var(--text); }

/* Settings tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a { padding: 10px 12px; color: var(--muted); border-bottom: 1px solid transparent; margin-bottom: -1px; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.tabs a.active { color: var(--text); border-color: var(--text); }

/* Onboarding */
.checklist { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.checklist li { display: flex; gap: 14px; align-items: flex-start; }
.checklist .tick { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.checklist li.done .tick { background: var(--hi); border-color: var(--hi); color: var(--lo); }
.checklist li.done .title { color: var(--faint); text-decoration: line-through; }
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.template { text-align: left; background: var(--code-bg); color: var(--text); border: 1px solid var(--border); border-radius: 12px; font-weight: 400; padding: 14px; }
.template:hover { border-color: var(--hi); opacity: 1; color: var(--text); }
.template b { display: block; margin-bottom: 4px; font-weight: 600; }
.template:disabled { cursor: default; }
.reveal { background: var(--code-bg); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 11px 13px; word-break: break-all; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.recovery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px; font-size: 14px; }

/* Usage & billing */
.num-col { text-align: right; font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--text); border-radius: inherit; }
.meter i.high { background: var(--warn); }
.meter i.full { background: var(--bad); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.plan { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.plan.current { border-color: var(--text); }
.plan ul { margin: 0; padding-left: 16px; color: var(--muted); font-size: 13px; flex: 1; }
.plan button, .plan .button { align-self: flex-start; }

/* Chat: the dashboard's home. Empty, it's a centered prompt; once a message is sent, the
   conversation fills the column and the composer docks at the bottom. */
body.chat-mode > main { max-width: none; padding: 0; height: 100vh; }
.chat { height: 100%; display: flex; flex-direction: column; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 0 20px; }
.chat-hero { max-width: 720px; margin: 0 auto 26px; text-align: center; }
/* Empty: hero and composer sit together in the middle of the screen. */
.chat:not(.active) { justify-content: center; padding-bottom: 8vh; }
.chat:not(.active) .chat-scroll { flex: none; overflow: visible; }
.chat-mark { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; border: 1px solid var(--border-strong); background: radial-gradient(circle at 50% 30%, rgb(var(--ink) / .12), transparent 70%); margin-bottom: 22px; }
.chat-mark .dot { width: 14px; height: 14px; }
.chat-hero h1 { font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.035em; margin: 0 0 10px; font-weight: 600; }
.chat-hero p { color: var(--muted); max-width: 520px; margin: 0 auto; }
.chat-log { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; padding: 28px 0 24px; }
.chat-log:empty { display: none; }
.chat.active .chat-hero { display: none; }
.chat-dock { width: 100%; max-width: 760px; margin: 0 auto; padding: 18px 20px 22px; }
.chat-composer { display: flex; align-items: flex-end; gap: 10px; padding: 12px 12px 12px 18px; border: 1px solid var(--border-strong); border-radius: 26px; background: var(--panel); box-shadow: 0 20px 60px rgb(0 0 0 / .6); transition: border-color .15s; }
.chat-composer:focus-within { border-color: #4a4a50; }
.chat-composer textarea { flex: 1; resize: none; border: 0; background: transparent; padding: 8px 0; font-size: 16px; line-height: 1.45; max-height: 240px; min-height: 0; box-shadow: none; outline: none; }
.chat-send { width: 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 18px; font-weight: 700; flex: none; }
.chat-send:disabled { opacity: .3; cursor: default; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.chat.active .chat-chips { display: none; }
.chip { background: transparent; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 400; }
.chip:hover { color: var(--text); border-color: #4a4a50; opacity: 1; }
.chat-foot { text-align: center; color: var(--faint); font-size: 11px; margin-top: 12px; letter-spacing: .02em; }
.msg { line-height: 1.6; white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.msg.me { align-self: flex-end; max-width: 80%; background: var(--panel-2, #151517); border: 1px solid var(--border); padding: 10px 16px; border-radius: 20px 20px 6px 20px; }
.msg.bot { align-self: stretch; color: rgb(var(--ink) / .9); }
.msg.bot code { font-family: var(--mono); font-size: 13px; background: var(--code-bg); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
.msg.thinking .dots { display: inline-flex; gap: 5px; }
.msg.thinking .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.msg.thinking .dots i:nth-child(2) { animation-delay: .2s; }
.msg.thinking .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.msg.tool { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; }
.msg.tool .spin { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--text); animation: spin .8s linear infinite; }
.msg.tool.ok .spin { animation: none; border-color: var(--ok); background: var(--ok); }
.msg.tool.bad .spin { animation: none; border-color: var(--bad); background: var(--bad); }
@keyframes spin { to { transform: rotate(360deg); } }
.msg.note { align-self: center; font-size: 12px; color: var(--muted); }
.msg.error { color: var(--bad); font-size: 14px; }
.msg.card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; border: 1px solid var(--border-strong); border-radius: 18px; background: linear-gradient(180deg, #0d0d0f, #070708); white-space: normal; }
.card-label { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 820px) { body.chat-mode > main { height: calc(100vh - 56px); } }

/* Chat replies: the Lark mark beside formatted text, actions underneath once done. */
.msg.bot { display: flex; gap: 14px; align-items: flex-start; white-space: normal; }
.msg-mark { flex: none; width: 28px; height: 28px; border-radius: 9px; border: 1px solid var(--border-strong); display: grid; place-items: center; margin-top: 2px; }
.msg-mark .dot { width: 8px; height: 8px; box-shadow: 0 0 8px rgb(var(--ink) / .5); }
.msg-main { flex: 1; min-width: 0; }
.msg-body > :first-child { margin-top: 0; }
.msg-body > :last-child { margin-bottom: 0; }
.msg-body p { margin: 0 0 12px; }
.msg-body h3, .msg-body h4, .msg-body h5 { margin: 18px 0 8px; font-size: 15px; letter-spacing: -0.01em; }
.msg-body ul, .msg-body ol { margin: 0 0 12px; padding-left: 22px; }
.msg-body li { margin: 4px 0; }
.msg-body a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.msg-body code { font-family: var(--mono); font-size: 13px; background: var(--code-bg); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
.code-block { margin: 0 0 12px; border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; background: #070708; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); text-transform: lowercase; }
.code-block pre { margin: 0; padding: 14px; overflow-x: auto; font-size: 13px; line-height: 1.55; }
.code-block pre code { background: none; border: 0; padding: 0; white-space: pre; }
.code-copy, .msg-action, .runwin-btn { padding: 3px 10px; font-size: 11px; border-radius: 8px; }
.msg-actions { display: flex; gap: 6px; margin-top: 6px; min-height: 0; opacity: 0; transition: opacity .15s; }
.msg.bot:hover .msg-actions { opacity: 1; }
.msg.thinking { align-items: center; }
.chat-send.stop { background: var(--text); color: var(--accent-text); font-size: 12px; }

/* Live run window: a small terminal onto what the agent is doing. */
.runwin { border: 1px solid var(--border-strong); border-radius: 14px; overflow: hidden; background: #050506; box-shadow: 0 16px 50px rgb(0 0 0 / .5); }
.runwin-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 12px; flex-wrap: wrap; }
.runwin-head .dots { display: inline-flex; gap: 5px; }
.runwin-head .dots i { width: 9px; height: 9px; border-radius: 50%; background: #2a2a2e; display: inline-block; }
.runwin-title { font-weight: 600; }
.runwin-clock, .runwin-cost { color: var(--muted); font-variant-numeric: tabular-nums; }
.runwin-actions { margin-left: auto; display: inline-flex; gap: 6px; }
.runwin-actions a.runwin-btn { border: 1px solid var(--border-strong); color: var(--text); display: inline-flex; align-items: center; }
.runwin-body { font-family: var(--mono); font-size: 12px; line-height: 1.6; padding: 10px 14px; max-height: 220px; overflow-y: auto; transition: max-height .2s; }
.runwin.open .runwin-body { max-height: 520px; }
.rl { white-space: pre-wrap; word-break: break-word; color: #c8c8cc; }
.rl.dim { color: var(--faint); }
.rl.cmd { color: #c7d2fe; }
.rl.out { color: var(--muted); }
.rl.say { color: var(--text); font-family: var(--font); font-size: 13px; margin: 4px 0; }
.rl.ok { color: var(--ok); }
.rl.bad, .runwin-result .bad { color: var(--bad); }
.runwin-result:empty { display: none; }
.runwin-result { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 14px; line-height: 1.6; }
.runwin-result p { margin: 0 0 10px; }

/* Triggers */
.trigger { display: flex; flex-direction: column; gap: 8px; }
.trigger-title { font-size: 15px; }
.trigger-when { font-size: 14px; color: var(--text); letter-spacing: -0.01em; }
.trigger-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.trigger-meta a { color: var(--muted); border-bottom: 1px solid var(--border-strong); }
.trigger-list { display: grid; gap: 12px; margin-top: 12px; }
.card-lite { padding: 16px 18px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.warn-text { color: var(--warn); }
.reveal-box { margin-top: 8px; }
.pill.on { color: var(--ok); border-color: rgb(74 222 128 / .3); }

/* Skills */
.skills-layout { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .skills-layout { grid-template-columns: 1fr; } }
.skill-list { display: flex; flex-direction: column; gap: 6px; }
.skill-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); transition: border-color .2s ease, background .2s ease, transform .2s ease; }
.skill-row:hover { border-color: var(--border-strong); background: rgb(var(--ink) / .02); transform: translateX(2px); }
.skill-row.active { border-color: var(--text); }
.code-area { font-family: var(--mono); font-size: 13px; line-height: 1.6; }
.skill-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Sessions */
.session-list { display: grid; gap: 8px; margin-top: 12px; }
.session-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; color: var(--text); transition: border-color .2s ease, background .2s ease, transform .2s ease; }
.session-row:hover { border-color: var(--border-strong); background: rgb(var(--ink) / .02); transform: translateY(-1px); }
.session-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.session-dot.busy { background: var(--ok); box-shadow: 0 0 0 4px rgb(74 222 128 / .12); animation: pulse 1.4s ease-in-out infinite; }
.session-head { max-width: 760px; width: 100%; margin: 0 auto 8px; display: flex; flex-direction: column; gap: 6px; }
.session-head h1 { margin: 0; font-size: 22px; }
.msg-meta { margin-top: 8px; font-size: 12px; color: var(--faint); }
.runwin.settled { opacity: .55; transition: opacity .4s ease; }
.chip-label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); min-width: 56px; }
.tool-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-list .chip { cursor: default; padding: 5px 11px; font-size: 12px; }

/* Live browser screen */
.screen { border: 1px solid var(--border-strong); border-radius: 14px; overflow: hidden; background: var(--bg-deep); margin: 0 0 14px; box-shadow: 0 24px 60px rgb(0 0 0 / .5); animation: rise .45s cubic-bezier(.2,.8,.2,1); }
.screen-chrome { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.screen-caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11px; }
.screen-frame { position: relative; aspect-ratio: 16 / 10; background: #0a0a0b; }
.screen-frame img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; cursor: zoom-in; transition: opacity .35s ease; }
.screen.flash .screen-frame img { animation: frame-in .45s ease; }
.screen.zoom { position: fixed; inset: 4vh 4vw; z-index: 50; margin: 0; }
.screen.zoom .screen-frame { aspect-ratio: auto; height: calc(100% - 34px); }
.screen.zoom .screen-frame img { object-fit: contain; cursor: zoom-out; }
.runwin .screen { margin: 10px 12px 0; box-shadow: none; }
@keyframes frame-in { from { opacity: .35; filter: blur(2px); } to { opacity: 1; filter: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pill.toggle { cursor: pointer; font: inherit; font-size: 11px; background: transparent; transition: all .2s ease; }
.pill.toggle:hover { color: var(--text); border-color: var(--border-strong); }

/* Notifications */
.notify-kind { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--border-strong); font-family: var(--mono); color: var(--muted); }
.switch { position: relative; display: inline-flex; width: 38px; height: 22px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #1c1c20; border: 1px solid var(--border-strong); transition: background .25s ease; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .3s cubic-bezier(.2,.8,.2,1), background .25s ease; }
.switch input:checked + span { background: #f4f4f5; }
.switch input:checked + span::after { transform: translateX(16px); background: var(--lo); }
.inline-select { width: auto; padding: 6px 30px 6px 12px; border-radius: 999px; font-size: 13px; }

/* ---------------------------------------------------------------------------
   Finish: depth, light and motion. Quiet by default, alive on interaction.
   --------------------------------------------------------------------------- */
:root {
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --glow: 0 0 0 1px rgb(var(--ink) / .04) inset, 0 24px 48px -28px rgb(0 0 0 / .95);
}
body { background: radial-gradient(1100px 520px at 62% -12%, rgb(var(--ink) / .055), transparent 62%), var(--bg); }
h1 { font-size: 26px; letter-spacing: -0.035em; }
h2 { letter-spacing: -0.02em; }

/* Scrollbars that don't shout */
* { scrollbar-width: thin; scrollbar-color: #26262b transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #1f1f23; border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #2e2e34; }

/* Surfaces gain depth when you reach for them */
.panel { transition: border-color .3s var(--ease), background .3s var(--ease), transform .35s var(--ease), box-shadow .35s var(--ease); }
a.panel:hover, .card-lite:hover, .grid > .panel:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--glow); }
.msg.card { box-shadow: var(--glow); transition: border-color .3s var(--ease); }
.msg.card:hover { border-color: #3a3a40; }

/* Controls: crisp, tactile */
button, .button { transition: opacity .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), transform .15s var(--ease), box-shadow .3s var(--ease); }
button:not(:disabled):active, .button:active { transform: scale(.97); }
button:not(.ghost):not(.danger):not(.chip):not(.pill):hover, .button:not(.ghost):hover { opacity: 1; box-shadow: 0 0 0 4px rgb(var(--ink) / .08), 0 8px 28px -8px rgb(var(--ink) / .35); }
input:focus, select:focus, textarea:focus { border-color: #d4d4d8; box-shadow: 0 0 0 4px rgb(var(--ink) / .06); }
input, select, textarea { transition: border-color .2s var(--ease), box-shadow .25s var(--ease), background .2s var(--ease); }
.chip { transition: color .2s var(--ease), border-color .2s var(--ease), background .25s var(--ease), transform .15s var(--ease); }
.chip:active { transform: scale(.96); }
.tabs a { transition: color .2s var(--ease), border-color .3s var(--ease); }
.tabs a:hover { color: var(--text); }
.side nav a { transition: background .2s var(--ease), color .2s var(--ease); position: relative; }
.side nav a.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 2px; border-radius: 2px; background: var(--hi); box-shadow: 0 0 10px rgb(var(--ink) / .7); animation: grow .35s var(--ease-out); }
@media (max-width: 820px) { .side nav a.active::before { display: none; } }

/* Loading: a hairline of light across the top while a page fetches */
body.routing::after { content: ""; position: fixed; top: 0; left: 0; height: 2px; width: 100%; z-index: 60; background: linear-gradient(90deg, transparent, var(--hi) 40%, var(--hi) 60%, transparent); transform-origin: left; animation: loading 1.1s var(--ease) infinite; opacity: .85; pointer-events: none; }

/* Toasts slide in and out */
.toast { animation: toast-in .45s var(--ease-out) both; backdrop-filter: blur(10px); }
.toast.leaving { animation: toast-out .35s var(--ease) both; }

@media (prefers-reduced-motion: no-preference) {
  /* Pages rise into place, their parts one after another */
  #app.page-in > * { animation: rise .55s var(--ease-out) both; }
  #app.page-in > *:nth-child(2) { animation-delay: .04s; }
  #app.page-in > *:nth-child(3) { animation-delay: .08s; }
  #app.page-in > *:nth-child(4) { animation-delay: .12s; }
  #app.page-in > *:nth-child(5) { animation-delay: .16s; }
  #app.page-in > *:nth-child(n+6) { animation-delay: .2s; }
  /* Lists cascade */
  .grid > *, .trigger-list > *, .session-list > *, .skill-list > *, .stat-row > * { animation: rise .5s var(--ease-out) both; }
  :is(.grid, .trigger-list, .session-list, .skill-list, .stat-row) > :nth-child(2) { animation-delay: .05s; }
  :is(.grid, .trigger-list, .session-list, .skill-list, .stat-row) > :nth-child(3) { animation-delay: .1s; }
  :is(.grid, .trigger-list, .session-list, .skill-list, .stat-row) > :nth-child(4) { animation-delay: .15s; }
  :is(.grid, .trigger-list, .session-list, .skill-list, .stat-row) > :nth-child(n+5) { animation-delay: .2s; }
  .enter { animation: rise .5s var(--ease-out) both; }
  /* Chat: messages float up; cards arrive with a breath of light */
  .msg { animation: msg-in .4s var(--ease-out) both; }
  .msg.card { animation: card-in .6s var(--ease-out) both; }
  form.panel:not([hidden]) { animation: rise .4s var(--ease-out) both; }
  tr { transition: background .2s var(--ease); }
}

@keyframes msg-in { from { opacity: 0; transform: translateY(10px) scale(.995); } to { opacity: 1; transform: none; } }
@keyframes card-in {
  0% { opacity: 0; transform: translateY(12px) scale(.985); box-shadow: 0 0 0 1px rgb(var(--ink) / 0); }
  60% { box-shadow: 0 0 0 1px rgb(var(--ink) / .22), 0 0 40px -6px rgb(var(--ink) / .18); }
  100% { opacity: 1; transform: none; box-shadow: var(--glow); }
}
@keyframes grow { from { transform: scaleY(0); } to { transform: none; } }
@keyframes loading { 0% { transform: translateX(-100%) scaleX(.35); } 100% { transform: translateX(100%) scaleX(.6); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
/* Reduced motion (often on by default on phones, with battery saver): calm, not frozen. Things fade
   in place instead of rising or sliding. */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  #app.page-in > *, .grid > *, .trigger-list > *, .session-list > *, .skill-list > *, .stat-row > *, .kpi-row > *, .plan-cards > *, .enter, .msg, .msg.card, form.panel:not([hidden]), .settings-pane { animation: fade-in .45s ease both; }
  .toast { animation: fade-in .3s ease both; }
  .toast.leaving { animation: fade-in .3s ease reverse both; }
}

/* Fit and finish */
.stack > .between, .trigger > .between, .msg.card .between { margin-bottom: 0; }
.chat-composer textarea:focus { box-shadow: none; border: 0; }
.chat-composer:focus-within { border-color: #55555c; box-shadow: 0 0 0 4px rgb(var(--ink) / .04), 0 20px 60px rgb(0 0 0 / .6); }
.session-head { padding-top: 18px; }
.session-head a.muted:hover { color: var(--text); }
#app > .screen { max-width: 960px; }

/* ===========================================================================
   App shell: a black rail, and the page as a rounded inset panel beside it.
   =========================================================================== */
:root { --rail: 236px; --sage-1: #7d9eab; --sage-2: #adc1b9; --sage-3: #ead3b8; }
body:has(> .side) { background: var(--lo); }
.side { width: var(--rail); background: var(--lo); border-right: 0; padding: 16px 12px 14px; gap: 4px; transition: width .35s var(--ease); }
.side svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 18px 10px; }
.wordmark { display: inline-flex; align-items: center; gap: 9px; font-size: 25px; font-weight: 300; letter-spacing: -.04em; color: var(--hi); line-height: 1; }
.wordmark .dot { width: 8px; height: 8px; }
.side-toggle { background: transparent; border: 0; color: var(--muted); padding: 6px; border-radius: 8px; cursor: pointer; }
.side-toggle:hover { background: rgb(var(--ink) / .07); color: var(--hi); opacity: 1; box-shadow: none !important; }
.new-chat { gap: 12px; padding: 10px 12px; margin: 0 0 10px; border-radius: 12px; border: 1px solid rgb(var(--ink) / .1); background: rgb(var(--ink) / .03); font-weight: 400; transition: background .2s, border-color .2s; }
.new-chat:hover { background: rgb(var(--ink) / .07); border-color: rgb(var(--ink) / .18); }
.side nav { gap: 3px; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; font-size: 14px; color: rgb(var(--ink) / .78); }
.side nav a:hover { background: rgb(var(--ink) / .06); color: var(--hi); }
.side nav a.active { background: rgb(var(--ink) / .1); color: var(--hi); }
.side nav a.active::before { display: none; }
.side nav a.active svg { stroke-width: 1.9; }
.side-foot { display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 10px 0 0; border-top: 0; }
.side-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; font-size: 14px; color: rgb(var(--ink) / .78); }
.side-link:hover { background: rgb(var(--ink) / .06); color: var(--hi); }
.side-link span { flex: 1; }
.side-link em { font-style: normal; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.side-foot select { margin: 4px 0; border-radius: 10px; font-size: 13px; }
.side .menu summary { width: auto; height: auto; background: transparent; color: var(--hi); display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; font-weight: 400; font-size: 14px; }
.side .menu summary:hover { background: rgb(var(--ink) / .06); }
.side .menu .avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #f97316, #ea580c); color: var(--hi); font-size: 12px; font-weight: 600; flex: none; }
.side .menu .user-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .menu .kebab { width: 16px; height: 16px; fill: currentColor; stroke: none; color: var(--muted); }
.side .menu-body { bottom: 48px; left: 0; right: 0; min-width: 0; }

/* The page: an inset panel with a hairline edge */
body:has(> .side) > main {
  margin: 8px 8px 8px calc(var(--rail) + 0px); min-height: calc(100vh - 16px); max-width: none;
  padding: 36px clamp(20px, 4vw, 56px) 64px; border-radius: 18px; border: 1px solid rgb(var(--ink) / .09);
  background: radial-gradient(1000px 420px at 70% -10%, rgb(var(--ink) / .045), transparent 60%), #0a0a0b;
  transition: margin .35s var(--ease);
}
body:has(> .side) > main > * { max-width: 1120px; margin-left: auto; margin-right: auto; }
body.chat-mode > main { height: calc(100vh - 16px); min-height: 0; padding: 0; overflow: hidden; }
body.chat-mode > main > * { max-width: none; }
#app h1 { font-weight: 400; font-size: 32px; letter-spacing: -.035em; }

/* Empty chat: a sky panel with a centered title, like a calm home screen */
body.chat-mode > main:has(.chat:not(.active)) {
  background:
    radial-gradient(900px 380px at 50% 34%, rgb(255 255 255 / .3), transparent 70%),
    radial-gradient(1100px 300px at 50% 100%, rgb(255 196 150 / .5), transparent 70%),
    linear-gradient(180deg, var(--sage-1), var(--sage-2) 60%, var(--sage-3));
  border-color: rgb(255 255 255 / .18);
}
.chat:not(.active) .chat-hero h1 { color: #fff; font-weight: 400; font-size: clamp(34px, 4.4vw, 52px); letter-spacing: -.045em; line-height: 1.08; text-shadow: 0 2px 30px rgb(0 0 0 / .12); }
.chat:not(.active) .chat-hero p { color: rgb(255 255 255 / .85); }
.chat:not(.active) .chat-mark { background: rgb(255 255 255 / .2); border-color: rgb(255 255 255 / .45); backdrop-filter: blur(8px); }
.chat:not(.active) .chat-composer { background: rgb(255 255 255 / .86); border-color: rgb(255 255 255 / .95); box-shadow: 0 30px 80px -20px rgb(20 40 35 / .45); }
.chat:not(.active) .chat-composer textarea { color: #0a0b0b; }
.chat:not(.active) .chat-composer textarea::placeholder { color: #6b726f; }
.chat:not(.active) .chat-send { background: #0a0b0b; color: #fff; border-color: #0a0b0b; }
.chat:not(.active) .chip { background: rgb(255 255 255 / .2); color: #fff; border-color: rgb(255 255 255 / .45); backdrop-filter: blur(8px); }
.chat:not(.active) .chip:hover { background: rgb(255 255 255 / .34); }
.chat:not(.active) .chat-foot { color: rgb(255 255 255 / .7); }

/* Cards: quieter, rounder, a touch of glass */
#app .panel { border-radius: 16px; border-color: rgb(var(--ink) / .08); background: rgb(var(--ink) / .025); }
#app a.panel:hover, #app .card-lite:hover { background: rgb(var(--ink) / .045); }
.stat { border-radius: 14px; background: rgb(var(--ink) / .025); border-color: rgb(var(--ink) / .08); }
.stat .n { font-weight: 300; font-size: 30px; letter-spacing: -.04em; }
.stat .muted.small { text-transform: none; letter-spacing: 0; }

/* Collapsed rail: icons only */
body.side-collapsed { --rail: 68px; }
body.side-collapsed .side nav a span, body.side-collapsed .side-link span, body.side-collapsed .side-link em, body.side-collapsed .new-chat span, body.side-collapsed .wordmark, body.side-collapsed .user-name, body.side-collapsed .kebab, body.side-collapsed .side-foot select { display: none; }
body.side-collapsed .side-head { justify-content: center; padding-inline: 0; }
body.side-collapsed .side nav a, body.side-collapsed .side-link, body.side-collapsed .new-chat, body.side-collapsed .side .menu summary { justify-content: center; padding-inline: 0; }

@media (max-width: 820px) {
  .side { width: auto; }
  .side svg { display: none; }
  .side-head { padding: 0 8px 0 0; }
  .side-toggle, .side-link { display: none; }
  .side nav a { padding: 7px 10px; }
  body:has(> .side) > main { margin: 0 6px 6px; min-height: auto; }
  body.chat-mode > main { height: calc(100vh - 64px); }
}

/* Agent cards: a head row, then big readouts under small labels */
.agent-list { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.agent-card { display: block; border-radius: 18px; border: 1px solid rgb(var(--ink) / .08); background: linear-gradient(180deg, rgb(var(--ink) / .04), rgb(var(--ink) / .015)); padding: 18px 22px 20px; color: var(--text); transition: border-color .25s var(--ease), background .25s var(--ease), transform .3s var(--ease); }
.agent-card:hover { border-color: rgb(var(--ink) / .18); background: linear-gradient(180deg, rgb(var(--ink) / .06), rgb(var(--ink) / .02)); transform: translateY(-2px); color: var(--text); }
.agent-card-head { display: flex; align-items: center; gap: 14px; }
.agent-glyph { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--hi); color: var(--lo); font-weight: 700; font-size: 15px; flex: none; }
.agent-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.agent-title b { font-weight: 500; font-size: 16px; letter-spacing: -.01em; }
.agent-title span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 11.5px; color: rgb(var(--ink) / .7); padding: 3px 10px; border-radius: 999px; border: 1px solid rgb(var(--ink) / .12); background: rgb(var(--ink) / .03); }
.agent-metrics { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 16px; margin-top: 18px; padding-top: 16px; border-top: 1px solid rgb(var(--ink) / .06); }
.agent-metrics div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.agent-metrics .right { text-align: right; }
.agent-metrics small { color: var(--muted); font-size: 12px; }
.agent-metrics span { font-size: 21px; font-weight: 300; letter-spacing: -.03em; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) { .agent-metrics { grid-template-columns: 1fr 1fr; } .agent-metrics .right { text-align: left; } .agent-tags { display: none; } }
/* Thinking: Frankie's status, with a soft shimmer */
.msg.thinking { gap: 12px; }
.thinking-label { font-size: 13px; letter-spacing: .01em; background: linear-gradient(90deg, var(--faint) 0%, var(--faint) 35%, #f4f4f5 50%, var(--faint) 65%, var(--faint) 100%); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.8s linear infinite; }
.thinking-label::after { content: "…"; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@media (prefers-reduced-motion: reduce) { .thinking-label { color: var(--muted); background: none; } }

/* Frankie at work: a card that says what it's doing and for how long */
.msg.thinking { display: flex; align-items: center; gap: 14px; align-self: flex-start; padding: 12px 16px 12px 14px; border-radius: 16px; border: 1px solid rgb(var(--ink) / .1); background: linear-gradient(110deg, rgb(var(--ink) / .03) 30%, rgb(var(--ink) / .07) 50%, rgb(var(--ink) / .03) 70%); background-size: 250% 100%; animation: card-shine 2.2s linear infinite, msg-in .4s var(--ease-out) both; min-width: 260px; }
@keyframes card-shine { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.thinking-ring { width: 22px; height: 22px; border-radius: 50%; flex: none; border: 2px solid rgb(var(--ink) / .12); border-top-color: #ffb86b; border-right-color: #fda4af; animation: spin-ring .9s linear infinite; box-shadow: 0 0 14px rgb(255 184 107 / .25); }
@keyframes spin-ring { to { transform: rotate(360deg); } }
.thinking-body { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.thinking-who { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.msg.thinking .thinking-label { font-size: 14px; }
.thinking-clock { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.msg.thinking .dots, .msg.thinking .msg-mark { display: none; }

/* The message box glows while Frankie works */
.chat-composer.busy { position: relative; border-color: transparent !important; isolation: isolate; }
.chat-composer.busy::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; background: conic-gradient(from var(--spin, 0deg), transparent 0 55%, #ffb86b 70%, #fda4af 80%, #93c5fd 90%, transparent 100%); -webkit-mask: linear-gradient(var(--lo) 0 0) content-box, linear-gradient(var(--lo) 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: spin-border 2s linear infinite; z-index: -1; }
@property --spin { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes spin-border { to { --spin: 360deg; } }
@media (prefers-reduced-motion: reduce) { .msg.thinking { animation: none; } .thinking-ring { animation-duration: 3s; } .chat-composer.busy::before { animation: none; background: rgb(255 184 107 / .6); } }

/* The Lark mark */
.logo { display: block; flex: none; width: 22px; height: 22px; border-radius: 6px; }
.wordmark .logo { width: 24px; height: 24px; border-radius: 7px; box-shadow: 0 0 18px rgb(246 160 124 / .35); }
.brand .logo { width: 22px; height: 22px; }
.msg-mark { background: none !important; border: 0 !important; }
.msg-mark .logo { width: 26px; height: 26px; border-radius: 8px; }
.chat-mark { background: none !important; border: 0 !important; width: auto !important; height: auto !important; }
.chat-mark .logo { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 18px 50px -10px rgb(246 160 124 / .55); }

/* Smooth chat: isolate each message's layout, let the pane do the scrolling, no anchoring fights */
.chat-scroll { overflow-anchor: none; overscroll-behavior: contain; scrollbar-gutter: stable; -webkit-overflow-scrolling: touch; }
.chat-log > .msg { contain: layout style; }
.msg-body { overflow-wrap: anywhere; }
.msg.thinking.settled { animation: card-shine 2.2s linear infinite; }
.chat-composer.busy::before { will-change: --spin; }

/* Frankie's action cards */
.card-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.card-fields div { display: flex; flex-direction: column; gap: 2px; }
.card-fields small { color: var(--muted); font-size: 11.5px; }
.card-fields span { font-size: 14px; overflow-wrap: anywhere; }
.card-link { color: var(--muted); align-self: flex-start; }
.card-link:hover { color: var(--text); }

/* Markdown extras and the run report */
.md-table { overflow-x: auto; margin: 0 0 14px; border: 1px solid var(--border); border-radius: 10px; }
.md-table table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.md-table th, .md-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.md-table th { font-weight: 600; background: var(--code-bg); }
.md-table tr:last-child td { border-bottom: 0; }
.msg-body blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--border); color: var(--muted); }
.msg-body hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.msg-body h6 { margin: 14px 0 6px; font-size: 13.5px; }
.msg-body a { color: inherit; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.report { padding: 22px 26px; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.report-head h3 { margin: 0; }
.report-body { font-size: 15px; line-height: 1.65; max-width: 860px; }
.report-body h3 { font-size: 18px; }
.report-body h4 { font-size: 16px; }

/* Recent chats */
.side nav { flex: 0 0 auto; }
.side-recent { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; margin: 14px 0 8px; padding-right: 2px; }
.side-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 12px 6px; }
.recent { display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 12px; border-radius: 9px; font-size: 13px; color: var(--muted); text-decoration: none; border: 0; }
.recent span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent:hover { background: var(--panel); color: var(--text); }
.recent.active { background: var(--panel-2, #111); color: var(--text); }
.recent-del { opacity: 0; border: 0; background: none; color: var(--muted); padding: 0 4px; font-size: 14px; line-height: 1; cursor: pointer; min-height: 0; }
.recent:hover .recent-del, .recent-del.armed { opacity: 1; }
.recent-del.armed { color: #f87171; font-size: 11.5px; }
body.side-collapsed .side-recent { display: none; }
@media (max-width: 860px) { .side-recent { display: none; } }

/* Talking to a running agent */
.run-talk { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 16px; }
.runwin .run-talk { margin: 0; padding: 10px 14px 14px; border-top: 1px solid var(--border); }
.run-talk .row { gap: 8px; flex-wrap: nowrap; }
.run-talk input { flex: 1; min-width: 0; }
.ask { border: 1px solid rgb(251 191 36 / .45); background: rgb(251 191 36 / .07); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; animation: grow .35s var(--ease-out); }
.ask-label { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: #fbbf24; }
.ask-dot { width: 8px; height: 8px; border-radius: 50%; background: #fbbf24; box-shadow: 0 0 0 0 rgb(251 191 36 / .6); animation: ask-pulse 1.6s infinite; }
@keyframes ask-pulse { 70% { box-shadow: 0 0 0 8px rgb(251 191 36 / 0); } 100% { box-shadow: 0 0 0 0 rgb(251 191 36 / 0); } }
.ask-q { font-size: 15px; }
.ask-q p:last-child { margin-bottom: 0; }
.ask-options { flex-wrap: wrap !important; }
.rl.ask, .ev.ask { color: #fbbf24; }
.rl.you, .ev.you { color: #93c5fd; }

/* Taking control of the agent's browser */
.screen-chrome { display: flex; align-items: center; gap: 10px; }
.screen-caption { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-take { font-size: 12px; padding: 4px 10px; min-height: 0; }
.screen-take.primary-ish { background: var(--hi); color: var(--lo); border-color: var(--hi); }
.screen-frame { position: relative; }
.screen.held .screen-frame { outline: 2px solid #60a5fa; outline-offset: -2px; }
.screen.held img { cursor: crosshair; }
.screen-tap { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 2px solid #60a5fa; pointer-events: none; animation: tap .6s ease-out forwards; }
@keyframes tap { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.screen-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); background: var(--panel); }
.screen-bar input { flex: 1 1 180px; min-width: 0; font-size: 13px; padding: 6px 10px; }
.screen-bar button { padding: 4px 10px; min-height: 0; font-size: 12px; }

/* Triggers page */
.howto { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.howto pre { white-space: pre-wrap; word-break: break-all; }
.howto-wrap { margin-top: 10px; }
.howto-wrap summary { cursor: pointer; color: var(--muted); }
.howto-wrap summary:hover { color: var(--text); }

/* ================= The polished layer: shared by every page ================= */
:root {
  --glass-bg: linear-gradient(180deg, rgb(var(--ink) / .045), rgb(var(--ink) / .012));
  --glass-border: rgb(var(--ink) / .085);
  --glass-border-hover: rgb(var(--ink) / .18);
  --dawn: linear-gradient(90deg, #ffb86b, #fda4af 45%, #93c5fd);
}

/* Page heading: eyebrow, title, a line, actions */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 4px 0 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 30px; font-weight: 600; letter-spacing: -.035em; margin: 2px 0 6px; }
.page-sub { margin: 0; color: var(--muted); font-size: 14.5px; max-width: 620px; }
.page-actions { display: flex; gap: 8px; }
.eyebrow { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); display: inline-flex; align-items: center; gap: 8px; }
.eyebrow::before { content: ""; width: 14px; height: 1px; background: var(--dawn); }

/* Glass cards, lit where the pointer is */
.glass, .run-row, .trigger-card, .kpi { position: relative; border: 1px solid var(--glass-border); background: var(--glass-bg); border-radius: 18px; isolation: isolate; transition: border-color .3s var(--ease), transform .35s var(--ease), box-shadow .35s var(--ease); }
.glass::after, .run-row::after, .trigger-card::after, .kpi::after, .agent-card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .35s var(--ease); background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgb(var(--ink) / .06), transparent 45%); z-index: -1; }
.glass:hover::after, .run-row:hover::after, .trigger-card:hover::after, .kpi:hover::after, .agent-card:hover::after { opacity: 1; }
.agent-card { position: relative; isolation: isolate; }
section.glass, form.glass { padding: 20px 22px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }

/* Figures */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
@media (max-width: 860px) { .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-n { font-size: 30px; font-weight: 300; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-hint { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi.live::before { content: ""; position: absolute; top: 18px; right: 18px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgb(74 222 128 / .6); animation: live-pulse 1.8s infinite; }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 9px rgb(74 222 128 / 0); } 100% { box-shadow: 0 0 0 0 rgb(74 222 128 / 0); } }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: live-pulse 1.8s infinite; vertical-align: middle; }

/* Filters */
.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--glass-border); background: transparent; color: var(--muted); font-size: 13px; min-height: 0; cursor: pointer; }
.fchip:hover { color: var(--text); border-color: var(--glass-border-hover); }
.fchip.on { background: var(--hi); color: var(--lo); border-color: var(--hi); }
.fchip em { font-style: normal; font-size: 11.5px; opacity: .6; font-variant-numeric: tabular-nums; }
.filter-right { display: flex; gap: 8px; }
.filter-select, .filter-search { width: auto; border-radius: 999px; padding: 7px 14px; font-size: 13px; background: rgb(var(--ink) / .03); }
.filter-search { min-width: 220px; }

/* Runs */
.run-groups { display: flex; flex-direction: column; gap: 8px; }
.run-day { display: flex; align-items: baseline; justify-content: space-between; margin: 14px 4px 2px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.run-day:first-child { margin-top: 0; }
.run-day em { font-style: normal; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.run-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px 18px; color: var(--text); overflow: hidden; }
.run-row:hover { border-color: var(--glass-border-hover); transform: translateY(-1px); color: var(--text); }
.run-row.arrive { animation: arrive .7s var(--ease-out) both; }
@keyframes arrive { from { opacity: 0; transform: translateY(-8px) scale(.99); box-shadow: 0 0 0 1px rgb(var(--ink) / .3); } to { opacity: 1; transform: none; } }
.run-orb { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); position: relative; }
.s-row-succeeded .run-orb { background: var(--ok); box-shadow: 0 0 12px rgb(74 222 128 / .45); }
.s-row-failed .run-orb { background: var(--bad); box-shadow: 0 0 12px rgb(248 113 113 / .45); }
.s-row-running .run-orb, .s-row-queued .run-orb { background: var(--hi); animation: live-pulse 1.6s infinite; box-shadow: 0 0 0 0 rgb(var(--ink) / .5); }
.agent-glyph.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; }
.run-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.run-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.run-top b { font-weight: 500; }
.run-task { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.run-error { color: var(--bad); font-size: 12.5px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-variant-numeric: tabular-nums; }
.run-cost { font-size: 17px; font-weight: 300; letter-spacing: -.02em; }
.run-dur, .run-clock { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.run-clock { color: var(--text); }
.run-ago { font-size: 11.5px; color: var(--faint); }
.run-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, transparent, #ffb86b, #fda4af, #93c5fd, transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: run-progress 1.8s var(--ease) infinite; }
@keyframes run-progress { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.t-trigger { color: #fbbf24; border-color: rgb(251 191 36 / .3); }
@media (max-width: 720px) { .run-row { grid-template-columns: auto minmax(0, 1fr) auto; } .run-row .agent-glyph { display: none; } .filter-search { min-width: 0; flex: 1; } }

/* Empty states */
.empty-state { padding: 44px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state h3 { font-size: 18px; margin: 6px 0 0; }
.empty-state p { margin: 0 0 10px; max-width: 420px; }
.empty-orb { width: 54px; height: 54px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffd8a8, #f6a07c 45%, #6c90a0 100%); box-shadow: 0 0 40px rgb(246 160 124 / .35); animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }

/* Usage & billing */
.billing-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 24px; padding: 26px 30px !important; overflow: hidden; }
.billing-hero::before { content: ""; position: absolute; inset: -40% -10% auto auto; width: 420px; height: 420px; background: radial-gradient(circle, rgb(246 160 124 / .14), transparent 60%); pointer-events: none; z-index: -1; }
.hero-left { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hero-n { font-size: 56px; font-weight: 200; letter-spacing: -.05em; line-height: 1; font-variant-numeric: tabular-nums; background: linear-gradient(180deg, var(--hi), #c8c8cc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13.5px; }
.hero-note { font-size: 13px; color: var(--muted); border-left: 2px solid rgb(251 191 36 / .5); padding-left: 10px; max-width: 560px; }
.plan-pill { padding: 3px 11px; border-radius: 999px; font-size: 12px; background: var(--hi); color: var(--lo); font-weight: 600; }
.plan-pill.off { background: transparent; color: var(--muted); border: 1px solid var(--glass-border); font-weight: 500; }
.ring-wrap { position: relative; width: 150px; height: 150px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring-track { stroke: rgb(var(--ink) / .07); }
.ring-arc { stroke: var(--hi); transition: stroke-dashoffset 1.4s var(--ease-out); filter: drop-shadow(0 0 6px rgb(var(--ink) / .35)); }
.ring-arc.high { stroke: var(--warn); filter: drop-shadow(0 0 6px rgb(251 191 36 / .45)); }
.ring-arc.full { stroke: var(--bad); filter: drop-shadow(0 0 6px rgb(248 113 113 / .5)); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-text b { font-size: 26px; font-weight: 300; letter-spacing: -.03em; }
.ring-text span { font-size: 11px; color: var(--muted); max-width: 90px; }
.billing-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; align-items: start; margin-bottom: 14px; }
.billing-grid > section, .stack-col > section { margin-bottom: 0; }
.stack-col { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 900px) { .billing-grid { grid-template-columns: 1fr; } .billing-hero { grid-template-columns: 1fr; } .hero-n { font-size: 44px; } }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 6px; }
.bar { flex: 1; height: 100%; display: flex; align-items: flex-end; border-radius: 4px; cursor: default; }
.bar:hover { background: rgb(var(--ink) / .04); }
.bar i { display: block; width: 100%; height: var(--h); border-radius: 4px 4px 2px 2px; background: linear-gradient(180deg, rgb(var(--ink) / .85), rgb(var(--ink) / .25)); transform-origin: bottom; animation: bar-up .9s var(--ease-out) both; animation-delay: var(--d); }
.bar.today i { background: var(--dawn); box-shadow: 0 0 14px rgb(253 164 175 / .4); }
@keyframes bar-up { from { transform: scaleY(0); } to { transform: none; } }
.bars-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.agent-spend { display: flex; flex-direction: column; gap: 6px; }
.spend-row { display: flex; gap: 14px; align-items: center; padding: 10px 8px; border-radius: 12px; color: var(--text); }
.spend-row:hover { background: rgb(var(--ink) / .03); color: var(--text); }
.spend-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.spend-n { font-variant-numeric: tabular-nums; font-weight: 300; font-size: 16px; }
.spend-bar { height: 4px; border-radius: 4px; background: rgb(var(--ink) / .06); overflow: hidden; }
.spend-bar i { display: block; height: 100%; width: var(--w); background: var(--dawn); border-radius: 4px; transform-origin: left; animation: bar-across 1s var(--ease-out) both; animation-delay: var(--d); }
@keyframes bar-across { from { transform: scaleX(0); } to { transform: none; } }
.spend-meta { font-size: 12px; color: var(--faint); }
.running-list { display: flex; flex-direction: column; gap: 4px; }
.running-item { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 8px 10px; border-radius: 10px; color: var(--text); align-items: baseline; }
.running-item:hover { background: rgb(var(--ink) / .03); color: var(--text); }
.limit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.limit-grid div { display: flex; flex-direction: column; gap: 2px; }
.limit-grid small { color: var(--muted); font-size: 12px; }
.limit-grid b { font-weight: 400; font-size: 15px; }
.budget-card .row input { max-width: 200px; }
.budget-sign { font-size: 20px; color: var(--muted); font-weight: 300; }
.plans-section { margin: 26px 0 10px; display: flex; flex-direction: column; gap: 14px; }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.plan-card { padding: 22px 20px; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.plan-card:hover { border-color: var(--glass-border-hover); transform: translateY(-2px); }
.plan-card.current { border-color: rgb(var(--ink) / .35); box-shadow: 0 0 0 1px rgb(var(--ink) / .08), 0 20px 50px -20px rgb(246 160 124 / .35); }
.plan-ribbon { position: absolute; top: 14px; right: 14px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; background: var(--dawn); color: var(--lo); font-weight: 700; }
.plan-name { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.plan-price { font-size: 14px; color: var(--muted); }
.plan-price b { font-size: 30px; font-weight: 300; color: var(--text); letter-spacing: -.03em; }
.plan-card ul { margin: 4px 0 6px; padding-left: 18px; color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 4px; flex: 1; }

/* Triggers */
.trigger-list { display: flex; flex-direction: column; gap: 10px; }
.trigger-card { padding: 18px 20px; }
.trigger-card:hover { border-color: var(--glass-border-hover); }
.trigger-head { display: flex; align-items: center; gap: 14px; }
.trigger-head-text { flex: 1; min-width: 0; }
.trigger-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; border: 1px solid var(--glass-border); background: rgb(var(--ink) / .03); position: relative; flex: none; }
.trigger-icon svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.trigger-icon.on svg { stroke: var(--hi); }
.trigger-icon.k-webhook.on::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 1px solid rgb(251 191 36 / .6); animation: listen 2.2s var(--ease-out) infinite; }
.trigger-icon.k-webhook.on svg { stroke: #fbbf24; }
@keyframes listen { from { transform: scale(1); opacity: .9; } to { transform: scale(1.45); opacity: 0; } }
.trigger-next { font-family: var(--mono); font-size: 12px; color: var(--text); padding: 3px 10px; border-radius: 999px; border: 1px solid var(--glass-border); font-variant-numeric: tabular-nums; }
.trigger .trigger-title { margin: 2px 0 0; }

/* Everywhere: panels and tables pick up the same glass and motion */
.panel { background: var(--glass-bg); border-color: var(--glass-border); border-radius: 18px; }
.panel:hover { border-color: rgb(var(--ink) / .12); }
.table-wrap table tbody tr:hover { background: rgb(var(--ink) / .025); }
#app > .between:first-child h1 { font-size: 28px; letter-spacing: -.035em; }
.tabs a.active { border-image: var(--dawn) 1; }
button:not(.ghost):not(.danger):not(.chip):not(.pill):not(.fchip):not(.recent-del) { position: relative; overflow: hidden; }
button:not(.ghost):not(.danger):not(.chip):not(.pill):not(.fchip):not(.recent-del)::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 35%, rgb(var(--ink) / .55) 50%, transparent 65%); transform: translateX(-120%); pointer-events: none; }
button:not(.ghost):not(.danger):not(.chip):not(.pill):not(.fchip):not(.recent-del):hover::after { transform: translateX(120%); transition: transform .8s var(--ease); }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px rgb(var(--ink) / .06), 0 0 0 1px rgb(var(--ink) / .25); }
@media (prefers-reduced-motion: no-preference) {
  .kpi-row > * { animation: rise .55s var(--ease-out) both; }
  .kpi-row > *:nth-child(2) { animation-delay: .05s; } .kpi-row > *:nth-child(3) { animation-delay: .1s; } .kpi-row > *:nth-child(4) { animation-delay: .15s; }
  .plan-cards > * { animation: rise .6s var(--ease-out) both; }
  .plan-cards > *:nth-child(2) { animation-delay: .06s; } .plan-cards > *:nth-child(3) { animation-delay: .12s; } .plan-cards > *:nth-child(4) { animation-delay: .18s; }
}
@media (prefers-reduced-motion: reduce) { .bar i, .spend-bar i, .run-progress, .empty-orb { animation: none; } .ring-arc { transition: none; } }

section.billing-hero.glass { display: grid; }
@media (max-width: 900px) { section.billing-hero.glass { display: flex; } }

/* Settings: tabs stay put, the pane fades in */
.settings-pane { animation: pane-in .35s var(--ease-out) both; }
@keyframes pane-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }


/* Skill generator */
.gen-card label { display: flex; flex-direction: column; gap: 6px; }
.gen-status { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.gen-status .thinking-ring { width: 18px; height: 18px; }
.draft-note { font-size: 13px; padding: 8px 12px; border-radius: 10px; border: 1px solid rgb(253 164 175 / .3); background: rgb(253 164 175 / .06); }

/* ============ Phones: a top bar, and a menu that opens over the page ============ */
.menu-toggle { display: none; }
@media (max-width: 820px) {
  body:has(> .side) { display: block; }
  .side { position: sticky; top: 0; z-index: 40; width: auto !important; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; overflow: visible; background: rgb(0 0 0 / .85); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
  .side-head { display: flex !important; align-items: center; flex: 1; min-width: 0; padding: 0 !important; }
  .side-head .wordmark { display: inline-flex !important; }
  .side-toggle { display: none !important; }
  .new-chat { order: 1; margin: 0 !important; padding: 7px 12px !important; }
  .new-chat span { display: none; }
  .menu-toggle { order: 2; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 11px; border: 1px solid var(--border-strong); background: transparent !important; color: var(--text); min-height: 0; }
  .menu-toggle svg { display: block !important; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; grid-area: 1 / 1; transition: opacity .25s, transform .35s var(--ease); }
  .menu-toggle .i-close { opacity: 0; transform: rotate(-90deg); }
  body.menu-open .menu-toggle .i-open { opacity: 0; transform: rotate(90deg); }
  body.menu-open .menu-toggle .i-close { opacity: 1; transform: none; }
  .menu-toggle::after { display: none !important; }
  .side .new-chat svg, .side-head .wordmark .logo { display: block !important; }
  .side .new-chat svg { width: 18px; height: 18px; }
  /* Closed: just the bar. Open: everything, full width, below it. */
  .side nav, .side-recent, .side-foot { display: none !important; }
  body.menu-open .side { height: 100vh; height: 100dvh; align-content: flex-start; overflow-y: auto; background: var(--bg-deep); }
  body.menu-open .side nav { display: flex !important; flex-direction: column !important; order: 3; flex: 0 0 100%; gap: 2px; margin-top: 10px; overflow: visible; }
  body.menu-open .side nav a { padding: 13px 14px !important; font-size: 16px !important; animation: rise .35s var(--ease-out) both; }
  body.menu-open .side nav a svg { display: block !important; width: 20px; height: 20px; }
  body.menu-open .side-recent { display: flex !important; order: 4; flex: 0 0 100%; max-height: none; }
  body.menu-open .side-foot { display: flex !important; order: 5; flex: 0 0 100%; flex-wrap: wrap; gap: 10px; padding-top: 14px !important; border-top: 1px solid var(--border) !important; }
  body.menu-open .side-foot .side-link { display: flex !important; }
  body.menu-open > main { display: none; }
  body:has(> .side) > main { margin: 0 !important; border-radius: 0; min-height: calc(100vh - 60px); padding: 22px 16px 60px !important; }
  body.chat-mode > main { height: calc(100dvh - 60px) !important; padding: 0 !important; }
  .page-head h1 { font-size: 26px; }
  .page-actions { width: 100%; }
  .page-actions > * { flex: 1; text-align: center; }
  .filter-bar, .filter-right { width: 100%; }
  .filter-right > * { flex: 1; min-width: 0; }
  .run-row { padding: 12px 14px; gap: 10px; }
  .billing-hero { padding: 20px !important; }
  .ring-wrap { width: 120px; height: 120px; margin: 0 auto; }
  .two { grid-template-columns: 1fr !important; }
  .skills-layout { grid-template-columns: 1fr !important; }
  .runwin-actions { flex-wrap: wrap; }
  .screen-bar input { flex-basis: 100%; }
  .db-drawer { width: 100vw; right: 0; top: 0; bottom: 0; border-radius: 0; }
}


/* ============ Day: the same design, lit ============ */
html[data-theme="day"] {
  --bg: #f4efe7;
  --bg-deep: #efe8dd;
  --panel: #fbf8f3;
  --panel-2: #f1ebe2;
  --text: #15161b;
  --muted: #5d5f69;
  --faint: #8d8f98;
  --border: #e3dbcf;
  --border-strong: #d2c8b9;
  --accent: #15161b;
  --accent-text: #ffffff;
  --code-bg: #f1ebe2;
  --ink: 20 24 40;
  --hi: #15161b;
  --lo: #ffffff;
  --glass-bg: linear-gradient(180deg, rgb(255 255 255 / .85), rgb(255 255 255 / .6));
  --glass-border: rgb(20 24 40 / .09);
  --glass-border-hover: rgb(20 24 40 / .2);
  color-scheme: light;
}
html[data-theme="day"] body { background: var(--bg); }
html[data-theme="day"] .side { background: var(--bg-deep); }
html[data-theme="day"] body:has(> .side) > main { background: radial-gradient(900px 420px at 100% 0%, rgb(255 214 120 / .18), transparent 60%), #fbf8f3; border-color: var(--border); }
html[data-theme="day"] .toast { background: #15161b; color: #fff; }
html[data-theme="day"] .hero-n { background: linear-gradient(180deg, #15161b, #4a4c57); -webkit-background-clip: text; background-clip: text; }
html[data-theme="day"] .bar i { background: linear-gradient(180deg, rgb(20 24 40 / .8), rgb(20 24 40 / .25)); }
html[data-theme="day"] .ring-arc { stroke: #15161b; filter: none; }
html[data-theme="day"] .run-orb { box-shadow: none; }
html[data-theme="day"] .s-row-running .run-orb, html[data-theme="day"] .s-row-queued .run-orb { background: #15161b; }
html[data-theme="day"] .msg.me { background: #15161b; color: #fff; }
html[data-theme="day"] .chat-composer, html[data-theme="day"] .chat-composer textarea { background: #fff; color: var(--text); }
html[data-theme="day"] input, html[data-theme="day"] select, html[data-theme="day"] textarea { background: #fff; color: var(--text); border-color: var(--border-strong); }
html[data-theme="day"] .runwin, html[data-theme="day"] .runwin-body { background: #fff; }
html[data-theme="day"] .rl.say, html[data-theme="day"] .rl.cmd { color: var(--text); }
html[data-theme="day"] .screen-chrome { background: #f1ebe2; }
html[data-theme="day"] .side nav a.active::before { box-shadow: none; }
html[data-theme="day"] .wordmark .logo { box-shadow: 0 0 14px rgb(246 160 124 / .4); }
html[data-theme="day"] .kpi.live::before, html[data-theme="day"] .live-dot { background: #16a34a; }
html[data-theme="day"] .error-box { color: #b91c1c; }

/* The night/day switch, as on the landing page */
.theme-switch { position: relative; width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 50%; border: 1px solid var(--border-strong); background: transparent !important; color: var(--text); display: grid; place-items: center; cursor: pointer; overflow: hidden; flex: none; }
.theme-switch::after { display: none !important; }
.theme-switch svg { grid-area: 1 / 1; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; transition: transform .6s var(--ease), opacity .4s; }
.theme-switch .i-moon { fill: currentColor; stroke: none; }
html:not([data-theme="day"]) .theme-switch .i-moon { transform: translateY(24px) rotate(40deg); opacity: 0; }
html[data-theme="day"] .theme-switch .i-sun { transform: translateY(-24px) rotate(-90deg); opacity: 0; }
html.theme-shift, html.theme-shift * { transition: background-color .7s var(--ease), color .7s var(--ease), border-color .7s var(--ease), fill .7s, stroke .7s !important; }

.side-head { gap: 6px; }
.side-head .theme-switch { margin-left: auto; }
body.side-collapsed .side-head .theme-switch { display: none; }
@media (max-width: 820px) { .side-head .theme-switch { order: 1; margin-left: auto; } .menu-toggle { margin-left: 6px; } }

/* ============ The empty chat wears the landing page's sky: night with a moon, day with a sun ============ */
body.chat-mode > main:has(.chat:not(.active)) {
  position: relative; isolation: isolate;
  background:
    radial-gradient(1px 1px at 12% 22%, #fff9, transparent), radial-gradient(1px 1px at 28% 64%, #fff6, transparent),
    radial-gradient(1px 1px at 44% 12%, #fff8, transparent), radial-gradient(1.5px 1.5px at 63% 38%, #fffa, transparent),
    radial-gradient(1px 1px at 76% 20%, #fff7, transparent), radial-gradient(1px 1px at 90% 58%, #fff6, transparent),
    radial-gradient(1px 1px at 7% 80%, #fff5, transparent), radial-gradient(1.5px 1.5px at 35% 34%, #fff8, transparent),
    radial-gradient(1px 1px at 56% 70%, #fff4, transparent), radial-gradient(1px 1px at 20% 46%, #fff6, transparent),
    radial-gradient(520px 520px at 84% 6%, rgb(196 210 255 / .16), transparent 60%),
    radial-gradient(1300px 380px at 50% 104%, rgb(124 92 255 / .38), transparent 70%),
    radial-gradient(900px 260px at 22% 100%, rgb(45 212 191 / .14), transparent 70%),
    linear-gradient(180deg, #04050d 0%, #0b1230 58%, #2a1d4a 100%);
  border-color: rgb(255 255 255 / .1);
}
body.chat-mode > main:has(.chat:not(.active))::before {
  content: ""; position: absolute; top: 9%; right: 9%; width: 56px; height: 56px; border-radius: 50%; z-index: -1; pointer-events: none;
  background: radial-gradient(circle at 38% 36%, #fbfbff 0%, #dfe4f7 45%, #b9c1de 100%);
  box-shadow: 0 0 40px 8px rgb(200 212 255 / .35), 0 0 140px 40px rgb(140 160 255 / .15);
  -webkit-mask: radial-gradient(circle at 70% 30%, transparent 19px, #000 20px); mask: radial-gradient(circle at 70% 30%, transparent 19px, #000 20px);
}
html[data-theme="day"] body.chat-mode > main:has(.chat:not(.active)) {
  background:
    radial-gradient(560px 560px at 84% 8%, rgb(255 236 179 / .75), transparent 60%),
    radial-gradient(1100px 300px at 50% 100%, rgb(255 196 150 / .45), transparent 70%),
    linear-gradient(180deg, #7fb2e5 0%, #b9d7ef 55%, #f6d7b8 100%);
  border-color: rgb(20 24 40 / .08);
}
html[data-theme="day"] body.chat-mode > main:has(.chat:not(.active))::before {
  background: radial-gradient(circle at 40% 38%, #fffbe8 0%, #ffe39a 45%, #ffbf5e 100%);
  box-shadow: 0 0 60px 18px rgb(255 214 120 / .55), 0 0 140px 50px rgb(255 214 120 / .25);
  -webkit-mask: none; mask: none;
}
html[data-theme="day"] .chat:not(.active) .chat-hero h1 { color: #10131c; text-shadow: 0 2px 30px rgb(255 255 255 / .35); }
html[data-theme="day"] .chat:not(.active) .chat-hero p, html[data-theme="day"] .chat:not(.active) .chat-foot { color: rgb(16 19 28 / .7); }
html[data-theme="day"] .chat:not(.active) .chip { background: rgb(255 255 255 / .55); color: #14151a; border-color: rgb(20 24 40 / .12); }
html[data-theme="day"] .chat:not(.active) .chip:hover { background: #fff; }
@media (max-width: 820px) { body.chat-mode > main:has(.chat:not(.active))::before { width: 40px; height: 40px; top: 6%; right: 7%; } }

/* Switching night and day: dusk falls from the top, dawn rises from the horizon (as on the landing page). */
@keyframes lk-dusk-in { from { mask-position: 0 100%; -webkit-mask-position: 0 100%; } to { mask-position: 0 0; -webkit-mask-position: 0 0; } }
@keyframes lk-dawn-in { from { mask-position: 0 0; -webkit-mask-position: 0 0; } to { mask-position: 0 100%; -webkit-mask-position: 0 100%; } }
@keyframes lk-dusk-out { to { filter: brightness(.55) saturate(1.25) hue-rotate(-12deg); } }
@keyframes lk-dawn-out { to { filter: brightness(1.35) saturate(.9); } }
html[data-shift]::view-transition-old(root), html[data-shift]::view-transition-new(root) { mix-blend-mode: normal; }
html[data-shift]::view-transition-new(root) { -webkit-mask-size: 100% 300%; mask-size: 100% 300%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
html[data-shift="dusk"]::view-transition-new(root) { -webkit-mask-image: linear-gradient(180deg, #000 33%, transparent 66%); mask-image: linear-gradient(180deg, #000 33%, transparent 66%); animation: lk-dusk-in 1.5s cubic-bezier(.65, 0, .35, 1) both; }
html[data-shift="dawn"]::view-transition-new(root) { -webkit-mask-image: linear-gradient(180deg, transparent 33%, #000 66%); mask-image: linear-gradient(180deg, transparent 33%, #000 66%); animation: lk-dawn-in 1.5s cubic-bezier(.65, 0, .35, 1) both; }
html[data-shift="dusk"]::view-transition-old(root) { animation: lk-dusk-out 1.5s ease-in both; }
html[data-shift="dawn"]::view-transition-old(root) { animation: lk-dawn-out 1.5s ease-in both; }

/* Attached files: a tray above the message, and labels under sent messages */
.chat-composer { flex-wrap: wrap; }
.chat-files { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 4px; }
.chat-files[hidden] { display: none; }
.chat-file { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 4px 6px 4px 10px; border-radius: 999px; font-size: 12.5px; background: rgb(var(--ink) / .06); border: 1px solid rgb(var(--ink) / .1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-file button { padding: 0 4px; min-height: 0; height: 18px; line-height: 1; border: 0; font-size: 15px; }
.msg-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.msg-files .chat-file { padding-right: 10px; }
.chat-attach { width: 38px; height: 38px; padding: 0; border-radius: 50%; flex: none; display: grid; place-items: center; border: 0; }
.chat-attach svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat:not(.active) .chat-attach { color: #0a0b0b; }
.chat:not(.active) .chat-file { color: #0a0b0b; background: rgb(0 0 0 / .05); border-color: rgb(0 0 0 / .1); }
.chat-composer.dropping { border-color: var(--accent, #7c5cff); box-shadow: 0 0 0 3px rgb(124 92 255 / .25); }

/* Day: cards in the chat are light panels, like the rest of the page */
html[data-theme="day"] .msg.card { background: linear-gradient(180deg, #fff, #faf7f2); border-color: rgb(20 24 40 / .12); }
html[data-theme="day"] .msg.card:hover { border-color: rgb(20 24 40 / .22); }
