@font-face { font-family: "Geist"; src: url("/fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

/* Dark is the default look (like Grok). Light and Auto are options in Settings. */
:root {
  --bg: #000000;
  --bg-elev: #0b0b0c;
  --surface: #121214;
  --surface-2: #18181b;
  --hover: #1c1c1f;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #f5f5f6;
  --text-2: #a3a3ab;
  --text-3: #66666e;
  --accent: #ffffff;
  --accent-text: #000000;
  --user: #1c1c1f;
  --ok: #3ecf8e;
  --warn: #f2a93b;
  --danger: #f2555a;
  --danger-soft: rgba(242, 85, 90, 0.1);
  --warn-soft: rgba(242, 169, 59, 0.09);
  --shadow: 0 0 0 1px var(--line), 0 16px 40px rgba(0, 0, 0, 0.55);
  --radius: 16px;
  --sidebar: 268px;
  --panel: 420px;
  --font: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --surface: #f4f4f5;
  --surface-2: #ececee;
  --hover: #efeff1;
  --line: rgba(0, 0, 0, 0.07);
  --line-strong: rgba(0, 0, 0, 0.13);
  --text: #0a0a0b;
  --text-2: #55555c;
  --text-3: #8f8f97;
  --accent: #0a0a0b;
  --accent-text: #ffffff;
  --user: #f1f1f3;
  --danger-soft: rgba(242, 85, 90, 0.08);
  --warn-soft: rgba(242, 169, 59, 0.1);
  --shadow: 0 0 0 1px var(--line), 0 16px 40px rgba(0, 0, 0, 0.08);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #ffffff; --bg-elev: #ffffff; --surface: #f4f4f5; --surface-2: #ececee; --hover: #efeff1;
    --line: rgba(0, 0, 0, 0.07); --line-strong: rgba(0, 0, 0, 0.13);
    --text: #0a0a0b; --text-2: #55555c; --text-3: #8f8f97; --accent: #0a0a0b; --accent-text: #ffffff; --user: #f1f1f3;
    --danger-soft: rgba(242, 85, 90, 0.08); --warn-soft: rgba(242, 169, 59, 0.1);
    --shadow: 0 0 0 1px var(--line), 0 16px 40px rgba(0, 0, 0, 0.08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); font-feature-settings: "ss01", "cv11"; -webkit-font-smoothing: antialiased; letter-spacing: -0.006em; }
body { overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; letter-spacing: inherit; }
input, textarea, select { font: inherit; color: var(--text); letter-spacing: inherit; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
::selection { background: rgba(127, 127, 127, 0.35); }
#app { height: 100dvh; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

.boot { height: 100%; display: grid; place-items: center; }
.boot .mark { width: 34px; height: 34px; animation: breathe 1.6s ease-in-out infinite; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100dvh; }
.shell.with-panel { grid-template-columns: var(--sidebar) 1fr var(--panel); }
.sidebar { background: var(--bg-elev); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding-top: env(safe-area-inset-top); }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.panel { border-left: 1px solid var(--line); background: var(--bg-elev); display: flex; flex-direction: column; min-height: 0; }

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 600; font-size: 16px; letter-spacing: -0.02em; }
.mark { width: 22px; height: 22px; color: var(--text); flex: none; }
.new-btn { margin: 0 12px 8px; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line-strong); font-size: 14px; color: var(--text); transition: background 0.15s; }
.new-btn:hover { background: var(--hover); }
.new-btn svg { width: 16px; height: 16px; }
.side-label { font-size: 11.5px; font-weight: 500; color: var(--text-3); padding: 14px 20px 6px; letter-spacing: 0.02em; }
.side-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 0 8px; }
.bot-row { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border-radius: 12px; text-align: left; transition: background 0.12s; }
.bot-row:hover { background: var(--hover); }
.bot-row.active { background: var(--surface-2); }
.bot-row .meta { min-width: 0; flex: 1; }
.bot-row .name { font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.bot-row .sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-row .sub.live { color: var(--text-2); }
.bot-row .sub.wait { color: var(--warn); }
.nav-row { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 12px; border-radius: 10px; color: var(--text-2); font-size: 14px; transition: background 0.12s, color 0.12s; }
.nav-row:hover { background: var(--hover); color: var(--text); }
.nav-row svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.side-foot { padding: 14px 18px; border-top: 1px solid var(--line); padding-bottom: calc(14px + env(safe-area-inset-bottom)); font-size: 12.5px; color: var(--text-3); }
.side-foot .plan { display: flex; align-items: center; gap: 8px; }
.pip { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }

.avatar { flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line-strong); position: relative; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--bg-elev); background: var(--ok); }
.avatar .dot.live { background: var(--text); animation: breathe 1.2s ease-in-out infinite; }
.avatar .dot.wait { background: var(--warn); }

