/* Hearth — warm paper by day, banked embers by night. */
:root {
  --bg: #f6f1ea;
  --surface: #fffaf3;
  --surface-2: #efe6da;
  --surface-3: #e6dacb;
  --ink: #241a13;
  --ink-2: #6e5d4f;
  --ink-3: #9a8878;
  --line: #e2d5c4;
  --ember: #d4511a;
  --ember-hi: #f07a32;
  --ember-soft: #fbe2d1;
  --ember-ink: #fff7f1;
  --glow: rgba(212, 81, 26, 0.18);
  --ok: #3d7a4c;
  --danger: #b3261e;
  --danger-soft: #f8dcd8;
  --code-bg: #2a201a;
  --code-ink: #f6e9dc;
  --shadow-1: 0 1px 2px rgba(60, 35, 15, 0.06), 0 2px 8px rgba(60, 35, 15, 0.05);
  --shadow-2: 0 10px 30px rgba(60, 35, 15, 0.12), 0 2px 6px rgba(60, 35, 15, 0.06);

  --font-ui: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: clamp(0.9375rem, 0.9rem + 0.15vw, 1rem);
  --text-lg: 1.125rem;
  --text-xl: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --r-pill: 999px;
  --rail-w: 272px;
  --side-w: clamp(360px, 30vw, 520px);
  --gutter: clamp(16px, 2.5vw, 32px);
  --bottom-nav-h: 0px;

  --fast: 140ms;
  --normal: 260ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15100d;
    --surface: #1d1612;
    --surface-2: #261d17;
    --surface-3: #31261e;
    --ink: #f4eadf;
    --ink-2: #b7a28e;
    --ink-3: #85715f;
    --line: #33281f;
    --ember: #ff7f36;
    --ember-hi: #ffa25a;
    --ember-soft: #3b2317;
    --ember-ink: #1a0f08;
    --glow: rgba(255, 127, 54, 0.22);
    --ok: #79c08a;
    --danger: #ff8a7f;
    --danger-soft: #3a1c19;
    --code-bg: #0f0b09;
    --code-ink: #f1e3d4;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 14px 40px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--text-base)/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; border-radius: var(--r-sm); }
[hidden] { display: none !important; }
code, pre { font-family: var(--font-mono); }

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--side-w);
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
}

