:root {
  color-scheme: light;
  --bg: #f3f5f3;
  --panel: #ffffff;
  --panel-soft: #f7f8f6;
  --panel-strong: #e9eeeb;
  --ink: #15201d;
  --ink-2: #34433e;
  --muted: #63726d;
  --faint: #8d9a95;
  --line: #dfe5e1;
  --line-strong: #ccd5d0;
  --nav: #0d1514;
  --nav-soft: #16211f;
  --nav-text: #a9b6b1;
  --primary: #0f766e;
  --primary-2: #115e59;
  --primary-soft: #e2f0ed;
  --cyan: #0e7490;
  --emerald: #16815f;
  --amber: #b86f17;
  --rose: #b9473f;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 12px 32px rgba(16, 24, 40, .08);
  --shadow-lg: 0 24px 64px rgba(16, 24, 40, .13);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --sidebar: 248px;
  --topbar: 76px;
  --ease: cubic-bezier(.2, .75, .25, 1);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1514;
  --panel: #151e1c;
  --panel-soft: #192421;
  --panel-strong: #202d29;
  --ink: #f0f5f2;
  --ink-2: #d1dbd6;
  --muted: #98a7a1;
  --faint: #71817b;
  --line: #273530;
  --line-strong: #374842;
  --nav: #09100f;
  --nav-soft: #121c1a;
  --nav-text: #a4b2ad;
  --primary: #35a89b;
  --primary-2: #27897f;
  --primary-soft: rgba(53, 168, 155, .14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; min-height: 100%; margin: 0; }
body { overflow: hidden; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
::selection { color: white; background: var(--primary); }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); grid-template-areas: "sidebar main"; width: 100%; height: 100%; min-height: 0; }
.main-stage { grid-area: main; min-width: 0; min-height: 0; display: grid; grid-template-rows: var(--topbar) minmax(0, 1fr); overflow: hidden; }
.sidebar { grid-area: sidebar; min-width: 0; position: relative; z-index: 30; display: flex; flex-direction: column; padding: 20px 14px 14px; overflow: hidden; color: white; background: var(--nav); border-right: 1px solid rgba(255,255,255,.05); }
.sidebar::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; pointer-events: none; background: var(--primary); }

