/* Iris: one token set and one component definition per layout state. */
:root {
  color-scheme: light;
  --profile-icon: var(--blue); --profile-icon-soft: var(--blue-soft);
  --theme-icon: var(--violet); --theme-icon-soft: var(--violet-soft);
  --exit-icon: var(--pink); --exit-icon-soft: var(--pink-soft);
  font-family: "Segoe UI Variable", "Segoe UI", Aptos, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  --canvas: #f7f5fa; --surface: #fff; --surface-raised: #fff;
  --text: #30283d; --muted: #6b5c7b; --faint: #756681;
  --line: #e0d9e9; --line-strong: #ccbedb; --hover: #e7def1;
  --accent: #7541b4; --accent-hover: #633298; --accent-ink: #fff; --accent-soft: #eee3fa;
  --button-bg: var(--accent); --button-hover: var(--accent-hover); --button-ink: var(--accent-ink);
  --sidebar: #eee9f4; --sidebar-hover: #e7def1; --sidebar-active: #fff;
  --sidebar-text: #30283d; --sidebar-muted: #6b5c7b; --sidebar-divider: #d8cee4;
  --sidebar-search: #f9f6fc; --sidebar-search-border: #d5c9e1;
  --sidebar-action: #7541b4; --sidebar-action-hover: #633298; --sidebar-action-text: #fff;
  --sidebar-mark: #7541b4; --sidebar-mark-text: #fff; --sidebar-indicator: #7541b4;
  --sidebar-skeleton: #d8cbe5;
  --blue: #3f63b3; --blue-soft: #e7edfb;
  --pink: #a44070; --pink-soft: #fae6ee;
  --violet: #7541b4; --violet-soft: #efe3fb;
  --cyan: #176e80; --cyan-soft: #e1f0f5;
  --amber: #8e5c1b; --amber-soft: #fbefdb;
  --mint: #24754e; --mint-soft: #e2f3e9;
  --success: #24754e; --warning: #865415; --warning-soft: #fff0d6;
  --danger: #a63248; --danger-soft: #fbe9ee; --danger-fill: #a63248;
  --user-bg: #eee5f6; --table-head: #f3eef8;
  --code-bg: #211b2c; --code-text: #f0e9f6; --code-muted: #bfb0ce;
  --code-line: #544460; --code-hover: #3c304b;
  --shadow: 0 14px 44px #38234512, 0 2px 7px #38234508;
  --menu-shadow: 0 18px 54px #30203f26;
  --overlay: #170f24a6; --content-width: 48rem;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --radius-sm: 9px; --radius: 14px; --radius-lg: 22px;
  --z-header: 2; --z-composer: 3; --z-scroll: 4; --z-menu: 7;
  --z-scrim: 9; --z-sidebar: 10; --z-toast: 40;
  --ease: 180ms ease-out;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --profile-icon: var(--cyan); --profile-icon-soft: var(--cyan-soft);
  --theme-icon: var(--amber); --theme-icon-soft: var(--amber-soft);
  --exit-icon: var(--danger); --exit-icon-soft: var(--danger-soft);
  --canvas: #1c1724; --surface: #261f30; --surface-raised: #32283f;
  --text: #f3edf8; --muted: #c4b4d0; --faint: #b09bbf;
  --line: #4a3b58; --line-strong: #675174; --hover: #392b49;
  --accent: #d2aeff; --accent-hover: #e1c5ff; --accent-ink: #301b4c; --accent-soft: #432c5c;
  --sidebar: #15111c; --sidebar-hover: #30243d; --sidebar-active: #392b49;
  --sidebar-text: #f3edf8; --sidebar-muted: #c1b0ce; --sidebar-divider: #41314e;
  --sidebar-search: #211929; --sidebar-search-border: #564264;
  --sidebar-action: #d2aeff; --sidebar-action-hover: #e1c5ff; --sidebar-action-text: #301b4c;
  --sidebar-mark: #d2aeff; --sidebar-mark-text: #301b4c; --sidebar-indicator: #d2aeff;
  --sidebar-skeleton: #4b395a;
  --blue: #a5beff; --blue-soft: #2e3656;
  --pink: #edaccd; --pink-soft: #4a2c41;
  --violet: #d0affb; --violet-soft: #442d5e;
  --cyan: #87d4e4; --cyan-soft: #263c47;
  --amber: #e9c38d; --amber-soft: #443725;
  --mint: #a5d8b7; --mint-soft: #2a4035;
  --success: #a5d8b7; --warning: #edc387; --warning-soft: #45321e;
  --danger: #f3a5b2; --danger-soft: #482533;
  --user-bg: #3c2b4c; --table-head: #30243c;
  --code-bg: #120e19; --code-text: #f0e9f6; --code-muted: #c4b3d1;
  --code-line: #4e3c5c; --code-hover: #35253f;
  --shadow: 0 14px 44px #0005, 0 2px 7px #0003;
  --menu-shadow: 0 18px 54px #0007; --overlay: #09050ec7;
}
/* Warm amber is a third palette, independent of the operating system theme. */
html[data-theme="yellow"] {
  color-scheme: light;
  --profile-icon: #287563; --profile-icon-soft: #e3efe5;
  --theme-icon: var(--amber); --theme-icon-soft: var(--amber-soft);
  --exit-icon: #9d4d37; --exit-icon-soft: #fae6db;
  --canvas: #fffbef; --surface: #fffef9; --surface-raised: #fffef9;
  --text: #3d3422; --muted: #736143; --faint: #7a694b;
  --line: #e6dcc0; --line-strong: #cdbd91; --hover: #f5edcf;
  --accent: #895b0c; --accent-hover: #704907; --accent-ink: #fff; --accent-soft: #f8edc5;
  --button-bg: #f0ce59; --button-hover: #e4bb3c; --button-ink: #44330c;
  --sidebar: #f3ecd5; --sidebar-hover: #e9dfbc; --sidebar-active: #fffdf4;
  --sidebar-text: #3d3422; --sidebar-muted: #736143; --sidebar-divider: #dcd0ad;
  --sidebar-search: #fcf7e8; --sidebar-search-border: #cdbd91;
  --sidebar-action: #f0ce59; --sidebar-action-hover: #e4bb3c; --sidebar-action-text: #44330c;
  --sidebar-mark: #f0ce59; --sidebar-mark-text: #44330c; --sidebar-indicator: #895b0c;
  --sidebar-skeleton: #dfd1a7;
  --amber: #895b0c; --amber-soft: #f8edc5;
  --warning: #865415; --warning-soft: #fbedcb;
  --user-bg: #f5e9bc; --table-head: #f7f0d8;
  --code-bg: #282319; --code-text: #fff5dd; --code-muted: #d1c3a5;
  --code-line: #65583d; --code-hover: #423925;
  --shadow: 0 14px 44px #67501812, 0 2px 7px #67501808;
  --menu-shadow: 0 18px 54px #4a381b26; --overlay: #251e12a6;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { display: flex; margin: 0; overflow: hidden; background: var(--canvas); color: var(--text); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.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; }
.icon-button { display: grid; flex: none; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); transition: color var(--ease), background var(--ease); }
.icon-button:hover { background: var(--accent-soft); color: var(--text); }
.mobile-only { display: none; }
.desktop-only { display: grid; }
#theme-toggle { background: var(--theme-icon-soft); color: var(--theme-icon); border: 1px solid color-mix(in srgb,var(--theme-icon) 20%,transparent); }
#theme-toggle:hover { background: color-mix(in srgb,var(--theme-icon) 18%,var(--surface)); color: var(--theme-icon); }
.theme-palette-icon { width: 21px; height: 21px; transition: transform 220ms ease-out; }
html[data-theme="dark"] .theme-palette-icon { transform: rotate(-12deg); }
html[data-theme="yellow"] .theme-palette-icon { transform: rotate(12deg); }
#theme-toggle:hover .theme-palette-icon { transform: rotate(-18deg); }
.palette-dot { stroke: none; }
.palette-blue { fill: var(--blue); }
.palette-pink { fill: var(--pink); }
.palette-mint { fill: var(--mint); }
.palette-amber { fill: var(--amber); }

