/* Bricolage Grotesque 600, latin-ext */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 600;
  font-stretch: 100%;
  font-display: swap;
  src: url(../fonts/bricolage-grotesque-latin-ext-10d6a582.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Bricolage Grotesque 600, latin */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 600;
  font-stretch: 100%;
  font-display: swap;
  src: url(../fonts/bricolage-grotesque-latin-3b58e8bd.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Bricolage Grotesque 700, latin-ext */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 700;
  font-stretch: 100%;
  font-display: swap;
  src: url(../fonts/bricolage-grotesque-latin-ext-10d6a582.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Bricolage Grotesque 700, latin */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 700;
  font-stretch: 100%;
  font-display: swap;
  src: url(../fonts/bricolage-grotesque-latin-3b58e8bd.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* IBM Plex Mono 400, latin-ext */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/ibm-plex-mono-latin-ext-7963a16e.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Mono 400, latin */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/ibm-plex-mono-latin-bc87d8e0.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* IBM Plex Mono 500, latin-ext */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../fonts/ibm-plex-mono-latin-ext-25040cb4.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Mono 500, latin */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../fonts/ibm-plex-mono-latin-a80b2cab.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* IBM Plex Sans 400, latin-ext */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-stretch: 100%;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-ext-effb1ea2.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Sans 400, latin */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-stretch: 100%;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-f6667783.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* IBM Plex Sans 500, latin-ext */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-stretch: 100%;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-ext-effb1ea2.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Sans 500, latin */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-stretch: 100%;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-f6667783.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* IBM Plex Sans 600, latin-ext */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-stretch: 100%;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-ext-effb1ea2.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Sans 600, latin */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-stretch: 100%;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-f6667783.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* AbelAI. Values come from the "AbelAI App Screens" design board; parts the
   board does not draw (drawer, dialogs, code blocks, dark setup screens) use
   the same tokens. Motion is short and off under prefers-reduced-motion. */

:root {
  --bg: #F5F6F2;
  --surface: #FFFFFF;
  --surface-2: #EEF0EA;
  --text: #15181C;
  --text-2: #586069;
  --border: #DDE0D8;
  --border-strong: #C9CDC4;
  --accent: #0B7A62;
  --accent-strong: #075E4B;
  --accent-soft: #E3F1EC;
  --on-accent: #FFFFFF;
  --link-hover: #075E4B;
  --bubble: #15181C;
  --on-bubble: #F5F6F2;
  --warn-soft: #FCEFD9;
  --warn-text: #8A4B0B;
  --hover: rgba(21, 24, 28, 0.06);
  --scrim: rgba(21, 24, 28, 0.32);
  --shadow: 0 18px 50px rgba(21, 24, 28, 0.16), 0 2px 8px rgba(21, 24, 28, 0.06);
  --font: 'IBM Plex Sans', system-ui, sans-serif;
  --font-display: 'Bricolage Grotesque', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
  --radius-s: 12px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1113;
    --surface: #171B1E;
    --surface-2: #13171A;
    --text: #E7EAE5;
    --text-2: #9AA3AB;
    --border: #2A3035;
    --border-strong: #3A4248;
    --accent: #43C9A5;
    --accent-strong: #7ADCC1;
    --accent-soft: #163029;
    --on-accent: #0E1113;
    --link-hover: #7ADCC1;
    --bubble: #242A2F;
    --on-bubble: #E7EAE5;
    --warn-soft: #33270F;
    --warn-text: #F2B866;
    --hover: rgba(231, 234, 229, 0.07);
    --scrim: rgba(0, 0, 0, 0.5);
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
  textarea::placeholder { color: #9AA3AB; }
}

html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
a { color: var(--accent); }
a:hover { color: var(--link-hover); }
svg { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.composer textarea:focus-visible { outline: none; }

.mark-bg { fill: var(--accent); }
.mark-fg { stroke: var(--on-accent); }
.mark-dot { fill: var(--on-accent); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes ring { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent); } 50% { box-shadow: 0 0 0 5px transparent; } }
@keyframes blink { to { visibility: hidden; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }

/* ---------- screens ---------- */

.screen { min-height: 100vh; display: flex; flex-direction: column; }
.screen-chat { height: 100vh; height: 100dvh; min-height: 0; }

.bar { border-bottom: 1px solid var(--border); flex: none; }
.bar-in { max-width: 1120px; margin: 0 auto; padding: 10px clamp(8px, 2vw, 24px); display: flex; align-items: center; gap: 4px; }
.bar-setup .bar-in { padding: 14px clamp(16px, 3vw, 24px); gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; flex-grow: 1; }
.word { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.bar-setup .word, .page .word { font-size: 22px; }
.tagline { font-family: var(--mono); font-size: 13px; color: var(--text-2); }
.bar-setup .tagline { padding-top: 3px; }

.icon-btn { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; transition: background-color 140ms var(--ease), transform 120ms var(--ease); }
.icon-btn:hover { background: var(--hover); }
.icon-btn:active { transform: scale(0.94); }

.model-chip { height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: border-color 140ms var(--ease), transform 120ms var(--ease); }
.model-chip:hover { border-color: var(--border-strong); }
.model-chip:active { transform: scale(0.97); }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.chip-dot[data-state="generating"] { animation: breathe 1.2s ease-in-out infinite; }

/* ---------- setup: pick a size, download, can't run ---------- */

.setup-main { flex-grow: 1; display: flex; align-items: center; justify-content: center; padding: clamp(28px, 6vw, 64px) 20px 48px; }
.setup-box { width: 100%; display: flex; flex-direction: column; animation: rise 320ms var(--ease) backwards; }
.setup-box[data-view="picker"] { max-width: 880px; gap: 22px; }
.setup-box[data-view="loading"] { max-width: 520px; gap: 26px; }
.setup-box[data-view="error"] { max-width: 560px; gap: 22px; }
.setup-box[data-view="checking"] { max-width: 520px; gap: 8px; align-items: center; color: var(--text-2); font-size: 15px; }
.setup-head { display: flex; flex-direction: column; gap: 8px; }
[data-view="error"] .setup-head { gap: 10px; }
.setup-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.9rem, 4vw, 2.5rem); line-height: 1.1; letter-spacing: -0.02em; }
[data-view="picker"] .setup-title { font-size: clamp(1.9rem, 4vw, 2.75rem); }
.setup-lead { margin: 0; font-size: 16px; line-height: 1.5; color: var(--text-2); }
[data-view="picker"] .setup-lead { max-width: 560px; }
[data-view="error"] .setup-lead { line-height: 1.55; }
.setup-note { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-2); }

.ok-note { align-self: flex-start; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-strong); font-size: 14px; line-height: 1.4; }
.ok-note svg { flex-shrink: 0; }

.sizes { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.size-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); cursor: pointer; animation: rise 360ms var(--ease) backwards; transition: border-color 160ms var(--ease); }
.size-card:nth-child(3) { animation-delay: 50ms; }
.size-card:nth-child(4) { animation-delay: 100ms; }
.size-card:hover { border-color: var(--border-strong); }
.size-card[data-selected="true"] { padding: 17px; border: 2px solid var(--accent); }
.size-card[data-disabled="true"] { cursor: default; opacity: 0.6; }
.size-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.size-top input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.size-name { font-weight: 600; font-size: 17px; }
.badge { padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 600; }
.size-meta { font-family: var(--mono); font-size: 13px; color: var(--text-2); }
.size-desc { font-size: 14px; line-height: 1.45; color: var(--text-2); }
.size-warn { font-size: 13px; line-height: 1.45; color: var(--warn-text); }

.picker-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; }
.btn-lg { height: 52px; border: 1px solid var(--border-strong); border-radius: 999px; background: transparent; color: var(--text); font-family: inherit; font-size: 16px; font-weight: 600; cursor: pointer; transition: background-color 160ms var(--ease), transform 120ms var(--ease), opacity 160ms var(--ease); }
.btn-lg:hover:not(:disabled) { background: var(--hover); }
.btn-lg:active:not(:disabled) { transform: scale(0.98); }
.btn-lg:disabled { cursor: default; opacity: 0.5; }
.btn-lg.primary { border: 0; background: var(--accent); color: var(--on-accent); }
.btn-lg.primary:hover:not(:disabled) { background: var(--accent-strong); }
.picker-actions .btn-lg { flex: 1 1 260px; max-width: 360px; }
.privacy-line { margin: 0; flex: 1 1 260px; display: flex; gap: 8px; align-items: center; font-size: 13px; line-height: 1.4; color: var(--text-2); }
.privacy-line svg { flex-shrink: 0; }
.back-link { align-self: flex-start; min-height: 44px; display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 15px; font-weight: 600; text-decoration: none; }
button.back-link { padding: 0; border: 0; background: none; font-family: inherit; cursor: pointer; }
.back-link svg { transition: transform 160ms var(--ease); }
.back-link:hover svg { transform: translateX(-3px); }

.progress { display: flex; flex-direction: column; gap: 10px; }
.track { height: 12px; border-radius: 999px; background: var(--border); overflow: hidden; }
.fill { width: 0; height: 100%; border-radius: 999px; background: var(--accent); transition: width 400ms var(--ease); }
.progress-labels { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 13px; color: var(--text-2); }
.steps { list-style: none; margin: 0; padding: 18px; display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; font-size: 15px; }
.step { display: flex; align-items: center; gap: 12px; }
.step[data-state="todo"] { color: var(--text-2); }
.step-icon { width: 26px; height: 26px; border-radius: 50%; box-sizing: border-box; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step[data-state="done"] .step-icon { background: var(--accent); color: var(--on-accent); }
.step[data-state="done"] .step-icon svg { animation: pop 280ms var(--ease) backwards; }
.step[data-state="current"] .step-icon { border: 2px solid var(--accent); animation: ring 1.6s ease-in-out infinite; }
.step[data-state="todo"] .step-icon { border: 2px solid var(--border-strong); }
.step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: breathe 1.4s ease-in-out infinite; }
.step-text { flex-grow: 1; }
.step[data-state="current"] .step-text { font-weight: 600; }

.err-icon { width: 56px; height: 56px; border-radius: 18px; background: var(--warn-soft); color: var(--warn-text); display: flex; align-items: center; justify-content: center; animation: pop 320ms var(--ease) backwards 80ms; }
.tips { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.tips h2 { margin: 0; font-size: 15px; font-weight: 600; }
.tips ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.5; }
.err-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.err-actions .btn-lg { flex: 1 1 200px; }

/* Errors and notices: a load failure on the picker, a lost GPU in chat. */
#setup-notice:empty, #chat-notice:empty { display: none; }
.notice { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "icon text close" "icon actions actions"; column-gap: 10px; padding: 12px 8px 12px 14px; border-radius: 14px; background: var(--warn-soft); color: var(--text); animation: rise 240ms var(--ease) backwards; }
.notice[data-tone="info"] { background: var(--accent-soft); }
.notice-icon { grid-area: icon; margin-top: 1px; color: var(--warn-text); }
.notice[data-tone="info"] .notice-icon { color: var(--accent-strong); }
.notice-text { grid-area: text; min-width: 0; }
.notice-title { margin: 0; font-weight: 600; font-size: 14px; line-height: 1.4; }
.notice-message { margin: 2px 0 0; color: var(--text-2); font-size: 13.5px; line-height: 1.45; }
.notice-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.notice-actions:empty { display: none; }
.notice-close { grid-area: close; width: 32px; height: 32px; margin-top: -6px; }
.pill-btn { height: 36px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background-color 140ms var(--ease), transform 120ms var(--ease); }
.pill-btn:hover:not(:disabled) { background: var(--hover); }
.pill-btn:active:not(:disabled) { transform: scale(0.97); }
.pill-btn:disabled { opacity: 0.5; cursor: default; }
.pill-btn.primary { border-color: transparent; background: var(--accent); color: var(--on-accent); }
.pill-btn.danger { color: var(--warn-text); }

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

/* Scrollable only when the messages overflow: Chrome draws a scroller on its own
   layer, which changes text antialiasing, so a short thread stays a plain box. */
.thread { flex-grow: 1; min-height: 0; overflow: hidden; overscroll-behavior: contain; display: flex; flex-direction: column; }
.thread[data-scroll="true"] { overflow-y: auto; }
.thread-inner { width: 100%; max-width: 760px; box-sizing: border-box; margin: auto auto 0; padding: 24px 16px 12px; display: flex; flex-direction: column; gap: 14px; }
.msg-new { animation: rise 240ms var(--ease) backwards; }
.msg-user { display: flex; justify-content: flex-end; }
.bubble { max-width: min(80%, 540px); background: var(--bubble); color: var(--on-bubble); padding: 10px 14px; border-radius: 18px 18px 4px 18px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-ai { display: flex; flex-direction: column; gap: 14px; }
.msg-body { font-size: 15px; line-height: 1.55; display: flex; flex-direction: column; gap: 8px; overflow-wrap: anywhere; }
.msg-body p, .msg-body .md-h, .msg-body blockquote, .msg-body .md-pre, .msg-body .md-table { margin: 0; }
.msg-body ul, .msg-body ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.msg-body li > ul, .msg-body li > ol { margin-top: 4px; }
.msg-body .md-h { font-family: var(--font-display); font-weight: 600; }
/* markdown.js shifts levels down two (# is h3), so ## and ### get the board's 18px. */
.msg-body h3.md-h { font-size: 20px; }
.msg-body h4.md-h, .msg-body h5.md-h { font-size: 18px; }
.msg-body h6.md-h { font-size: 16px; }
.msg-body blockquote { padding-left: 12px; border-left: 2px solid var(--border-strong); color: var(--text-2); }
.msg-body hr { width: 100%; margin: 4px 0; border: 0; border-top: 1px solid var(--border); }
.msg-body a { text-underline-offset: 2px; }
.msg-body code.md-code { font-family: var(--mono); font-size: 0.9em; padding: 0.1em 0.35em; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); }
.md-pre { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.md-pre-bar { display: flex; align-items: center; justify-content: space-between; height: 36px; padding: 0 4px 0 14px; border-bottom: 1px solid var(--border); }
.md-pre-lang { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.md-copy { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font-family: inherit; font-size: 12.5px; cursor: pointer; }
.md-copy:hover { background: var(--hover); color: var(--text); }
.md-copy svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.md-pre pre { margin: 0; padding: 12px 14px; overflow-x: auto; font: 13.5px/1.6 var(--mono); tab-size: 2; }
.md-pre code { font: inherit; white-space: pre; }
.md-table { overflow-x: auto; }
.md-table table { border-collapse: collapse; font-size: 14px; width: 100%; max-width: 520px; }
.md-table th, .md-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.md-table th { color: var(--text-2); font-weight: 500; }

.caret { display: inline-block; width: 8px; height: 16px; margin-left: 3px; vertical-align: -2px; background: var(--accent); border-radius: 2px; animation: blink 1s steps(2, start) infinite; }
.thinking { display: flex; gap: 5px; padding: 8px 0; }
.thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); animation: breathe 1.2s ease-in-out infinite; }
.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }

.msg-meta { display: flex; align-items: center; gap: 2px; margin-top: -4px; animation: fade 260ms var(--ease) backwards; }
.msg-stat { flex-grow: 1; font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.msg-writing { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.meta-btn { color: var(--text-2); }
.meta-btn:hover { color: var(--text); }
.meta-btn[data-done="true"] svg { animation: pop 260ms var(--ease) backwards; color: var(--accent); }
.msg-error { padding: 10px 12px; border-radius: 12px; background: var(--warn-soft); font-size: 14px; line-height: 1.45; }
.msg-error strong { display: block; color: var(--warn-text); font-weight: 600; }
.msg-error p { margin: 0; color: var(--text-2); }
.msg-note { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.45; }

.ctx-divider { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 12px; }
.ctx-line { flex-grow: 1; height: 1px; background: var(--border); }
.ctx-text { text-align: center; max-width: 260px; line-height: 1.4; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 24px 0 8px; animation: rise 320ms var(--ease) backwards; }
.empty h1 { margin: 6px 0 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.6rem, 3vw, 2rem); line-height: 1.1; letter-spacing: -0.02em; }
.empty p { margin: 0; max-width: 420px; font-size: 15px; line-height: 1.5; color: var(--text-2); }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; margin-top: 14px; }
.suggestion { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text-2); text-align: left; font-family: inherit; font-size: 14px; line-height: 1.45; cursor: pointer; animation: rise 360ms var(--ease) backwards; transition: border-color 160ms var(--ease); }
.suggestion:nth-child(2) { animation-delay: 40ms; }
.suggestion:nth-child(3) { animation-delay: 80ms; }
.suggestion:nth-child(4) { animation-delay: 120ms; }
.suggestion:hover { border-color: var(--border-strong); }
.suggestion strong { color: var(--text); font-weight: 600; }