.brand { position: relative; display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border: 1px solid #2eaaa0; border-radius: 11px; color: white; background: #106d66; box-shadow: 0 8px 20px rgba(0,0,0,.18); font: 800 13px/1 "Segoe UI"; letter-spacing: -.4px; }
.brand-mark span { color: #9ad9d2; font-size: 10px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: -.2px; }
.brand small { margin-top: 3px; color: #7f899d; font-size: 9px; letter-spacing: .8px; text-transform: uppercase; }

.new-chat-button { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 13px; cursor: pointer; color: white; background: #0f766e; border: 1px solid #248f85; border-radius: 11px; box-shadow: 0 8px 20px rgba(0,0,0,.18); transition: transform .2s var(--ease), background .2s; }
.new-chat-button:hover { background: #13857b; transform: translateY(-1px); }
.new-chat-button svg { width: 17px; }
.new-chat-button span { flex: 1; text-align: start; font-size: 12px; font-weight: 700; }
.new-chat-button kbd { direction: ltr; padding: 2px 5px; color: rgba(255,255,255,.65); background: rgba(0,0,0,.16); border: 1px solid rgba(255,255,255,.12); border-radius: 5px; font: 9px monospace; }

.main-nav { display: grid; gap: 3px; margin-top: 18px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 42px; padding: 0 12px; cursor: pointer; color: var(--nav-text); background: transparent; border: 0; border-radius: 11px; transition: .2s var(--ease); }
.nav-item:hover { color: white; background: rgba(255,255,255,.055); }
.nav-item.active { color: white; background: rgba(53,168,155,.13); box-shadow: inset 3px 0 0 var(--primary); }
.nav-item svg { width: 18px; height: 18px; }
.nav-item span { flex: 1; text-align: start; font-size: 11px; font-weight: 650; }
.nav-item em { padding: 2px 5px; color: #8be9fd; background: rgba(6,182,212,.12); border-radius: 5px; font: 700 8px sans-serif; font-style: normal; letter-spacing: .5px; }

.sidebar-section { min-height: 0; display: flex; flex: 1; flex-direction: column; margin-top: 25px; }
.sidebar-label { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 9px; color: #667085; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.sidebar-label button { cursor: pointer; color: inherit; background: none; border: 0; }
.recent-list { min-height: 0; display: grid; align-content: start; gap: 3px; overflow: auto; }
.recent-item { display: block; width: 100%; padding: 9px 10px; overflow: hidden; cursor: pointer; text-align: start; color: #8f99ad; background: transparent; border: 0; border-radius: 9px; white-space: nowrap; text-overflow: ellipsis; font-size: 10px; transition: .18s; }
.recent-item:hover, .recent-item.active { color: #eef1f7; background: rgba(255,255,255,.05); }
.recent-placeholder { padding: 10px; color: #535d70; font-size: 10px; }
.sidebar-bottom { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.06); }
.profile-card { display: grid; grid-template-columns: 36px 1fr 8px; align-items: center; gap: 9px; padding: 9px; border-radius: 12px; background: rgba(255,255,255,.035); }
.profile-card strong, .profile-card small { display: block; }
.profile-card strong { overflow: hidden; color: #eef1f7; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.profile-card small { margin-top: 2px; color: #707b90; font-size: 8px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 9px; color: white; background: #176e67; font-size: 12px; font-weight: 800; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 0 3px rgba(16,185,129,.1); }

.topbar { display: flex; align-items: center; justify-content: space-between; min-width: 0; padding: 0 26px; background: color-mix(in srgb, var(--panel) 90%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.topbar-leading, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar h1 { margin: 2px 0 0; font-size: 17px; letter-spacing: -.4px; }
.eyebrow { margin: 0; color: var(--primary); font-size: 9px; font-weight: 800; letter-spacing: .45px; text-transform: uppercase; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; cursor: pointer; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-sm); transition: .2s var(--ease); }
.icon-button:hover { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 32%, var(--line)); transform: translateY(-1px); }
.icon-button.small { width: 32px; height: 32px; }
.icon-button.small svg { width: 16px; }
.mobile-menu { display: none; }
.connection-pill { display: flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 10px; color: var(--muted); background: var(--panel-soft); border: 1px solid var(--line); border-radius: 99px; font-size: 9px; font-weight: 700; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(245,158,11,.12); }
.connection-pill.live .pulse-dot { background: var(--emerald); box-shadow: 0 0 0 3px rgba(16,185,129,.12); }
.connection-pill.error .pulse-dot { background: var(--rose); box-shadow: 0 0 0 3px rgba(239,71,111,.12); }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 15px; cursor: pointer; border-radius: 11px; font-size: 10px; font-weight: 750; transition: .2s var(--ease); }
.primary-button { color: white; background: var(--primary); border: 1px solid var(--primary); box-shadow: 0 7px 18px rgba(15,118,110,.18); }
.primary-button:hover { background: var(--primary-2); transform: translateY(-1px); }
.primary-button.compact { min-height: 36px; padding: 0 12px; }
.primary-button svg, .secondary-button svg { width: 16px; }
.secondary-button { color: var(--ink-2); background: var(--panel); border: 1px solid var(--line); }
.secondary-button:hover { color: var(--primary); border-color: var(--primary); }

.view { min-width: 0; min-height: 0; height: 100%; display: none; overflow: hidden; }
.view.active { display: block; height: 100%; animation: view-in .28s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 292px; height: 100%; min-height: 0; }
.conversation-pane { min-width: 0; min-height: 0; position: relative; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: var(--bg); }
.message-scroll { min-height: 0; overflow: auto; padding: 36px max(32px, calc((100% - 850px) / 2)) 28px; scroll-behavior: smooth; }
.welcome { max-width: 820px; margin: 24px auto 0; text-align: center; }
.welcome-orbit { position: relative; display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 19px; border: 1px solid #258d84; border-radius: 18px; color: white; background: #0f766e; box-shadow: 0 14px 34px rgba(15,118,110,.18); }
.welcome-orbit b { font-size: 16px; }
.welcome-orbit span { display: none; }
.welcome-orbit span:nth-child(1) { top: 8px; right: 15px; }
.welcome-orbit span:nth-child(2) { left: 8px; bottom: 20px; background: #ffd166; }
.welcome-orbit span:nth-child(3) { right: -4px; bottom: 9px; background: #91f5c5; }
.welcome h2 { max-width: 670px; margin: 8px auto 9px; font-size: clamp(26px, 3.1vw, 40px); line-height: 1.25; letter-spacing: -1.4px; }
.welcome-copy { max-width: 650px; margin: 0 auto; color: var(--muted); font-size: 12px; line-height: 1.9; }
.prompt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 28px; }
.prompt-card { display: grid; grid-template-columns: 40px minmax(0, 1fr) 16px; align-items: center; gap: 11px; min-height: 78px; padding: 13px; cursor: pointer; text-align: start; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); transition: .22s var(--ease); }
.prompt-card:hover { border-color: color-mix(in srgb, var(--primary) 26%, var(--line)); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.prompt-card strong, .prompt-card small { display: block; }
.prompt-card strong { margin-bottom: 4px; font-size: 11px; }
.prompt-card small { color: var(--muted); font-size: 9px; line-height: 1.45; }
.prompt-card .arrow { width: 14px; color: var(--faint); transition: transform .2s; }
.prompt-card:hover .arrow { color: var(--primary); transform: translateX(3px); }
.prompt-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; }
.prompt-icon svg { width: 18px; }
.prompt-icon.violet { color: var(--primary); background: var(--primary-soft); }
.prompt-icon.cyan { color: var(--cyan); background: rgba(6,182,212,.1); }
.prompt-icon.amber { color: var(--amber); background: rgba(245,158,11,.1); }
.prompt-icon.emerald { color: var(--emerald); background: rgba(16,185,129,.1); }
.capability-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; margin-top: 22px; color: var(--faint); font-size: 9px; }
.capability-row span { display: inline-flex; align-items: center; gap: 6px; }
.capability-row i { width: 5px; height: 5px; border-radius: 50%; background: var(--emerald); }

#messages { max-width: 850px; margin: 0 auto; }
.message { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; margin-bottom: 24px; animation: message-in .35s var(--ease); }
.message.user { grid-template-columns: minmax(0, 1fr) 34px; }
@keyframes message-in { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
.message-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: white; background: #176e67; font-size: 9px; font-weight: 850; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.message.user .message-avatar { grid-column: 2; background: var(--ink); box-shadow: none; }
.message-content { min-width: 0; }
.message.user .message-content { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; align-items: flex-end; }
.message-label { display: flex; align-items: center; gap: 8px; margin: 0 2px 7px; color: var(--muted); font-size: 9px; }
.message-label time { color: var(--faint); direction: ltr; }
.message-bubble { max-width: 100%; padding: 16px 18px; color: var(--ink-2); background: var(--panel); border: 1px solid var(--line); border-radius: 5px var(--radius-lg) var(--radius-lg) var(--radius-lg); box-shadow: var(--shadow-sm); font-size: 12px; line-height: 1.85; }
.message.user .message-bubble { max-width: 76%; color: white; background: #176e67; border: 1px solid #23877e; border-radius: var(--radius-lg) 5px var(--radius-lg) var(--radius-lg); box-shadow: 0 8px 20px rgba(15,118,110,.15); }
.message-bubble p { margin: 0 0 10px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble h2, .message-bubble h3, .message-bubble h4 { margin: 18px 0 8px; color: var(--ink); line-height: 1.45; }
.message-bubble h2 { font-size: 16px; }.message-bubble h3 { font-size: 14px; }.message-bubble h4 { font-size: 12px; }
.message-bubble ul, .message-bubble ol { margin: 7px 0; padding-right: 20px; }
.message-bubble li { margin: 4px 0; }
.message-bubble code { direction: ltr; padding: 2px 5px; color: color-mix(in srgb, var(--primary) 86%, var(--ink)); background: var(--primary-soft); border-radius: 5px; font: 10px Consolas, monospace; }
.message-bubble pre { direction: ltr; padding: 14px; overflow: auto; color: #d7def0; background: #0b1020; border-radius: 12px; font: 10px/1.7 Consolas, monospace; }
.message-bubble blockquote { margin: 10px 0; padding: 8px 12px; color: var(--muted); background: var(--panel-soft); border-right: 3px solid var(--primary); border-radius: 8px; }
.table-wrap { margin: 12px 0; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.message-bubble table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 10px; }
.message-bubble th { color: var(--ink); background: var(--panel-strong); font-weight: 750; }
.message-bubble th, .message-bubble td { padding: 9px 11px; text-align: start; border-bottom: 1px solid var(--line); }
.message-bubble tr:last-child td { border-bottom: 0; }
.structured-view-stack { display: grid; gap: 12px; margin-top: 12px; }
.structured-view { min-width: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); }
.structured-view-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 15px 16px; border-bottom: 1px solid var(--line); }
.structured-view-header > div:first-child { min-width: 0; }
.structured-eyebrow { display: block; margin-bottom: 3px; color: var(--primary); font-size: 7px; font-weight: 850; letter-spacing: .13em; }
.structured-view-header h4 { margin: 0; color: var(--ink); font-size: 12px; }
.structured-view-header p { margin: 4px 0 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.time-context { flex: 0 0 auto; max-width: 220px; padding: 8px 10px; color: var(--muted); background: var(--panel-soft); border: 1px solid var(--line); border-radius: 9px; }
.time-context span,.time-context strong,.time-context small { display: block; }
.time-context span { color: var(--faint); font-size: 6px; font-weight: 800; letter-spacing: .12em; }
.time-context strong { margin-top: 2px; color: var(--ink); font-size: 9px; direction: ltr; }
.time-context small { margin-top: 2px; font-size: 7px; line-height: 1.4; }
.record-grid-head,.smart-record-summary { display: grid; align-items: center; min-width: max-content; }
.record-grid-head { padding: 8px 34px 8px 13px; color: var(--faint); background: var(--panel-strong); border-bottom: 1px solid var(--line); font-size: 7px; font-weight: 800; letter-spacing: .03em; }
.record-grid-head span { padding-inline: 7px; }
.record-list { max-height: 520px; overflow: auto; }
.record-group { min-width: max-content; }
.record-group + .record-group { border-top: 1px solid var(--line-strong); }
.record-group-header { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; min-width: max-content; padding: 9px 14px; background: var(--panel-strong); border-bottom: 1px solid var(--line); }
.record-group-header > div:first-child { display: flex; align-items: baseline; gap: 8px; }
.record-group-header strong { color: var(--ink); font-size: 10px; }
.record-group-header small { color: var(--faint); font-size: 7px; }
.record-group-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.record-group-chips span { padding: 3px 6px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 7px; }
.record-group-chips b { margin-inline-start: 3px; color: var(--primary); }
.smart-record { width: 100%; min-width: max-content; margin: 0; color: inherit; background: transparent; border: 0; border-bottom: 1px solid var(--line); text-align: start; font: inherit; }
.smart-record:last-child { border-bottom: 0; }
.smart-record-summary { position: relative; min-height: 48px; padding: 0 104px 0 13px; cursor: pointer; color: var(--ink-2); font-size: 9px; transition: background .18s ease, box-shadow .18s ease; }
.smart-record-summary:hover { background: var(--primary-soft); }
.smart-record-summary:focus-visible { z-index: 1; outline: 2px solid var(--primary); outline-offset: -2px; }
.record-cell { min-width: 0; padding: 9px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-primary { color: var(--ink); font-weight: 780; }
.smart-record.active .record-cell:nth-last-of-type(1) { color: var(--primary); font-weight: 750; }
.smart-record.complete .record-cell:nth-last-of-type(1) { color: var(--emerald); font-weight: 750; }
.smart-record.warning .record-cell:nth-last-of-type(1) { color: var(--amber); font-weight: 750; }
.record-open-label { position: absolute; inset-inline-end: 31px; top: 50%; color: var(--primary); font-size: 7px; font-weight: 780; transform: translateY(-50%); }
.record-chevron { position: absolute; inset-inline-end: 12px; top: 50%; width: 14px; height: 14px; color: var(--faint); transform: translateY(-50%); transition: transform .18s ease; }
.record-chevron svg { width: 100%; }
.record-modal[hidden] { display: none; }
.record-modal { position: fixed; z-index: 120; inset: 0; display: grid; place-items: center; padding: 28px; }
.record-modal-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; background: rgba(3,12,17,.72); border: 0; cursor: default; }
.record-modal-panel { position: relative; display: grid; grid-template-rows: auto minmax(0,1fr); width: min(860px, 100%); max-height: min(780px, calc(100dvh - 56px)); overflow: hidden; color: var(--ink-2); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); }
.record-modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 22px; background: var(--panel-strong); border-bottom: 1px solid var(--line); }
.record-modal-header h3 { margin: 3px 0 0; color: var(--ink); font-size: 18px; }
.record-modal-header p { margin: 5px 0 0; color: var(--muted); font-size: 9px; }
.record-modal-close { display: grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font: 22px/1 sans-serif; }
.record-modal-close:hover { color: var(--ink); border-color: var(--primary); }
.record-modal-body { display: grid; gap: 14px; padding: 18px 20px 22px; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.record-detail-group { min-width: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.record-detail-group h4 { margin: 0; padding: 11px 14px; color: var(--ink); background: var(--panel-soft); border-bottom: 1px solid var(--line); font-size: 10px; }
.record-detail-table { display: grid; }
.record-detail-row { display: grid; grid-template-columns: minmax(150px,.7fr) minmax(0,1.5fr); border-bottom: 1px solid var(--line); }
.record-detail-row:last-child { border-bottom: 0; }
.record-detail-row > span,.record-detail-row > strong { min-width: 0; padding: 10px 14px; overflow-wrap: anywhere; font-size: 9px; line-height: 1.55; }
.record-detail-row > span { color: var(--muted); background: var(--panel-soft); border-inline-end: 1px solid var(--line); font-weight: 650; }
.record-detail-row > strong { color: var(--ink); font-weight: 650; }
body.modal-open { overflow: hidden; }
.record-detail-group dt { color: var(--faint); font-size: 7px; font-weight: 750; }
.record-detail-group dd { margin: 2px 0 0; overflow-wrap: anywhere; color: var(--ink-2); font-size: 8px; line-height: 1.45; }
.message-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.message-action { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 0 8px; cursor: pointer; color: var(--muted); background: transparent; border: 0; border-radius: 7px; font-size: 8px; }
.message-action:hover { color: var(--primary); background: var(--primary-soft); }
.message-action svg { width: 13px; }
.feedback-actions { display: inline-flex; align-items: center; gap: 2px; padding-inline-start: 4px; border-inline-start: 1px solid var(--line); }
.feedback-button { width: 30px; padding: 0; justify-content: center; }
.feedback-button.active { color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 28%, transparent); }
.feedback-button:disabled { cursor: wait; opacity: .5; }

.thinking-card { display: flex; align-items: center; gap: 11px; min-height: 54px; padding: 11px 14px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 5px var(--radius-md) var(--radius-md) var(--radius-md); box-shadow: var(--shadow-sm); font-size: 10px; }
.thinking-orb { position: relative; width: 25px; height: 25px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.thinking-text strong, .thinking-text span { display: block; }
.thinking-text strong { color: var(--ink-2); font-size: 10px; }
.thinking-text span { margin-top: 2px; color: var(--faint); font-size: 8px; }

.composer-wrap { position: relative; z-index: 5; padding: 12px max(30px, calc((100% - 850px) / 2)) 16px; background: var(--bg); border-top: 1px solid color-mix(in srgb, var(--line) 65%, transparent); }
.composer { padding: 10px 12px 9px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 19px; box-shadow: 0 14px 42px rgba(16,24,40,.11); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--primary) 58%, var(--line)); box-shadow: 0 16px 46px rgba(15,118,110,.1), 0 0 0 3px rgba(15,118,110,.06); }
.composer textarea { display: block; width: 100%; max-height: 150px; padding: 4px 4px 9px; resize: none; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 12px; line-height: 1.7; }
.composer textarea::placeholder { color: var(--faint); }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer-meta { display: flex; align-items: center; gap: 10px; }
.scope-chip { display: inline-flex; align-items: center; gap: 5px; min-height: 25px; padding: 0 8px; color: var(--muted); background: var(--panel-soft); border-radius: 8px; font-size: 8px; }
.scope-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--emerald); }
.token-label { color: var(--faint); font-size: 8px; }
.send-button { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; cursor: pointer; color: white; background: var(--primary); border: 0; border-radius: 11px; box-shadow: 0 8px 20px rgba(79,70,229,.25); transition: .2s var(--ease); }
.send-button:hover { transform: translateY(-1px) scale(1.02); background: var(--primary-2); }
.send-button:disabled { cursor: wait; opacity: .5; transform: none; }
.send-button svg { width: 17px; }
.composer-note { margin: 7px 0 0; color: var(--faint); text-align: center; font-size: 7px; }

.insight-pane { min-width: 0; overflow: auto; padding: 22px 18px; background: var(--panel); border-left: 1px solid var(--line); }
.insight-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.insight-header h3 { margin: 3px 0 0; font-size: 13px; }
.context-card { padding: 13px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: var(--radius-md); }
.context-user { display: flex; align-items: center; gap: 10px; }
.context-user strong, .context-user small { display: block; }
.context-user strong { font-size: 10px; }.context-user small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.context-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
.context-grid div { min-width: 0; }.context-grid span, .context-grid strong { display: block; }
.context-grid span { color: var(--faint); font-size: 7px; }.context-grid strong { margin-top: 3px; overflow: hidden; color: var(--ink-2); font-size: 8px; white-space: nowrap; text-overflow: ellipsis; }
.insight-section { margin-top: 23px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-heading h4 { margin: 0; font-size: 10px; }.section-heading span { color: var(--faint); font-size: 8px; }
.source-timeline { display: grid; gap: 8px; }
.source-timeline.empty { padding: 16px; color: var(--faint); text-align: center; background: var(--panel-soft); border: 1px dashed var(--line-strong); border-radius: 12px; font-size: 8px; line-height: 1.7; }
.source-item { position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 9px; padding: 9px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 11px; }
.source-item-icon { display: grid; place-items: center; width: 26px; height: 26px; color: var(--primary); background: var(--primary-soft); border-radius: 8px; }
.source-item-icon svg { width: 13px; }
.source-item strong, .source-item small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.source-item strong { font-size: 8px; }.source-item small { margin-top: 3px; color: var(--faint); font-size: 7px; direction: ltr; text-align: right; }
.source-item.ok::after { content: ""; position: absolute; top: 8px; left: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--emerald); }
.source-item.fail::after { background: var(--rose); }
.trust-meter { display: grid; gap: 7px; }
.trust-meter div { display: flex; justify-content: space-between; padding: 8px 9px; background: var(--panel-soft); border-radius: 9px; font-size: 8px; }
.trust-meter span { color: var(--muted); }.trust-meter b { color: var(--emerald); }

.page-scroll { width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: auto; padding: clamp(18px, 2.5vw, 30px); overscroll-behavior: contain; }
.page-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; max-width: 1240px; margin: 0 auto 24px; }
.page-intro h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.6px; }.page-intro p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.count-badge { min-width: 36px; padding: 6px 10px; color: var(--primary); text-align: center; background: var(--primary-soft); border-radius: 99px; font: 750 10px sans-serif; }
.analytics-surface, .card-grid, .catalog-grid { max-width: 1240px; margin: 0 auto; }
.analytics-response { display: grid; gap: 16px; }
.analytics-summary { padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); font-size: 11px; line-height: 1.8; }
.skeleton-dashboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.skeleton-dashboard i { display: block; height: 150px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); animation: skeleton-pulse 1.5s ease-in-out infinite alternate; }
@keyframes skeleton-pulse { to { background: var(--panel-strong); } }
.skeleton-dashboard i:first-child { grid-column: span 3; height: 210px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 13px; }
.report-card { padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); transition: .2s var(--ease); }
.report-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.report-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.report-icon { display: grid; place-items: center; width: 34px; height: 34px; color: var(--primary); background: var(--primary-soft); border-radius: 10px; }.report-icon svg { width: 16px; }
.report-card h3 { margin: 13px 0 6px; font-size: 12px; }.report-card p { min-height: 34px; margin: 0; color: var(--muted); font-size: 9px; line-height: 1.7; }
.report-meta { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 10px; color: var(--faint); border-top: 1px solid var(--line); font-size: 8px; }
.report-actions { display: flex; gap: 5px; }.report-actions a { padding: 5px 7px; color: var(--primary); text-decoration: none; background: var(--primary-soft); border-radius: 7px; font-size: 8px; font-weight: 700; }
.empty-state { grid-column: 1/-1; padding: 70px 20px; color: var(--muted); text-align: center; background: var(--panel); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); }.empty-state span { font-size: 30px; }.empty-state h3 { margin: 8px 0 4px; color: var(--ink); font-size: 13px; }.empty-state p { margin: 0; font-size: 9px; }
.search-box { display: flex; align-items: center; gap: 9px; max-width: 1240px; margin: 0 auto 12px; padding: 0 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }.search-box:focus-within { border-color: var(--primary); }.search-box svg { width: 16px; color: var(--faint); }.search-box input { width: 100%; height: 43px; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 10px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 1240px; margin: 0 auto 17px; }.filter-chip { padding: 6px 9px; cursor: pointer; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 99px; font-size: 8px; }.filter-chip.active { color: white; background: var(--primary); border-color: var(--primary); }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.catalog-card { padding: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; }.catalog-card header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }.catalog-card h3 { margin: 0; overflow: hidden; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }.catalog-card .category { padding: 3px 6px; color: var(--primary); background: var(--primary-soft); border-radius: 5px; font-size: 7px; }.catalog-card p { margin: 8px 0; min-height: 28px; color: var(--muted); font-size: 8px; line-height: 1.6; }.catalog-card code { display: block; direction: ltr; overflow: hidden; color: var(--faint); font: 7px Consolas, monospace; white-space: nowrap; text-overflow: ellipsis; }

.developer-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); width: 100%; height: 100%; min-height: 0; overflow: hidden; }
.developer-tabs { display: flex; align-items: end; gap: 4px; min-height: 52px; padding: 9px clamp(14px, 2vw, 24px) 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.developer-tab { position: relative; min-height: 42px; padding: 0 14px; cursor: pointer; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; font-size: 10px; font-weight: 750; }
.developer-tab:hover { color: var(--ink); }.developer-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.developer-tab span { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-inline-start: 5px; padding: 0 5px; color: white; background: var(--amber); border-radius: 99px; font-size: 8px; }
.developer-tab span[hidden],.schema-errors[hidden] { display: none; }
.widget-preview-link { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; margin: 0 0 7px auto; padding: 0 10px; color: var(--primary); border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--line)); border-radius: 9px; text-decoration: none; font-size: 9px; font-weight: 750; }.widget-preview-link:hover { background: var(--primary-soft); }.widget-preview-link svg { width: 13px; height: 13px; }
.developer-panel { display: none; min-width: 0; min-height: 0; height: 100%; overflow: hidden; }.developer-panel.active { display: block; }
.developer-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, .8fr); grid-template-rows: minmax(0, 1fr); gap: 16px; width: 100%; height: 100%; min-height: 0; padding: clamp(14px, 2vw, 24px); overflow: hidden; }
.sql-editor-card, .sql-result-card { width: 100%; height: 100%; min-width: 0; min-height: 0; display: grid; background: #0d1717; border: 1px solid #263936; border-radius: 16px; box-shadow: var(--shadow-md); overflow: hidden; }
.sql-editor-card { grid-template-rows: 54px minmax(0, 1fr) 54px; }.sql-result-card { grid-template-rows: 54px minmax(0, 1fr); }
.sql-editor-card header, .sql-editor-card footer, .sql-result-card header { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 15px; color: #a7b7b2; background: #111e1c; border-bottom: 1px solid #263936; font-size: 9px; }.sql-editor-card footer { border-top: 1px solid #263936; border-bottom: 0; }.sql-editor-card header div { min-width: 0; display: flex; align-items: center; gap: 8px; }.status-led { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 0 3px rgba(22,129,95,.16); }
.sql-editor-card select { min-width: 0; width: min(190px, 45%); padding: 7px 9px; color: #d7e2de; background: #182724; border: 1px solid #314640; border-radius: 8px; outline: 0; font: 9px Consolas, monospace; }
.sql-editor-card textarea { width: 100%; height: 100%; min-height: 0; padding: 20px; resize: none; color: #d7e2de; caret-color: #66bfb5; background: #0d1717; border: 0; outline: 0; font: 12px/1.8 Consolas, monospace; tab-size: 2; }
.sql-result-card pre { min-width: 0; min-height: 0; margin: 0; padding: 18px; overflow: auto; color: #b7c7c1; background: #0a1312; font: 10px/1.75 Consolas, monospace; text-align: left; direction: ltr; }.sql-result-card header span { color: #71847e; font-size: 8px; }

/* Developer-reviewed schema intelligence */
.intelligence-scroll { height: 100%; padding: clamp(18px, 2.5vw, 30px); overflow: auto; overscroll-behavior: contain; }
.intelligence-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; max-width: 1180px; margin: 0 auto; }
.intelligence-hero h2 { margin: 5px 0 7px; font-size: clamp(20px, 2.2vw, 29px); letter-spacing: -.7px; }.intelligence-hero p { max-width: 720px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.intelligence-kicker { color: var(--primary); font-size: 9px; font-weight: 850; letter-spacing: .6px; text-transform: uppercase; }
.safety-contract { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 12px; max-width: 1180px; margin: 19px auto 0; padding: 12px 14px; color: var(--ink-2); background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 26%, var(--line)); border-radius: 13px; }
.safety-icon { display: grid; place-items: center; width: 38px; height: 38px; color: white; background: var(--primary); border-radius: 10px; font: 800 9px monospace; }.safety-contract strong { display: block; margin-bottom: 2px; font-size: 10px; }.safety-contract p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.intelligence-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; max-width: 1180px; margin: 14px auto 0; }
.intelligence-metrics article { min-width: 0; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-sm); }.intelligence-metrics span,.intelligence-metrics small { display: block; color: var(--muted); font-size: 8px; }.intelligence-metrics strong { display: block; margin: 7px 0 4px; font-size: 22px; letter-spacing: -.8px; }
.intelligence-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; max-width: 1180px; margin: 11px auto 0; color: var(--faint); font-size: 8px; }
.schema-errors { display: grid; gap: 5px; max-width: 1180px; margin: 12px auto 0; padding: 12px 14px; color: #8c4c12; background: #fff8e8; border: 1px solid #edd7ab; border-radius: 12px; font-size: 9px; }.schema-errors span,.schema-errors small { display: block; }.schema-errors small { color: #8b6c40; }
:root[data-theme="dark"] .schema-errors { color: #f3bd74; background: #2b2114; border-color: #5a4326; }
.schema-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; max-width: 1180px; margin: 24px auto 12px; }.schema-toolbar .filter-chips { margin: 0; }
.schema-search { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 8px; }.schema-search input { width: min(290px, 32vw); min-height: 34px; padding: 0 11px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 9px; outline: 0; font-size: 9px; }.schema-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.schema-change-list { display: grid; gap: 11px; max-width: 1180px; margin: 0 auto; padding-bottom: 30px; }
.schema-change-card { min-width: 0; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--primary); border-radius: 14px; box-shadow: var(--shadow-sm); }.schema-change-card.high { border-left-color: var(--rose); }.schema-change-card.low { border-left-color: var(--emerald); }
.schema-change-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }.change-heading { min-width: 0; }.change-type { display: block; margin-bottom: 4px; color: var(--muted); font-size: 8px; font-weight: 750; text-transform: uppercase; letter-spacing: .4px; }.change-heading h3 { margin: 0; overflow-wrap: anywhere; font: 650 12px/1.5 Consolas, monospace; }
.change-badges { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 5px; }.risk-badge,.status-badge { padding: 4px 7px; border-radius: 99px; font-size: 7px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; }.risk-badge { color: var(--amber); background: color-mix(in srgb, var(--amber) 11%, transparent); }.risk-badge.high { color: var(--rose); background: color-mix(in srgb, var(--rose) 10%, transparent); }.status-badge { color: var(--primary); background: var(--primary-soft); }.status-badge.waiting_for_data,.status-badge.deferred { color: var(--amber); background: color-mix(in srgb, var(--amber) 11%, transparent); }.status-badge.rejected { color: var(--rose); background: color-mix(in srgb, var(--rose) 10%, transparent); }
.change-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 9px; color: var(--faint); font-size: 8px; }.change-summary strong { color: var(--amber); font-weight: 700; }
.change-evidence { margin-top: 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }.change-evidence summary { padding: 10px 0; cursor: pointer; color: var(--muted); font-size: 9px; font-weight: 700; }.evidence-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding-bottom: 9px; }.evidence-grid section,.sample-evidence { min-width: 0; padding: 10px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; }.evidence-grid h4,.sample-evidence h4 { margin: 0 0 7px; color: var(--muted); font-size: 8px; text-transform: uppercase; }.evidence-grid pre { max-height: 145px; margin: 0; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); font: 8px/1.55 Consolas, monospace; }.evidence-grid section > span { color: var(--faint); font-size: 8px; }
.sample-evidence { margin-bottom: 10px; }.sample-evidence > div { display: grid; grid-template-columns: minmax(90px, .3fr) minmax(0, 1fr); gap: 10px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 8px; }.sample-evidence > div:first-of-type { border-top: 0; }.sample-evidence code { overflow-wrap: anywhere; color: var(--primary); }.sample-evidence span,.sample-evidence p { margin: 0; overflow-wrap: anywhere; color: var(--muted); line-height: 1.5; }
.schema-review { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(190px, .6fr); gap: 10px; margin-top: 12px; }.schema-review label { display: grid; gap: 5px; color: var(--muted); font-size: 8px; font-weight: 700; }.schema-review textarea,.schema-review input { width: 100%; min-width: 0; padding: 9px 10px; resize: vertical; color: var(--ink); background: var(--panel-soft); border: 1px solid var(--line); border-radius: 9px; outline: 0; font-size: 9px; line-height: 1.5; }.schema-review textarea:focus,.schema-review input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }.schema-review-actions { grid-column: 1/-1; display: flex; justify-content: flex-end; gap: 7px; }.primary-button.compact,.secondary-button.compact { min-height: 34px; padding: 0 11px; }.danger-action { color: var(--rose); }.danger-action:hover { color: white; background: var(--rose); border-color: var(--rose); }
.review-outcome { margin-top: 12px; padding: 10px 12px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; }.review-outcome strong { font-size: 9px; }.review-outcome p { margin: 4px 0; color: var(--ink-2); font-size: 9px; line-height: 1.5; }.review-outcome small { color: var(--muted); font-size: 8px; }