.meter { height: 3px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--text); border-radius: 3px; transition: width 0.4s; }
.meter.hot > i { background: var(--warn); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); min-height: 58px; background: linear-gradient(var(--bg) 60%, transparent); position: relative; z-index: 2; }
.topbar .title { min-width: 0; flex: 1; display: flex; align-items: center; gap: 10px; padding: 4px 8px; border-radius: 10px; text-align: left; }
.topbar .title:hover { background: var(--hover); }
.topbar .title b { display: block; font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
.topbar .t-wrap { min-width: 0; display: block; }
.topbar .title b { color: var(--text); }
.topbar .title .sub { display: block; font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title .sub.live { color: var(--text-2); }
.topbar .title .sub.wait { color: var(--warn); }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--text-2); transition: background 0.12s, color 0.12s; flex: none; position: relative; }
.icon-btn:hover, .icon-btn.on { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.chip.btn { cursor: pointer; transition: background 0.12s, color 0.12s; }
.chip.btn:hover { background: var(--hover); color: var(--text); }
.mobile-only { display: none !important; }

/* ---------- messages ---------- */
.messages { flex: 1; overflow-y: auto; padding: 8px 20px 12px; min-height: 0; }
.messages-inner { max-width: 740px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; padding-bottom: 8px; }
.msg { display: flex; gap: 12px; animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
.msg .body { min-width: 0; flex: 1; }
.msg.user { justify-content: flex-end; }
.msg.user .body { flex: 0 1 auto; max-width: min(560px, 85%); display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .text { background: var(--user); padding: 10px 16px; border-radius: 22px; }
.msg.bot .text { padding-top: 3px; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.62; }
.text b { font-weight: 600; }
.text code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.text pre { font-family: var(--mono); font-size: 12.5px; background: var(--bg-elev); border: 1px solid var(--line); padding: 12px 14px; border-radius: 12px; overflow-x: auto; white-space: pre; margin: 8px 0; }
.text.error { color: var(--danger); }
.header-line { font-size: 12px; font-weight: 500; color: var(--text-3); margin-bottom: 4px; letter-spacing: 0.01em; }
.msg.system { justify-content: center; }
.msg.system .text { color: var(--text-3); font-size: 13px; text-align: center; max-width: 560px; }
.msg-foot { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-3); margin-top: 6px; min-height: 20px; }
.msg.bot .msg-foot { opacity: 0.0; transition: opacity 0.15s; }
.msg.bot:hover .msg-foot, .msg.bot .msg-foot.keep { opacity: 1; }
.msg-foot .fb { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: var(--text-3); transition: background 0.12s, color 0.12s; }
.msg-foot .fb:hover, .msg-foot .fb.picked { color: var(--text); background: var(--hover); }
.msg-foot .fb svg { width: 15px; height: 15px; }
@media (hover: none) { .msg.bot .msg-foot { opacity: 1; } }

.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb { width: 240px; max-width: 100%; border-radius: 14px; border: 1px solid var(--line); display: block; cursor: zoom-in; background: var(--surface); }
.file-chip { display: inline-flex; align-items: center; gap: 10px; padding: 9px 14px 9px 10px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--bg-elev); font-size: 13.5px; color: var(--text); text-decoration: none; max-width: 100%; transition: background 0.12s; }
.file-chip:hover { background: var(--hover); }
.file-chip .ext { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font: 600 9.5px var(--mono); color: var(--text-2); text-transform: uppercase; flex: none; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- run (activity) ---------- */
.run { border-radius: var(--radius); }
.run-head { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 2px 0; color: var(--text-2); font-size: 14px; }
.run-head .label { min-width: 0; flex: 1; display: flex; gap: 8px; align-items: baseline; overflow: hidden; }
.run-head .label b { font-weight: 500; color: var(--text); white-space: nowrap; }
.run-head .label span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-3); }
.run-head .time { font: 12px var(--mono); color: var(--text-3); flex: none; }
.shimmer { background: linear-gradient(90deg, var(--text-3) 0%, var(--text) 45%, var(--text-3) 70%); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent !important; animation: shimmer 2.2s linear infinite; }
.run.waiting .run-head .label b { color: var(--warn); }
.run-body { margin: 10px 0 0 8px; padding-left: 18px; border-left: 1px solid var(--line-strong); display: grid; gap: 12px; animation: rise 0.2s ease-out; }
.plan { display: grid; gap: 7px; font-size: 13.5px; }
.plan div { display: flex; gap: 10px; align-items: center; color: var(--text-2); }
.plan .done { color: var(--text-3); }
.plan .now { color: var(--text); font-weight: 500; }
.tick { width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--line-strong); flex: none; display: grid; place-items: center; }
.tick.done { background: var(--text); border-color: var(--text); }
.tick.done svg { width: 9px; height: 9px; color: var(--bg); }
.tick.now { border-color: var(--text); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.steps { display: grid; gap: 6px; font-size: 13px; color: var(--text-3); max-height: 280px; overflow-y: auto; }
.steps div { display: flex; gap: 12px; }
.steps div:last-child { color: var(--text-2); }
.steps time { font: 11.5px var(--mono); color: var(--text-3); flex: none; padding-top: 2px; opacity: 0.8; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-strong); border-top-color: var(--text); animation: spin 0.8s linear infinite; flex: none; }
.state-dot { width: 14px; height: 14px; flex: none; display: grid; place-items: center; }
.state-dot svg { width: 14px; height: 14px; }
.chev { transition: transform 0.2s; color: var(--text-3); display: grid; }
.chev svg { width: 15px; height: 15px; }
.chev.open { transform: rotate(90deg); }