/* Navigation */
aside { position: relative; display: flex; flex: none; flex-direction: column; width: 254px; min-height: 0; height: 100dvh; padding: 26px 14px 14px; border-right: 1px solid var(--sidebar-divider); background-color: var(--sidebar); background-image: radial-gradient(color-mix(in srgb,var(--sidebar-divider) 32%,transparent) .5px,transparent .5px); background-size: 9px 9px; color: var(--sidebar-text); transition: background-color var(--ease), color var(--ease); }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 27px; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; margin-left: 5px; font-size: 17px; font-weight: 700; letter-spacing: -.04em; }
.brand-mark { display: grid; flex: none; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: var(--sidebar-mark); color: var(--sidebar-mark-text); font-size: 17px; font-weight: 750; letter-spacing: -.08em; }
.brand-name { white-space: nowrap; }
.brand .brand-name span { color: var(--sidebar-muted); font-weight: 450; }
.sidebar-top .icon-button { width: 28px; height: 30px; color: var(--sidebar-muted); }
.sidebar-top .icon-button:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
#new-chat { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 11px 13px; border: 0; border-radius: 13px; background: var(--sidebar-action); color: var(--sidebar-action-text); text-align: left; font-size: 13px; font-weight: 650; transition: background var(--ease), transform var(--ease); }
#new-chat:hover { background: var(--sidebar-action-hover); transform: translateY(-1px); }
.new-chat-icon, .new-chat-arrow { display: inline-flex; flex: none; align-items: center; }
.new-chat-arrow { margin-left: auto; }
#history-section { display: flex; flex: 1; flex-direction: column; min-height: 0; margin-top: 18px; }
#history-search { width: calc(100% - 8px); min-height: 38px; margin: 0 4px 9px; padding: 9px 11px; border: 1px solid var(--sidebar-search-border); border-radius: 10px; background: var(--sidebar-search); color: var(--sidebar-text); outline: none; font-size: 12px; }
#history-search::placeholder { color: var(--sidebar-muted); }
#history-search:focus { border-color: var(--sidebar-indicator); box-shadow: 0 0 0 2px color-mix(in srgb,var(--sidebar-indicator) 18%,transparent); }
#history-list { display: flex; flex-direction: column; gap: 3px; min-height: 0; padding-bottom: 12px; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--sidebar-divider) var(--sidebar); }
#history-list p { margin: 9px 12px; color: var(--sidebar-muted); font-size: 12px; line-height: 1.6; }
.history-group { margin: 18px 12px 7px; color: var(--sidebar-muted); font-size: 10px; font-weight: 650; letter-spacing: .04em; }
.history-entry { position: relative; display: flex; align-items: center; min-width: 0; border-radius: 9px; transition: background var(--ease); }
.history-entry:hover, .history-entry:focus-within { background: var(--sidebar-hover); }
.history-entry.active { background: var(--sidebar-active); box-shadow: inset 2px 0 var(--sidebar-indicator); }
.history-item { flex: 1; min-width: 0; padding: 11px 5px 11px 12px; border: 0; background: transparent; color: var(--sidebar-muted); text-align: left; font-size: 12px; }
.history-entry.active .history-item { color: var(--sidebar-text); font-weight: 650; }
.history-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-more { flex: none; width: 28px; height: 30px; margin-right: 3px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--sidebar-text); font-size: 21px; line-height: 1; opacity: 0; }
.history-entry:hover .history-more, .history-entry:focus-within .history-more, .history-more[aria-expanded="true"] { opacity: 1; }
.history-more:hover, .history-more[aria-expanded="true"] { background: var(--sidebar-hover); }
.history-menu { position: absolute; z-index: var(--z-menu); top: calc(100% - 2px); right: 2px; min-width: 160px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-raised); color: var(--text); box-shadow: var(--menu-shadow); }
.history-menu button { width: 100%; min-height: 38px; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; font-size: 12px; }
.history-menu button:hover { background: var(--hover); }
.history-menu .danger-action { color: var(--danger); }
.history-menu .danger-action:hover { background: var(--danger-soft); }
.sidebar-bottom { position: relative; margin-top: auto; padding-top: 10px; }
#docs-link { display: flex; justify-content: space-between; margin: 0 5px 13px; padding: 12px 7px; border-bottom: 1px solid var(--sidebar-divider); color: var(--sidebar-muted); text-decoration: none; font-size: 12px; }
#docs-link:hover { color: var(--sidebar-text); }
.profile { position: relative; }
.profile-row { min-width: 0; }
.company-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--sidebar-text); font-size: 12px; font-weight: 650; }
.profile-menu-button { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; min-height: 58px; padding: 7px; border: 1px solid transparent; border-radius: 16px; background: transparent; color: var(--sidebar-text); text-align: left; transition: background var(--ease), border-color var(--ease); }
.profile-menu-button:hover, .profile-menu-button:focus-visible, .profile-menu-button[aria-expanded="true"] { border-color: color-mix(in srgb,var(--profile-icon) 20%,transparent); background: var(--sidebar-hover); }
.profile-symbol { display: grid; flex: none; place-items: center; width: 40px; height: 40px; border: 1px solid color-mix(in srgb,var(--profile-icon) 22%,transparent); border-radius: 13px; background: var(--profile-icon-soft); color: var(--profile-icon); }
.profile-more { flex: none; width: 17px; height: 17px; color: var(--sidebar-muted); opacity: .6; transition: opacity var(--ease); }
.profile-menu-button:hover .profile-more, .profile-menu-button:focus-visible .profile-more, .profile-menu-button[aria-expanded="true"] .profile-more { opacity: 1; }
.profile-avatar { width: 23px; height: 23px; pointer-events: none; }
.profile-loading { display: flex; align-items: center; min-height: 48px; padding: 2px 4px; }
.profile-loading-avatar { display: block; width: 44px; height: 44px; border-radius: 15px; }
.profile-menu { position: absolute; z-index: 8; bottom: calc(100% + 9px); left: 4px; width: min(238px,calc(100vw - 42px)); padding: 9px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-raised); color: var(--text); box-shadow: var(--menu-shadow); }
.profile-menu-heading { padding: 6px 8px 2px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.profile-menu-name { overflow-wrap: anywhere; padding: 3px 8px 12px; margin-bottom: 5px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 650; }
.profile-menu button { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 40px; padding: 10px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; font-size: 12px; }
.profile-menu button:hover { background: var(--accent-soft); }
.profile-action-icon { display: grid; flex: none; place-items: center; width: 30px; height: 30px; border-radius: 10px; }
.profile-action-icon svg { width: 18px; height: 18px; }
.theme-action-icon { color: var(--theme-icon); background: var(--theme-icon-soft); }
.logout-action-icon { color: var(--exit-icon); background: var(--exit-icon-soft); }
.profile-loading-avatar { background: var(--sidebar-skeleton); animation: skeleton 1.5s ease-in-out infinite alternate; }

/* Workspace and welcome */
main { position: relative; display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; height: 100dvh; background: var(--canvas); }
header { z-index: var(--z-header); display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 74px; padding: 14px 32px; border-bottom: 1px solid var(--line); }
.header-title, .header-actions { display: flex; align-items: center; gap: 12px; }
header strong { display: block; font-size: 13px; font-weight: 650; }
header small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 7px 9px; border-radius: 999px; background: var(--mint-soft); color: var(--success); font-size: 10px; font-weight: 600; white-space: nowrap; }
.badge svg { width: 13px; height: 13px; }
#messages { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 26px 32px var(--composer-clearance,250px); scroll-padding-bottom: var(--composer-clearance,250px); scrollbar-width: thin; scrollbar-color: var(--line-strong) var(--canvas); }
#welcome, .message { width: min(100%,var(--content-width)); margin-inline: auto; }
#welcome { padding: 20px 0 20px; }
.welcome-hero { position: relative; isolation: isolate; min-height: 218px; padding: 4px 0 24px; }
.eyebrow { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .13em; }
.eyebrow-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
h1 { max-width: 530px; margin: 19px 0 16px; color: var(--text); font-family: Georgia,"Times New Roman",serif; font-size: clamp(44px,4vw,54px); font-weight: 400; line-height: 1.08; letter-spacing: -.045em; }
h1 em { color: var(--accent); font-weight: 400; }
.welcome-description { max-width: 470px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.welcome-art { position: absolute; z-index: -1; top: 10px; right: 2px; width: 220px; padding: 14px 5px; border-radius: 110px 110px 22px 22px; background-color: var(--accent-soft); background-image: radial-gradient(var(--line-strong) .7px,transparent .7px); background-size: 16px 16px; opacity: .7; pointer-events: none; }
.welcome-art svg { display: block; width: 100%; height: auto; }
.art-line { stroke: var(--line); }
.art-one { fill: var(--pink-soft); stroke: var(--pink); stroke-opacity: .25; }
.art-two { fill: var(--amber-soft); stroke: var(--amber); stroke-opacity: .25; }
.art-three { fill: var(--accent); fill-opacity: .32; stroke: var(--accent); stroke-opacity: .2; }
.art-ring { stroke: var(--blue); stroke-width: 5px; stroke-opacity: .45; }
.art-trend { stroke: var(--accent); stroke-width: 2px; stroke-linecap: round; }
.suggestion-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 20px 0 13px; font-size: 12px; font-weight: 650; }
.suggestion-heading small { color: var(--muted); font-size: 10px; font-weight: 400; }
.suggestions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.suggestions button { display: flex; align-items: center; gap: 12px; min-width: 0; min-height: 84px; padding: 15px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); text-align: left; box-shadow: 0 3px 10px #44245e04; transition: border-color var(--ease), transform var(--ease), box-shadow var(--ease); }
.suggestions button:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.suggestion-icon { display: inline-grid; flex: none; place-items: center; width: 38px; height: 38px; border-radius: 13px; background: var(--category-soft); color: var(--category); }
.suggestion-icon svg { width: 19px; height: 19px; }
.suggestion-copy { flex: 1; min-width: 0; }
.suggestions strong { display: block; color: var(--text); font-size: 12px; font-weight: 650; }
.suggestions small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.45; }
.suggestion-arrow { display: inline-flex; flex: none; align-self: center; margin-left: auto; color: var(--faint); }
.suggestion-arrow svg { width: 14px; height: 14px; }
[data-category="blue"] { --category: var(--blue); --category-soft: var(--blue-soft); }
[data-category="pink"] { --category: var(--pink); --category-soft: var(--pink-soft); }
[data-category="violet"] { --category: var(--violet); --category-soft: var(--violet-soft); }
[data-category="cyan"] { --category: var(--cyan); --category-soft: var(--cyan-soft); }
[data-category="amber"] { --category: var(--amber); --category-soft: var(--amber-soft); }
[data-category="mint"] { --category: var(--mint); --category-soft: var(--mint-soft); }
#welcome > .hint { display: flex; align-items: flex-start; gap: 7px; margin: 18px 0 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.hint svg { flex: none; width: 14px; height: 14px; margin-top: 2px; color: var(--violet); }