/* End-user widget: a second surface of the same application, never a fork. */
.widget-launcher,.widget-close,.widget-history-button,.widget-history-panel { display: none; }
body.widget-surface { background: transparent; }
body.widget-surface::before { content: ""; position: fixed; z-index: 39; inset: 0; pointer-events: none; opacity: 0; background: rgba(5, 13, 12, .46); backdrop-filter: blur(2px); transition: opacity .3s var(--ease); }
body.widget-surface.widget-expanded::before { opacity: 1; }
body.widget-surface .widget-launcher { position: fixed; z-index: 60; top: 50%; right: 0; display: grid; grid-template-columns: 44px minmax(125px, 1fr) 18px; align-items: center; gap: 9px; width: 224px; min-height: 58px; padding: 7px 11px 7px 7px; cursor: pointer; color: white; background: #0d1514; border: 1px solid #2b4540; border-right: 0; border-radius: 15px 0 0 15px; box-shadow: 0 14px 34px rgba(5, 13, 12, .25); transform: translate(calc(100% - 58px), -50%); transition: transform .28s var(--ease), opacity .2s, box-shadow .2s; }
body.widget-surface .widget-launcher:hover,body.widget-surface .widget-launcher:focus-visible { outline: 0; transform: translate(0, -50%); box-shadow: 0 18px 42px rgba(5, 13, 12, .32); }
.widget-launcher-mark { display: grid; place-items: center; width: 44px; height: 44px; color: white; background: #0f766e; border: 1px solid #2b9b91; border-radius: 11px; font: 850 10px sans-serif; }.widget-launcher-copy { min-width: 0; text-align: left; }.widget-launcher-copy strong,.widget-launcher-copy small { display: block; white-space: nowrap; }.widget-launcher-copy strong { font-size: 10px; }.widget-launcher-copy small { margin-top: 4px; color: #8ea39c; font-size: 7px; }.widget-launcher > svg { width: 16px; color: #7ec8c0; }
body.widget-surface.widget-expanded .widget-launcher { visibility: hidden; opacity: 0; pointer-events: none; transform: translate(calc(100% - 58px), -50%); }
body.widget-surface .app-shell { position: fixed; z-index: 50; inset: 14px 18px; width: auto; height: auto; grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; overflow: hidden; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 22px; box-shadow: 0 30px 80px rgba(5, 13, 12, .28); transform-origin: right center; transition: opacity .28s var(--ease), transform .32s var(--ease), visibility .28s; }
body.widget-surface.widget-collapsed .app-shell { visibility: hidden; opacity: 0; pointer-events: none; transform: translateX(28px) scale(.985); }
body.widget-surface.widget-expanded .app-shell { visibility: visible; opacity: 1; transform: none; }
body.widget-surface .sidebar,body.widget-surface .insight-pane,body.widget-surface .mobile-menu { display: none; }
body.widget-surface .main-stage { grid-area: main; }
body.widget-surface .chat-layout { grid-template-columns: minmax(0, 1fr); }
body.widget-surface .conversation-pane { background: var(--bg); }
body.widget-surface .topbar { padding-inline: 22px; }
body.widget-surface .widget-close { display: grid; }
body.widget-surface .widget-history-button { display: grid; }
body.widget-surface .connection-pill { display: none; }
body.widget-surface .widget-history-panel { position: fixed; z-index: 58; top: 14px; right: 18px; bottom: 14px; display: grid; grid-template-rows: auto minmax(0, 1fr); width: min(390px, calc(100vw - 36px)); overflow: hidden; color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 0 22px 22px 0; box-shadow: -20px 0 55px rgba(5,13,12,.2); visibility: hidden; opacity: 0; pointer-events: none; transform: translateX(26px); transition: opacity .24s var(--ease), transform .28s var(--ease), visibility .24s; }
body.widget-surface .widget-history-panel.open { visibility: visible; opacity: 1; pointer-events: auto; transform: none; }
.widget-history-panel > header { display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.widget-history-panel > header small { color: var(--primary); font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.widget-history-panel > header h2 { margin: 3px 0 0; font-size: 16px; }
.widget-history-panel > header .icon-button { font-size: 20px; }
.widget-history-list { min-height: 0; padding: 8px; overflow: auto; }
.widget-history-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 13px 12px; cursor: pointer; text-align: start; color: var(--ink); background: transparent; border: 1px solid transparent; border-bottom-color: var(--line); border-radius: 10px; }
.widget-history-item:hover,.widget-history-item.active { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 28%, var(--line)); }
.widget-history-item strong,.widget-history-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-history-item strong { font-size: 10px; }
.widget-history-item small { margin-top: 5px; color: var(--muted); font-size: 8px; }
.widget-history-item em { display: grid; place-items: center; min-width: 25px; height: 25px; color: var(--primary); background: var(--bg); border-radius: 8px; font: 600 8px sans-serif; font-style: normal; }
.widget-history-empty { display: grid; place-items: center; align-content: center; min-height: 240px; padding: 22px; text-align: center; color: var(--muted); }
.widget-history-empty > span { color: var(--primary); font-size: 32px; }
.widget-history-empty strong { margin-top: 8px; color: var(--ink); font-size: 11px; }
.widget-history-empty small { max-width: 230px; margin-top: 5px; font-size: 9px; line-height: 1.5; }
body.widget-surface .message-scroll { padding-inline: max(28px, calc((100% - 920px) / 2)); }
body.widget-surface .composer-wrap { padding-inline: max(28px, calc((100% - 920px) / 2)); }
body.widget-surface .view:not(#viewChat) { display: none !important; }
body.widget-surface #viewChat { display: block; }

/* Structured visualizations */
.viz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 11px; margin-top: 14px; }
.viz-card { min-width: 0; padding: 15px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }.viz-card:only-child { grid-column: 1/-1; }
.viz-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; margin-bottom: 14px; }.viz-card h4 { margin: 3px 0 0; color: var(--ink); font-size: 10px; }.viz-eyebrow { color: var(--primary); font-size: 7px; font-weight: 850; }.viz-source { direction: ltr; max-width: 140px; padding: 3px 6px; overflow: hidden; color: var(--faint); background: var(--panel); border-radius: 5px; font: 7px Consolas, monospace; white-space: nowrap; text-overflow: ellipsis; }
.viz-mode-switcher { display: flex; flex-wrap: wrap; gap: 5px; margin: -3px 0 13px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.viz-mode-switcher button { padding: 5px 9px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; font: 700 7px sans-serif; }
.viz-mode-switcher button:hover { color: var(--ink); border-color: var(--primary); }
.viz-mode-switcher button.active { color: var(--primary); background: var(--primary-soft); border-color: rgba(15,118,110,.38); }
.viz-content { min-width: 0; }
.viz-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }.viz-metric { position: relative; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }.viz-metric::before { content: ""; position: absolute; inset: 9px auto 9px 0; width: 3px; background: var(--metric-color); border-radius: 3px; }.viz-metric span { display: block; overflow: hidden; color: var(--muted); font-size: 8px; white-space: nowrap; text-overflow: ellipsis; }.viz-metric strong { display: block; margin-top: 5px; color: var(--ink); font: 800 20px sans-serif; direction: ltr; text-align: right; }
.viz-bars { display: grid; gap: 9px; }.viz-bar-row { display: grid; grid-template-columns: minmax(75px, 120px) 1fr; align-items: center; gap: 8px; }.viz-bar-label { overflow: hidden; color: var(--muted); font-size: 8px; white-space: nowrap; text-overflow: ellipsis; }.viz-bar-tracks { display: grid; gap: 3px; }.viz-bar-track { position: relative; height: 16px; overflow: hidden; direction: ltr; background: var(--panel); border-radius: 6px; }.viz-bar-track i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; opacity: .82; transition: width .7s var(--ease); }.viz-bar-track b { position: absolute; inset: 0 5px auto auto; color: var(--ink); font: 700 8px/16px sans-serif; }
.viz-donut-layout { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 18px; }.viz-donut { position: relative; display: grid; place-items: center; width: 132px; height: 132px; }.viz-donut svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }.viz-donut circle { fill: none; stroke-width: 18; }.viz-donut .donut-track { stroke: var(--line); }.viz-donut>div { position: relative; z-index: 1; display: grid; place-content: center; width: 82px; height: 82px; text-align: center; background: var(--panel-soft); border-radius: 50%; }.viz-donut strong { color: var(--ink); font: 800 19px sans-serif; }.viz-donut span { color: var(--faint); font-size: 7px; }.viz-donut-legend { display: grid; gap: 7px; }.viz-donut-legend div { display: grid; grid-template-columns: 7px 1fr auto; align-items: center; gap: 6px; color: var(--muted); font-size: 8px; }.viz-donut-legend i,.viz-legend i { width: 6px; height: 6px; border-radius: 50%; }.viz-donut-legend b { color: var(--ink); font-size: 8px; }
.viz-line-wrap { direction: ltr; overflow: auto; }.viz-line { display: block; width: 100%; min-width: 450px; min-height: 230px; height: auto; }.viz-line .viz-gridline { stroke: var(--line); stroke-width: 1; }.viz-line polyline { fill: none; stroke: currentColor; stroke-width: 3; vector-effect: non-scaling-stroke; }.viz-line circle { fill: var(--panel-soft); stroke: currentColor; stroke-width: 2.5; vector-effect: non-scaling-stroke; }.viz-line text { fill: var(--faint); font: 8px sans-serif; }.viz-line .viz-axis-label { fill: var(--muted); font-weight: 700; }.viz-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; color: var(--muted); font-size: 7px; }.viz-legend span { display: flex; align-items: center; gap: 4px; }
.viz-table-wrap { max-height: 330px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; scrollbar-gutter: stable; }
.viz-table { width: 100%; min-width: 420px; border-collapse: collapse; color: var(--ink-2); font-size: 8px; }
.viz-table th,.viz-table td { padding: 9px 11px; text-align: start; border-bottom: 1px solid var(--line); }
.viz-table th { position: sticky; z-index: 1; top: 0; color: var(--ink); background: var(--panel-strong); font-weight: 800; }
.viz-table td:not(:first-child) { direction: ltr; text-align: end; font-variant-numeric: tabular-nums; }
.viz-table tr:last-child td { border-bottom: 0; }