/* ---------- cards ---------- */
.card { border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--bg-elev); padding: 16px; display: grid; gap: 10px; animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
.card.pending { border-color: color-mix(in srgb, var(--text) 30%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 4%, transparent); }
.card.approval.pending { border-color: color-mix(in srgb, var(--warn) 55%, transparent); box-shadow: 0 0 0 4px var(--warn-soft); }
.card-kicker { font-size: 12px; font-weight: 500; color: var(--text-3); display: flex; align-items: center; gap: 8px; letter-spacing: 0.01em; }
.card-kicker .k-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); }
.card.approval .k-dot { background: var(--warn); }
.card-title { font-weight: 600; font-size: 15.5px; letter-spacing: -0.015em; }
.card-body { font-size: 14px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow-y: auto; }
.card-body.code { font-family: var(--mono); font-size: 12.5px; background: var(--bg); border: 1px solid var(--line); padding: 10px 12px; border-radius: 10px; color: var(--text); }
.card-note { font-size: 13px; padding: 9px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--text-2); }
.card-note.info { background: var(--surface); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.card-answer { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.draft-field { display: grid; gap: 6px; font-size: 12.5px; color: var(--text-3); }
.draft-field textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); padding: 12px; resize: vertical; color: var(--text); font-size: 14.5px; min-height: 130px; outline: 0; line-height: 1.55; }
.draft-field textarea:focus { border-color: var(--text-2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 15px; border-radius: 999px; font-weight: 500; font-size: 14px; border: 1px solid var(--line-strong); color: var(--text); transition: transform 0.08s, background 0.12s, opacity 0.12s; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.primary:hover { opacity: 0.88; background: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; color: var(--text-2); }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn svg { width: 15px; height: 15px; flex: none; }

/* ---------- empty state / starters ---------- */
.hello { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; gap: 6px; }
.hello .avatar { margin-bottom: 14px; }
.hello h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.hello p { margin: 0; color: var(--text-3); max-width: 460px; font-size: 14.5px; }
.starters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 740px; margin: 0 auto 10px; padding: 0 4px; }
.starter { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 13.5px; color: var(--text-2); transition: background 0.12s, color 0.12s; }
.starter:hover { background: var(--hover); color: var(--text); }

/* ---------- composer ---------- */
.composer-wrap { padding: 4px 20px calc(14px + env(safe-area-inset-bottom)); }
.composer { max-width: 740px; margin: 0 auto; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 26px; padding: 10px 10px 8px 14px; transition: border-color 0.15s, background 0.15s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--text) 28%, transparent); }
.composer textarea { width: 100%; border: 0; outline: 0; resize: none; background: transparent; padding: 4px 2px 6px; max-height: 220px; min-height: 26px; line-height: 1.5; display: block; font-size: 15.5px; }
.composer textarea::placeholder { color: var(--text-3); }
.composer-row { display: flex; align-items: center; gap: 4px; }
.composer-row .spacer { flex: 1; }
.composer-row .icon-btn { width: 34px; height: 34px; border-radius: 50%; }
.composer-row .chip { margin-left: 4px; }
.send { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; transition: transform 0.1s, opacity 0.15s; }
.send:active { transform: scale(0.93); }
.send:disabled { opacity: 0.25; }
.send svg { width: 17px; height: 17px; }
.rec { background: var(--danger) !important; color: #fff !important; animation: breathe 1.2s ease-in-out infinite; }
.attach-list { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 0 8px; }
.attach-list .chip { background: var(--bg-elev); }
.attach-list .chip button { font-size: 15px; line-height: 1; color: var(--text-3); }
.composer-hint { max-width: 740px; margin: 7px auto 0; font-size: 12px; color: var(--text-3); text-align: center; min-height: 16px; }

/* ---------- panel ---------- */
.panel-tabs { display: flex; gap: 2px; padding: 12px 12px 10px; padding-top: calc(12px + env(safe-area-inset-top)); align-items: center; border-bottom: 1px solid var(--line); }
.tab { padding: 6px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--text-3); transition: color 0.12s, background 0.12s; }
.tab:hover { color: var(--text); }
.tab.on { background: var(--surface-2); color: var(--text); }
.panel-body { flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }
.screen-box { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line-strong); background: #000; }
.screen-box img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.screen-box.control { outline: 2px solid var(--warn); outline-offset: -2px; cursor: crosshair; }
.screen-badge { position: absolute; left: 10px; top: 10px; background: rgba(0, 0, 0, 0.6); color: #fff; border-color: rgba(255, 255, 255, 0.15); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.ripple { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 2px solid var(--warn); animation: ripple 0.5s ease-out forwards; pointer-events: none; }
.keys { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.type-row { display: flex; gap: 8px; margin-top: 12px; }
.input { flex: 1; height: 40px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); padding: 0 13px; outline: 0; min-width: 0; transition: border-color 0.12s; }
textarea.input { height: auto; padding: 10px 13px; }
.input:focus { border-color: var(--text-2); }
.list { display: grid; gap: 1px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg-elev); min-width: 0; }
.list .row + .row { border-top: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .grow span { display: block; font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.row svg { width: 17px; height: 17px; flex: none; }
.empty { color: var(--text-3); font-size: 14px; text-align: center; padding: 34px 10px; }
.section-title { font-size: 12px; font-weight: 500; color: var(--text-3); margin: 26px 0 10px; letter-spacing: 0.01em; }
.section-title:first-child { margin-top: 0; }
.hint { font-size: 13px; color: var(--text-3); line-height: 1.5; }

/* ---------- sheets ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 40; animation: fade 0.18s; display: flex; align-items: center; justify-content: center; padding: 20px; }
.sheet { width: min(620px, 100%); max-height: min(86dvh, 900px); background: var(--bg-elev); border-radius: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); overflow: hidden; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 14px; }
.sheet-head h2 { margin: 0; font-size: 18px; font-weight: 600; flex: 1; letter-spacing: -0.02em; }
.sheet-body { padding: 4px 20px 24px; overflow-y: auto; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 8px; }
.tpl { text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); transition: border-color 0.15s, background 0.15s; display: grid; gap: 4px; align-content: start; }
.tpl:hover { border-color: var(--line-strong); background: var(--hover); }
.tpl b { font-size: 14px; font-weight: 500; }
.tpl span { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.toggle-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.toggle-row .grow { flex: 1; min-width: 0; }
.toggle-row .grow b { display: block; font-size: 14.5px; font-weight: 500; }
.toggle-row .grow span { display: block; font-size: 13px; color: var(--text-3); }
.switch { width: 42px; height: 25px; border-radius: 25px; background: var(--surface-2); border: 1px solid var(--line-strong); position: relative; transition: background 0.2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: var(--text-3); transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s; }
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on::after { transform: translateX(17px); background: var(--accent-text); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { padding: 5px 12px; border-radius: 999px; font-size: 13px; color: var(--text-3); transition: color 0.12s, background 0.12s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-2); color: var(--text); font-weight: 500; box-shadow: 0 0 0 1px var(--line-strong); }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.92); z-index: 60; display: grid; place-items: center; padding: 16px; animation: fade 0.2s; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 500; z-index: 70; animation: rise 0.2s; max-width: calc(100% - 32px); }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #000; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; }
.badge.neutral { background: var(--text); color: var(--bg); }

/* ---------- login ---------- */
.login { height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-box { width: min(360px, 100%); display: grid; gap: 14px; text-align: center; }
.login-box .mark { width: 40px; height: 40px; margin: 0 auto 6px; }
.login-box h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.login-box p { margin: 0 0 8px; color: var(--text-3); font-size: 14px; }
.login-box .btn { height: 42px; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .shell, .shell.with-panel { grid-template-columns: 1fr; }
  .mobile-only { display: inline-grid !important; }
  .desktop-only { display: none !important; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 50; transform: translateX(-102%); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 45; animation: fade 0.2s; }
  .panel { position: fixed; inset: 0; z-index: 48; animation: slideup 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); border-left: 0; }
  .messages { padding: 4px 16px 10px; }
  .composer-wrap { padding: 4px 12px calc(10px + env(safe-area-inset-bottom)); }
  .overlay { padding: 0; align-items: flex-end; }
  .sheet { width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; animation: slideup 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); padding-bottom: env(safe-area-inset-bottom); }
  .topbar { padding-left: 8px; padding-right: 8px; }
  .msg.user .body { max-width: 88%; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { opacity: 0.4; } }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.975); } }
