/* ==========================================================================
   WTECH AI LAB — Design System
   Tecnologia séria + laboratório experimental.
   Near-black canvas · electric blue / cyan accents · subtle glass · generous space.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root,
[data-theme="dark"] {
    --bg: #05070b;
    --bg-elev: #0a0e15;
    --bg-elev-2: #0e131c;
    --surface: rgba(255, 255, 255, 0.022);
    --surface-2: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.06);
    --glass: rgba(12, 17, 26, 0.72);
    --border: rgba(255, 255, 255, 0.065);
    --border-strong: rgba(255, 255, 255, 0.12);
    --text: #e7ecf3;
    --text-2: #a3aebd;
    --text-3: #687485;
    --accent: #2fd9ff;
    --accent-2: #3b82f6;
    --accent-ink: #031018;
    --accent-soft: rgba(47, 217, 255, 0.09);
    --accent-line: rgba(47, 217, 255, 0.28);
    --accent-glow: rgba(47, 217, 255, 0.16);
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.1);
    --warning-soft: rgba(251, 191, 36, 0.1);
    --grid-line: rgba(255, 255, 255, 0.028);
    --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.75);
    --shadow-soft: 0 8px 30px -12px rgba(0, 0, 0, 0.6);
    --code-bg: #070a10;
    color-scheme: dark;
}

[data-theme="light"] {
    --bg: #f5f7fa;
    --bg-elev: #ffffff;
    --bg-elev-2: #f0f3f7;
    --surface: rgba(10, 22, 40, 0.018);
    --surface-2: rgba(10, 22, 40, 0.035);
    --surface-hover: rgba(10, 22, 40, 0.055);
    --glass: rgba(255, 255, 255, 0.8);
    --border: rgba(10, 22, 40, 0.085);
    --border-strong: rgba(10, 22, 40, 0.15);
    --text: #0b1220;
    --text-2: #475467;
    --text-3: #8a94a6;
    --accent: #0891b2;
    --accent-2: #2563eb;
    --accent-ink: #ffffff;
    --accent-soft: rgba(8, 145, 178, 0.08);
    --accent-line: rgba(8, 145, 178, 0.3);
    --accent-glow: rgba(8, 145, 178, 0.12);
    --success: #059669;
    --warning: #b45309;
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.07);
    --warning-soft: rgba(180, 83, 9, 0.08);
    --grid-line: rgba(10, 22, 40, 0.035);
    --shadow: 0 18px 50px -20px rgba(15, 30, 60, 0.25);
    --shadow-soft: 0 8px 26px -14px rgba(15, 30, 60, 0.2);
    --code-bg: #0b1220;
    color-scheme: light;
}

:root {
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --radius-xs: 6px;
    --radius-sm: 9px;
    --radius: 13px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --sidebar: 256px;
    --sidebar-collapsed: 72px;
    --topbar: 56px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --fast: 140ms;
    --mid: 260ms;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background var(--mid) var(--ease), color var(--mid) var(--ease);
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; font-weight: 600; }
p { margin: 0; }
code, kbd, pre { font-family: var(--mono); }
::selection { background: var(--accent-line); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; border-radius: 6px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-hover); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--border-strong); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 3. Utilities ---------- */
.mono { font-family: var(--mono); letter-spacing: 0.02em; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.right { text-align: right; }
.accent, .accent-text { color: var(--accent); }
.eyebrow {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.16em;
    color: var(--text-3);
    text-transform: uppercase;
}
.hint { font-size: 12px; color: var(--text-3); }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: var(--success); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15); margin-right: 8px;
}
.status-dot.is-warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }

/* ---------- 4. Controls ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: 13.5px; font-weight: 500; letter-spacing: 0.01em;
    cursor: pointer; white-space: nowrap;
    transition: background var(--fast), border-color var(--fast), color var(--fast), transform var(--fast), box-shadow var(--fast);
}
.btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
    background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 600;
    box-shadow: 0 0 0 1px rgba(47, 217, 255, 0.25), 0 8px 24px -10px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent); color: var(--accent-ink); filter: brightness(1.08); box-shadow: 0 0 0 1px var(--accent-line), 0 10px 30px -10px var(--accent-glow); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { background: var(--danger-soft); border-color: rgba(248, 113, 113, 0.35); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-google { background: var(--bg-elev); border-color: var(--border-strong); }
.btn-sm { height: 31px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 14.5px; border-radius: 11px; }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px; border-radius: 9px;
    background: transparent; border: 1px solid transparent; color: var(--text-2);
    cursor: pointer; transition: background var(--fast), color var(--fast), border-color var(--fast);
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn-sm { width: 28px; height: 28px; border-radius: 7px; }
.icon-btn-xs { width: 20px; height: 20px; border-radius: 5px; }

.input {
    width: 100%; min-height: 40px; padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text); font: inherit; font-size: 14px;
    transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface-2); }
.input:disabled { opacity: 0.6; }
textarea.input { resize: vertical; line-height: 1.55; }
select.input { appearance: none; padding-right: 32px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; }
select.input option { background: var(--bg-elev); color: var(--text); }
.input-sm { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.textarea-lg { min-height: 180px; }
.input-row { display: flex; gap: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field-grow { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.toggle input {
    appearance: none; width: 32px; height: 18px; border-radius: 20px; flex-shrink: 0;
    background: var(--surface-hover); border: 1px solid var(--border-strong); position: relative; cursor: pointer;
    transition: background var(--fast), border-color var(--fast);
}
.toggle input::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--text-2); transition: transform var(--mid) var(--ease), background var(--fast);
}
.toggle input:checked { background: var(--accent-soft); border-color: var(--accent-line); }
.toggle input:checked::after { transform: translateX(14px); background: var(--accent); }
.toggle-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; line-height: 1.5; }
.toggle-row input { margin-top: 2px; }
.toggle-row b { color: var(--text); font-weight: 500; }

.range { width: 100%; accent-color: var(--accent); }
.range-labels { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-3); letter-spacing: 0.12em; }

.tag {
    display: inline-flex; align-items: center; gap: 5px;
    height: 22px; padding: 0 8px; border-radius: 6px;
    font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.08em;
    color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
    white-space: nowrap;
}
.tag-accent { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.tag-success { color: var(--success); background: rgba(52, 211, 153, 0.08); border-color: rgba(52, 211, 153, 0.3); }
.tag-warning { color: var(--warning); background: var(--warning-soft); border-color: rgba(251, 191, 36, 0.3); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 20px;
    font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
}
.chip-action { cursor: pointer; height: 32px; padding: 0 13px; font-size: 12.5px; transition: all var(--fast); }
.chip-action:hover:not(:disabled) { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.chip-action:disabled { opacity: 0.45; cursor: not-allowed; }

.meter { height: 4px; border-radius: 4px; background: var(--surface-hover); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 600ms var(--ease); }
.meter.is-low i { background: var(--warning); }
.meter-lg { height: 8px; margin: 12px 0 8px; }

.alert {
    display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; margin-bottom: 14px;
    border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2);
    font-size: 13px; color: var(--text-2);
}
.alert .icon { flex-shrink: 0; margin-top: 2px; }
.alert-danger { border-color: rgba(248, 113, 113, 0.35); background: var(--danger-soft); color: var(--danger); }
.alert-warning { border-color: rgba(251, 191, 36, 0.3); background: var(--warning-soft); color: var(--warning); }

.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.tab { height: 30px; padding: 0 12px; border-radius: 7px; border: 0; background: transparent; color: var(--text-2); font-size: 12.5px; cursor: pointer; transition: all var(--fast); }
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--bg-elev-2); color: var(--text); box-shadow: 0 1px 0 var(--border-strong) inset, var(--shadow-soft); }
.tabs-sm .tab { height: 26px; padding: 0 10px; font-size: 12px; }

.segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.segment { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); cursor: pointer; }
.segment.is-active { background: var(--bg-elev-2); color: var(--text); box-shadow: 0 1px 0 var(--border-strong) inset; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; font-weight: 500; color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th.right, .table td.right { text-align: right; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table .tag { margin-right: 4px; }

kbd {
    display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 5px;
    font-size: 10.5px; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border);
}

.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite; display: inline-block; }

.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-3); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- 5. Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.logo-mark { width: 26px; height: 26px; flex-shrink: 0; }
.logo-dot { fill: var(--accent); filter: drop-shadow(0 0 4px var(--accent-glow)); }
.logo-text { font-family: var(--mono); font-weight: 600; font-size: 14.5px; letter-spacing: 0.14em; }
.logo-text b { color: var(--accent); font-weight: 600; margin-left: 6px; }
.logo-collapsed { display: none; }

/* ---------- 6. Boot / loader / reconnect ---------- */
.boot {
    position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
    background: radial-gradient(600px 300px at 50% 45%, var(--accent-glow), transparent 70%), var(--bg);
    transition: opacity 400ms var(--ease), visibility 400ms;
}
.boot.is-done { opacity: 0; visibility: hidden; }
.boot-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; animation: fadeUp 600ms var(--ease) both; }
.boot-title { font-family: var(--mono); font-weight: 600; letter-spacing: 0.36em; font-size: 17px; padding-left: 0.36em; }
.boot-sub { font-family: var(--mono); font-size: 11px; letter-spacing: 0.24em; color: var(--text-3); }
.boot-dots::after { content: "..."; animation: dots 1.4s steps(4) infinite; display: inline-block; width: 1.4em; text-align: left; overflow: hidden; vertical-align: bottom; }
.boot-bar { width: 180px; height: 2px; background: var(--surface-hover); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.boot-bar i { display: block; width: 40%; height: 100%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: scan 1.3s var(--ease) infinite; }
.boot-mark, .loader-mark { display: flex; gap: 6px; }
.boot-mark span, .loader-mark span { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); animation: pulse 1.2s var(--ease) infinite; }
.boot-mark span:nth-child(2), .loader-mark span:nth-child(2) { animation-delay: 150ms; }
.boot-mark span:nth-child(3), .loader-mark span:nth-child(3) { animation-delay: 300ms; }

.loader { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 64px 16px; animation: fadeIn 300ms var(--ease) both; }
.loader-inline { padding: 8px; flex-direction: row; }
.loader-mark span { width: 6px; height: 6px; }
.loader-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.24em; color: var(--text-3); }

.reconnect { display: none; }
.reconnect.components-reconnect-show, .reconnect.components-reconnect-failed, .reconnect.components-reconnect-rejected {
    display: grid; place-items: center; position: fixed; inset: 0; z-index: 2000; background: rgba(3, 5, 8, 0.72); backdrop-filter: blur(6px);
}
.reconnect-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 32px; border-radius: var(--radius-lg); background: var(--bg-elev); border: 1px solid var(--border-strong); box-shadow: var(--shadow); text-align: center; }
.reconnect-title { font-family: var(--mono); font-size: 12px; letter-spacing: 0.22em; }
.reconnect-card p { display: none; color: var(--text-2); font-size: 13px; }
.reconnect-card a { color: var(--accent); }
.components-reconnect-show .reconnect-show, .components-reconnect-failed .reconnect-failed, .components-reconnect-rejected .reconnect-rejected { display: block; }
.reconnect-pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: ping 1.4s var(--ease) infinite; }

/* ---------- 7. Public site ---------- */
.public-shell { position: relative; min-height: 100vh; overflow-x: hidden; }
.bg-grid {
    position: absolute; inset: 0 0 auto 0; height: 900px; pointer-events: none; z-index: 0;
    background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 70% 60% at 50% 20%, #000 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 20%, #000 30%, transparent 75%);
}
.public-nav {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 24px;
    height: 68px; padding: 0 clamp(18px, 4vw, 48px);
    background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
.public-links { display: flex; gap: 28px; font-size: 13.5px; color: var(--text-2); }
.public-links a:hover { color: var(--text); }
.public-main { position: relative; z-index: 1; }

.hero {
    position: relative; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: clamp(32px, 5vw, 72px); align-items: center;
    max-width: 1240px; margin: 0 auto; padding: clamp(56px, 9vw, 120px) clamp(18px, 4vw, 48px) clamp(56px, 8vw, 110px);
}
.hero-glow { position: absolute; top: -10%; right: 5%; width: 520px; height: 520px; border-radius: 50%; background: radial-gradient(circle, var(--accent-glow), transparent 65%); filter: blur(30px); pointer-events: none; }
.hero-brand { display: flex; flex-direction: column; gap: 10px; margin-bottom: 30px; }
.hero-wordmark { font-family: var(--mono); font-weight: 600; font-size: clamp(15px, 1.6vw, 18px); letter-spacing: 0.42em; }
.hero-sub { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.3em; color: var(--text-3); }
.hero-sub i { color: var(--accent); font-style: normal; }
.hero-title { font-size: clamp(36px, 5.4vw, 64px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.04; max-width: 13ch; }
.hero-desc { margin-top: 24px; max-width: 52ch; font-size: clamp(15px, 1.35vw, 17px); color: var(--text-2); line-height: 1.7; }
.hero-cta { display: flex; gap: 12px; margin-top: 36px; flex-wrap: wrap; }
.hero-meta { display: flex; gap: 24px; margin-top: 40px; font-size: 11px; letter-spacing: 0.16em; color: var(--text-3); flex-wrap: wrap; }

.hero-console {
    position: relative; border-radius: var(--radius-lg); background: var(--glass); border: 1px solid var(--border-strong);
    box-shadow: var(--shadow), 0 0 0 1px rgba(47, 217, 255, 0.04), 0 30px 80px -40px var(--accent-glow);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); overflow: hidden;
}
.console-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); }
.console-head .mono { flex: 1; }
.console-dots { display: flex; gap: 6px; }
.console-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--surface-hover); }
.console-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; font-size: 13.5px; }
.console-msg { line-height: 1.6; }
.console-user { align-self: flex-end; max-width: 85%; padding: 10px 14px; border-radius: 14px 14px 4px 14px; background: var(--surface-2); border: 1px solid var(--border); }
.console-file { align-self: flex-end; display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); padding: 6px 10px; border-radius: 8px; border: 1px dashed var(--border-strong); }
.console-file span { color: var(--text-3); font-family: var(--mono); font-size: 11px; }
.console-ai { padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.console-ai ul { margin: 8px 0 0; padding-left: 18px; color: var(--text-2); }
.console-ai li { margin: 4px 0; }
.console-ai em { color: var(--text-3); font-style: normal; font-size: 12px; }
.console-label { font-size: 10.5px; letter-spacing: 0.2em; color: var(--accent); margin-bottom: 6px; }
.console-foot { display: flex; gap: 18px; padding: 11px 18px; border-top: 1px solid var(--border); font-size: 10.5px; color: var(--text-3); letter-spacing: 0.1em; }

.section { max-width: 1240px; margin: 0 auto; padding: clamp(48px, 8vw, 96px) clamp(18px, 4vw, 48px); }
.section-head { max-width: 640px; margin-bottom: 44px; display: flex; flex-direction: column; gap: 12px; }
.section-head h2 { font-size: clamp(26px, 3.2vw, 38px); letter-spacing: -0.03em; }

.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.pillar { position: relative; padding: 30px 26px 32px; background: var(--bg); display: flex; flex-direction: column; gap: 12px; transition: background var(--mid); }
.pillar:hover { background: var(--bg-elev); }
.pillar-index { font-size: 11px; color: var(--text-3); }
.pillar-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); margin: 8px 0 6px; }
.pillar-name { font-size: 12px; letter-spacing: 0.24em; color: var(--text-2); }
.pillar-verb { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; }
.pillar p { color: var(--text-2); font-size: 13.5px; }
.pillar .tag { position: absolute; top: 26px; right: 22px; }