.trace-details { margin-top: 9px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }.trace-details summary { padding: 8px 10px; cursor: pointer; color: var(--muted); background: var(--panel-soft); font-size: 8px; font-weight: 700; }.trace-details pre { display: block; max-height: min(52dvh, 520px); margin: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; border-radius: 0; white-space: pre; }
.token-usage { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.token-usage-brand { margin-inline-end: 2px; color: var(--faint); font-size: 7px; font-weight: 760; letter-spacing: .04em; }
.token-usage > span:not(.token-usage-brand) { display: flex; align-items: baseline; gap: 5px; padding: 5px 8px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 7px; }
.token-usage small { color: var(--faint); font-size: 6px; font-weight: 700; text-transform: uppercase; }
.token-usage strong { color: var(--ink-2); font-size: 8px; }
.toast-region { position: fixed; z-index: 100; left: 20px; bottom: 20px; display: grid; gap: 8px; pointer-events: none; }.toast { min-width: 240px; max-width: min(360px, calc(100vw - 28px)); padding: 11px 13px; color: var(--ink-2); background: var(--panel); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-lg); font-size: 9px; animation: toast-in .25s var(--ease); }.toast.error { border-color: rgba(185,71,63,.42); }.toast.success { border-color: rgba(22,129,95,.4); }@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.mobile-overlay { display: none; }