.composer-bar { border-top: 1px solid var(--border); flex: none; }
.composer-in { max-width: 760px; margin: 0 auto; padding: 10px 12px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.composer-in .notice { margin-bottom: 10px; }
.composer { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 10px 8px 8px 14px; transition: border-color 160ms var(--ease); }
.composer:focus-within { border-color: var(--border-strong); }
.composer textarea { border: 0; resize: none; background: transparent; color: var(--text); font-family: inherit; font-size: 16px; line-height: 1.4; padding: 2px 0; outline: none; max-height: 220px; }
.composer-row { display: flex; align-items: center; justify-content: space-between; }
.search-toggle { height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text-2); display: flex; align-items: center; gap: 6px; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease); }
.search-toggle[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.send-btn, .stop-btn { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-left: auto; cursor: pointer; transition: background-color 140ms var(--ease), transform 120ms var(--ease); animation: pop 200ms var(--ease) backwards; }
.send-btn { background: var(--accent); color: var(--on-accent); }
.send-btn:hover { background: var(--accent-strong); }
.stop-btn { background: var(--text); color: var(--bg); }
.send-btn:active, .stop-btn:active { transform: scale(0.92); }
.composer-note { margin: 8px 4px 0; text-align: center; font-size: 12px; line-height: 1.4; color: var(--text-2); }
.composer-note a { font-weight: 600; }

/* ---------- drawer ---------- */

.drawer { position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(320px, 86vw); display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--border); box-shadow: var(--shadow); transform: translateX(-104%); visibility: hidden; transition: transform 280ms var(--ease), visibility 0s linear 280ms; }
.drawer[data-open="true"] { transform: none; visibility: visible; transition: transform 280ms var(--ease), visibility 0s; }
.scrim { position: fixed; inset: 0; z-index: 20; background: var(--scrim); animation: fade 220ms var(--ease) backwards; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 18px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.conv-list { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; overscroll-behavior: contain; }
.conv-group { margin: 14px 8px 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.conv-group:first-child { margin-top: 4px; }
.conv-row { position: relative; }
.conv-item { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 44px 0 12px; border: 0; border-radius: 12px; background: transparent; color: var(--text); text-align: left; font-family: inherit; font-size: 14px; cursor: pointer; transition: background-color 140ms var(--ease); }
.conv-item:hover { background: var(--hover); }
.conv-item[aria-current="true"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.conv-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-live { flex: none; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--accent); animation: breathe 1.2s ease-in-out infinite; }
.conv-del { position: absolute; right: 0; top: 0; color: var(--text-2); opacity: 0; transition: opacity 140ms var(--ease), background-color 140ms var(--ease), color 140ms var(--ease); }
.conv-row:hover .conv-del, .conv-del:focus-visible, .conv-row:focus-within .conv-del { opacity: 1; }
.conv-del:hover { color: var(--warn-text); }
@media (hover: none) { .conv-del { opacity: 1; } }
.conv-empty { padding: 8px 12px; color: var(--text-2); font-size: 14px; }
.drawer-foot { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.foot-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; color: var(--text); font-family: inherit; font-size: 14px; text-decoration: none; cursor: pointer; transition: background-color 140ms var(--ease); }
.foot-item:hover { background: var(--hover); color: var(--text); }
.foot-item svg { color: var(--text-2); }
.foot-site { font-family: var(--mono); font-size: 12px; color: var(--text-2); }

/* ---------- dialogs and toast ---------- */

.sheet { width: min(560px, calc(100vw - 32px)); max-height: min(86vh, 820px); padding: 0; border: 1px solid var(--border); border-radius: 22px; background: var(--bg); color: var(--text); box-shadow: var(--shadow); overflow: hidden; }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 220ms var(--ease) backwards; }
.sheet::backdrop { background: var(--scrim); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 22px; border-bottom: 1px solid var(--border); flex: none; }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.sheet-body { padding: 20px 22px 24px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 20px; }
.facts { margin: 0; padding: 18px; list-style: none; display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }
.facts li { color: var(--text-2); font-size: 14px; line-height: 1.55; }
.facts strong { display: block; color: var(--text); font-weight: 600; }
.data-section { display: flex; flex-direction: column; gap: 8px; }
.data-section h3 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.data-summary, .about p { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cached-list { display: flex; flex-direction: column; gap: 8px; }
.cached-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); font-size: 14px; }
.cached-empty { margin: 0; color: var(--text-2); font-size: 14px; }
.sheet-small { width: min(420px, calc(100vw - 32px)); }
.confirm { padding: 24px; display: flex; flex-direction: column; gap: 8px; }
.confirm h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; line-height: 1.2; }
.confirm p { margin: 0 0 10px; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); padding: 9px 16px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 13px; font-weight: 500; box-shadow: var(--shadow); animation: rise 200ms var(--ease) backwards; z-index: 50; pointer-events: none; }