.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.feature { padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); transition: border-color var(--mid), transform var(--mid) var(--ease), background var(--mid); }
.feature:hover { border-color: var(--accent-line); transform: translateY(-2px); background: var(--surface-2); }
.feature-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: var(--accent); background: var(--accent-soft); margin-bottom: 16px; }
.feature h3 { font-size: 15px; margin-bottom: 6px; }
.feature p { font-size: 13px; color: var(--text-2); }
.features-3 { grid-template-columns: repeat(3, 1fr); }

.engineering { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 5vw, 64px); align-items: center; padding: clamp(28px, 4vw, 48px); border-radius: var(--radius-xl); border: 1px solid var(--border); background: linear-gradient(180deg, var(--surface-2), transparent); }
.engineering-copy { display: flex; flex-direction: column; gap: 14px; }
.engineering-copy h2 { font-size: clamp(24px, 2.8vw, 34px); }
.stack { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.stack span { font-size: 11px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border-strong); color: var(--text-2); letter-spacing: 0.06em; }
.capability-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.capability { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; }
.capability i { width: 6px; height: 6px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); flex-shrink: 0; }
.steps { list-style: none; display: flex; flex-direction: column; gap: 18px; margin-top: 10px; padding: 0; }
.steps li { display: grid; grid-template-columns: 36px 1fr; gap: 14px; align-items: start; }
.step-num { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.steps b { display: block; font-size: 15px; margin-bottom: 2px; }
.steps span { color: var(--text-2); font-size: 13.5px; }

.cta-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: clamp(40px, 6vw, 72px) 24px; border-radius: var(--radius-xl); border: 1px solid var(--border); background: radial-gradient(500px 220px at 50% 0%, var(--accent-glow), transparent 70%), var(--surface); }
.cta-card h2 { font-size: clamp(26px, 3.2vw, 38px); }
.cta-card .btn { margin-top: 10px; }

.site-footer { position: relative; z-index: 1; border-top: 1px solid var(--border); padding: 40px clamp(18px, 4vw, 48px) 28px; margin-top: 40px; }
.footer-inner { max-width: 1240px; margin: 0 auto; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.footer-brand { display: flex; flex-direction: column; gap: 10px; }
.footer-labs { font-family: var(--mono); font-size: 11px; letter-spacing: 0.3em; color: var(--accent); }
.footer-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 13px; color: var(--text-2); }
.footer-meta a { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.footer-meta a:hover { color: var(--accent); }
.footer-bottom { max-width: 1240px; margin: 28px auto 0; padding-top: 18px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-3); gap: 12px; flex-wrap: wrap; }

.auth { display: grid; place-items: center; min-height: calc(100vh - 68px - 180px); padding: 48px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 36px 32px; border-radius: var(--radius-xl); background: var(--glass); border: 1px solid var(--border-strong); box-shadow: var(--shadow); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); animation: fadeUp 500ms var(--ease) both; }
.auth-brand { display: flex; flex-direction: column; gap: 8px; margin-bottom: 28px; }
.auth-sub { font-size: 10.5px; letter-spacing: 0.3em; color: var(--text-3); }
.auth-card h1 { font-size: 24px; margin-bottom: 8px; }
.auth-card > p { margin-bottom: 24px; font-size: 13.5px; }
.auth-form { display: flex; flex-direction: column; }
.auth-form .hint { margin-top: 10px; text-align: center; }
.auth-back { display: inline-flex; align-items: center; gap: 4px; margin-top: 22px; font-size: 12.5px; color: var(--text-3); }