@media (max-width: 1180px) {
  :root { --sidebar: 220px; }
  .chat-layout { grid-template-columns: minmax(0, 1fr) 260px; }
  .message-scroll { padding-inline: 26px; }
  .composer-wrap { padding-inline: 26px; }
}

@media (max-width: 940px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-105%); transition: transform .28s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .mobile-overlay { position: fixed; z-index: 25; inset: 0; display: block; visibility: hidden; opacity: 0; background: rgba(2,6,18,.48); backdrop-filter: blur(3px); transition: .25s; }
  .mobile-overlay.open { visibility: visible; opacity: 1; }
  .mobile-menu { display: grid; }
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .insight-pane { position: fixed; z-index: 20; top: var(--topbar); right: 0; bottom: 0; width: 290px; transform: translateX(105%); box-shadow: var(--shadow-lg); transition: transform .28s var(--ease); }
  .insight-pane.open { transform: none; }
  #viewDeveloper { overflow: auto; overscroll-behavior: contain; }
  .developer-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(420px, min(62dvh, 620px))); height: auto; min-height: 100%; overflow: visible; }
  .sql-editor-card,.sql-result-card { height: auto; min-height: 420px; }
  .intelligence-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  :root { --topbar: 66px; }
  .topbar { padding: 0 14px; overflow: hidden; }.topbar-actions { gap: 7px; }.connection-pill, #btnNewChatTop { display: none; }.primary-button.compact span { display: none; }.topbar .primary-button { width: 38px; padding: 0; font-size: 0; }
  .message-scroll { padding: 23px 13px 18px; }.composer-wrap { padding: 9px 12px 12px; }.composer-note { display: none; }
  .main-stage, .view, .chat-layout, .conversation-pane { width: 100vw; min-width: 0; max-width: 100vw; overflow-x: hidden; }
  .message-scroll, .composer-wrap, .composer, .welcome, .prompt-grid { min-width: 0; max-width: 100%; }
  .welcome { width: calc(100vw - 26px); margin-top: 9px; }.welcome h2 { font-size: 27px; }.welcome-copy { width: min(100%, 360px); padding-inline: 4px; overflow-wrap: anywhere; font-size: 10px; }.prompt-grid { width: 100%; grid-template-columns: minmax(0, 1fr); }.prompt-card { width: 100%; }.capability-row { gap: 9px; }
  .message { gap: 8px; }.message-bubble { padding: 13px; font-size: 11px; }.message.user .message-bubble { max-width: 90%; }
  .structured-view-header { align-items: stretch; flex-direction: column; gap: 9px; padding: 13px; }.time-context { max-width: none; }.record-grid-head { display: none; }.record-list { max-height: 460px; }.record-group { min-width: 0; }.record-group-header { min-width: 0; align-items: flex-start; flex-direction: column; gap: 6px; }.record-group-chips { justify-content: flex-start; }.smart-record { min-width: 0; }.smart-record-summary { min-width: 0; grid-template-columns: minmax(125px,1.5fr) repeat(2,minmax(68px,1fr)) !important; padding-inline: 7px 86px; }.record-cell { padding-inline: 6px; }.record-cell:nth-child(n+4) { display: none; }.record-open-label { inset-inline-end: 25px; }.record-chevron { inset-inline-end: 8px; }.record-modal { padding: 10px; }.record-modal-panel { max-height: calc(100dvh - 20px); border-radius: 14px; }.record-modal-header { padding: 15px; }.record-modal-body { padding: 12px; }.record-detail-row { grid-template-columns: minmax(105px,.7fr) minmax(0,1.3fr); }.token-usage { flex-wrap: wrap; justify-content: flex-start; }.token-usage-brand { flex-basis: 100%; }
  .page-scroll { padding: 20px 13px; }.page-intro { align-items: stretch; flex-direction: column; }.page-intro .secondary-button { align-self: flex-start; }
  .skeleton-dashboard { grid-template-columns: 1fr; }.skeleton-dashboard i:first-child { grid-column: auto; }
  .developer-layout { gap: 12px; padding: 12px; grid-template-rows: repeat(2, minmax(360px, 58dvh)); }.sql-editor-card,.sql-result-card { min-height: 360px; }.sql-editor-card select { min-width: 0; width: 44%; }
  .developer-tabs { min-height: 48px; padding-inline: 10px; overflow-x: auto; }.developer-tab { flex: 0 0 auto; padding-inline: 10px; }
  .intelligence-scroll { padding: 16px 12px; }.intelligence-hero { align-items: stretch; flex-direction: column; gap: 14px; }.intelligence-hero .primary-button { align-self: flex-start; }.intelligence-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }.schema-toolbar { align-items: stretch; flex-direction: column; }.schema-toolbar .filter-chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 3px; }.schema-toolbar .filter-chip { flex: 0 0 auto; }.schema-search { width: 100%; }.schema-search input { width: 100%; }.schema-change-card > header { flex-direction: column; }.change-badges { justify-content: flex-start; }.schema-review { grid-template-columns: minmax(0, 1fr); }.schema-review-actions { grid-column: auto; flex-wrap: wrap; }.evidence-grid { grid-template-columns: minmax(0, 1fr); }.sample-evidence > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .viz-grid { grid-template-columns: 1fr; }.viz-donut-layout { grid-template-columns: 1fr; justify-items: center; }.viz-donut-legend { width: 100%; }.viz-bar-row { grid-template-columns: 72px 1fr; }
  .card-grid, .catalog-grid { grid-template-columns: minmax(0, 1fr); }
  .toast-region { right: 14px; left: 14px; bottom: 14px; }.toast { width: 100%; min-width: 0; }
  body.widget-surface .app-shell { inset: 0; border: 0; border-radius: 0; }
  body.widget-surface .widget-history-panel { inset: 0 0 0 auto; width: min(360px, 92vw); border-radius: 0; }
  body.widget-surface .topbar { padding-inline: 13px; }
  body.widget-surface .message-scroll { padding-inline: 13px; }
  body.widget-surface .composer-wrap { padding-inline: 12px; }
  body.widget-surface .widget-launcher { min-height: 54px; transform: translate(calc(100% - 54px), -50%); }
}