/* Messages and Markdown */
.message { margin-bottom: 32px; animation: rise-in 180ms ease-out; }
.message .who { margin-bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 650; }
.message-time { margin-left: 12px; color: var(--faint); font-size: 10px; font-weight: 400; }
.message .body { overflow-wrap: anywhere; font-size: 14px; line-height: 1.8; }
.message.user { display: flex; flex-direction: column; align-items: flex-end; margin-top: 4px; }
.message.user .who { padding-right: 4px; }
.message.user .body { max-width: min(84%,600px); padding: 13px 18px; border-radius: 18px 18px 5px 18px; background: var(--user-bg); white-space: pre-wrap; }
.message.assistant { padding-bottom: 10px; }
.assistant-avatar { display: inline-grid; flex: none; place-items: center; width: 27px; height: 27px; margin-right: 8px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 750; letter-spacing: -.08em; }
.message.assistant .who { display: flex; align-items: center; font-size: 12px; }
.message.assistant .body { padding-left: 35px; }
.answer-text { white-space: pre-wrap; }
.answer-text + .answer-text { margin-top: 14px; }
.answer-text .answer-paragraph { margin: 0 0 13px; }
.answer-text .answer-paragraph:last-child { margin-bottom: 0; }
.answer-text h2, .answer-text h3, .answer-text h4 { margin: 20px 0 10px; line-height: 1.35; font-weight: 650; letter-spacing: -.02em; }
.answer-text h2 { font-size: 21px; }
.answer-text h3 { font-size: 18px; }
.answer-text h4 { font-size: 16px; }
.answer-text ul, .answer-text ol { margin: 10px 0 15px; padding-left: 24px; }
.answer-text li + li { margin-top: 5px; }
.message code:not(pre code) { padding: 2px 5px; border-radius: 5px; background: var(--accent-soft); color: var(--text); font-family: Consolas,monospace; font-size: .9em; }
.code-block { overflow: hidden; margin: 18px 0 21px; border: 1px solid var(--code-line); border-radius: 14px; background: var(--code-bg); color: var(--code-text); }
.code-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 40px; padding: 0 14px; border-bottom: 1px solid var(--code-line); color: var(--code-muted); font-size: 11px; }
.code-copy { padding: 6px 9px; border: 0; border-radius: 7px; background: transparent; color: var(--code-text); font-size: 11px; }
.code-copy:hover { background: var(--code-hover); }
.code-block pre { overflow: auto; max-height: 480px; margin: 0; padding: 16px 18px; color: var(--code-text); font-family: Consolas,monospace; font-size: 12px; line-height: 1.7; tab-size: 2; }
.code-block code { font: inherit; white-space: pre; }
.message-actions { display: flex; flex-wrap: wrap; gap: 5px; margin: 12px 0 0 35px; }
.message-actions button, .request-error button { padding: 7px 9px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); font-size: 11px; }
.message-actions button:hover, .request-error button:hover { background: var(--accent-soft); color: var(--accent); }
.message-organization { max-width: 90%; margin-top: 7px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.thinking { display: flex; align-items: center; gap: 9px; min-height: 38px; color: var(--muted); font-size: 12px; }
.thinking-indicator { flex: none; width: 12px; height: 12px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
.request-error { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; width: min(100%,var(--content-width)); margin: -15px auto 24px; padding: 12px 14px; border: 1px solid color-mix(in srgb,var(--danger) 38%,var(--line)); border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: 12px; line-height: 1.6; }
.request-error button { color: var(--danger); font-weight: 650; }

/* Tables: preserve the existing rendering, pagination, CSV and copy controls. */
.inventory-table-note { display: flex; align-items: center; gap: 8px; margin: 20px 0 8px; color: var(--text); font-size: 13px; font-weight: 650; }
.inventory-table-note::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 2px; background: var(--cyan); }
.table-warning { margin: 12px 0; padding: 13px 15px; border: 1px solid color-mix(in srgb,var(--warning) 45%,var(--line)); border-radius: 12px; background: var(--warning-soft); color: var(--warning); font-size: 12px; line-height: 1.65; }
.answer-table-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; max-width: 100%; margin-top: 14px; padding: 10px; border: 1px solid var(--line); border-radius: 16px 16px 0 0; background: var(--surface); }
.answer-table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin: 8px 0 16px; }
.answer-table-toolbar .answer-table-tools { display: contents; }
.answer-table-tools button, .table-action { order: 2; min-height: 33px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); font-size: 11px; }
.answer-table-tools button:hover, .table-action:hover { border-color: var(--cyan); background: var(--cyan-soft); color: var(--cyan); }
.answer-table-tools span { order: 4; flex-basis: 100%; color: var(--muted); font-size: 11px; line-height: 1.6; }
.answer-table-tools span:empty { display: none; }
.table-search { order: 0; flex: 1 1 150px; min-width: 130px; width: 100%; max-width: 270px; min-height: 33px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas); color: var(--text); font-size: 11px; }
.table-search::placeholder { color: var(--faint); }
.table-search:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
.answer-table-scroll { position: relative; max-width: 100%; max-height: 460px; margin: 0 0 10px; overflow: auto; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 16px 16px; background: var(--surface); scrollbar-width: thin; scrollbar-color: var(--line-strong) var(--surface); white-space: normal; }
.answer-table { border-collapse: collapse; width: 100%; font-size: 12px; line-height: 1.6; overflow-wrap: normal; font-variant-numeric: tabular-nums; }
.answer-table th, .answer-table td { min-width: 110px; max-width: 360px; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.answer-table th { position: sticky; z-index: 1; top: 0; background: var(--table-head); color: var(--muted); font-size: 11px; font-weight: 650; white-space: normal; }
.answer-table tbody tr:hover { background: var(--accent-soft); }
.answer-table tbody tr:last-child td { border-bottom: 0; }
.answer-table-total { border-top: 1px solid var(--line-strong); background: var(--table-head); font-weight: 700; }
.table-sort { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; width: 100%; min-height: 32px; padding: 0; border: 0; background: none; color: inherit; text-align: inherit; font-size: inherit; font-weight: inherit; }
.table-sort-label { flex: 1; width: max-content; max-width: 24ch; white-space: normal; overflow-wrap: break-word; }
.table-sort-icon { flex: none; color: var(--cyan); font-weight: 400; }
.table-sort:hover, .table-sort:focus-visible { color: var(--accent); }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 9px 0 18px; color: var(--muted); font-size: 11px; }
.table-footer button { flex: none; min-height: 32px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 11px; }
.table-footer button:hover { background: var(--accent-soft); }
.excel-copy-fallback { display: block; order: 5; flex-basis: 100%; width: 100%; min-height: 100px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-family: Consolas,monospace; white-space: pre; }
.answer-table-scroll.is-fullscreen { position: fixed; z-index: 30; inset: 12px; width: auto; max-width: none; max-height: none; margin: 0; padding: 48px 12px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 0 0 100vmax var(--overlay); }
.table-close-full { position: fixed; z-index: 32; top: 23px; right: 25px; min-height: 32px; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-raised); color: var(--text); font-size: 12px; }