/* ---------- 8. App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar);
    display: flex; flex-direction: column; gap: 14px; padding: 16px 12px;
    background: var(--bg-elev); border-right: 1px solid var(--border);
    transition: transform var(--mid) var(--ease), width var(--mid) var(--ease);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 6px; }
.sidebar-close { display: none; }
.command-trigger {
    display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-3); cursor: pointer; font-size: 13px;
    transition: border-color var(--fast), color var(--fast);
}
.command-trigger:hover { border-color: var(--border-strong); color: var(--text-2); }
.command-trigger-text { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.nav-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em; color: var(--text-3); padding: 14px 10px 6px; }
.nav-item {
    position: relative; display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 10px; border-radius: 9px;
    color: var(--text-2); font-size: 13.5px; font-weight: 450; transition: background var(--fast), color var(--fast);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active .icon { color: var(--accent); }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 2px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.sidebar-bottom { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.labs-mark { display: flex; align-items: center; gap: 8px; padding: 0 10px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.3em; color: var(--text-3); }
.labs-dot { width: 5px; height: 5px; border-radius: 1px; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); }
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-logout { margin: 0; }
.avatar { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; overflow: hidden; background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: var(--accent-ink); font-size: 12px; font-weight: 600; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 56px; height: 56px; border-radius: 14px; font-size: 18px; }

.credit-meter { padding: 10px 10px 12px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.credit-head { display: flex; align-items: center; justify-content: space-between; }
.credit-label { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--text-3); }
.credit-label .icon { color: var(--accent); }
.credit-value { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.credit-value small { color: var(--text-3); font-weight: 400; }
.credit-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.credit-pill .icon { color: var(--accent); }

.drawer-scrim { display: none; }
.app-main { flex: 1; min-width: 0; margin-left: var(--sidebar); display: flex; flex-direction: column; min-height: 100vh; transition: margin var(--mid) var(--ease); }
.topbar { display: none; }
.app-content { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 32px clamp(18px, 3vw, 40px) 48px; animation: fadeIn 300ms var(--ease) both; }
.app-content:has(> .chat-layout) { max-width: none; padding: 0; }
.bottom-nav { display: none; }

/* ---------- 9. Page elements ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-header-text { display: flex; flex-direction: column; gap: 8px; max-width: 720px; }
.page-header h1 { font-size: clamp(22px, 2.4vw, 30px); letter-spacing: -0.03em; }
.page-header p { color: var(--text-2); font-size: 14px; }
.page-header-actions { display: flex; gap: 10px; align-items: center; }

.card { padding: 20px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); margin-bottom: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h3 { font-size: 15.5px; margin-top: 4px; }

.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.stats-grid-6 { grid-template-columns: repeat(6, 1fr); }
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card { padding: 16px 16px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; transition: border-color var(--mid); animation: fadeUp 400ms var(--ease) both; }
.stat-card:hover { border-color: var(--border-strong); }
.stat-head { display: flex; justify-content: space-between; align-items: center; }
.stat-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--text-3); }
.stat-icon { color: var(--text-3); }
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12px; color: var(--text-3); }
.stat-card .meter { margin-top: 4px; }

.grid-2-1 { display: grid; grid-template-columns: 1.7fr 1fr; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2-1 > .card, .grid-2 > .card { margin-bottom: 16px; }

.chart { position: relative; }
.chart-svg { width: 100%; height: 180px; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 5; vector-effect: non-scaling-stroke; }
.chart-bar { fill: var(--accent-line); transition: fill var(--fast); }
.chart-bar.is-current { fill: var(--accent); }
.chart-bar-group:hover .chart-bar { fill: var(--accent); }
.chart-labels { display: grid; margin-top: 8px; font-family: var(--mono); font-size: 10px; color: var(--text-3); text-align: center; }
.chart-labels .is-hidden { visibility: hidden; }
.chart-empty { position: absolute; inset: 0 0 24px; display: grid; place-items: center; color: var(--text-3); font-size: 12.5px; z-index: 1; }
.chart-summary { display: flex; gap: 20px; margin-top: 14px; font-size: 11px; color: var(--text-3); letter-spacing: 0.08em; }

.quick-actions { display: flex; flex-direction: column; gap: 6px; }
.quick-action { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 11px; border: 1px solid transparent; transition: all var(--fast); }
.quick-action:hover { background: var(--surface-hover); border-color: var(--border); color: var(--text); }
.quick-action > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.quick-action b { font-weight: 500; font-size: 13.5px; }
.quick-action small { color: var(--text-3); font-size: 12px; }
.quick-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }

.activity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.activity-item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: 0; }
.activity-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); background: var(--surface-2); flex-shrink: 0; }
.activity-icon.is-error { color: var(--danger); background: var(--danger-soft); }
.activity-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
.activity-text b { font-weight: 500; }
.activity-text a, .activity-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.activity-text a:hover { color: var(--accent); }
.activity-time { font-size: 11px; color: var(--text-3); white-space: nowrap; }

.section-block { margin-bottom: 32px; }
.section-label { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-box .input { padding-left: 36px; }

/* ---------- 10. Empty & error states ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 44px 20px; border-radius: var(--radius-lg); border: 1px dashed var(--border-strong); animation: fadeIn 300ms var(--ease) both; }
.empty-icon { width: 54px; height: 54px; border-radius: 15px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); margin-bottom: 6px; }
.empty-title { font-size: 17px; }
.empty-desc { color: var(--text-2); font-size: 13.5px; max-width: 42ch; }
.empty-actions { margin-top: 10px; display: flex; gap: 10px; }

.error-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: clamp(64px, 12vw, 140px) 20px; animation: fadeUp 500ms var(--ease) both; }
.error-compact { padding: 48px 20px; }
.error-code { font-family: var(--mono); font-size: 12px; letter-spacing: 0.3em; color: var(--accent); padding: 6px 12px; border-radius: 6px; border: 1px solid var(--accent-line); background: var(--accent-soft); }
.error-signal { display: flex; gap: 4px; align-items: flex-end; height: 22px; margin: 6px 0; }
.error-signal span { width: 4px; border-radius: 2px; background: var(--border-strong); animation: signal 1.6s var(--ease) infinite; }
.error-signal span:nth-child(1) { height: 6px; }
.error-signal span:nth-child(2) { height: 10px; animation-delay: 100ms; }
.error-signal span:nth-child(3) { height: 14px; animation-delay: 200ms; }
.error-signal span:nth-child(4) { height: 18px; animation-delay: 300ms; }
.error-signal span:nth-child(5) { height: 22px; animation-delay: 400ms; }
.error-title { font-family: var(--mono); font-size: clamp(20px, 2.8vw, 28px); letter-spacing: 0.12em; font-weight: 600; }
.error-desc { color: var(--text-2); max-width: 46ch; }
.error-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- 11. Chat ---------- */
.chat-layout { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }
.chat-sidebar { border-right: 1px solid var(--border); background: var(--bg); min-height: 0; display: flex; flex-direction: column; }
.chat-scrim { display: none; }
.conv-list { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.conv-list-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 14px 12px; gap: 8px; }
.conv-scroll { flex: 1; overflow-y: auto; padding: 0 8px 20px; }
.conv-group { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; color: var(--text-3); padding: 14px 8px 6px; text-transform: uppercase; }
.conv-item { position: relative; display: flex; align-items: center; gap: 4px; border-radius: 8px; transition: background var(--fast); }
.conv-item:hover { background: var(--surface-hover); }
.conv-item.is-active { background: var(--accent-soft); }
.conv-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; padding: 8px 8px; font-size: 13px; color: var(--text-2); }
.conv-item.is-active .conv-link { color: var(--text); }
.conv-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-actions { display: none; padding-right: 4px; }
.conv-item:hover .conv-actions, .conv-item.is-active .conv-actions { display: flex; }
.conv-item .input { margin: 3px 0 3px 4px; }
.conv-empty { padding: 20px 16px; color: var(--text-3); font-size: 12.5px; line-height: 1.6; }