/* ---------- rail ---------- */
.rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  padding: 18px 12px calc(12px + env(safe-area-inset-bottom));
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand img { border-radius: 8px; box-shadow: 0 4px 14px var(--glow); }
.brand-name { font-weight: 700; font-size: var(--text-lg); letter-spacing: -0.02em; flex: 1; }
.new-conv {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border: 1px dashed color-mix(in oklab, var(--ember) 45%, var(--line));
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ember);
  font-weight: 600;
  transition: background var(--fast), border-color var(--fast), transform var(--fast) var(--ease);
}
.new-conv:hover { background: var(--ember-soft); border-style: solid; }
.new-conv:active { transform: scale(0.98); }
.conv-list { flex: 1; overflow-y: auto; margin: 14px -4px 8px; padding: 0 4px; scrollbar-width: thin; }
.conv-day { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin: 14px 10px 6px; font-weight: 600; }
.conv {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 8px;
  width: 100%; text-align: left;
  padding: 9px 12px; margin-bottom: 2px;
  border: 0; border-radius: var(--r-md);
  background: transparent;
  transition: background var(--fast);
}
.conv:hover { background: var(--surface-3); }
.conv[aria-current="true"] { background: var(--surface); box-shadow: var(--shadow-1); }
.conv[aria-current="true"]::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px;
  border-radius: 3px; background: var(--ember);
}
.conv-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: var(--text-xs); color: var(--ink-3); }
.conv-flag { grid-column: 2; grid-row: 1; width: 8px; height: 8px; border-radius: 50%; background: var(--ember); }
.conv[data-busy="true"] .conv-flag { animation: ember 1.4s ease-in-out infinite; }
.conv-empty { color: var(--ink-3); font-size: var(--text-sm); padding: 12px; }
.rail-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 0; border-top: 1px solid var(--line); font-size: var(--text-sm); color: var(--ink-2); }
.conn { display: inline-flex; align-items: center; gap: 8px; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.conn[data-state="live"] .conn-dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 22%, transparent); }
.conn[data-state="down"] .conn-dot { background: var(--danger); }
.link-btn { border: 0; background: none; color: var(--ember); font-weight: 600; padding: 4px; }
.link-btn:hover { text-decoration: underline; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.chat-head {
  display: flex; align-items: center; gap: 6px;
  padding: 14px var(--gutter) 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  z-index: 2;
}
.title-wrap { flex: 1; min-width: 0; }
.chat-head h1 { margin: 0; font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-input { width: 100%; font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.025em; border: 0; border-bottom: 2px solid var(--ember); background: transparent; padding: 0 0 2px; outline: none; }
.chat-sub { margin: 2px 0 0; font-size: var(--text-sm); color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.chat-sub .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--ember); animation: ember 1.4s ease-in-out infinite; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--ink-2);
  transition: background var(--fast), color var(--fast);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.only-drawer { display: none; }

.log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 28px var(--gutter) 24px;
}
.log > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.empty-state { text-align: center; margin-top: 12vh; color: var(--ink-2); }
.empty-state img { width: 64px; height: 64px; filter: drop-shadow(0 10px 24px var(--glow)); }
.empty-state h2 { color: var(--ink); font-size: var(--text-xl); letter-spacing: -0.02em; margin: 18px 0 6px; }
.empty-state p { margin: 0 auto; max-width: 34ch; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.suggestion { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: var(--r-pill); font-size: var(--text-sm); color: var(--ink-2); transition: border-color var(--fast), color var(--fast), transform var(--fast) var(--ease); }
.suggestion:hover { border-color: var(--ember); color: var(--ink); transform: translateY(-1px); }

.msg { margin-top: 22px; animation: rise var(--normal) var(--ease) both; }
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  max-width: min(78%, 560px);
  background: var(--ember);
  color: var(--ember-ink);
  padding: 10px 16px;
  border-radius: var(--r-lg) var(--r-lg) 6px var(--r-lg);
  white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: 0 6px 18px var(--glow);
}
.msg-hearth { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; }
.avatar { width: 28px; height: 28px; border-radius: 8px; margin-top: 2px; }
.prose { overflow-wrap: anywhere; min-width: 0; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 0.75em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 0.2em 0; }
.prose h3, .prose h4 { margin: 1.1em 0 0.4em; font-size: 1.02em; letter-spacing: -0.01em; }
.prose a { color: var(--ember); text-underline-offset: 2px; }
.prose code { font-size: 0.86em; background: var(--surface-2); padding: 0.1em 0.38em; border-radius: 5px; }
.prose pre { position: relative; background: var(--code-bg); color: var(--code-ink); padding: 14px 16px; border-radius: var(--r-md); overflow-x: auto; font-size: var(--text-sm); line-height: 1.6; margin: 0 0 0.9em; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.copy-btn { position: absolute; top: 8px; right: 8px; border: 0; border-radius: 6px; padding: 3px 8px; font-size: var(--text-xs); background: rgba(255, 255, 255, 0.1); color: var(--code-ink); opacity: 0; transition: opacity var(--fast); }
.prose pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* the work log: what Hearth is doing, step by step */
.steps {
  margin-top: 16px;
  margin-left: 40px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  animation: rise var(--normal) var(--ease) both;
}
.steps summary {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  list-style: none;
  font-size: var(--text-sm); font-weight: 600; color: var(--ink-2);
  cursor: pointer;
}
.steps summary::-webkit-details-marker { display: none; }
.steps summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 1.8px solid var(--ink-3); border-bottom: 1.8px solid var(--ink-3); transform: rotate(45deg); transition: transform var(--fast); }
.steps[open] summary::after { transform: rotate(-135deg); }
.steps-mark { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); flex: none; }
.steps.live .steps-mark { background: var(--ember); animation: ember 1.2s ease-in-out infinite; }
.steps.live summary { color: var(--ink); }
.steps-count { font-weight: 500; color: var(--ink-3); }
.steps ol { margin: 0; padding: 4px 0 8px; list-style: none; border-top: 1px solid var(--line); counter-reset: step; max-height: 340px; overflow-y: auto; }
.step {
  counter-increment: step;
  display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 4px;
  padding: 5px 14px;
  font: 400 var(--text-sm)/1.5 var(--font-mono);
  animation: slide var(--normal) var(--ease) both;
}
.step::before { content: counter(step); color: var(--ink-3); font-size: var(--text-xs); padding-top: 1px; }
.step-name { color: var(--ember); font-weight: 500; }
.step-args { color: var(--ink-2); overflow-wrap: anywhere; }
.steps.live .step:last-child { background: linear-gradient(90deg, var(--ember-soft), transparent 70%); }