/* ---------- disclaimer page ---------- */

.page { min-height: 100vh; display: flex; flex-direction: column; }
.page .bar-in { padding: 12px clamp(16px, 3vw, 24px); gap: 12px; }
.brand-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-height: 44px; }
.brand-link:hover { color: var(--text); }
.bar-spacer { flex-grow: 1; }
.open-chat { height: 44px; padding: 0 20px; border-radius: 999px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; text-decoration: none; font-size: 15px; font-weight: 600; transition: background-color 160ms var(--ease), transform 120ms var(--ease); }
.open-chat:hover { background: var(--accent-strong); color: var(--on-accent); }
.open-chat:active { transform: scale(0.97); }
.page-main { flex-grow: 1; width: 100%; max-width: 760px; box-sizing: border-box; margin: 0 auto; padding: clamp(36px, 7vw, 72px) 20px clamp(48px, 8vw, 88px); display: flex; flex-direction: column; gap: 28px; }
.page-main > * { animation: rise 420ms var(--ease) backwards; }
.page-main > :nth-child(2) { animation-delay: 70ms; }
.page-main > :nth-child(3) { animation-delay: 140ms; }
.page-head { display: flex; flex-direction: column; gap: 14px; }
.date-chip { align-self: flex-start; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-family: var(--mono); font-size: 12px; font-weight: 500; }
.page-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(2.1rem, 5vw, 3.4rem); line-height: 1.05; letter-spacing: -0.025em; }
.page-card { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: clamp(1.25rem, 4vw, 2.5rem); display: flex; flex-direction: column; gap: 18px; font-size: 1.0625rem; line-height: 1.65; }
.page-card p { margin: 0; }
.page-foot { border-top: 1px solid var(--border); background: var(--surface-2); }
.page-foot-in { max-width: 1120px; margin: 0 auto; padding: 40px clamp(16px, 3vw, 24px) 48px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 28px 40px; font-size: 14px; line-height: 1.55; }
.foot-col { display: flex; flex-direction: column; gap: 6px; }
.foot-col:first-child { gap: 10px; }
.foot-col p { margin: 0; color: var(--text-2); }
.foot-brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.foot-brand .word { font-size: 18px; letter-spacing: normal; }
.foot-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); margin-bottom: 4px; }
.foot-nav { display: flex; flex-direction: column; gap: 2px; }
.foot-nav a { min-height: 40px; display: flex; align-items: center; }
.foot-nav a[aria-current="page"] { font-weight: 600; color: var(--text); }

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