.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; position: relative; }
.chat-head { display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 18px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); flex-shrink: 0; }
.chat-list-toggle { display: none; }
.chat-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.chat-title-text { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-actions { display: flex; align-items: center; gap: 6px; }
.agent-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 7px; font-size: 12px; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); white-space: nowrap; }

.chat-messages { flex: 1; overflow-y: auto; padding: 28px clamp(16px, 4vw, 40px) 24px; scroll-behavior: smooth; }
.chat-thread { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 26px; }

.chat-welcome { max-width: 760px; margin: clamp(20px, 8vh, 90px) auto 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; animation: fadeUp 500ms var(--ease) both; }
.chat-welcome h2 { font-size: clamp(22px, 3vw, 30px); letter-spacing: -0.03em; }
.welcome-mark { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border-strong); margin-bottom: 6px; box-shadow: 0 0 40px -10px var(--accent-glow); }
.welcome-mark .logo-mark { width: 30px; height: 30px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 22px; }
.suggestion { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: all var(--fast); }
.suggestion:hover { border-color: var(--accent-line); background: var(--surface-2); }
.suggestion b { font-weight: 500; font-size: 13.5px; }
.suggestion span { font-size: 12px; color: var(--text-3); }
.agent-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.agent-hero p { max-width: 52ch; }

.msg { display: flex; gap: 14px; animation: fadeUp 320ms var(--ease) both; }
.msg-user { justify-content: flex-end; }
.msg-avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); flex-shrink: 0; }
.msg-avatar .logo-mark { width: 17px; height: 17px; }
.msg-body { min-width: 0; max-width: 100%; }
.msg-user .msg-body { max-width: min(80%, 620px); display: flex; flex-direction: column; align-items: flex-end; }
.msg-ai .msg-body { flex: 1; }
.msg-text { white-space: pre-wrap; word-wrap: break-word; padding: 11px 15px; border-radius: 16px 16px 4px 16px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14.5px; }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; justify-content: flex-end; }
.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity var(--fast); min-height: 28px; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
.msg-meta { font-size: 10.5px; color: var(--text-3); margin-left: 8px; letter-spacing: 0.06em; }
.msg-actions .tag { margin-left: 6px; }
.msg-edit { width: min(620px, 100%); display: flex; flex-direction: column; gap: 8px; }
.msg-edit-actions { display: flex; justify-content: flex-end; gap: 8px; }
.msg-error { display: flex; gap: 12px; padding: 13px 15px; border-radius: 12px; border: 1px solid rgba(248, 113, 113, 0.3); background: var(--danger-soft); color: var(--text-2); font-size: 13.5px; }
.msg-error .icon { color: var(--danger); flex-shrink: 0; margin-top: 2px; }
.msg-error b { color: var(--text); font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; font-weight: 600; }

.file-chip { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 6px 0 9px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; max-width: 260px; }
.file-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip small { color: var(--text-3); font-family: var(--mono); font-size: 10.5px; }
.file-chip img { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; }

.thinking { display: inline-flex; align-items: center; gap: 5px; height: 30px; color: var(--text-3); font-size: 12.5px; }
.thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s var(--ease) infinite; }
.thinking span:nth-child(2) { animation-delay: 140ms; }
.thinking span:nth-child(3) { animation-delay: 280ms; }
.thinking em { font-style: normal; margin-left: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; }

.stream-cursor { display: inline-block; width: 8px; height: 16px; margin-left: 2px; vertical-align: -3px; background: var(--accent); border-radius: 1px; animation: blink 1s steps(2) infinite; box-shadow: 0 0 8px var(--accent-glow); }
.msg-ai.is-streaming .md > :last-child { display: inline; }

/* Markdown */
.md { font-size: 14.5px; line-height: 1.72; color: var(--text); word-wrap: break-word; }
.md > * + * { margin-top: 0.85em; }
.md h1, .md h2, .md h3, .md h4 { margin-top: 1.4em; margin-bottom: 0.2em; letter-spacing: -0.015em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.28em; } .md h3 { font-size: 1.12em; } .md h4 { font-size: 1em; }
.md > :first-child { margin-top: 0; }
.md p { margin: 0; }
.md ul, .md ol { padding-left: 1.4em; margin: 0; }
.md li + li { margin-top: 0.3em; }
.md li::marker { color: var(--text-3); }
.md a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
.md strong { font-weight: 600; color: var(--text); }
.md blockquote { margin: 0; padding: 4px 0 4px 16px; border-left: 2px solid var(--accent-line); color: var(--text-2); }
.md hr { border: 0; height: 1px; background: var(--border); margin: 1.4em 0; }
.md :not(pre) > code { padding: 2px 6px; border-radius: 5px; font-size: 0.86em; background: var(--surface-hover); border: 1px solid var(--border); }
.md table { width: 100%; border-collapse: collapse; font-size: 13.5px; display: block; overflow-x: auto; }
.md th, .md td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; }
.md input[type="checkbox"] { accent-color: var(--accent); margin-right: 6px; }