.thinking { display: grid; grid-template-columns: 28px 1fr; gap: 12px; margin-top: 18px; align-items: center; color: var(--ink-2); font-size: var(--text-sm); }
.embers { display: inline-flex; gap: 5px; vertical-align: middle; margin-right: 8px; }
.embers span { width: 7px; height: 7px; border-radius: 50%; background: var(--ember); animation: ember 1.2s ease-in-out infinite; }
.embers span:nth-child(2) { animation-delay: 0.15s; }
.embers span:nth-child(3) { animation-delay: 0.3s; }

.note { margin-top: 16px; text-align: center; font-size: var(--text-sm); color: var(--ink-2); }
.note span { display: inline-block; background: var(--surface-2); padding: 6px 12px; border-radius: var(--r-lg); white-space: pre-wrap; text-align: left; }
.note.error span { background: var(--danger-soft); color: var(--danger); }

/* files Hearth handed over, inline in the chat */
.attachment { margin-left: 40px; margin-top: 12px; animation: rise var(--normal) var(--ease) both; }
.attachment .thumb-btn { display: block; padding: 0; border: 0; background: none; border-radius: var(--r-md); cursor: zoom-in; }
.attachment img.thumb { display: block; max-width: min(100%, 520px); max-height: 360px; border-radius: var(--r-md); border: 1px solid var(--line); box-shadow: var(--shadow-1); background: var(--surface-2); }
.attachment audio, .attachment video { width: min(100%, 420px); border-radius: var(--r-md); }
.file-card {
  display: inline-flex; align-items: center; gap: 12px;
  max-width: 100%;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow-1);
  text-align: left;
  transition: border-color var(--fast), transform var(--fast) var(--ease);
}
.file-card:hover { border-color: var(--ember); transform: translateY(-1px); }
.file-ico { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: var(--ember-soft); color: var(--ember); font: 600 var(--text-xs) var(--font-mono); text-transform: uppercase; flex: none; }
.file-meta { min-width: 0; }
.file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { font-size: var(--text-xs); color: var(--ink-3); }