/* Sources and server-provided timing */
details { margin-top: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); font-size: 12px; }
summary { cursor: pointer; }
details pre { max-height: 320px; overflow: auto; margin-bottom: 0; color: var(--text); font-family: Consolas,monospace; font-size: 11px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.sources { margin: 12px 0 0 35px; padding: 12px 0; border: 0; border-block: 1px solid var(--line); border-radius: 0; background: transparent; }
.sources > summary { color: var(--violet); font-size: 12px; font-weight: 650; }
.source-list { display: grid; gap: 8px; margin-top: 12px; }
.source-item { margin: 0; background: var(--surface); }
.source-item > summary { display: flex; align-items: center; gap: 8px; list-style-position: inside; }
.source-chip { display: inline-flex; padding: 5px 9px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 650; }
.source-chip[data-source="search_demoai_metadata"] { background: var(--blue-soft); color: var(--blue); }
.source-chip[data-source="run_dynamic_query"], .source-chip[data-source="edit_saved_table"], .source-chip[data-source="update_table_totals"] { background: var(--cyan-soft); color: var(--cyan); }
.source-failure { color: var(--danger); }
.source-query { margin: 12px 0; border: 1px solid var(--code-line); border-radius: 11px; background: var(--code-bg); color: var(--code-text); }
.source-query > span { display: block; padding: 12px 12px 0; color: var(--code-muted); font-size: 11px; line-height: 1.65; }
.source-query button { display: block; max-width: calc(100% - 16px); margin: 8px 8px 8px auto; padding: 6px 9px; border: 1px solid var(--code-line); border-radius: 7px; background: var(--code-hover); color: var(--code-text); font-size: 11px; }
.source-query pre { margin: 0; padding: 12px; color: var(--code-text); white-space: pre; overflow: auto; }
.source-technical { margin-top: 8px; background: var(--canvas); }
.source-technical summary { color: var(--muted); }
.execution-timing { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin: 14px 0 0 35px; color: var(--muted); font-size: 11px; }
.execution-timing > span { font-variant-numeric: tabular-nums; }
.execution-timing details { min-width: 0; margin: 0; padding: 0; border: 0; background: transparent; font-size: 11px; }
.execution-timing dl { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 5px 20px; margin: 10px 0 0; }
.execution-timing dt { overflow-wrap: anywhere; }
.execution-timing dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Floating composer and context menus */
.compose { position: absolute; z-index: var(--z-composer); right: 0; bottom: 0; left: 0; isolation: isolate; padding: 12px 32px max(16px,env(safe-area-inset-bottom)); pointer-events: none; }
.compose::before { content: ""; position: absolute; z-index: -1; inset: 0 max(24px,calc((100% - var(--content-width))/2 - 8px)) 0; border-radius: 22px 22px 0 0; background: color-mix(in srgb,var(--canvas) 94%,transparent); backdrop-filter: blur(18px); pointer-events: none; }
.compose > * { width: min(100%,var(--content-width)); margin-inline: auto; pointer-events: auto; }
.compose > .sr-only { width: 1px; margin: -1px; pointer-events: none; }
.composer-controls { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-start; gap: 8px; padding: 0 2px 10px; }
.composer-input-row { position: relative; }
.organization-control { position: relative; display: flex; align-items: center; flex: 0 1 auto; gap: 6px; min-width: 0; max-width: min(100%,385px); }
#organization-trigger { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; min-height: 35px; padding: 4px 7px 4px 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); text-align: left; transition: border-color var(--ease), background var(--ease); }
#organization-trigger:hover:not(:disabled), #organization-trigger[aria-expanded="true"] { border-color: var(--blue); background: var(--surface-raised); }
#organization-trigger:disabled { opacity: 1; cursor: default; }
#organization-trigger > svg { flex: none; color: var(--blue); }
.organization-label { flex: none; white-space: nowrap; font-size: 10px; font-weight: 500; }
.organization-value { display: inline-flex; align-items: center; gap: 6px; min-width: 0; min-height: 25px; color: var(--text); font-size: 11px; font-weight: 600; }
#organization-current { min-width: 0; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.organization-chevron { flex: none; color: var(--muted); transition: transform var(--ease); }
#organization-trigger[aria-expanded="true"] .organization-chevron { transform: rotate(180deg); }
.organization-control[data-single="true"] .organization-chevron { display: none; }
.reasoning-control { position: relative; display: inline-flex; align-items: center; gap: 7px; max-width: 100%; min-height: 35px; padding: 4px 6px 4px 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); transition: border-color var(--ease), background var(--ease); }
.reasoning-control:hover, .reasoning-control:focus-within { border-color: var(--violet); background: var(--surface-raised); }
.reasoning-control > svg { flex: none; color: var(--violet); }
.reasoning-label { white-space: nowrap; font-size: 10px; font-weight: 500; }
#reasoning-trigger { display: inline-flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 87px; min-height: 25px; padding: 3px 5px 3px 4px; border: 0; border-radius: 7px; background: transparent; color: var(--text); text-align: left; font-size: 11px; font-weight: 600; }
#reasoning-trigger:hover, #reasoning-trigger[aria-expanded="true"] { background: var(--violet-soft); }
#reasoning-trigger svg { flex: none; color: var(--muted); transition: transform var(--ease); }
#reasoning-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
#reasoning-menu, #organization-menu { position: absolute; z-index: var(--z-menu); bottom: calc(100% + 9px); left: 0; max-width: calc(100vw - 32px); padding: 8px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface-raised); color: var(--text); box-shadow: var(--menu-shadow); }
#reasoning-menu { display: grid; gap: 3px; width: 246px; }
#reasoning-menu button { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 55px; padding: 10px 27px 10px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; font-size: 12px; }
#reasoning-menu button:hover, #reasoning-menu button:focus-visible { outline-offset: -2px; background: var(--hover); }
#reasoning-menu button[aria-checked="true"] { background: var(--violet-soft); color: var(--violet); font-weight: 650; }
#reasoning-menu button[aria-checked="true"]::after { content: "✓"; position: absolute; right: 10px; top: 16px; font-size: 14px; }
.mode-icon { display: grid; flex: none; place-items: center; width: 31px; height: 31px; border-radius: 9px; background: var(--category-soft); color: var(--category); }
.mode-icon svg { width: 17px; height: 17px; }
.mode-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 400; }
#organization-menu { width: min(360px,calc(100vw - 32px)); }
.organization-menu-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 8px 14px; }
.organization-menu-head strong { color: var(--text); font-size: 14px; }
.organization-menu-head span { color: var(--muted); font-size: 10px; white-space: nowrap; }
#organization-search { display: block; width: 100%; min-height: 39px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); color: var(--text); font: inherit; font-size: 12px; }
#organization-search::placeholder { color: var(--faint); }
#organization-options { display: grid; gap: 3px; max-height: min(280px,38dvh); overflow: auto; margin-top: 7px; overscroll-behavior: contain; scrollbar-width: thin; }
#organization-options button { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 42px; padding: 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; font-size: 12px; line-height: 1.5; text-align: left; overflow-wrap: anywhere; }
#organization-options button:hover, #organization-options button:focus-visible { outline-offset: -2px; background: var(--hover); }
#organization-options button[aria-checked="true"] { background: var(--blue-soft); color: var(--blue); font-weight: 650; }
#organization-options button[aria-checked="true"]::after { content: "✓"; flex: none; font-size: 14px; }
#organization-note { margin: 10px 8px 5px; color: var(--muted); font-size: 11px; line-height: 1.6; }
#organization-refresh { display: block; min-height: 32px; margin: 5px 0 0 auto; padding: 6px 9px; border: 0; border-radius: 8px; background: transparent; color: var(--blue); font-size: 11px; }
#organization-refresh:hover { background: var(--blue-soft); }
#organization-continue { flex: none; min-height: 33px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--blue-soft); color: var(--blue); font-size: 11px; }
#status { min-height: 0; padding: 0 4px 7px; color: var(--muted); font-size: 12px; line-height: 1.6; }
#status:empty { display: none; }
#status.is-error { color: var(--danger); }
#form { display: flex; align-items: flex-end; gap: 12px; min-height: 76px; padding: 12px 12px 12px 19px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); transition: border-color var(--ease), box-shadow var(--ease); }
#form:focus-within { border-color: var(--accent); box-shadow: var(--shadow),0 0 0 2px color-mix(in srgb,var(--accent) 12%,transparent); }
#message { display: block; flex: 1; min-width: 0; min-height: 42px; max-height: 192px; padding: 10px 1px 8px 0; resize: none; overflow-y: auto; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; line-height: 1.6; }
#message::placeholder { color: var(--faint); }
#send { display: grid; flex: none; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 13px; background: var(--button-bg); color: var(--button-ink); transition: background var(--ease), transform var(--ease); }
#send:not(:disabled):hover { background: var(--button-hover); transform: translateY(-1px); }
#send:disabled { opacity: .45; }
.compose > small { display: block; margin-top: 10px; color: var(--muted); font-size: 10px; line-height: 1.5; text-align: center; }
#scroll-bottom { position: absolute; z-index: var(--z-scroll); right: max(32px,calc((100% - var(--content-width))/2)); bottom: var(--composer-clearance,240px); border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface-raised); color: var(--accent); box-shadow: var(--shadow); }
.conversation-banner { margin-bottom: 9px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); font-size: 12px; line-height: 1.6; }
.conversation-banner button { padding: 0; border: 0; background: none; color: var(--accent); font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }
.send-control { position: relative; flex: none; display: inline-flex; border-radius: 13px; }
.send-control[data-hint] { cursor: not-allowed; }
.send-control[data-hint] #send:disabled { pointer-events: none; }
.send-control[data-hint]:is(:hover,:focus-visible)::after { content: attr(data-hint); position: absolute; z-index: var(--z-menu); right: 0; bottom: calc(100% + 12px); width: max-content; max-width: min(280px,calc(100vw - 48px)); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface-raised); color: var(--text); box-shadow: var(--menu-shadow); font-size: 12px; line-height: 1.6; text-align: left; pointer-events: none; }
.send-hint { margin: 8px auto 0; padding-inline: 5px; color: var(--muted); font-size: 12px; line-height: 1.6; }