@media (max-width: 430px) {
  .topbar-leading { min-width: 0; }.topbar-leading>div { min-width: 0; }.topbar h1 { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 15px; }.eyebrow { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 7px; }
  .welcome h2 { font-size: 24px; letter-spacing: -.9px; }.welcome-orbit { width: 58px; height: 58px; border-radius: 15px; }.prompt-card { grid-template-columns: 36px minmax(0, 1fr) 14px; min-height: 70px; padding: 11px; }.prompt-icon { width: 36px; height: 36px; }
  .composer-footer { gap: 7px; }.composer-meta { min-width: 0; gap: 6px; }.token-label { display: none; }.scope-chip { max-width: 150px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .sql-editor-card header, .sql-editor-card footer, .sql-result-card header { padding-inline: 11px; }.sql-editor-card header strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }.sql-editor-card textarea, .sql-result-card pre { padding: 14px; font-size: 10px; }
  .intelligence-metrics { grid-template-columns: minmax(0, 1fr); }.schema-review-actions button { flex: 1 1 auto; }
}

@media (max-height: 720px) and (min-width: 941px) {
  :root { --topbar: 64px; }
  .sidebar { padding-top: 14px; }.brand { padding-bottom: 14px; }.main-nav { margin-top: 12px; }.sidebar-section { margin-top: 17px; }
  .message-scroll { padding-top: 22px; }.welcome { margin-top: 6px; }.welcome-orbit { width: 56px; height: 56px; margin-bottom: 12px; border-radius: 15px; }.welcome h2 { font-size: 28px; }.prompt-grid { margin-top: 18px; }.prompt-card { min-height: 66px; }.capability-row { margin-top: 14px; }
}

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