/* ---------- composer ---------- */
.composer { padding: 10px var(--gutter) calc(12px + env(safe-area-inset-bottom)); }
.composer > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.attachments:not(:empty) { margin-bottom: 8px; }
.pending-file { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: var(--r-pill); background: var(--surface-2); font-size: var(--text-sm); max-width: 240px; }
.pending-file span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pending-file[data-state="uploading"] { opacity: 0.6; }
.pending-file[data-state="failed"] { background: var(--danger-soft); color: var(--danger); }
.pending-file button { border: 0; background: none; padding: 2px; display: grid; color: inherit; }
.pending-file svg { width: 14px; height: 14px; }
.composer-box {
  display: flex; align-items: flex-end; gap: 4px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.composer-box:focus-within { border-color: color-mix(in oklab, var(--ember) 55%, var(--line)); box-shadow: var(--shadow-2), 0 0 0 4px var(--glow); }
.composer textarea {
  flex: 1; min-width: 0;
  max-height: 40vh;
  resize: none;
  border: 0; outline: 0; background: transparent;
  padding: 9px 6px;
  line-height: 1.45;
}
.composer textarea::placeholder { color: var(--ink-3); }
.attach { cursor: pointer; }
.chip {
  align-self: center;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 4px 11px; font-size: var(--text-sm); font-weight: 500;
  background: transparent; color: var(--ink-2);
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip[aria-pressed="true"] { background: var(--ember-soft); border-color: var(--ember); color: var(--ember); }
.send {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border: 0; border-radius: 13px;
  background: var(--ember); color: var(--ember-ink);
  box-shadow: 0 4px 14px var(--glow);
  transition: transform var(--fast) var(--ease), background var(--fast), opacity var(--fast);
}
.send:hover:not(:disabled) { background: var(--ember-hi); }
.send:active:not(:disabled) { transform: scale(0.94); }
.send:disabled { opacity: 0.4; cursor: default; box-shadow: none; }
.send.wide { width: auto; padding: 0 22px; font-weight: 600; }
.composer-note { margin: 7px auto 0; font-size: var(--text-xs); color: var(--ink-3); text-align: center; }
.composer-note.warn { color: var(--ember); font-weight: 500; }

/* ---------- side: screen + files ---------- */
.side { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-left: 1px solid var(--line); background: var(--surface); }
.tabs { display: flex; gap: 4px; padding: 14px 16px 0; border-bottom: 1px solid var(--line); }
.tab {
  position: relative;
  border: 0; background: none;
  padding: 10px 14px 12px;
  font-weight: 600; color: var(--ink-3);
  transition: color var(--fast);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ember); }
.pane { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.screen {
  position: relative; margin: 0;
  aspect-ratio: 16 / 10;
  border-radius: var(--r-md);
  background: #0e0a08 repeating-linear-gradient(45deg, transparent 0 10px, rgba(255, 255, 255, 0.025) 10px 20px);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line), var(--shadow-2);
}
.screen img { display: block; width: 100%; height: 100%; object-fit: contain; }
.screen img:not([src]) { visibility: hidden; }
.screen:fullscreen { border-radius: 0; background: #000; }
.screen-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; color: #b9a593; font-size: var(--text-sm); }
.screen-bar { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.screen-live { display: inline-flex; align-items: center; gap: 7px; font-size: var(--text-sm); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.screen-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.screen-live[data-state="paused"] .screen-live-dot { background: var(--ink-3); }
.screen-live[data-state="error"] .screen-live-dot { background: var(--danger); }
.screen-live[data-state="live"] .screen-live-dot { animation: ember 2s ease-in-out infinite; }
.spacer { flex: 1; }
.ghost-btn {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 5px 11px;
  background: var(--surface); color: var(--ink-2);
  font-size: var(--text-sm); font-weight: 500; text-decoration: none;
  transition: border-color var(--fast), color var(--fast);
}
.ghost-btn:hover { border-color: var(--ember); color: var(--ink); }
.ghost-btn[aria-pressed="true"] { background: var(--ember-soft); border-color: var(--ember); color: var(--ember); }
.pane-note { font-size: var(--text-xs); color: var(--ink-3); margin: 12px 2px 0; }

.files-bar { display: flex; align-items: center; margin-bottom: 4px; }
.files-total { font-size: var(--text-sm); color: var(--ink-2); }
.file-group { margin-top: 14px; }
.file-group h3 { display: flex; align-items: baseline; gap: 8px; margin: 0 0 6px; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.file-group h3 b { font-weight: 600; color: var(--ink-2); }
.file-row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 0; border-radius: var(--r-sm);
  background: transparent; text-align: left;
  transition: background var(--fast);
}
.file-row:hover { background: var(--surface-2); }
.file-row .file-ico { width: 34px; height: 34px; font-size: 10px; }
.file-row .file-sub { text-align: right; white-space: nowrap; }
.file-row .file-path { font-size: var(--text-xs); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row.fresh { background: linear-gradient(90deg, var(--ember-soft), transparent); }
.files-empty { color: var(--ink-3); font-size: var(--text-sm); padding: 6px 8px; }

/* ---------- viewer ---------- */
.viewer {
  width: min(960px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-2);
}
.viewer[open] { display: flex; flex-direction: column; animation: rise var(--normal) var(--ease); }
.viewer::backdrop { background: rgba(20, 12, 8, 0.55); backdrop-filter: blur(4px); }
.viewer-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.viewer-head h2 { flex: 1; margin: 0; font-size: var(--text-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-body { overflow: auto; padding: 16px; display: grid; place-items: center; min-height: 160px; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 72dvh; border-radius: var(--r-md); }
.viewer-body pre { justify-self: stretch; margin: 0; background: var(--code-bg); color: var(--code-ink); padding: 16px; border-radius: var(--r-md); font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.viewer-body p { color: var(--ink-2); }

/* ---------- sign-in, toast, nav ---------- */
.signin { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 24px; text-align: center; background: radial-gradient(circle at 50% 75%, var(--ember-soft), var(--bg) 60%); }
.signin img { filter: drop-shadow(0 12px 30px var(--glow)); }
.signin h1 { margin: 12px 0 0; letter-spacing: -0.03em; }
.signin p { margin: 0 0 16px; color: var(--ink-2); max-width: 38ch; }
.signin form { display: flex; gap: 8px; width: min(420px, 100%); }
.signin input { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--bottom-nav-h) + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: var(--r-md); background: var(--ink); color: var(--bg); font-size: var(--text-sm); box-shadow: var(--shadow-2); animation: rise var(--normal) var(--ease); }
.bottom-nav { display: none; }
.scrim { display: none; }

/* ---------- tablet: conversations become a drawer ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: minmax(0, 1fr) var(--side-w); }
  .only-drawer { display: inline-grid; }
  .rail {
    position: fixed; z-index: 20; top: 0; bottom: 0; left: 0;
    width: min(var(--rail-w), 86vw);
    padding-top: calc(18px + env(safe-area-inset-top));
    transform: translateX(-102%);
    transition: transform var(--normal) var(--ease);
    box-shadow: var(--shadow-2);
  }
  .app.drawer-open .rail { transform: none; }
  .app.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 19; background: rgba(20, 12, 8, 0.4); }
}

/* ---------- phone: one section at a time, tabs at the bottom ---------- */
@media (max-width: 760px) {
  :root { --bottom-nav-h: 60px; --gutter: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .app .only-drawer { display: none; }
  .rail, .chat, .side { grid-column: 1; grid-row: 1; }
  .rail { position: static; width: auto; transform: none; box-shadow: none; border-right: 0; padding-top: 18px; transition: none; }
  .app:not([data-view="chats"]) .rail,
  .app:not([data-view="chat"]) .chat,
  .app:not([data-view="screen"]):not([data-view="files"]) .side { display: none; }
  .side { border-left: 0; }
  .side .tabs { display: none; }
  .composer-note:not(.warn) { display: none; }
  .msg-user .bubble { max-width: 88%; }
  .msg-hearth { grid-template-columns: minmax(0, 1fr); }
  .msg-hearth .avatar { display: none; }
  .attachment, .steps { margin-left: 0; }
  .thinking { grid-template-columns: 1fr; }
  .thinking .avatar { display: none; }
  .bottom-nav {
    grid-row: 2;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .bottom-nav button {
    display: grid; justify-items: center; align-content: center; gap: 3px;
    height: var(--bottom-nav-h);
    border: 0; background: none;
    font-size: 11px; font-weight: 600; color: var(--ink-3);
  }
  .bottom-nav button[aria-current="page"] { color: var(--ember); }
  .bottom-nav button[aria-current="page"] svg { stroke-width: 2.2; }
}

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slide { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
@keyframes ember { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.82); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