/* Authentication, confirmation and feedback */
#company-login, #confirm-delete, #theme-dialog { padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-raised); color: var(--text); box-shadow: var(--menu-shadow); }
#company-login { width: min(420px,calc(100vw - 32px)); }
#company-login::backdrop, #confirm-delete::backdrop, #theme-dialog::backdrop { background: var(--overlay); backdrop-filter: blur(5px); }
#company-login-form { display: grid; gap: 15px; padding: 34px; }
#company-login-form h2 { margin: 0; font-size: 28px; font-weight: 650; letter-spacing: -.04em; }
#company-login-form p { margin: 0 0 7px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.login-icon { display: grid; place-items: center; width: 45px; height: 45px; margin-bottom: 6px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-size: 21px; font-weight: 750; letter-spacing: -.08em; }
#company-login-form label { display: grid; gap: 8px; color: var(--text); font-size: 12px; }
#company-login-form input { width: 100%; min-height: 45px; padding: 12px 13px; border: 1px solid var(--line-strong); border-radius: 11px; outline: none; background: var(--canvas); color: var(--text); }
#company-login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb,var(--accent) 14%,transparent); }
#company-login-form button { min-height: 45px; padding: 12px; border: 0; border-radius: 11px; background: var(--button-bg); color: var(--button-ink); font-size: 13px; font-weight: 650; }
#company-login-form button:hover { background: var(--button-hover); }
#company-login-form .login-error { min-height: 17px; margin: 0; color: var(--danger); font-size: 12px; }
/* Theme chooser: miniatures keep their own palette in all three themes. */
#theme-dialog { width: min(700px,calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 28px; overflow: auto; }
.theme-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.theme-heading .eyebrow { color: var(--muted); font-size: 10px; letter-spacing: .1em; }
.theme-heading h2 { margin: 8px 0 0; font-size: 28px; font-weight: 650; letter-spacing: -.04em; }
#theme-close svg { width: 20px; height: 20px; }
#theme-description { margin: 12px 0 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.theme-choices { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.theme-choice { position: relative; display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 9px 9px 16px; border: 1px solid var(--line-strong); border-radius: 15px; background: var(--surface); color: var(--text); text-align: left; transition: border-color var(--ease), box-shadow var(--ease), background var(--ease); }
.theme-choice:hover { border-color: var(--accent); background: var(--canvas); }
.theme-choice[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-choice-info { display: grid; gap: 5px; padding: 0 4px; }
.theme-choice-info strong { font-size: 13px; font-weight: 650; }
.theme-choice-info small { font-size: 11px; color: var(--muted); }
.theme-check { position: absolute; top: 17px; right: 17px; display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--preview-edge); border-radius: 50%; background: var(--preview-surface); color: transparent; }
.theme-check svg { width: 16px; height: 16px; }
.theme-choice[aria-checked="true"] .theme-check { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
[data-theme-choice="light"] { --preview-bg: #f7f5fa; --preview-surface: #fff; --preview-side: #eee9f4; --preview-accent: #7541b4; --preview-edge: #d9cde5; --preview-line: #d4c7e0; }
[data-theme-choice="dark"] { --preview-bg: #1c1724; --preview-surface: #32283f; --preview-side: #15111c; --preview-accent: #d2aeff; --preview-edge: #6a547c; --preview-line: #78608a; }
[data-theme-choice="yellow"] { --preview-bg: #fffbef; --preview-surface: #fffef9; --preview-side: #f3ecd5; --preview-accent: #e8c44e; --preview-edge: #d8c58e; --preview-line: #d5c69d; }
.theme-preview { display: flex; width: 100%; height: 122px; overflow: hidden; border: 1px solid var(--preview-edge); border-radius: 9px; background: var(--preview-bg); }
.preview-sidebar { display: flex; flex-direction: column; flex: 0 0 24%; gap: 8px; padding: 13px 7px; background: var(--preview-side); border-right: 1px solid var(--preview-edge); }
.preview-sidebar i { display: block; width: 100%; height: 4px; border-radius: 3px; background: var(--preview-line); }
.preview-sidebar i:first-child { height: 10px; margin-bottom: 4px; background: var(--preview-accent); }
.preview-chat { display: flex; flex: 1; flex-direction: column; gap: 6px; padding: 27px 11px 11px; }
.preview-chat > i { display: block; width: 65%; height: 5px; border-radius: 3px; background: var(--preview-line); }
.preview-chat > i:first-child { width: 42%; height: 8px; background: var(--preview-accent); }
.preview-cards { display: flex; gap: 5px; margin-top: 5px; }
.preview-cards i { width: 40%; height: 17px; border: 1px solid var(--preview-edge); border-radius: 4px; background: var(--preview-surface); }
.preview-composer { display: flex; justify-content: flex-end; height: 19px; margin-top: auto; padding: 4px; border: 1px solid var(--preview-edge); border-radius: 5px; background: var(--preview-surface); }
.preview-composer i { width: 10px; border-radius: 2px; background: var(--preview-accent); }
.theme-footer { display: flex; align-items: center; gap: 24px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
#theme-note { flex: 1; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
#theme-done { min-height: 40px; padding: 10px 23px; border: 0; border-radius: 11px; background: var(--button-bg); color: var(--button-ink); font-weight: 650; font-size: 13px; }
#theme-done:hover { background: var(--button-hover); }
@media (max-width:600px) {
  #theme-dialog { padding: 22px; }
  .theme-choices { grid-template-columns: 1fr; gap: 10px; }
  .theme-choice { flex-direction: row; align-items: center; gap: 12px; padding: 10px; }
  .theme-preview { flex: 0 0 86px; height: 72px; }
  .preview-sidebar { gap: 5px; padding: 9px 4px; }
  .preview-chat { gap: 4px; padding: 12px 6px 6px; }
  .preview-cards { display: none; }
  .theme-choice-info { padding: 0 22px 0 0; }
  .theme-choice-info strong { font-size: 12px; }
  .theme-check { top: 12px; right: 10px; width: 18px; height: 18px; }
  .theme-footer { gap: 12px; margin-top: 18px; padding-top: 16px; }
}

#confirm-delete { width: min(390px,calc(100vw - 32px)); padding: 25px; }
#confirm-delete h2 { margin: 0 0 10px; font-size: 20px; }
#confirm-delete p { margin: 0 0 23px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.dialog-actions button { min-height: 38px; padding: 8px 13px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 12px; }
.dialog-actions .danger-button { border-color: var(--danger-fill); background: var(--danger-fill); color: #fff; }
#toast { position: fixed; z-index: var(--z-toast); right: 20px; bottom: 20px; max-width: min(340px,calc(100vw - 40px)); padding: 12px 15px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-raised); color: var(--text); box-shadow: var(--menu-shadow); font-size: 12px; line-height: 1.6; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes skeleton { to { opacity: .45; } }

/* Responsive layout: no historical overrides below these states. */
@media (hover:none) { .history-more { opacity: 1; } }
@media (min-width:901px) {
  body.sidebar-collapsed aside { width: 72px; padding-inline: 10px; }
  body.sidebar-collapsed .sidebar-top { flex-direction: column; gap: 12px; }
  body.sidebar-collapsed .brand { margin: 0; }
  body.sidebar-collapsed .brand-name, body.sidebar-collapsed .new-chat-label, body.sidebar-collapsed .new-chat-arrow,
  body.sidebar-collapsed #history-section, body.sidebar-collapsed #docs-link span:first-child,
  body.sidebar-collapsed .company-name, body.sidebar-collapsed .profile-more { display: none; }
  body.sidebar-collapsed #new-chat { justify-content: center; margin-top: 20px; padding: 0; }
  body.sidebar-collapsed #new-chat .new-chat-icon svg { width: 22px; height: 22px; }
  body.sidebar-collapsed #docs-link { justify-content: center; margin-inline: 0; }
  body.sidebar-collapsed .profile-menu-button { justify-content: center; min-height: 52px; padding: 5px; }
  body.sidebar-collapsed .profile-loading { justify-content: center; padding-inline: 0; }
  body.sidebar-collapsed .profile-menu { left: 52px; right: auto; bottom: 0; width: 220px; }
}
@media (min-width:901px) and (max-height:850px) {
  #messages { padding-top: 18px; }
  #welcome { padding-top: 8px; }
  .welcome-hero { min-height: 0; padding-bottom: 10px; }
  h1 { margin: 13px 0 12px; font-size: 40px; }
  .welcome-description { max-width: 460px; font-size: 12px; line-height: 1.65; }
  .welcome-art { top: 0; width: 180px; }
  .suggestion-heading { margin: 13px 0 10px; }
  .suggestions { gap: 8px; }
  .suggestions button { min-height: 70px; padding: 11px 13px; }
  .suggestion-icon { width: 32px; height: 32px; border-radius: 11px; }
  .suggestions small { margin-top: 4px; font-size: 10px; }
  #welcome > .hint { margin-top: 12px; font-size: 9px; }
}
@media (max-width:1100px) and (min-width:901px) {
  aside { width: 232px; padding-inline: 11px; }
  .brand { font-size: 15px; gap: 7px; }
  .organization-label { display: none; }
}
@media (max-width:900px) {
  body.sidebar-open { overflow: hidden; }
  #sidebar-scrim:not([hidden]) { position: fixed; z-index: var(--z-scrim); inset: 0; background: var(--overlay); }
  aside { position: fixed; z-index: var(--z-sidebar); inset: 0 auto 0 0; width: min(310px,88vw); transform: translateX(-105%); box-shadow: 16px 0 50px #150b2029; transition: transform 220ms ease-out, background-color var(--ease), color var(--ease); }
  aside.is-open { transform: translateX(0); }
  .mobile-only { display: grid; }
  .desktop-only { display: none; }
  header { min-height: 67px; padding: 12px 20px; }
  #messages { padding: 25px 24px var(--composer-clearance,280px); }
  #welcome { padding-top: 18px; }
  h1 { font-size: 46px; }
  .welcome-art { width: 185px; opacity: .5; }
  .welcome-description { max-width: 420px; }
  .compose { padding: 12px 24px max(12px,env(safe-area-inset-bottom)); }
  .compose::before { inset-inline: 16px; }
  .organization-label { display: none; }
  .table-search { max-width: none; }
  .answer-table-toolbar { gap: 6px; }
  #scroll-bottom { right: 25px; }
}
@media (max-width:600px) {
  header { gap: 7px; min-height: 65px; padding: 12px 13px; }
  .header-title, .header-actions { gap: 6px; }
  header strong { font-size: 12px; white-space: nowrap; }
  header small { font-size: 9px; }
  .badge { padding: 6px 7px; font-size: 9px; }
  .badge svg { width: 11px; height: 11px; }
  #theme-toggle { width: 30px; }
  #messages { padding: 24px 18px var(--composer-clearance,290px); }
  #welcome { padding-top: 8px; }
  .welcome-hero { min-height: 220px; padding-bottom: 12px; }
  .eyebrow { font-size: 8px; letter-spacing: .08em; }
  h1 { max-width: 320px; margin: 19px 0 15px; font-size: 38px; line-height: 1.1; }
  .welcome-description { font-size: 12px; line-height: 1.7; }
  .welcome-art { top: 48px; right: -4px; width: 125px; opacity: .18; }
  .suggestion-heading { margin: 10px 0; font-size: 11px; }
  .suggestion-heading small { display: none; }
  .suggestions { gap: 8px; }
  .suggestions button { flex-direction: column; align-items: flex-start; gap: 9px; min-height: 125px; padding: 12px; border-radius: 15px; }
  .suggestion-icon { width: 30px; height: 30px; border-radius: 10px; }
  .suggestion-icon svg { width: 17px; height: 17px; }
  .suggestions strong { font-size: 11px; }
  .suggestions small { margin-top: 5px; font-size: 10px; line-height: 1.45; }
  .suggestion-arrow { display: none; }
  #welcome > .hint { margin-top: 14px; font-size: 9px; }
  .message { margin-bottom: 25px; }
  .message.user .body { max-width: 94%; padding: 12px 15px; font-size: 13px; }
  .message.assistant .body { padding-left: 0; }
  .message .body { font-size: 13px; }
  .message-actions, .execution-timing, .sources { margin-left: 0; }
  .message-actions { gap: 1px; }
  .message-actions button { padding: 7px 6px; font-size: 10px; }
  .answer-text h2 { font-size: 20px; }
  .answer-table-toolbar { padding: 8px; }
  .table-search { flex-basis: 100%; min-width: 0; }
  .table-action, .answer-table-tools button { flex: 1 0 auto; padding: 7px 8px; font-size: 10px; }
  .answer-table th, .answer-table td { min-width: 105px; padding: 10px 12px; }
  .table-footer { align-items: flex-start; font-size: 10px; line-height: 1.6; }
  .answer-table-scroll.is-fullscreen { inset: 4px; padding-inline: 6px; }
  .table-close-full { top: 14px; right: 14px; }
  .compose { padding: 10px 12px max(10px,env(safe-area-inset-bottom)); }
  .compose::before { inset-inline: 5px; }
  .composer-controls { gap: 7px; padding-bottom: 9px; }
  .organization-control { max-width: 100%; }
  .reasoning-label { display: none; }
  #organization-current { max-width: 235px; }
  #organization-trigger { padding-inline: 8px; }
  #reasoning-trigger { min-width: 84px; }
  #reasoning-menu { width: 238px; }
  #organization-menu { max-height: calc(100dvh - 180px); overflow-y: auto; }
  #form { min-height: 69px; gap: 8px; padding: 10px 10px 10px 14px; border-radius: 19px; }
  #message { font-size: 13px; }
  #send { width: 38px; height: 38px; border-radius: 12px; }
  .compose > small { margin-top: 8px; font-size: 8px; line-height: 1.5; }
  .send-hint { font-size: 11px; }
  #scroll-bottom { right: 17px; }
  #company-login-form { padding: 28px 24px; }
}
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* A widget is an attachment to the existing message, not a second chat surface. */
.widget-message-attachment { box-sizing: border-box; width: min(100%,420px); margin-top: 10px; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-raised); color: var(--text); text-align: left; }
.widget-attachment-open { display: block; max-width: 100%; min-height: 36px; padding: 0; border: 0; background: transparent; color: var(--accent); text-align: left; font: inherit; font-weight: 600; overflow-wrap: anywhere; }
.widget-attachment-open:hover { text-decoration: underline; }
.widget-attachment-meta { display: block; margin-top: 5px; font-size: 11px; line-height: 1.6; color: var(--muted); overflow-wrap: anywhere; }
.widget-attachment-table-preview { display: grid; gap: 6px; margin-top: 10px; font-size: 12px; }
.widget-attachment-table-preview > div { display: flex; justify-content: space-between; gap: 12px; }
.widget-attachment-table-preview span { min-width: 0; overflow-wrap: anywhere; }
.widget-attachment-table-preview strong { flex: none; font-variant-numeric: tabular-nums; }
.widget-attachment-table-preview small { font-size: 10px; color: var(--muted); line-height: 1.5; }
.widget-attachment-error { display: block; color: var(--danger); font-size: 12px; margin-top: 8px; }
.widget-attachment-error:empty { display: none; }
.widget-scope-choice { padding: 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-raised); margin-bottom: 12px; font-size: 13px; }
.widget-scope-choice p { margin: 0 0 8px; }
.widget-scope-choice button { min-height: 40px; margin: 4px 8px 4px 0; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 12px; }
.widget-scope-choice button:hover { background: var(--hover); }


/* A request belongs to its conversation; sidebar progress never blocks navigation. */
.conversation-thread[hidden] { display: none; }
.history-item { display: flex; align-items: center; gap: 9px; }
.history-item .history-title { flex: 1; min-width: 0; }
.history-pending-indicator { flex: none; box-sizing: border-box; width: 13px; height: 13px; border: 2px solid var(--sidebar-divider); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
.history-ready-indicator { flex: none; width: 6px; height: 6px; margin: 3px; border-radius: 50%; background: var(--accent); }
@media (prefers-reduced-motion: reduce) { .history-pending-indicator { animation: none; border-style: dotted; } }
