:root {
  --bg: #07070d;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.12);
  --text: #eceaf6;
  --muted: #a3a0b8;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --danger: #ff5c7a;
  --radius: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
[hidden] { display: none !important; }

.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40vw 40vw at 10% 0%, rgba(124, 92, 255, .28), transparent 60%),
    radial-gradient(35vw 35vw at 95% 20%, rgba(34, 211, 238, .18), transparent 60%),
    radial-gradient(45vw 45vw at 50% 110%, rgba(236, 72, 153, .14), transparent 60%);
}

.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 30px rgba(0,0,0,.35);
}

/* Top bar */
.topbar {
  position: sticky; top: 12px; z-index: 20;
  margin: 12px; padding: 10px 14px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; letter-spacing: -.01em; }
.brand b { color: var(--accent-2); font-weight: 700; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 0 18px rgba(124,92,255,.6); }
.dataset-name { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; gap: 8px; }

/* Layout: dashboard on the left, chat panel on the right (~22%) */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 22vw, 440px); gap: 12px; padding: 0 12px 12px; align-items: start; }
.main { min-width: 0; display: grid; gap: 12px; align-content: start; }

/* Chat panel */
.chat { position: sticky; top: 84px; height: calc(100vh - 96px); display: flex; flex-direction: column; overflow: hidden; }
.chat-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.chat-title { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
#model-settings summary { cursor: pointer; color: var(--muted); font-size: 12px; }
#model-settings[open] { max-height: 45vh; overflow: auto; }
#model-settings > * + * { margin-top: 10px; }
.messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 100%; padding: 10px 12px; border-radius: 14px; font-size: 13.5px; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 88%; background: linear-gradient(135deg, rgba(124,92,255,.55), rgba(91,140,255,.45)); }
.msg.agent { align-self: stretch; background: var(--glass-strong); border: 1px solid var(--border); }
.msg.agent.error { border-color: rgba(255,92,122,.45); }
.msg.agent.error .insight { color: var(--danger); }
.msg .insight { margin: 0; }
.msg .added { margin: 6px 0 0; font-size: 12px; color: var(--accent-2); cursor: pointer; }
.msg .msg-actions { display: flex; gap: 6px; margin-top: 6px; }
.msg pre.sql { margin: 6px 0 0; padding: 8px; border-radius: 8px; background: rgba(0,0,0,.45); font: 11px/1.5 var(--mono); white-space: pre-wrap; }
.ask { padding: 10px; border-top: 1px solid var(--border); }
.ask-row { display: flex; gap: 6px; }
.ask-row input { flex: 1; min-width: 0; }
@keyframes flash { 0% { box-shadow: 0 0 0 2px var(--accent-2), 0 0 30px rgba(34,211,238,.5); } 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 30px rgba(0,0,0,.35); } }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--glass-strong); color: var(--text);
  font: inherit; text-decoration: none; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: rgba(255,255,255,.14); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5b8cff); border-color: transparent; font-weight: 600; }
.btn.danger { color: var(--danger); border-color: rgba(255,92,122,.4); background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 20px; cursor: pointer; }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field span { font-size: 12px; color: var(--muted); }
input, select {
  width: 100%; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: rgba(0,0,0,.35); color: var(--text); font: inherit;
}
input:focus, select:focus { outline: 2px solid rgba(124,92,255,.6); outline-offset: 1px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.cmd { display: block; margin-top: 6px; padding: 8px; border-radius: 8px; background: rgba(0,0,0,.45); font: 11px/1.4 var(--mono); word-break: break-all; user-select: all; }
.progress { position: relative; height: 22px; margin-top: 8px; border-radius: 8px; background: rgba(0,0,0,.4); overflow: hidden; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; }
.progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; }