@keyframes slideup { from { transform: translateY(28px); opacity: 0; } }
@keyframes ripple { from { transform: scale(0.4); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Blip, the mascot: a mouse pointer that came alive ----------
   States follow the agent: idle (bob + blink), working (clicks, ripples), needs (hops, amber "!"),
   done (happy eyes, sparkles), sleep (zz). In light mode the character inverts to black. */
:root { --m-body: #f4f4f6; --m-ink: #0b0b0c; --m-blush: rgba(255, 138, 160, 0.55); --m-amber: #f2a93b; }
:root[data-theme="light"] { --m-body: #0b0b0c; --m-ink: #ffffff; }
@media (prefers-color-scheme: light) { :root[data-theme="auto"] { --m-body: #0b0b0c; --m-ink: #ffffff; } }
.m { display: block; flex: none; line-height: 0; }
.m svg { display: block; width: 100%; height: auto; overflow: visible; }
.m .bd { fill: var(--m-body); stroke: var(--m-body); }
.m .ink { fill: var(--m-ink); }
.m .hl { fill: var(--m-body); }
.m .inks { stroke: var(--m-ink); fill: none; stroke-width: 4; stroke-linecap: round; }
.m .ck { fill: var(--m-blush); }
.m .fx-ring { fill: none; stroke: var(--text); stroke-width: 3; }
.m .bang rect { fill: var(--m-amber); }
.m .bang path { fill: #000; }
.m .spark { fill: var(--text); }
.m .zz { fill: var(--text-2); font: 600 22px var(--font); }
.m .g-body { transform-box: fill-box; transform-origin: 30% 20%; }
/* Idle and sleep bob the whole drawing, and blinks come from one shared timer (app.js): animating shapes inside the SVG
   repaints it every frame, which made the Mac app flicker on Intel Macs. A moving layer costs nothing. */
.m[data-state="idle"] svg, .m[data-state="sleep"] svg { will-change: transform; animation: m-bob 3.2s ease-in-out infinite; }
.m .eo { transform-box: fill-box; transform-origin: center; transition: transform 70ms; }
.blink .m:not(.still) .eo { transform: scaleY(0.12); }
.m .eh, .m .ec, .m .mo-o, .m .mo-big, .m .fx-work, .m .bang, .m .spark-g, .m .zz-g { display: none; }
.m[data-state="working"] .g-body { animation: m-tap 1s ease-in-out infinite; }
.m[data-state="working"] .eyes-open { animation: m-look 1.8s ease-in-out infinite; }
.m[data-state="working"] .fx-work { display: inline; }
.m[data-state="working"] .mo-smile, .m[data-state="needs"] .mo-smile, .m[data-state="done"] .mo-smile, .m[data-state="sleep"] .mo-smile { display: none; }
.m[data-state="working"] .mo-o, .m[data-state="needs"] .mo-o { display: inline; }
.m[data-state="needs"] .g-body { animation: m-hop 0.9s cubic-bezier(.3,.7,.4,1) infinite; transform-origin: 50% 100%; }
.m[data-state="needs"] .bang { display: inline; transform-box: fill-box; transform-origin: 0% 100%; animation: m-pop 0.9s ease-in-out infinite; }
.m[data-state="done"] .g-body { animation: m-wiggle 1.6s ease-in-out infinite; }
.m[data-state="done"] .eo, .m[data-state="sleep"] .eo { display: none; }
.m[data-state="done"] .eh, .m[data-state="done"] .mo-big, .m[data-state="done"] .spark-g { display: inline; }
.m[data-state="done"] .spark { transform-box: fill-box; transform-origin: center; animation: m-twinkle 1.4s ease-in-out infinite; }
.m[data-state="done"] .spark:nth-child(2) { animation-delay: 0.45s; }
.m[data-state="done"] .spark:nth-child(3) { animation-delay: 0.9s; }
.m[data-state="sleep"] svg { animation-duration: 5.5s; }
.m[data-state="sleep"] .ec, .m[data-state="sleep"] .zz-g { display: inline; }
.m[data-state="sleep"] .zz { animation: m-drift 3s ease-in infinite; }
.m[data-state="sleep"] .zz:nth-child(2) { animation-delay: 1.5s; }
.m[data-state="working"] .ripple { transform-box: fill-box; transform-origin: center; animation: m-ripple 1s ease-out infinite; }
.m[data-state="working"] .ripple:nth-child(2) { animation-delay: 0.5s; }
.m.still *, .m.still { animation: none !important; }
.avatar .m { width: 84%; }
.brand .m, .login-box .m, .boot .m { flex: none; }
@keyframes m-bob { 50% { transform: translateY(-4%); } }
@keyframes m-tap { 0%, 100% { transform: rotate(0) translateY(0); } 40% { transform: rotate(-4deg) translateY(3%); } }
@keyframes m-hop { 0%, 100% { transform: translateY(0) scaleY(1); } 15% { transform: translateY(0) scaleY(0.94); } 45% { transform: translateY(-10%) scaleY(1.03); } 70% { transform: translateY(0) scaleY(0.97); } }
@keyframes m-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes m-look { 0%, 100% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
@keyframes m-ripple { from { transform: scale(0.3); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
@keyframes m-pop { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.12); } }
@keyframes m-twinkle { 0%, 100% { transform: scale(0.4); opacity: 0.3; } 50% { transform: scale(1); opacity: 1; } }
@keyframes m-drift { from { transform: translate(0, 0); opacity: 0; } 20% { opacity: 1; } to { transform: translate(14px, -30px); opacity: 0; } }

/* ---------- Customize Blip ---------- */
.style-stage { display: grid; place-items: center; height: 230px; border-radius: 18px; background: radial-gradient(circle at 50% 62%, var(--surface-2) 0%, var(--bg) 72%); margin-bottom: 14px; overflow: hidden; }
.style-tabs { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.style-tabs .tab { flex: none; }
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-top: 12px; }
.style-tile { display: grid; justify-items: center; gap: 6px; padding: 12px 6px 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); transition: border-color 0.15s, background 0.15s, transform 0.1s; }
.style-tile:hover { background: var(--hover); }
.style-tile:active { transform: scale(0.97); }
.style-tile.on { border-color: var(--text); background: var(--surface); }
.style-tile span { font-size: 12.5px; color: var(--text-2); }
.style-tile.on span { color: var(--text); font-weight: 500; }
.tpl .m { margin-bottom: 4px; }