pre, .md pre {
    position: relative; margin: 0; padding: 38px 16px 16px; border-radius: 12px; overflow-x: auto;
    background: var(--code-bg); border: 1px solid var(--border-strong); color: #d6deeb;
    font-size: 13px; line-height: 1.6;
}
.md pre + *, * + .md pre { margin-top: 1em; }
pre code { font-size: inherit; background: none !important; padding: 0 !important; border: 0 !important; white-space: pre; }
pre::before { content: attr(data-lang); position: absolute; top: 10px; left: 16px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: #6b7a90; }
pre:not(.code-block) { padding-top: 16px; }
.code-copy { position: absolute; top: 7px; right: 8px; height: 24px; padding: 0 9px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.04); color: #93a1b5; font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; cursor: pointer; transition: all var(--fast); }
.code-copy:hover { color: #fff; border-color: rgba(255,255,255,0.22); }
.code-copy.is-copied { color: #34d399; border-color: rgba(52, 211, 153, 0.4); }

/* highlight.js tokens (brand palette) */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-type { color: #7cc4ff; }
.hljs-string, .hljs-attr + .hljs-string, .hljs-regexp { color: #a5e4b8; }
.hljs-number, .hljs-literal, .hljs-symbol { color: #f5b97a; }
.hljs-comment, .hljs-quote { color: #5c6b80; font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #2fd9ff; }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-variable, .hljs-template-variable { color: #c7b8ff; }
.hljs-meta, .hljs-doctag { color: #8fa2bd; }
.hljs-params { color: #d6deeb; }
.hljs-deletion { color: #f87171; } .hljs-addition { color: #34d399; }

/* Composer */
.composer-wrap { position: relative; padding: 0 clamp(16px, 4vw, 40px) 18px; flex-shrink: 0; }
.composer-wrap > * { max-width: 820px; margin-left: auto; margin-right: auto; }
.composer {
    position: relative; display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 8px;
    border-radius: 16px; border: 1px solid var(--border-strong); background: var(--bg-elev);
    box-shadow: var(--shadow-soft); transition: border-color var(--fast), box-shadow var(--fast);
}
.composer:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-soft); }
.composer-input { flex: 1; min-width: 0; min-height: 38px; max-height: 220px; padding: 8px 4px; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); font: inherit; font-size: 14.5px; line-height: 1.55; }
.composer-input::placeholder { color: var(--text-3); }
.composer-attach { position: relative; overflow: hidden; cursor: pointer; }
.composer-attach input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.send-btn { width: 38px; height: 38px; border-radius: 11px; border: 0; display: grid; place-items: center; flex-shrink: 0; cursor: pointer; background: var(--accent); color: var(--accent-ink); transition: filter var(--fast), opacity var(--fast), transform var(--fast); }
.send-btn:hover:not(:disabled) { filter: brightness(1.1); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.send-btn.is-stop { background: var(--text); color: var(--bg); }
.composer-hint { display: flex; justify-content: space-between; margin-top: 8px; font-size: 10px; letter-spacing: 0.12em; color: var(--text-3); padding: 0 6px; }
.composer-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.composer-inline { margin-top: 14px; }
.composer-inline .composer-input { min-height: 38px; padding: 8px 10px; }
.drop-overlay { display: none; }
.composer-wrap.is-dragging .drop-overlay { display: flex; position: absolute; inset: -8px clamp(8px, 3vw, 32px) 10px; z-index: 5; align-items: center; justify-content: center; gap: 10px; border-radius: 16px; border: 1.5px dashed var(--accent); background: color-mix(in srgb, var(--bg) 88%, transparent); color: var(--accent); font-size: 13px; max-width: none; }

/* Model selector / dropdown */
.model-selector { position: relative; }
.model-trigger { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12.5px; cursor: pointer; }
.model-trigger:hover:not(:disabled) { border-color: var(--border-strong); }
.model-trigger:disabled { opacity: 0.6; cursor: default; }
.model-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.dropdown-backdrop { position: fixed; inset: 0; z-index: 49; }
.dropdown { position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; min-width: 290px; padding: 6px; border-radius: 13px; background: var(--bg-elev); border: 1px solid var(--border-strong); box-shadow: var(--shadow); animation: fadeDown 180ms var(--ease) both; }
.dropdown-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; color: var(--text-3); padding: 8px 10px 6px; }
.model-option { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.model-option:hover:not(:disabled) { background: var(--surface-hover); }
.model-option:disabled { cursor: not-allowed; opacity: 0.5; }
.model-option.is-selected { background: var(--accent-soft); }
.model-option-main { flex: 1; display: flex; flex-direction: column; }
.model-option-name { font-size: 13px; font-weight: 500; }
.model-option-desc { font-size: 11.5px; color: var(--text-3); }

/* ---------- 12. Documents / Vision / Q&A ---------- */
.docs-layout { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.docs-list { display: flex; flex-direction: column; gap: 12px; }
.dropzone {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
    min-height: 140px; padding: 22px; border-radius: var(--radius-lg); border: 1.5px dashed var(--border-strong); background: var(--surface);
    color: var(--text-2); transition: all var(--mid) var(--ease); cursor: pointer;
}
.dropzone .icon { color: var(--accent); }
.dropzone b { color: var(--text); font-weight: 500; font-size: 13.5px; }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.dropzone:hover, .dropzone.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.is-busy { pointer-events: none; }
.retention-note { display: flex; gap: 8px; align-items: flex-start; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.retention-note .icon { flex-shrink: 0; margin-top: 2px; }
.doc-items { display: flex; flex-direction: column; gap: 6px; }
.doc-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 10px 11px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); text-align: left; cursor: pointer; transition: all var(--fast); }
.doc-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.doc-item.is-active { border-color: var(--accent-line); background: var(--accent-soft); }
.doc-type { font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.08em; width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-elev-2); border: 1px solid var(--border-strong); color: var(--accent); flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-info b { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-info small { font-size: 11.5px; color: var(--text-3); }
.doc-panel { min-height: 560px; padding: 22px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; }
.doc-panel > .empty-state { margin: auto 0; border: 0; }
.doc-head { display: flex; align-items: flex-start; gap: 12px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.doc-head > div { flex: 1; min-width: 0; }
.doc-head h2 { font-size: 20px; margin: 4px 0; word-break: break-word; }
.doc-meta { font-size: 11px; color: var(--text-3); letter-spacing: 0.06em; }
.doc-back { display: none; }

.qa-thread { flex: 1; min-height: 240px; max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding-right: 4px; }
.qa-intro { display: flex; flex-direction: column; gap: 14px; padding: 8px 0; }
.qa-q { display: flex; justify-content: flex-end; }
.qa-q span { max-width: 80%; padding: 10px 14px; border-radius: 14px 14px 4px 14px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; white-space: pre-wrap; }
.qa-a { display: flex; gap: 12px; animation: fadeUp 300ms var(--ease) both; }
.qa-answer { flex: 1; min-width: 0; }
.qa-answer .msg-actions { opacity: 1; }

.vision-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.vision-stage { display: flex; flex-direction: column; gap: 12px; }
.dropzone-stage { min-height: 420px; }
.dropzone-stage.has-image { padding: 10px; background: var(--code-bg); border-style: solid; }
.vision-image { max-height: 560px; width: auto; max-width: 100%; margin: 0 auto; border-radius: 10px; object-fit: contain; }
.vision-file { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.vision-file span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vision-chat { display: flex; flex-direction: column; min-height: 520px; }

/* ---------- 13. Structured AI ---------- */
.structured-layout { display: grid; grid-template-columns: 1.05fr 1fr; gap: 16px; align-items: start; }
.structured-left { display: flex; flex-direction: column; }
.structured-left .card .input + .input { margin-top: 10px; }
.structured-left > .btn { margin-bottom: 16px; }
.structured-output { position: sticky; top: 20px; }
.json-view pre { max-height: 560px; min-height: 260px; }
.validation-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--warning); }
.validation-list li { display: flex; gap: 6px; align-items: center; }
.structured-output .row-actions { margin-top: 14px; }
.schema-fields { display: flex; flex-direction: column; gap: 10px; }
.schema-fields.depth-2, .schema-fields.depth-3 { margin: 10px 0 0 14px; padding-left: 14px; border-left: 1px dashed var(--border-strong); }
.schema-field { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); }
.schema-row { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.schema-row .field { margin: 0; }
.schema-row .field-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.schema-row .toggle { height: 32px; font-size: 11.5px; }
.schema-desc { font-size: 12.5px; }
.schema-add { align-self: flex-start; }

/* ---------- 14. Agents & Prompts ---------- */
.agent-grid, .prompt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.agent-card, .prompt-card { display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); transition: border-color var(--mid), transform var(--mid) var(--ease), background var(--mid); animation: fadeUp 400ms var(--ease) both; }
.agent-card:hover, .prompt-card:hover { border-color: var(--border-strong); transform: translateY(-2px); background: var(--surface-2); }
.agent-card.is-official { background: linear-gradient(180deg, var(--accent-soft), transparent 55%), var(--surface); border-color: var(--accent-line); }
.agent-card h3, .prompt-card h3 { font-size: 15.5px; }
.agent-card p, .prompt-card p { font-size: 13px; color: var(--text-2); flex: 1; }
.agent-card-head, .prompt-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prompt-card-head .star { margin-left: auto; }
.agent-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--border); }
.agent-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: var(--accent); background: var(--bg-elev-2); border: 1px solid var(--border-strong); }
.agent-icon-lg { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 0 40px -12px var(--accent-glow); }
.prompt-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.star.is-on { color: var(--warning); }
.star.is-on svg { fill: currentColor; }

.editor-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.editor-form { margin: 0; }
.editor-preview { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 10px; }
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, 44px); gap: 6px; }
.icon-choice { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; transition: all var(--fast); }
.icon-choice:hover { border-color: var(--border-strong); color: var(--text); }
.icon-choice.is-selected { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tool-option { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: all var(--fast); }
.tool-option input { position: absolute; opacity: 0; pointer-events: none; }
.tool-option .icon { color: var(--text-3); flex-shrink: 0; margin-top: 2px; }
.tool-option span { display: flex; flex-direction: column; gap: 3px; }
.tool-option b { font-weight: 500; font-size: 13.5px; }
.tool-option small { font-size: 12px; color: var(--text-3); }
.tool-option.is-selected { border-color: var(--accent-line); background: var(--accent-soft); }
.tool-option.is-selected .icon { color: var(--accent); }

/* ---------- 15. Timeline / Settings ---------- */
.timeline { display: flex; flex-direction: column; gap: 28px; max-width: 820px; }
.timeline-date { font-size: 13px; font-family: var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-2); margin-bottom: 10px; }
.timeline ol { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline ol::before { content: ""; position: absolute; left: 67px; top: 12px; bottom: 12px; width: 1px; background: var(--border); }
.timeline-item { display: flex; align-items: center; gap: 16px; padding: 9px 0; animation: fadeIn 300ms var(--ease) both; }
.timeline-time { width: 44px; font-size: 12px; color: var(--text-3); text-align: right; }
.timeline-dot { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--bg-elev-2); border: 1px solid var(--border-strong); color: var(--accent); flex-shrink: 0; }
.timeline-body { display: flex; flex-direction: column; min-width: 0; }
.timeline-type { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; color: var(--text-3); text-transform: uppercase; }
.timeline-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.settings { display: flex; flex-direction: column; gap: 4px; max-width: 980px; }
.settings-section { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.settings-label { display: flex; flex-direction: column; gap: 6px; }
.profile-row { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.profile-row .chips { margin-top: 8px; }
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.info-grid > div { display: flex; flex-direction: column; gap: 3px; padding: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.privacy-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 13px; color: var(--text-2); }
.privacy-list li { display: flex; gap: 10px; align-items: flex-start; }
.privacy-list .icon { color: var(--accent); flex-shrink: 0; margin-top: 3px; }
.data-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.data-row:last-child { border-bottom: 0; }
.data-row span { display: flex; flex-direction: column; gap: 2px; }
.data-row b { font-weight: 500; }
.danger-zone { border-color: rgba(248, 113, 113, 0.18); }

.system-strip { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; }
.system-strip > :last-child { margin-left: auto; }

/* ---------- 16. Modal / palette / toasts ---------- */
.modal-backdrop, .palette-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(2, 4, 8, 0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fadeIn 180ms var(--ease) both; }
.modal { position: fixed; z-index: 91; left: 50%; top: 50%; transform: translate(-50%, -50%); width: calc(100% - 32px); max-height: calc(100vh - 48px); display: flex; flex-direction: column; border-radius: var(--radius-xl); background: var(--bg-elev); border: 1px solid var(--border-strong); box-shadow: var(--shadow); animation: modalIn 240ms var(--ease) both; }
.modal-sm { max-width: 440px; } .modal-md { max-width: 560px; } .modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 12px; }
.modal-head h2 { font-size: 18px; margin-top: 4px; }
.modal-body { padding: 8px 22px; overflow-y: auto; }
.modal-body > p { margin-bottom: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; }

.palette { position: fixed; z-index: 91; left: 50%; top: 14vh; transform: translateX(-50%); width: calc(100% - 32px); max-width: 580px; border-radius: 18px; background: var(--glass); border: 1px solid var(--border-strong); box-shadow: var(--shadow), 0 0 80px -30px var(--accent-glow); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); overflow: hidden; animation: fadeDown 200ms var(--ease) both; }
.palette-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 0; }
.palette-title { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.26em; color: var(--accent); }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 10px 16px 14px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.palette-input { flex: 1; height: 36px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; }
.palette-input::placeholder { color: var(--text-3); }
.palette-list { max-height: 360px; overflow-y: auto; padding: 8px; }
.palette-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.palette-item.is-active { background: var(--surface-hover); }
.palette-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.palette-item.is-active .palette-icon { color: var(--accent); background: var(--accent-soft); }
.palette-label { font-size: 14px; font-weight: 500; }
.palette-hint { margin-left: auto; font-size: 12px; color: var(--text-3); }
.palette-empty { padding: 24px; text-align: center; color: var(--text-3); font-size: 13px; }

.toasts { position: fixed; z-index: 120; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 10px 11px 14px; border-radius: 12px; background: var(--bg-elev); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 13px; animation: toastIn 260ms var(--ease) both; }
.toast span { flex: 1; }
.toast-success .icon:first-child { color: var(--success); }
.toast-error { border-color: rgba(248, 113, 113, 0.35); }
.toast-error .icon:first-child { color: var(--danger); }
.toast-warning .icon:first-child { color: var(--warning); }
.toast-info .icon:first-child { color: var(--accent); }

/* ---------- 17. Animations ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeDown { from { opacity: 0; transform: translate(var(--tx, 0), -6px); } to { opacity: 1; transform: translate(var(--tx, 0), 0); } }
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1); } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes blink { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes scan { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dots { from { width: 0; } to { width: 1.4em; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 var(--accent-line); } 100% { box-shadow: 0 0 0 14px transparent; } }
@keyframes signal { 0%, 100% { background: var(--border-strong); } 50% { background: var(--accent); } }
.palette { --tx: -50%; }
.reveal { animation: fadeUp 700ms var(--ease) both; }
.reveal-delay { animation-delay: 150ms; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

/* ---------- 18. Responsive ---------- */
/* Large tablets / small laptops */
@media (max-width: 1280px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .stats-grid-6 { grid-template-columns: repeat(3, 1fr); }
    .features { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet: collapsed icon sidebar */
@media (max-width: 1100px) {
    .sidebar { width: var(--sidebar-collapsed); padding: 16px 10px; align-items: center; }
    .sidebar .logo:not(.logo-collapsed) { display: none; }
    .sidebar .logo-collapsed { display: inline-flex; }
    .sidebar-top { padding: 4px 0 6px; }
    .command-trigger { width: 44px; justify-content: center; padding: 0; }
    .command-trigger-text, .command-trigger kbd { display: none; }
    .nav { width: 100%; align-items: center; }
    .nav-label { display: none; }
    .nav-item { width: 44px; justify-content: center; padding: 0; }
    .nav-item span { display: none; }
    .nav-item.active::before { left: -10px; }
    .sidebar-bottom { width: 100%; align-items: center; }
    .credit-meter, .labs-mark, .user-meta, .user-logout { display: none; }
    .user-chip { padding: 4px; border: 0; background: none; }
    .app-main { margin-left: var(--sidebar-collapsed); }
    .chat-layout { grid-template-columns: 1fr; }
    .chat-sidebar { position: fixed; z-index: 45; top: 0; bottom: 0; left: var(--sidebar-collapsed); width: 290px; transform: translateX(-120%); transition: transform var(--mid) var(--ease); box-shadow: var(--shadow); }
    .chat-layout.list-open .chat-sidebar { transform: none; }
    .chat-layout.list-open .chat-scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(2, 4, 8, 0.45); }
    .chat-list-toggle { display: inline-grid; }
    .hero { grid-template-columns: 1fr; }
    .hero-console { max-width: 620px; }
    .pillars { grid-template-columns: repeat(2, 1fr); }
    .engineering { grid-template-columns: 1fr; }
    .grid-2-1, .grid-2 { grid-template-columns: 1fr; }
    .docs-layout { grid-template-columns: 300px 1fr; }
    .vision-layout, .structured-layout { grid-template-columns: 1fr; }
    .structured-output { position: static; }
    .editor-layout { grid-template-columns: 1fr; }
    .editor-preview { position: static; }
    .settings-section { grid-template-columns: 1fr; gap: 12px; }
}

/* Mobile: drawer + bottom navigation */
@media (max-width: 760px) {
    body { font-size: 14px; }
    .public-links { display: none; }
    .public-nav { height: 60px; }
    .sidebar { width: min(300px, 86vw); padding: 16px 12px; align-items: stretch; transform: translateX(-105%); box-shadow: var(--shadow); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .sidebar .logo:not(.logo-collapsed) { display: inline-flex; }
    .sidebar .logo-collapsed { display: none; }
    .sidebar-top { padding: 4px 8px 6px; }
    .sidebar-close { display: inline-grid; }
    .command-trigger { width: auto; justify-content: flex-start; padding: 0 10px; }
    .command-trigger-text { display: inline; }
    .nav { align-items: stretch; }
    .nav-label { display: block; }
    .nav-item { width: auto; justify-content: flex-start; padding: 0 10px; }
    .nav-item span { display: inline; }
    .sidebar-bottom { align-items: stretch; }
    .credit-meter, .labs-mark, .user-meta, .user-logout { display: flex; }
    .user-meta { display: block; }
    .user-chip { padding: 8px; border: 1px solid var(--border); background: var(--surface); }
    .drawer-open .sidebar { transform: none; }
    .drawer-open .drawer-scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(2, 4, 8, 0.55); animation: fadeIn 200ms both; }
    .app-main { margin-left: 0; padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
    .topbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30; height: var(--topbar); padding: 0 10px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
    .topbar-brand { flex: 1; }
    .topbar-brand .logo-text { font-size: 13px; }
    .topbar-actions { display: flex; align-items: center; gap: 6px; }
    .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 35; left: 0; right: 0; bottom: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg-elev) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border); }
    .bottom-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border: 0; background: none; color: var(--text-3); font-size: 10.5px; cursor: pointer; border-radius: 10px; }
    .bottom-item.active { color: var(--accent); }
    .app-content { padding: 20px 14px 32px; }
    .chat-layout, .chat-main { height: calc(100dvh - var(--topbar) - 62px - env(safe-area-inset-bottom)); }
    .chat-sidebar { left: 0; width: min(300px, 86vw); }
    .chat-head { height: 52px; padding: 0 10px; }
    .chat-messages { padding: 18px 12px; }
    .composer-wrap { padding: 0 10px 10px; }
    .composer-hint { display: none; }
    .composer-input { font-size: 16px; } /* prevents iOS zoom */
    .suggestions { grid-template-columns: 1fr; }
    .msg { gap: 10px; }
    .msg-avatar { display: none; }
    .msg-user .msg-body { max-width: 90%; }
    .msg-actions { opacity: 1; }
    .model-trigger .model-name { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .dropdown { right: -40px; min-width: 260px; }
    .stats-grid, .stats-grid-6, .stats-grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-value { font-size: 22px; }
    .features, .pillars, .capability-grid { grid-template-columns: 1fr; }
    .hero-cta .btn { flex: 1; }
    .docs-layout { grid-template-columns: 1fr; }
    .docs-layout.has-selection .docs-list { display: none; }
    .docs-layout:not(.has-selection) .doc-panel { display: none; }
    .doc-back { display: inline-grid; }
    .doc-head { flex-wrap: wrap; }
    .doc-panel { padding: 16px; min-height: 0; }
    .qa-thread { max-height: none; }
    .dropzone-stage { min-height: 240px; }
    .form-grid, .tool-grid, .info-grid { grid-template-columns: 1fr; }
    .page-header { margin-bottom: 20px; }
    .page-header-actions { width: 100%; }
    .page-header-actions > * { flex: 1; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-box { max-width: none; }
    .tabs { overflow-x: auto; flex-wrap: nowrap; }
    .timeline ol::before { left: 59px; }
    .timeline-time { width: 36px; }
    .toasts { left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); max-width: none; }
    .palette { top: 10vh; }
    .data-row { flex-direction: column; align-items: stretch; }
    .footer-meta { align-items: flex-start; }
    .system-strip > :last-child { margin-left: 0; }
}

/* Headings receive programmatic focus on navigation (accessibility) without a visible ring. */
h1:focus { outline: none; }
.composer-input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1280px) { .stats-grid, .stats-grid-6 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
@media (max-width: 760px) { .stats-grid, .stats-grid-6, .stats-grid-4 { grid-template-columns: repeat(2, 1fr); } }