/* Empty state */
.drop-zone { padding: 56px 24px; text-align: center; }
.drop-zone h1 { margin: 0 0 8px; font-size: clamp(28px, 5vw, 48px); letter-spacing: -.03em;
  background: linear-gradient(135deg, #fff, #b9a8ff 50%, var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.drop-zone p { color: var(--muted); margin: 0 auto 24px; max-width: 560px; }
.drop-target { margin: 0 auto 20px; max-width: 520px; padding: 28px; border: 2px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
body.dragging .drop-target, body.dragging .drop-zone { border-color: var(--accent); }
.cta-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.status { padding: 10px 14px; border-radius: 12px; background: var(--glass); border: 1px solid var(--border); color: var(--muted); }
.status.error { color: var(--danger); border-color: rgba(255,92,122,.4); }

/* Cards */
.dashboard { --kpis: 3; display: grid; grid-auto-flow: row dense; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; align-items: start; container-type: inline-size; }
.card { padding: 14px 16px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head h4 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); flex: 1; }
.card-actions { display: flex; gap: 6px; }
.card .insight { margin: 0; color: var(--text); }
.card .question { margin: 0; font-size: 15px; font-weight: 600; }
.card pre.sql { margin: 0; padding: 10px; border-radius: 10px; background: rgba(0,0,0,.45); font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-x: auto; }
.card .empty { color: var(--muted); padding: 24px 0; text-align: center; }
.card.error { border-color: rgba(255,92,122,.45); }
.card.error .insight { color: var(--danger); }
.kpi-value { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 11px var(--font); }
.table-wrap { overflow: auto; max-height: 360px; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 6px 10px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.06); white-space: nowrap; }
th { position: sticky; top: 0; background: #14131f; color: var(--muted); font-weight: 600; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.steps { font-size: 12px; color: var(--muted); }
.thinking { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.thinking::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Ask bar */
.suggestions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.suggestions:empty { display: none; }
.chip { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--glass); color: var(--muted); cursor: pointer; font: 12px var(--font); }
.chip:hover { color: var(--text); border-color: var(--accent); }

.only-mobile { display: none; }
@media (max-width: 900px) {
  .only-mobile { display: inline-flex; }
  .hide-mobile { display: none; }
  .layout { grid-template-columns: 1fr; }
  .chat { display: none; position: fixed; inset: 0; top: 0; height: 100dvh; z-index: 40; border-radius: 0; background: rgba(14,13,24,.97); }
  body.chat-open .chat { display: flex; }
  .chat-fab { position: fixed; right: 16px; bottom: 16px; z-index: 35; box-shadow: 0 8px 24px rgba(124,92,255,.5); }
  body.chat-open .chat-fab { display: none; }
  .topbar { flex-wrap: wrap; }
}

/* ===== Polish: bento grid, icons, tooltip, motion, a11y ===== */
.card { grid-column: span 6; transition: border-color .2s, background .2s; }
.card.kind-kpi { grid-column: span calc(12 / var(--kpis)); }
.card.kind-line, .card.kind-table { grid-column: span 12; }
@container (max-width: 720px) {
  .card { grid-column: span 12; }
  .card.kind-kpi { grid-column: span 6; }
}
@container (max-width: 420px) { .card.kind-kpi { grid-column: span 12; } }
.card:hover { border-color: rgba(255,255,255,.2); }
.card-head h4 { line-height: 1.3; }
.card-icon { display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 8px; background: rgba(124,92,255,.18); color: #c4b5ff; }
.card.kind-kpi .card-icon { background: rgba(34,211,238,.14); color: var(--accent-2); }
.card.kind-kpi { padding-bottom: 16px; }
.kpi-value { font-variant-numeric: tabular-nums; background: linear-gradient(135deg, #fff, #cfc6ff); -webkit-background-clip: text; background-clip: text; color: transparent; }

.icon { flex: none; display: block; }
.btn .icon { opacity: .9; }
.btn.icon-only { padding: 8px 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); background: none; border: 0; cursor: pointer; }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.08); }
@media (hover: hover) {
  .card-remove { opacity: 0; transition: opacity .15s; }
  .card:hover .card-remove, .card:focus-within .card-remove { opacity: 1; }
}
.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; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
button, label.btn, .chip, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* Top bar */
.dataset { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.dataset-name { flex: none; max-width: 40vw; color: var(--text); font-weight: 600; }
.dataset-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Charts */
.chart .bar { cursor: pointer; transition: filter .15s; }
.chart .bar:hover { filter: brightness(1.25) drop-shadow(0 0 6px rgba(34,211,238,.5)); }
.chart .slice { cursor: pointer; transition: filter .15s; }
.chart .slice:hover { filter: brightness(1.2); }
.chart .hit { cursor: pointer; }
.tip { position: fixed; z-index: 100; pointer-events: none; padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 500;
  background: rgba(18,16,30,.96); border: 1px solid rgba(255,255,255,.16); box-shadow: 0 8px 24px rgba(0,0,0,.45); white-space: nowrap; }
tbody tr:nth-child(even) td { background: rgba(255,255,255,.02); }
tbody tr:hover td { background: rgba(124,92,255,.08); }

/* Empty state */
.drop-target { display: flex; flex-direction: column; align-items: center; gap: 8px; transition: border-color .2s, background .2s; }
.drop-target .icon { color: var(--accent); }
body.dragging .drop-target { background: rgba(124,92,255,.08); }
.cta-row .btn { padding: 10px 16px; }
.features { list-style: none; padding: 0; margin: 28px auto 0; max-width: 820px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: left; }
.feature { display: flex; gap: 10px; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--border); }
.feature .icon { color: var(--accent-2); margin-top: 2px; }
.feature b { display: block; font-size: 13px; }
.feature span { color: var(--muted); font-size: 12px; }

/* Chat */
.chat-name { display: inline-flex; align-items: center; gap: 8px; }
.avatar { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 0 12px rgba(124,92,255,.5); }
#model-settings summary { display: inline-flex; align-items: center; gap: 6px; list-style: none; }
#model-settings summary::-webkit-details-marker { display: none; }
.msg.agent { position: relative; margin-left: 30px; }
.msg.agent::before { content: ""; position: absolute; left: -30px; top: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 0 10px rgba(124,92,255,.4); }
.msg.agent.error::before { background: linear-gradient(135deg, #ff5c7a, #f472b6); }
.msg.pending { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.msg.pending .thinking::before { display: none; }
.typing { display: inline-flex; gap: 4px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-2); opacity: .5; }
.msg .added { display: inline-flex; align-items: center; gap: 4px; }
.msg .added:hover { text-decoration: underline; }
.ask-row input { padding: 11px 12px; }
.chip { transition: color .15s, border-color .15s, background .15s; }
.chip:hover { background: rgba(124,92,255,.12); }

/* Skeleton */
.skeleton { pointer-events: none; padding: 14px 16px; grid-column: span 6; }
.skeleton.sk-kpi { grid-column: span 4; }
.skeleton.sk-line { grid-column: span 12; }
.sk { border-radius: 8px; background: rgba(255,255,255,.06); }
.sk-title { height: 12px; width: 40%; margin-bottom: 14px; }
.sk-body { height: 150px; }
.skeleton.sk-kpi .sk-body { height: 38px; width: 60%; }
.skeleton.sk-line .sk-body { height: 220px; }

@media (prefers-reduced-motion: no-preference) {
  .card { animation: rise .45s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 45ms); }
  .card.flash { animation: flash 1.6s ease-out; }
  .chart .bar { transform-box: fill-box; transform-origin: left center; animation: growx .7s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 50ms + 120ms); }
  .chart .line-path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s ease-out .15s forwards; }
  .chart .area, .chart .dot { animation: fadein .6s ease-out .6s both; }
  .chart .slice { transform-box: view-box; transform-origin: 110px 110px; animation: pop .5s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 60ms + 100ms); }
  .msg { animation: rise .25s ease-out both; }
  .typing span { animation: bounce 1s infinite ease-in-out; }
  .typing span:nth-child(2) { animation-delay: .15s; }
  .typing span:nth-child(3) { animation-delay: .3s; }
  .sk { background: linear-gradient(90deg, rgba(255,255,255,.04) 0%, rgba(255,255,255,.11) 50%, rgba(255,255,255,.04) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
  .btn:hover { transform: translateY(-1px); }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes growx { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 900px) {
  .features { grid-template-columns: 1fr; }
  .dataset-meta { display: none; }
}
@media (max-width: 600px) {
  .btn-text { display: none; }
  .topbar-actions .btn { padding: 8px 10px; }
}

/* Mobile-only controls stay hidden on desktop, whatever their own display rule. */
@media (min-width: 901px) { .only-mobile { display: none !important; } }
@media (max-width: 900px) { .main { padding-bottom: 72px; } }
.kind-bar .chart svg { max-width: 600px; }

/* ======================= Liquid Glass theme ======================= */
body.glass-theme {
  --text: #ffffff; --muted: rgba(255,255,255,.74); --faint: rgba(255,255,255,.55);
  --border: rgba(255,255,255,.2); --accent: #ffffff; --accent-2: #7dd3fc;
  background-color: #0a0614;
  background-image:
    radial-gradient(45vw 45vw at 8% 12%, rgba(124,58,237,.75), transparent 60%),
    radial-gradient(40vw 40vw at 70% 0%, rgba(37,99,235,.62), transparent 60%),
    radial-gradient(45vw 45vw at 95% 85%, rgba(236,72,153,.52), transparent 60%),
    radial-gradient(40vw 40vw at 35% 100%, rgba(249,115,22,.42), transparent 60%);
  background-attachment: fixed;
}
.glass-theme .bg-glow { display: none; }
/* Glass surfaces. Real blur only on the floating layers (top bar, chat); cards fake it. */
.glass-theme .glass, .glass-theme .card, .glass-theme .preview, .glass-theme .mini, .glass-theme .msg, .glass-theme .feature {
  background: linear-gradient(135deg, rgba(255,255,255,.15), rgba(255,255,255,.05));
  border: 1px solid rgba(255,255,255,.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.42), inset 0 -1px 0 rgba(255,255,255,.05), 0 12px 40px rgba(0,0,0,.28);
}
.glass-theme .card, .glass-theme .drop-zone { backdrop-filter: none; -webkit-backdrop-filter: none; border-radius: 22px; }
.glass-theme .topbar, .glass-theme .chat { backdrop-filter: blur(28px) saturate(180%); -webkit-backdrop-filter: blur(28px) saturate(180%);
  background: linear-gradient(135deg, rgba(255,255,255,.16), rgba(255,255,255,.06)); }
.glass-theme .topbar { border-radius: 18px; }
.glass-theme .chat { border-radius: 24px; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass-theme .topbar, .glass-theme .chat { background: rgba(40,24,70,.92); }
}
.glass-theme .logo { background: #fff; box-shadow: 0 0 18px rgba(255,255,255,.5); }
.glass-theme .brand b { color: #fff; }
.glass-theme .dataset-name { color: #fff; }
.glass-theme .dataset-meta, .glass-theme .hint, .glass-theme .field span { color: var(--faint); }

/* Buttons and inputs */
.glass-theme .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.26); color: #fff; }
.glass-theme .btn:hover { background: rgba(255,255,255,.22); }
.glass-theme .btn.primary { background: #fff; color: #1b1030; border-color: transparent; }
.glass-theme .btn.primary:hover { background: #f1eaff; }
.glass-theme .btn.danger { color: #fecdd3; border-color: rgba(254,205,211,.45); background: transparent; }
.glass-theme input, .glass-theme select { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.24); color: #fff; }
.glass-theme select option { color: #111; }
.glass-theme input::placeholder { color: rgba(255,255,255,.6); }
.glass-theme :focus-visible { outline-color: #fff; }

/* Empty state: plain white headline, no gradient text */
.glass-theme .drop-zone h1 { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: #fff; text-shadow: 0 4px 30px rgba(255,255,255,.25); }
.glass-theme .drop-zone p { color: var(--muted); }
.glass-theme .drop-target { border-color: rgba(255,255,255,.35); color: var(--muted); }
.glass-theme .drop-target .icon, .glass-theme .feature .icon { color: #fff; }

/* Cards */
.glass-theme .card-head { flex-wrap: wrap; }
.glass-theme .card-head h4 { flex: 0 1 auto; color: #fff; font-weight: 600; }
.card-sub { color: var(--faint); font-size: 12px; }
.card-actions { margin-left: auto; }
.glass-theme .card-icon, .glass-theme .card.kind-kpi .card-icon { background: rgba(255,255,255,.14); color: #fff; }
.tag { font-size: 11px; color: #fff; border: 1px solid rgba(255,255,255,.45); background: rgba(255,255,255,.12); border-radius: 999px; padding: 0 8px; }
.glass-theme .kpi-value { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: #fff; font-size: 32px; text-shadow: 0 2px 20px rgba(255,255,255,.25); }
.kpi-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.delta { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 7px; }
.delta.up { color: #bbf7d0; background: rgba(34,197,94,.24); }
.delta.down { color: #fecaca; background: rgba(239,68,68,.26); }
.spark { color: rgba(255,255,255,.85); flex: none; }
.k-compare { color: var(--faint); font-size: 12px; margin-top: 6px; }
.glass-theme .chart text { fill: rgba(255,255,255,.72); }
.glass-theme .chart .bar.top { filter: drop-shadow(0 0 8px rgba(255,255,255,.55)); }
.glass-theme .chart .line-path { filter: drop-shadow(0 0 6px rgba(255,255,255,.6)); }
.glass-theme .chart .bar:hover { filter: brightness(1.15) drop-shadow(0 0 8px rgba(255,255,255,.6)); }
.glass-theme th { background: rgba(28,16,52,.92); color: var(--muted); }
.glass-theme tbody tr:nth-child(even) td { background: rgba(255,255,255,.04); }
.glass-theme tbody tr:hover td { background: rgba(255,255,255,.1); }
.glass-theme .card .insight { color: #fff; }
.glass-theme .tip { background: rgba(30,18,56,.95); border-color: rgba(255,255,255,.3); }
.glass-theme .legend { color: var(--muted); }

/* Chat */
.glass-theme .chat-head, .glass-theme .ask { border-color: rgba(255,255,255,.16); }
.glass-theme .avatar, .glass-theme .msg.agent::before { background: #fff; box-shadow: 0 0 14px rgba(255,255,255,.55); color: #1b1030; }
.glass-theme .msg.user { background: linear-gradient(135deg, rgba(255,255,255,.3), rgba(255,255,255,.14)); border: 1px solid rgba(255,255,255,.35); }
.glass-theme .msg.agent { color: #fff; }
.glass-theme .msg.pending { color: #fff; }
.steps { display: flex; flex-direction: column; gap: 5px; margin: 0 0 8px 2px; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.25); font-size: 12.5px; }
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.step .ok { width: 15px; height: 15px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 9px; background: rgba(134,239,172,.22); color: #bbf7d0; }
.step.failed .ok { background: rgba(239,68,68,.28); color: #fecaca; }
.step.running { color: #fff; }
.step .t { margin-left: auto; color: var(--faint); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.spin { width: 12px; height: 12px; flex: none; border-radius: 50%; border: 2px solid #fff; border-top-color: transparent; }
@media (prefers-reduced-motion: no-preference) { .spin { animation: spin .8s linear infinite; } }
.steps-note { font-size: 12px; color: var(--faint); margin-top: 4px; }
.preview { border-radius: 14px; overflow: hidden; font-size: 12px; }
.preview .ph { display: flex; gap: 8px; align-items: baseline; padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.14); color: var(--muted); }
.preview .ph b { color: #fff; font-weight: 600; }
.preview .types { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 10px; }
.col-chip { font-size: 11px; color: #fff; background: rgba(255,255,255,.12); border-radius: 6px; padding: 1px 7px; }
.mini { margin-top: 8px; padding: 8px 10px; border-radius: 12px; }
.mini svg { display: block; width: 100%; height: auto; max-height: 90px; }
.mini svg text { fill: rgba(255,255,255,.7); }
.mini .ft { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--faint); }
.mini .ft span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini .ft .added { color: #7dd3fc; text-decoration: none; white-space: nowrap; }
.mini .ft .added:hover { text-decoration: underline; }
.cols { margin-top: 8px; font-size: 12px; color: var(--faint); }
.cols code { font: 11px var(--mono); color: #fff; background: rgba(255,255,255,.14); padding: 1px 6px; border-radius: 5px; margin-left: 4px; }
.msg-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.glass-theme .msg-actions .btn { padding: 3px 9px; font-size: 12px; background: rgba(255,255,255,.08); }
.next { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.next-q { text-align: left; font: 12.5px var(--font); color: #fff; padding: 7px 10px; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.22); }
.next-q::before { content: "→ "; color: #7dd3fc; }
.next-q:hover { background: rgba(255,255,255,.16); }
.glass-theme .chip { color: #fff; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.24); }
.glass-theme #model-settings summary { color: var(--muted); }
.glass-theme .cmd { background: rgba(0,0,0,.35); }

/* Fixes: sparkline keeps its own size; step rows and the dashboard link never overflow */
.chart svg.spark { width: 88px; height: 28px; }
.step > span:nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.step .t { max-width: none; flex: none; }
.mini .ft .added { white-space: normal; }
@media (max-width: 900px) {
  /* Full-screen chat on phones is a sheet, not a window: keep the dashboard from showing through. */
  .glass-theme .chat { background: linear-gradient(160deg, rgba(48,26,92,.97), rgba(70,22,70,.97)); }
}

/* A settings panel that an error button pointed at */
.provider-panel.attention { border-radius: 12px; outline: 2px solid rgba(125,211,252,.85); outline-offset: 4px; }
@media (prefers-reduced-motion: no-preference) { .provider-panel.attention { animation: attn 1.2s ease-out 2; } }
@keyframes attn { 50% { outline-color: rgba(255,255,255,.25); } }

/* No-key demo label */
.demo-note { margin-top: 8px; font-size: 12px; color: var(--faint); }
.link-btn { background: none; border: 0; padding: 0; color: #7dd3fc; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: #fff; }

/* ===== Dashboard spacing ===== */
.dashboard { gap: 16px; align-items: stretch; }
.card { padding: 18px 20px; gap: 10px; }
.card.kind-kpi { padding: 16px 20px 18px; }
.card.wide { grid-column: span 12; }
/* Header: icon, title, tag and actions on one line; the insight always on its own line below */
.card-head { flex-wrap: wrap; row-gap: 2px; }
.card-actions { order: 1; }
.card-sub { order: 2; flex-basis: 100%; padding-left: 34px; line-height: 1.4; }
/* Charts fill the card so cards in one row line up; text insight stays at the bottom */
.card.kind-bar .chart, .card.kind-donut .chart, .card.kind-line .chart { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.card .insight { margin-top: 2px; line-height: 1.5; }
.card.wide.kind-donut .chart { flex-direction: row; align-items: center; justify-content: center; gap: 40px; }
.card.wide.kind-donut .legend { flex-direction: column; gap: 8px; font-size: 13px; }
@container (max-width: 720px) { .card.wide { grid-column: span 12; } }

/* Privacy badge in the top bar */
.privacy-badge { display: inline-flex; align-items: center; gap: 7px; flex: none; max-width: 46vw; padding: 5px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; color: #fff; background: rgba(34,197,94,.18); border: 1px solid rgba(134,239,172,.45);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.privacy-badge .icon { color: #86efac; }
.privacy-badge.remote { background: rgba(251,191,36,.16); border-color: rgba(253,224,71,.45); }
.privacy-badge.remote .icon { color: #fde68a; }
.privacy-badge span { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) { .privacy-badge { order: 5; flex-basis: 100%; max-width: none; justify-content: center; } }

/* Active-model pill in the header */
.model-pill { display: inline-flex; align-items: center; gap: 8px; flex: none; max-width: 30vw; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  font: 500 12.5px var(--font); color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.28); box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }
.model-pill:hover { background: rgba(255,255,255,.2); }
.model-pill .pill-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-pill .dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: rgba(255,255,255,.5); }
.model-pill[data-tone="ok"] .dot { background: #4ade80; box-shadow: 0 0 8px #4ade80; }
.model-pill[data-tone="warn"] .dot { background: #fbbf24; box-shadow: 0 0 8px #fbbf24; }
.model-pill[data-tone="busy"] .dot { background: #7dd3fc; box-shadow: 0 0 8px #7dd3fc; }
@media (prefers-reduced-motion: no-preference) { .model-pill[data-tone="busy"] .dot { animation: pulse 1s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: .35; } }
.pill-bar { width: 70px; height: 5px; flex: none; border-radius: 99px; background: rgba(255,255,255,.2); overflow: hidden; }
.pill-bar i { display: block; height: 100%; width: 0; background: #7dd3fc; box-shadow: 0 0 8px #7dd3fc; transition: width .3s; }
@media (max-width: 900px) { .model-pill { max-width: none; order: 4; } }

/* ===== Chat history sidebar: history | dashboard | chat ===== */
.layout { --side: 248px; grid-template-columns: var(--side) minmax(0, 1fr) clamp(320px, 22vw, 440px); }
@media (max-width: 1200px) { .layout { --side: 216px; } }
.history { position: sticky; top: 84px; height: calc(100vh - 96px); display: flex; flex-direction: column; gap: 10px; padding: 12px 10px; overflow: hidden; min-width: 0; }
.glass-theme .history { backdrop-filter: blur(28px) saturate(180%); -webkit-backdrop-filter: blur(28px) saturate(180%);
  background: linear-gradient(135deg, rgba(255,255,255,.16), rgba(255,255,255,.06)); border-radius: 24px; }
.history-head { display: flex; align-items: center; gap: 6px; padding: 0 2px; }
.history-title { flex: 1; font-weight: 600; white-space: nowrap; }
.new-chat { justify-content: flex-start; gap: 8px; font-weight: 600; }
.new-chat .plus { font-size: 18px; line-height: 1; width: 16px; text-align: center; }
.history-list { list-style: none; margin: 0 -4px; padding: 0 4px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.conv { position: relative; display: flex; align-items: center; border-radius: 12px; border: 1px solid transparent; transition: background .15s, border-color .15s; }
.conv:hover, .conv:focus-within { background: rgba(255,255,255,.1); }
.conv.active { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.32); box-shadow: inset 0 1px 0 rgba(255,255,255,.3); }
.conv-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border: 0; background: none; color: var(--text); text-align: left; cursor: pointer; font: inherit; border-radius: 12px; }
.conv-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--faint, var(--muted)); }
.conv-actions { display: flex; align-items: center; gap: 0; padding-right: 4px; }
.conv-btn { width: 26px; height: 26px; font-size: 14px; }
.conv-btn.danger { color: #fecdd3; }
.conv-ask { font-size: 12px; color: #fecdd3; padding: 0 2px; white-space: nowrap; }
.conv.confirming { background: rgba(239,68,68,.16); border-color: rgba(254,205,211,.35); }
.conv-edit { margin: 4px; padding: 6px 8px; font-size: 13px; }
.conv-empty { color: var(--faint, var(--muted)); font-size: 12px; padding: 8px 10px; }
@media (hover: hover) {
  .conv:not(.confirming) .conv-actions { opacity: 0; transition: opacity .15s; }
  .conv:hover .conv-actions, .conv:focus-within .conv-actions { opacity: 1; }
}
/* A tiny "sidebar" glyph drawn in CSS (no new icon path needed). */

/* Collapsed to a thin rail (desktop only) */
@media (min-width: 901px) {
  body.history-collapsed .layout { --side: 60px; }
  body.history-collapsed .history { padding: 12px 8px; align-items: center; }
  body.history-collapsed .history-title, body.history-collapsed .history-list, body.history-collapsed .nc-text { display: none; }
  body.history-collapsed .new-chat { width: 40px; height: 40px; padding: 0; justify-content: center; }
}

/* Phones and small tablets: hidden, opened as an overlay from the top-bar menu button */
.history-backdrop { position: fixed; inset: 0; z-index: 44; background: rgba(5,3,12,.55); }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .history { display: none; }
  body.history-open .history { display: flex; position: fixed; top: 0; left: 0; bottom: 0; width: min(320px, 86vw); height: 100dvh; z-index: 45; border-radius: 0 20px 20px 0; }
  .glass-theme.history-open .history { background: linear-gradient(160deg, rgba(48,26,92,.97), rgba(70,22,70,.97)); }
}
@media (min-width: 901px) { .history-backdrop { display: none !important; } }

/* ===== Storage pill + popover ===== */
.storage-pill { display: inline-flex; align-items: center; flex: none; padding: 5px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font: 500 12.5px var(--font); color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.28); box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }
.storage-pill:hover, .storage-pill[aria-expanded="true"] { background: rgba(255,255,255,.2); }
.storage-pop { position: fixed; z-index: 60; width: min(340px, calc(100vw - 24px)); padding: 14px; display: grid; gap: 10px; }
.glass-theme .storage-pop { backdrop-filter: blur(28px) saturate(180%); -webkit-backdrop-filter: blur(28px) saturate(180%);
  background: linear-gradient(160deg, rgba(48,26,92,.94), rgba(40,22,70,.94)); border-radius: 18px; }
.sp-head { display: flex; align-items: center; justify-content: space-between; }
.sp-total { margin: 0; font-size: 15px; font-weight: 600; }
.sp-meter { height: 6px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.sp-meter i { display: block; height: 100%; width: 0; background: #7dd3fc; box-shadow: 0 0 8px #7dd3fc; }
.storage-rows { display: grid; gap: 6px; }
.storage-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--muted); }
.storage-row b { color: #fff; font-weight: 600; white-space: nowrap; }
.storage-pop .hint { margin: 0; }
@media (max-width: 900px) { .storage-pill { order: 4; } }
/* Top bar stays tidy with the extra pill: the dataset line shrinks (ellipsis) instead of overlapping. */
.dataset { overflow: hidden; }
.dataset-name { min-width: 0; flex: 0 1 auto; }
.dataset-meta { min-width: 0; flex: 0 1000 auto; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) { #history-toggle { display: none; } }

/* Brand logo image */
.brand img.logo, .glass-theme .brand img.logo { background: none; border-radius: 7px; box-shadow: 0 0 16px rgba(124,58,237,.55); }

/* Date range switch */
.range-bar { display: flex; align-items: center; gap: 4px; justify-self: end; padding: 4px; border-radius: 12px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); }
.range-bar .range-label { color: var(--faint); font-size: 12px; padding: 0 6px; }
.range-bar button { font: 500 12.5px var(--font); color: rgba(255,255,255,.8); background: none; border: 0; border-radius: 8px; padding: 5px 11px; cursor: pointer; }
.range-bar button:hover { color: #fff; background: rgba(255,255,255,.12); }
.range-bar button[aria-pressed="true"] { color: #1b1030; background: #fff; }

/* Dataset name + size sit in the dashboard header next to the date range, not in the crowded top bar */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 0; }
.dash-head:has(.dataset-name:empty):has(.range-bar[hidden]) { display: none; }
.dash-head .dataset { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.dash-head .dataset-name { font-size: 20px; font-weight: 700; letter-spacing: -.02em; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-head .dataset-meta { display: block; font-size: 13px; }
.dash-head .range-bar { justify-self: auto; flex: none; }
.topbar .brand { margin-right: auto; }

/* Phones: never wider than the screen. The single column must be allowed to shrink below its content. */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .main { min-width: 0; }
  .dash-head { flex-wrap: wrap; }
  .dash-head .range-bar { max-width: 100%; overflow-x: auto; }
  .dash-head .range-label { display: none; }
}
@media (max-width: 900px) { .dash-head .dataset { flex-basis: 100%; } }

/* An answer sentence written for a different date range */
.card .insight.stale { color: var(--faint); font-style: italic; }

/* Brand artwork: header logo, start-screen hero, and the agent's avatar in chat */
.brand img.logo, .glass-theme .brand img.logo { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 0 16px rgba(91,92,255,.55); }
.hero-logo { display: block; margin: 0 auto 18px; width: 128px; height: 128px; border-radius: 28px;
  box-shadow: 0 0 40px rgba(91,92,255,.55), 0 16px 40px rgba(0,0,0,.4); }
.chat-name .avatar, .glass-theme .avatar { width: 28px; height: 28px; padding: 0; background: none; overflow: hidden; border-radius: 8px; box-shadow: 0 0 12px rgba(91,92,255,.55); }
.chat-name .avatar img { display: block; width: 100%; height: 100%; }
.msg.agent::before, .glass-theme .msg.agent::before { width: 24px; height: 24px; top: 4px; left: -30px; border-radius: 7px;
  background: url("../assets/logo-art-128.png") center / cover no-repeat; box-shadow: 0 0 10px rgba(91,92,255,.5); }
.glass-theme .msg.agent.error::before { background: url("../assets/logo-art-128.png") center / cover no-repeat; filter: grayscale(.4); outline: 2px solid rgba(254,202,202,.7); }
@media (max-width: 600px) { .hero-logo { width: 96px; height: 96px; border-radius: 22px; } }

/* ===== In-browser model download card (chat panel) ===== */
.model-card { margin: 12px 14px 0; padding: 16px; border-radius: 18px; display: grid; gap: 12px; position: relative;
  background: linear-gradient(160deg, rgba(124,58,237,.38), rgba(37,99,235,.26) 55%, rgba(236,72,153,.22));
  border: 1px solid rgba(255,255,255,.32);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 10px 30px rgba(76,29,149,.45), 0 0 0 1px rgba(125,211,252,.08); }
.mc-top { display: flex; align-items: center; gap: 12px; }
.mc-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 13px; color: #fff;
  background: linear-gradient(135deg, #7c3aed, #2563eb); box-shadow: 0 0 18px rgba(124,58,237,.7), inset 0 1px 0 rgba(255,255,255,.4); }
.mc-title { display: grid; gap: 2px; min-width: 0; }
.mc-heading { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.mc-sub { font-size: 12.5px; color: rgba(255,255,255,.8); }
.mc-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; color: rgba(255,255,255,.86); }
.mc-points li { display: flex; align-items: center; gap: 8px; }
.mc-points .icon { color: #86efac; flex: none; }
.glass-theme .btn.mc-btn { min-height: 46px; gap: 10px; font-size: 15px; font-weight: 700; color: #fff; border: 0; border-radius: 13px;
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 45%, #0ea5e9 100%);
  box-shadow: 0 8px 24px rgba(99,102,241,.55), inset 0 1px 0 rgba(255,255,255,.45); }
.glass-theme .btn.mc-btn:hover { background: linear-gradient(135deg, #a78bfa 0%, #818cf8 45%, #38bdf8 100%); }
.glass-theme .btn.mc-btn .icon { opacity: 1; }
.mc-progress { display: grid; gap: 6px; }
.mc-bar { height: 10px; border-radius: 99px; background: rgba(0,0,0,.3); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.35); }
.mc-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #a78bfa, #38bdf8);
  box-shadow: 0 0 12px rgba(56,189,248,.8); transition: width .3s ease; }
.mc-meta { display: flex; align-items: baseline; gap: 10px; font-size: 12.5px; color: rgba(255,255,255,.85); }
.mc-pct { font-size: 20px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; min-width: 3ch; }
.mc-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-other { justify-self: center; font-size: 12px; color: rgba(255,255,255,.75); }
@media (prefers-reduced-motion: no-preference) {
  .model-card.busy .mc-bar i { background-size: 200% 100%; background-image: linear-gradient(90deg, #a78bfa, #38bdf8, #a78bfa); animation: shimmer 1.6s linear infinite; }
  .glass-theme .btn.mc-btn { transition: transform .15s, box-shadow .15s; }
  .glass-theme .btn.mc-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(99,102,241,.7), inset 0 1px 0 rgba(255,255,255,.45); }
}
/* The settings-panel button matches */
.glass-theme #webllm-load { min-height: 40px; font-weight: 600; background: linear-gradient(135deg, #8b5cf6, #0ea5e9); border: 0; color: #fff; }

/* Download card: long messages wrap instead of breaking the layout; a calm no-GPU variant */
.mc-meta { flex-wrap: wrap; row-gap: 2px; }
.mc-text { white-space: normal; overflow: visible; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; min-width: 0; flex: 1 1 160px; }
.model-card { min-width: 0; overflow: hidden; }
.model-card.no-gpu { background: linear-gradient(160deg, rgba(255,255,255,.14), rgba(255,255,255,.06)); box-shadow: inset 0 1px 0 rgba(255,255,255,.35); }
.model-card.no-gpu .mc-icon { background: rgba(255,255,255,.16); box-shadow: none; }
.mc-nogpu { display: grid; gap: 10px; font-size: 12.5px; color: rgba(255,255,255,.85); }
.mc-nogpu p { margin: 0; line-height: 1.5; }
.mc-nogpu code { font: 11px var(--mono); background: rgba(0,0,0,.3); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
.mc-alts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mc-alts .btn { padding: 8px 10px; font-size: 12.5px; }
.model-card.no-gpu .mc-other { display: none; }

/* Copy-the-flag button in the no-GPU card */
.flag-copy { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 10px; cursor: pointer; text-align: left;
  background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.25); color: #fff; font: inherit; }
.flag-copy:hover { border-color: #7dd3fc; background: rgba(0,0,0,.4); }
.flag-copy code { flex: 1; min-width: 0; background: none; padding: 0; font: 11.5px var(--mono); overflow-wrap: anywhere; user-select: all; }
.flag-copy-label { flex: none; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 7px; background: #fff; color: #1b1030; }
.mc-or { margin: 0; }

/* GPU notice: one slim line until "How to fix" is opened */
.model-card.no-gpu:not(.expanded) { padding: 10px 12px; gap: 0; }
.model-card.no-gpu:not(.expanded) .mc-icon { width: 30px; height: 30px; border-radius: 9px; }
.model-card.no-gpu:not(.expanded) .mc-icon .icon { width: 16px; height: 16px; }
.model-card.no-gpu:not(.expanded) .mc-heading { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-card.no-gpu .mc-top { gap: 10px; }
.model-card.no-gpu .mc-title { flex: 1; }
.model-card .mc-fix { flex: none; padding: 4px 10px; font-size: 12px; }
.model-card .mc-dismiss { flex: none; width: 28px; height: 28px; margin-right: -4px; }
.model-card.no-gpu:not(.expanded) .mc-progress, .model-card.no-gpu:not(.expanded) .mc-other { display: none; }

/* Expanded GPU notice: buttons stay on the first row, the heading gets its own full-width line */
.model-card.no-gpu.expanded .mc-top { flex-wrap: wrap; row-gap: 10px; }
.model-card.no-gpu.expanded .mc-title { order: 3; flex-basis: 100%; }
.model-card.no-gpu.expanded .mc-fix { margin-left: auto; }

/* ===== Fluid layout: columns scale with the screen; nothing has a fixed width ===== */
@media (min-width: 901px) {
  .layout { --side: clamp(200px, 15vw, 280px); --chat: clamp(300px, 24vw, 460px);
    grid-template-columns: var(--side) minmax(0, 1fr) var(--chat); }
  body.history-collapsed .layout { --side: 60px; }
}
@media (min-width: 901px) and (max-width: 1100px) { .layout { --chat: 290px; } }
/* Top bar: pills shrink with an ellipsis instead of pushing the page wider; buttons never wrap */
.topbar { min-width: 0; }
.topbar > * { min-width: 0; }
.model-pill, .privacy-badge { flex: 0 1 auto; min-width: 0; }
.topbar-actions { flex: none; display: flex; gap: 8px; }
.topbar-actions .btn { white-space: nowrap; }
@media (max-width: 1500px) {
  .topbar-actions .btn-text { display: none; }
  .topbar-actions .btn { padding: 8px 11px; }
}
@media (max-width: 1200px) { #storage-pill { display: none; } }
/* Charts are drawn at their real width; never let one grow taller than a featured chart */
.card.kind-line .chart svg { max-height: 300px; }

/* The model card must never be squeezed by the fixed-height chat column: it keeps its natural
   height, and only if the window is too short does it scroll inside (the messages shrink first). */
.model-card { flex: 0 0 auto; min-height: auto; max-height: 60%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.model-card.no-gpu:not(.expanded) { overflow: hidden; }
.chat .messages { min-height: 120px; }

/* CPU / GPU switch in the header */
.engine-switch { display: inline-flex; flex: none; padding: 3px; gap: 2px; border-radius: 999px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.24); }
.engine-switch button { font: 600 12px var(--font); color: rgba(255,255,255,.8); background: none; border: 0; border-radius: 999px; padding: 4px 11px; cursor: pointer; }
.engine-switch button:hover { color: #fff; background: rgba(255,255,255,.12); }
.engine-switch button[aria-pressed="true"] { color: #1b1030; background: #fff; box-shadow: 0 0 10px rgba(255,255,255,.35); }
.engine-switch .unavailable { text-decoration: line-through; text-decoration-thickness: 1.5px; opacity: .65; }
.engine-switch .unavailable[aria-pressed="true"] { text-decoration: none; opacity: 1; }
.mc-cpu-row { margin-bottom: 2px; }
.glass-theme .btn.mc-cpu { color: #fff; border: 0; font-weight: 700; min-height: 40px;
  background: linear-gradient(135deg, #8b5cf6, #0ea5e9); box-shadow: 0 6px 18px rgba(99,102,241,.45); }

/* Minimized chat: a slim rail on the right */
.chat-title { gap: 8px; }
.chat-minimize { margin-left: auto; width: 30px; height: 30px; }
.chat-rail { display: none; }
@media (min-width: 901px) {
  body.chat-min .layout { --chat: 64px; }
  body.chat-min #chat > :not(.chat-rail) { display: none !important; }
  body.chat-min .chat-rail { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; height: 100%;
    padding: 14px 0; background: none; border: 0; color: #fff; cursor: pointer; border-radius: inherit; }
  body.chat-min .chat-rail:hover { background: rgba(255,255,255,.08); }
  .chat-rail img { border-radius: 10px; box-shadow: 0 0 14px rgba(91,92,255,.55); }
  .chat-rail span { writing-mode: vertical-rl; font-weight: 600; font-size: 13px; letter-spacing: .02em; color: rgba(255,255,255,.85); }
}
@media (max-width: 900px) { .chat-minimize { display: none !important; } }

/* Export dropdown */
.export-wrap { position: relative; flex: none; }
.export-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 270px; padding: 6px; display: grid; gap: 2px;
  border-radius: 14px; background: rgba(28,16,52,.96); border: 1px solid rgba(255,255,255,.22);
  box-shadow: 0 18px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.2); backdrop-filter: blur(20px); }
.export-menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px;
  background: none; color: #fff; font: inherit; text-align: left; cursor: pointer; }
.export-menu button:hover, .export-menu button:focus-visible { background: rgba(255,255,255,.12); outline: none; }
.export-menu .icon { color: #c4b5fd; flex: none; }
.export-menu span { display: grid; }
.export-menu b { font-size: 13.5px; font-weight: 600; }
.export-menu small { font-size: 11.5px; color: rgba(255,255,255,.65); }

/* Send button: round, gradient, clearly off when there's nothing to send */
.send-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, #8b5cf6, #6366f1 50%, #0ea5e9); box-shadow: 0 6px 18px rgba(99,102,241,.55), inset 0 1px 0 rgba(255,255,255,.4);
  transition: transform .12s, box-shadow .15s, opacity .15s, filter .15s; }
.send-btn:hover:not(:disabled) { transform: translateY(-1px) scale(1.04); box-shadow: 0 10px 24px rgba(99,102,241,.7), inset 0 1px 0 rgba(255,255,255,.4); }
.send-btn:active:not(:disabled) { transform: scale(.96); }
.send-btn:disabled { cursor: default; opacity: .45; filter: saturate(.3); box-shadow: none; }
.send-btn .icon { stroke-width: 2.5; }
#stop-btn { border-radius: 50%; width: 44px; height: 44px; padding: 0; }
/* Resend on your own messages (shows on hover / focus) */
.msg.user { position: relative; display: flex; align-items: flex-start; gap: 6px; }
.msg-resend { position: absolute; left: -34px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; opacity: 0; transition: opacity .15s; }
.msg.user:hover .msg-resend, .msg-resend:focus-visible { opacity: 1; }
@media (hover: none) { .msg-resend { opacity: .8; } }

@media (min-width: 901px) { .chat-name { cursor: pointer; } .chat-name:hover { color: #fff; } }
.chat-minimize { border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08); border-radius: 9px; }
.chat-minimize:hover { background: rgba(255,255,255,.18); }
/* Export menu: each format gets its own coloured tile */
.export-menu .icon { box-sizing: content-box; padding: 8px; border-radius: 10px; color: #fff; }
.export-menu [data-export="png"] .icon { background: linear-gradient(135deg, #ec4899, #8b5cf6); }
.export-menu [data-export="html"] .icon { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.export-menu [data-export="pdf"] .icon { background: linear-gradient(135deg, #f97316, #ef4444); }

/* Desktop: the page never scrolls. Header stays put; dashboard, chats and chat each scroll on their own. */
@media (min-width: 901px) {
  html, body { height: 100%; overflow: hidden; }
  body { display: flex; flex-direction: column; height: 100dvh; }
  body > .topbar { flex: none; }
  body > .layout { flex: 1 1 auto; min-height: 0; align-items: stretch; }
  .layout > .main { height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    scrollbar-gutter: stable; padding-right: 4px; }
  .layout > .main { display: flex; flex-direction: column; }
  .layout > .main > * { flex: none; }
  .layout > .history, .layout > .chat { position: relative; top: 0; height: 100%; min-height: 0; }
}

/* Model settings: arrow shows open/closed; Done closes it */
#model-settings summary::-webkit-details-marker { display: none; }
#model-settings summary { padding: 4px 8px; margin-left: -8px; border-radius: 8px; }
#model-settings summary:hover { background: rgba(255,255,255,.08); color: #fff; }
.ms-chevron { display: inline-flex; transition: transform .18s ease; }
#model-settings[open] .ms-chevron { transform: rotate(180deg); }
.ms-done { display: inline-flex; align-items: center; gap: 6px; }
.ms-done .icon { transform: rotate(180deg); }

/* Shown only without JavaScript (and to crawlers) */
.noscript { max-width: 680px; margin: 15vh auto; padding: 24px; color: #fff; font-size: 16px; line-height: 1.6; }
.noscript h1 { font-size: 28px; line-height: 1.2; }
.noscript a { color: #c4b5fd; }
