/* ---------- tokens ---------- */
:root {
  --bg: #f2f3f7;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --surface-3: #e2e5ec;
  --border: #dfe2ea;
  --text: #13161d;
  --muted: #667085;
  --accent: #6d5cf0;
  --accent-soft: #ece9fe;
  --accent-text: #ffffff;
  --danger: #d03535;
  --danger-soft: #fdeaea;
  --ok: #1b8a4a;
  --ok-soft: #e3f5ea;
  --warn: #a15c00;
  --warn-soft: #fff3de;
  --claude: #d0764a;
  --codex: #20806d;
  --custom: #6b5bd6;
  --user-bg: #d9fdd3;
  --user-text: #17201b;
  --code-bg: #f4f5f8;
  --shadow: 0 1px 2px rgb(16 24 40 / .05), 0 1px 3px rgb(16 24 40 / .08);
  --shadow-lg: 0 12px 32px rgb(16 24 40 / .18);
  --radius: 16px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --tabbar-h: 58px;
  --grad: linear-gradient(135deg, #5b7cfa 0%, #6d5cf0 55%, #8b46e8 100%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e12;
    --surface: #16191f;
    --surface-2: #1d2128;
    --surface-3: #262b34;
    --border: #262b34;
    --text: #e9edf5;
    --muted: #8f99ab;
    --accent: #a394ff;
    --accent-soft: #241d45;
    --accent-text: #0c0e12;
    --danger: #ff7a7a;
    --danger-soft: #3a1d1f;
    --ok: #5fd08e;
    --ok-soft: #173024;
    --warn: #f2b84b;
    --warn-soft: #33280f;
    --claude: #e8956a;
    --codex: #4fc2aa;
    --custom: #a397ff;
    --user-bg: #005c4b;
    --user-text: #ffffff;
    --code-bg: #0f1216;
    --shadow: none;
    --shadow-lg: 0 12px 32px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0e12;
  --surface: #16191f;
  --surface-2: #1d2128;
  --surface-3: #262b34;
  --border: #262b34;
  --text: #e9edf5;
  --muted: #8f99ab;
  --accent: #a394ff;
  --accent-soft: #241d45;
  --accent-text: #0c0e12;
  --danger: #ff7a7a;
  --danger-soft: #3a1d1f;
  --ok: #5fd08e;
  --ok-soft: #173024;
  --warn: #f2b84b;
  --warn-soft: #33280f;
  --claude: #e8956a;
  --codex: #4fc2aa;
  --custom: #a397ff;
  --user-bg: #005c4b;
  --user-text: #ffffff;
  --code-bg: #0f1216;
  --shadow: none;
  --shadow-lg: 0 12px 32px rgb(0 0 0 / .5);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
p { margin: 0 0 8px; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }
.center { text-align: center; justify-content: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap, .wrap { flex-wrap: wrap; }
.gap { gap: 8px; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.ml6 { margin-left: 6px; }
.full { width: 100%; }
[hidden] { display: none !important; }

.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ic.sm { width: 18px; height: 18px; }
.ic.xs { width: 14px; height: 14px; }

/* ---------- layout ---------- */
.shell { min-height: 100dvh; max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; }
.shell.has-tabs main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); }
main { flex: 1; padding: 8px 16px 24px; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px 16px;
  min-height: 56px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar .icon-btn:first-child { margin-left: -8px; }
.title-wrap { flex: 1; min-width: 0; }
.title { font-weight: 700; font-size: 17px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subtitle { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tab {
  position: relative; flex: 1; max-width: 160px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; color: var(--muted); font-size: 11px; font-weight: 600;
}
.tab.active { color: var(--accent); }
.tab::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 46px; height: 32px;
  transform: translateX(-50%) scale(.7); border-radius: 12px;
  background: var(--accent-soft); opacity: 0; transition: opacity .16s, transform .16s;
}
.tab.active::before { opacity: 1; transform: translateX(-50%) scale(1); }
.tab .ic, .tab span, .tab .jobs-badge { position: relative; }
.jobs-badge {
  position: absolute; top: 0; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-weight: 600; font-size: 15px; white-space: nowrap; color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 4px 14px -4px rgb(109 92 240 / .55); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.big { width: 100%; min-height: 50px; font-size: 16px; border-radius: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent;
  color: var(--text); cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.ghost { color: var(--muted); }
.icon-btn.ghost:hover { color: var(--text); }
.icon-btn.accent { background: var(--accent-soft); color: var(--accent); border-radius: 50%; }
.icon-btn.rec { background: var(--danger); color: #fff; border-radius: 50%; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 14px; padding: 6px; }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 11px 14px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
}
textarea { resize: none; line-height: 1.45; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.notice { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); margin: 0 0 10px; font-size: 14px; }
.notice.warn { background: var(--warn-soft); color: var(--text); }
.spinner { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; color: var(--muted); padding: 48px 16px; }

.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggles { gap: 16px; margin: 10px 0 4px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 15px; cursor: pointer; }
.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--surface-3); position: relative; cursor: pointer; flex-shrink: 0; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .15s; }
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(18px); }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px calc(env(safe-area-inset-bottom) + 24px); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 26px; padding: 28px 22px 20px; box-shadow: var(--shadow-lg); }
.login .logo { width: 68px; height: 68px; border-radius: 20px; filter: drop-shadow(0 10px 24px rgb(109 92 240 / .45)); }
.login h1 { font-size: 24px; margin: 14px 0 2px; }
.login form { margin-top: 18px; }
.login-foot { display: flex; align-items: center; gap: 6px; margin-top: 16px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 48px; }
.eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.otp { font-size: 24px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* ---------- lists ---------- */
.searchbar { position: sticky; top: calc(env(safe-area-inset-top) + 56px); z-index: 10; background: var(--bg); padding: 8px 16px 4px; margin: 0 -16px; }
.search { background: var(--surface-2) !important; border-color: transparent !important; min-height: 40px !important; padding: 8px 14px !important; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; white-space: nowrap; font-size: 14px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.group { margin-top: 18px; }
.group-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 4px 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 14px 16px; }
.list-card { overflow: hidden; }
.row-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; color: inherit; border-top: 1px solid var(--border); min-width: 0; }
.row-item:first-child { border-top: 0; }
.row-item:hover { background: var(--surface-2); }
.row-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.row-top .t { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-top .time { font-size: 13px; color: var(--muted); flex-shrink: 0; }
.row-sub { display: flex; align-items: center; gap: 6px; margin-top: 3px; min-width: 0; font-size: 13px; color: var(--muted); }
.folder { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.folder.big { display: flex; font-family: var(--mono); font-size: 13px; white-space: normal; word-break: break-all; }
.avatar { width: 36px; height: 36px; border-radius: 12px; box-shadow: 0 2px 6px -2px rgb(0 0 0 / .35); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #fff; flex-shrink: 0; background: var(--custom); }
.avatar.claude { background: var(--claude); }
.avatar.codex { background: var(--codex); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; white-space: nowrap; }
.tag.subtle { background: var(--surface-2); color: var(--muted); }
.tag.live, .tag.status-running { background: var(--warn-soft); color: var(--warn); }
.tag.status-done { background: var(--ok-soft); color: var(--ok); }
.tag.status-failed, .tag.status-cancelled { background: var(--danger-soft); color: var(--danger); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex-shrink: 0; animation: pulse 1.2s ease-in-out infinite; }

/* ---------- chat ---------- */
.session-intro { padding: 8px 0 4px; }
.thread { display: flex; flex-direction: column; gap: 12px; padding: 8px 0 16px; }
.msg { min-width: 0; max-width: 100%; }
.msg .body { overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 86%; }
.msg.user .body { background: var(--user-bg); color: var(--user-text); padding: 9px 13px; border-radius: 16px 16px 4px 16px; box-shadow: var(--shadow); }
.msg.user .body p:last-child { margin: 0; }
.msg.user .body code { background: rgb(255 255 255 / .18); }
.msg.user .body a { color: inherit; text-decoration: underline; }
.msg.user.meta .body { background: var(--surface-2); color: var(--muted); font-size: 12px; white-space: pre-wrap; max-height: 180px; overflow: auto; font-family: var(--mono); }
.msg .time { font-size: 11px; color: var(--muted); text-align: right; margin-top: 3px; padding-right: 6px; }
.msg.assistant .who { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.msg.assistant .who .avatar { width: 22px; height: 22px; font-size: 11px; }
.msg.assistant { align-self: flex-start; max-width: 92%; }
.msg.assistant .body { padding: 10px 13px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.msg.error .body { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; font-size: 14px; }
.msg.system { font-size: 12px; color: var(--muted); text-align: center; padding: 0 12px; overflow-wrap: anywhere; }
.working .dots { display: inline-flex; gap: 4px; padding: 10px 14px; background: var(--surface-2); border-radius: 16px; }
.working .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite ease-in-out; }
.working .dots i:nth-child(2) { animation-delay: .15s; }
.working .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

/* markdown */
.md p { margin: 0 0 10px; }
.md > :last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md .md-h { margin: 14px 0 6px; font-size: 16px; }
.md h3.md-h { font-size: 18px; }
.md blockquote { margin: 0 0 10px; padding: 2px 12px; border-left: 3px solid var(--border); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.codeblock { margin: 6px 0 10px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.codeblock pre { margin: 0; padding: 10px 12px; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.codeblock code { background: none; padding: 0; font-size: 13px; }
.copy { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 12px; }
.copy:hover { background: var(--surface-2); color: var(--text); }
.table-wrap { overflow-x: auto; margin: 0 0 10px; }
.md table { border-collapse: collapse; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }

/* steps (tool calls) */
details.steps { align-self: flex-start; max-width: 100%; }
details.steps > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 600; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
details.steps > summary::-webkit-details-marker { display: none; }
details.steps[open] > summary { margin-bottom: 6px; }
.steps-ic { color: var(--muted); }
.steps-body { display: flex; flex-direction: column; gap: 2px; border-left: 2px solid var(--border); margin-left: 12px; padding-left: 10px; }
details.step { font-size: 13px; }
details.step > summary { list-style: none; cursor: pointer; display: flex; gap: 8px; min-width: 0; padding: 4px 0; }
details.step > summary::-webkit-details-marker { display: none; }
details.step .n { font-family: var(--mono); font-weight: 700; flex-shrink: 0; }
details.step .p { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-family: var(--mono); }
details.step.result .n { color: var(--muted); font-weight: 500; }
details.step.err .n { color: var(--danger); }
details.step.thinking .n { font-family: inherit; font-style: italic; font-weight: 500; color: var(--muted); }
details.step pre { margin: 4px 0 6px; padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; overflow: auto; max-height: 360px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12px; }

.fab { position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 150px); z-index: 15; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* ---------- composer ---------- */
.dock {
  position: sticky; bottom: 0; z-index: 12;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.dock .notice { margin-bottom: 8px; }
.running-bar { padding: 8px 10px; margin-bottom: 8px; border-radius: 12px; background: var(--warn-soft); }
.composer { display: flex; flex-direction: column; gap: 6px; }
.pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; scroll-padding: 0 12px; -webkit-overflow-scrolling: touch; }
.pills::after { content: ''; flex: 0 0 4px; }
.pills::-webkit-scrollbar { display: none; }
.pill { position: relative; display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; white-space: nowrap; }
.pill select { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; min-height: 0; padding: 0; cursor: pointer; font-size: 16px; }
.pill .caret { color: var(--muted); font-size: 10px; }
.toggle-pill { color: var(--muted); }
.toggle-pill[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.inputbar { display: flex; align-items: flex-end; gap: 2px; padding: 4px; border: 1px solid var(--border); background: var(--surface); border-radius: 24px; box-shadow: var(--shadow); }
.inputbar:focus-within { border-color: var(--accent); }
.inputbar .grow-wrap { flex: 1; min-width: 0; }
.inputbar textarea { border: 0; background: transparent; padding: 9px 6px; outline: none; }
.inputbar textarea:focus-visible { outline: none; }
.keyboard-hide { display: none; }

/* ---------- waiting activity ---------- */
.waiting-dialog {
  width: min(560px, calc(100vw - 20px)); height: min(820px, calc(100dvh - 20px));
  max-width: none; max-height: none; margin: auto; padding: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: 24px; background: var(--bg); color: var(--text);
  box-shadow: 0 24px 80px rgb(0 0 0 / .45);
}
.waiting-dialog::backdrop { background: rgb(5 7 12 / .72); backdrop-filter: blur(8px); }
.waiting-head { display: flex; align-items: center; gap: 10px; min-height: 66px; padding: 10px 12px 8px 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.waiting-head strong { display: block; font-size: 16px; }
.waiting-status { color: var(--muted); font-size: 12px; margin-top: 2px; }
.waiting-status.running::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--warn); animation: pulse 1.2s infinite; }
.waiting-status.done { color: var(--ok); }
.waiting-status.failed { color: var(--danger); }
.waiting-close { font-size: 28px; font-weight: 300; }
.waiting-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 7px; background: var(--surface); border-bottom: 1px solid var(--border); }
.waiting-tab { min-height: 40px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.waiting-tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.waiting-stage { height: calc(100% - 121px); background: #0d1018; }
.happydev-frame { display: block; width: 100%; height: 100%; border: 0; background: #0d1018; }
.reels-card { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 28px; text-align: center; background: radial-gradient(circle at 50% 25%, #472864 0, #15101f 42%, #090b12 100%); color: #fff; }
.reels-card h2, .reels-card p { margin: 0; }
.reels-card .muted { color: #bbb4c9; }
.reels-mark { display: grid; place-items: center; width: 82px; height: 82px; border-radius: 24px; font-size: 60px; line-height: 1; background: linear-gradient(135deg, #ffcc5c, #f77737 35%, #c13584 65%, #5851db); box-shadow: 0 14px 40px rgb(193 53 132 / .4); }

/* Auto-growing textarea, no inline styles (Safari refuses them under our CSP):
   ::after mirrors the text and the grid takes the taller of the two. */
.grow-wrap { display: grid; }
.grow-wrap > textarea,
.grow-wrap::after {
  grid-area: 1 / 1 / 2 / 2;
  font: inherit; line-height: 1.45;
  padding: 9px 6px; border: 0;
  white-space: pre-wrap; overflow-wrap: anywhere;
  min-height: 40px; max-height: 35dvh;
}
.grow-wrap.tall > textarea, .grow-wrap.tall::after { min-height: 104px; max-height: 50dvh; }
.grow-wrap::after { content: attr(data-value) " "; visibility: hidden; }
.grow-wrap > textarea { overflow-y: auto; resize: none; }
.composer.inline .inputbar { border-radius: 18px; }
.send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; box-shadow: 0 3px 10px -2px rgb(109 92 240 / .6); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.send:disabled { opacity: .5; }
.send .ic { width: 20px; height: 20px; stroke-width: 2.5; }
.status { padding: 0 8px; }
.status:empty { display: none; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 60px; height: 60px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgb(0 0 0 / .6); color: #fff; cursor: pointer; line-height: 1; }

/* ---------- new prompt ---------- */
.new-form { display: flex; flex-direction: column; }
.section-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 4px 8px; }
.segmented { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 10px; white-space: nowrap; font-size: 15px; border: 0; border-radius: 11px; background: transparent; font-weight: 600; cursor: pointer; color: var(--muted); }
.segmented button .avatar { width: 24px; height: 24px; font-size: 12px; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dirs { display: flex; flex-direction: column; margin-top: 8px; border: 1px solid var(--border); border-radius: 12px; max-height: 300px; overflow-y: auto; }
.dirs button { display: flex; align-items: center; gap: 8px; text-align: left; border: 0; border-top: 1px solid var(--border); background: var(--surface); padding: 11px 14px; cursor: pointer; font-size: 15px; }
.dirs button:first-child { border-top: 0; }
.dirs button:hover { background: var(--surface-2); }
.dirs button.done { color: var(--accent); font-weight: 600; position: sticky; bottom: 0; }

/* ---------- settings ---------- */
.sub { padding: 12px 0 0; margin-top: 12px; border-top: 1px solid var(--border); }
.sub:first-of-type { border-top: 0; margin-top: 4px; }
.sub-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 10px; }
.sub-title .avatar { width: 24px; height: 24px; font-size: 12px; }
.device { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.device:first-child { border-top: 0; }
.device .t { font-weight: 600; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) minmax(0, 1fr); gap: 8px 14px; margin: 8px 0 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.audit { list-style: none; padding: 0; margin: 8px 0 0; max-height: 420px; overflow-y: auto; }
.audit li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.audit li:first-child { border-top: 0; }
.audit .aic { width: 20px; text-align: center; flex-shrink: 0; }
.audit li.bad { color: var(--danger); }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 8px); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 12px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 8px; width: 100%; max-width: 480px; padding: 10px 8px 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 14px; animation: drop .2s ease-out; }
.toast.ok { border-left: 4px solid var(--ok); }
.toast.error { border-left: 4px solid var(--danger); }
.toast-action { border: 0; background: var(--accent-soft); color: var(--accent); font-weight: 700; border-radius: 10px; padding: 6px 12px; cursor: pointer; }
.toast-close { border: 0; background: transparent; color: var(--muted); font-size: 20px; width: 32px; height: 32px; cursor: pointer; }
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- wider screens ---------- */
@media (min-width: 720px) {
  main { padding: 12px 24px 32px; }
  .searchbar { margin: 0 -24px; padding-left: 24px; padding-right: 24px; }
  .dock { padding-left: 24px; padding-right: 24px; }
  .msg.user { max-width: 70%; }
}

@media (max-width: 719px), (pointer: coarse) {
  .inputbar:focus-within .keyboard-hide { display: inline-flex; }
  .msg.assistant { max-width: 94%; }
  .waiting-dialog { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
}

/* sessions grouped by day */
.groups { display: flex; flex-direction: column; gap: 22px; }
.pill-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
