:root {
  color-scheme: light;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --brand: #01605f;
  --brand-hover: #087675;
  --ink: #181d1d;
  --text: #353c3b;
  --muted: #515a59;
  --subtle: #626b6a;
  --paper: #ffffff;
  --composer-fill: #f1f2f2;
  --composer-border: #d6dada;
  --sidebar: #f7f8f8;
  --map: #f6faf9;
  --surface: #f2f4f3;
  --hover: #eaeef0;
  --line: #e6e9e8;
  --border: #d9dedc;
  --accent: var(--brand);
  --accent-strong: #005653;
  --accent-wash: #e0f1ee;
  --accent-line: #b6d9d3;
  --dot: #d7e5e1;
  --path: #81aaa5;
  --path-active: #016e6a;
  --node-stroke: #c4d9d5;
  --sub-stroke: #cadcde;
  --sub-wash: #e6f2f4;
  --sub-ink: #315b63;
  --sub-dot: #6e969d;
  --shade: #0b1111;
  --danger: #a04423;
  --sidebar-width: 232px;
  --sidebar-rail: 56px;
  --map-width: clamp(362px, 30.3vw, 520px);
  --header-height: 77px;
  --panel-duration: .32s;
  --panel-ease: cubic-bezier(.22, .85, .25, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f5f4f1;
  --text: #dededb;
  --muted: #b1b4b1;
  --subtle: #a2a5a2;
  --paper: #191919;
  --composer-fill: #303030;
  --composer-border: #444;
  --sidebar: #151515;
  --map: #161b1a;
  --surface: #232424;
  --hover: #2c3332;
  --line: #2d302f;
  --border: #3b413f;
  --accent: #56c3b6;
  --accent-strong: #94ded4;
  --accent-wash: #203a36;
  --accent-line: #376b64;
  --dot: #293734;
  --path: #4b837d;
  --path-active: #60d0c1;
  --node-stroke: #3b625b;
  --sub-stroke: #415d60;
  --sub-wash: #273b3f;
  --sub-ink: #a7d5d9;
  --sub-dot: #7db0b5;
  --shade: #080909;
  --danger: #ffb79f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; height: 100%; }
body { color: var(--ink); background: var(--paper); font: 14px/1.5 var(--font); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button, a { -webkit-tap-highlight-color: transparent; }
svg { display: block; flex: none; }
h1, h2, h3, p { margin: 0; }
::selection { background: var(--accent-line); color: var(--ink); }
::highlight(branch-excerpt) { background: var(--accent-wash); color: var(--accent-strong); }

.workspace {
  --sidebar-track: var(--sidebar-width);
  --map-track: var(--map-width);
  display: grid;
  height: 100dvh;
  grid-template-columns: var(--sidebar-track) minmax(0, 1fr) var(--map-track);
  transition: grid-template-columns var(--panel-duration) var(--panel-ease);
  overflow: hidden;
}
.workspace.resizing { transition: none; }
.workspace.map-hidden { --map-track: 0px; }
.workspace.sidebar-hidden { --sidebar-track: var(--sidebar-rail); }
.sidebar, .chat, .map-panel { min-width: 0; min-height: 0; }
.scrim {
  position: fixed;
  inset: 0;
  z-index: 9;
  border: 0;
  background: #0009;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--panel-duration) var(--panel-ease), visibility 0s linear var(--panel-duration);
}
.scrim-visible .scrim { opacity: 1; visibility: visible; transition-delay: 0s; }

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 22px 12px 16px;
  overflow: hidden;
}
.brand-row { position: relative; display: flex; justify-content: space-between; align-items: center; padding-left: 5px; min-height: 38px; }
.sidebar-body { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.brand, .sidebar-close, .sidebar-body { transition: opacity .2s ease, visibility 0s; }
.sidebar-hidden .brand, .sidebar-hidden .sidebar-close, .sidebar-hidden .sidebar-body {
  opacity: 0;
  visibility: hidden;
  transition-delay: 0s, .2s;
}
.brand { text-decoration: none; display: inline-flex; align-items: center; flex: none; color: var(--ink); font-size: 21px; line-height: 1; font-weight: 750; letter-spacing: -.85px; }
.brand > span:last-child { color: var(--accent); }
.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  color: var(--accent);
}
.brand-mark { width: 32px; height: 34px; margin-right: 7px; }
.brand-mark svg { width: 27px; height: 27px; }

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}
.icon-button svg { width: 18px; height: 18px; }
.icon-button.small { width: 29px; height: 29px; }
.icon-button.small svg { width: 16px; height: 16px; }
.icon-button:hover { background: var(--hover); color: var(--accent); }
.icon-button:disabled { opacity: .4; background: transparent; }
.sidebar-open.icon-button {
  position: absolute;
  top: 0;
  left: calc((var(--sidebar-rail) - 38px) / 2 - 12px);
  width: 38px;
  height: 38px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .18s ease, visibility 0s linear .18s, background-color .16s ease;
}
.sidebar-hidden .sidebar-open { opacity: 1; visibility: visible; transition-delay: 0s; }
.mobile-menu-slot, .mobile-welcome-slot { display: none; }
.shortcut-tooltip { position: fixed; z-index: 30; display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 0; border-radius: 8px; background: #303030; color: #f3f3f3; box-shadow: 0 2px 6px #0002; font-size: 12px; font-weight: 500; line-height: 1.4; white-space: nowrap; pointer-events: none; max-width: calc(100vw - 16px); }
.shortcut-tooltip kbd { flex: none; border: 0; padding: 0; color: #b0b0b0; font: 500 11px/1.4 var(--font); }
.new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  min-height: 35px;
  padding: 7px 9px;
  margin: 20px 0 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-weight: 550;
  font-size: 12.5px;
  white-space: nowrap;
  transition: background .15s ease;
}
.new-chat:hover { background: var(--hover); }
.primary-button:hover { background: var(--brand-hover); }
.new-chat svg { width: 18px; height: 18px; }
.sidebar-search { margin-bottom: 24px; }
.history-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 5px 0 9px; }
.history-heading h2 { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.history { flex: 1; overflow: auto; margin-top: 3px; padding-bottom: 14px; scrollbar-width: thin; }
.history-group + .history-group { margin-top: 21px; }
.history-group-label {
  margin: 10px 0 6px 10px;
  font-size: 10px;
  font-weight: 720;
  text-transform: uppercase;
  letter-spacing: .085em;
  color: var(--subtle);
}
.history-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 9px 9px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12.4px;
}
.history-item svg { width: 17px; height: 17px; color: var(--subtle); }
.history-item[aria-current] { background: var(--accent-wash); border-color: var(--accent-line); color: var(--accent-strong); font-weight: 650; }
.history-item[aria-current] svg { color: var(--accent); }
.history-item:hover:not([aria-current]) { background: var(--hover); }
.history-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-row { position: relative; }
.history-row .history-item { padding-right: 36px; }
.history-delete.icon-button { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 27px; height: 27px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
.history-delete svg { width: 15px; height: 15px; }
.history-row:hover .history-delete, .history-row:focus-within .history-delete { opacity: 1; pointer-events: auto; }
.history-delete.icon-button:hover { color: var(--danger); background: var(--hover); }
@media (hover: none), (pointer: coarse) {
  .history-delete.icon-button { opacity: 1; pointer-events: auto; }
}
.history-search {
  margin: 4px 1px 3px;
  min-width: 0;
  padding: 8px 11px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.history-no-results { padding: 12px 9px; color: var(--muted); font-size: 12px; }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 9px; }
.utility { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-radius: 8px; background: transparent; text-align: left; font-weight: 550; color: var(--text); padding: 9px 9px; font-size: 12.5px; }
.utility svg { width: 17px; height: 17px; color: var(--muted); }
.utility:hover { background: var(--hover); }
.admin-link { text-decoration: none; }
.workspace-account { display: flex; align-items: center; gap: 10px; margin: 10px 2px 0; padding: 12px 5px 2px; border-top: 1px solid var(--line); }
.account-avatar { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-wash); color: var(--accent); border: 1px solid var(--accent-line); }
.account-avatar svg { width: 17px; height: 17px; }
.workspace-account strong, .workspace-account small { display: block; }
.workspace-account strong { font-size: 12.5px; font-weight: 700; }
.workspace-account small { color: var(--subtle); font-size: 11px; }
.workspace-account > div { flex: 1; min-width: 0; }
.workspace-account strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-avatar { font-size: 13px; font-weight: 650; }

.chat { grid-column: 2; display: flex; flex-direction: column; background: var(--paper); }
.chat-header, .map-header {
  display: flex;
  flex: 0 0 var(--header-height);
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  border-bottom: 1px solid var(--line);
  padding: 0 23px;
}
.chat-identity, .map-heading, .header-actions, .map-actions { display: flex; min-width: 0; align-items: center; gap: 11px; }
.chat-identity { flex: 1; }
.chat-identity > div { min-width: 0; }
.map-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 37px;
  height: 37px;
  border-radius: 10px;
  border: 1px solid var(--accent-line);
  color: var(--accent);
  background: var(--accent-wash);
}
.chat-symbol { display: grid; place-items: center; flex: none; width: 22px; height: 24px; color: var(--subtle); }
.chat-symbol svg { width: 18px; height: 18px; }
.map-mark svg { width: 19px; height: 19px; }
.chat-identity h1 { color: var(--ink); font-size: 15px; line-height: 1.35; font-weight: 700; letter-spacing: -.28px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-subtitle { margin-top: 3px; display: flex; gap: 5px; align-items: center; color: var(--subtle); font-size: 11.5px; white-space: nowrap; }
.chat-subtitle svg { width: 13px; height: 13px; }
.return-root { display: inline-flex; flex-direction: row-reverse; align-items: center; gap: 3px; color: var(--accent); border: 0; background: transparent; padding: 0; font-size: inherit; }
.return-root:hover { text-decoration: underline; }
.header-actions, .map-actions { gap: 5px; flex: none; }
.connection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  min-height: 34px;
  padding: 0 9px;
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.connection:hover, .connection[aria-expanded="true"] { background: var(--accent-wash); border-color: var(--accent-line); color: var(--accent-strong); }
.connection-key svg { width: 15px; height: 15px; color: var(--muted); }
.connected .connection-key svg { color: var(--accent); }
.connection-chevron svg { width: 13px; height: 13px; color: var(--subtle); }
.map-toggle-slot:empty { display: none; }
.map-toggle-slot { display: inline-flex; flex: none; width: 34px; height: 34px; }
#panel-map-slot { display: inline-flex; }
.map-toggle.icon-button { position: relative; z-index: 2; color: var(--accent-strong); }
.map-toggle[aria-expanded="true"] { background: var(--accent-wash); border-color: var(--accent-line); }
.map-toggle svg { width: 20px; height: 20px; }
.map-toggle > svg { transition: opacity .15s ease, transform .18s ease; }
.map-toggle-hint { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transform: scale(.85); transition: opacity .15s ease, transform .18s ease; pointer-events: none; }
.map-toggle:focus-visible > svg { opacity: 0; transform: scale(.85); }
.map-toggle:focus-visible .map-toggle-hint { opacity: 1; transform: scale(1); }
@media (hover: hover) {
  .map-toggle:hover > svg { opacity: 0; transform: scale(.85); }
  .map-toggle:hover .map-toggle-hint { opacity: 1; transform: scale(1); }
}
.map-toggle.map-flash { animation: map-button-glow .64s ease-out both; }
.map-branch-shine { opacity: 0; }
.map-flash .map-branch-shine { animation: map-branch-sweep .84s ease-in-out both; }
@keyframes map-button-glow {
  0%, 100% { rotate: 0deg; scale: 1; }
  22% { rotate: -12deg; scale: .92; }
  48% { rotate: 8deg; scale: 1.08; background: var(--accent-line); }
  72% { rotate: -3deg; scale: 1; }
}
@keyframes map-branch-sweep {
  0% { opacity: 0; transform: translateX(0); }
  22%, 68% { opacity: 1; }
  100% { opacity: 0; transform: translateX(46px); }
}
.temporary-toggle.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px dashed transparent;
  background: transparent;
  color: var(--subtle);
  border-radius: 8px;
  transition: border-color .18s ease, color .18s ease;
}
.temporary-toggle svg { width: 20px; height: 20px; }
.temporary-toggle.icon-button:hover { background: transparent; color: var(--accent); }
.temporary-toggle.icon-button[aria-pressed="true"] { border-color: var(--accent); background: transparent; color: var(--accent-strong); }
.temporary-toggle.icon-button:disabled { opacity: 1; }

.chat-scroll { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.messages { display: flex; flex-direction: column; gap: 31px; max-width: 876px; margin: 0 auto; padding: 35px 38px 24px; min-height: 100%; }
.message { min-width: 0; }
.message.user { display: flex; justify-content: flex-end; }
.user-content { display: flex; flex-direction: column; align-items: flex-end; max-width: min(92%, 560px); }
.user-bubble {
  position: relative;
  border: 0;
  border-radius: 15px 15px 4px 15px;
  padding: 11px 16px;
  background: var(--accent-wash);
  color: var(--ink);
  font-size: 14px;
  font-weight: 570;
  overflow-wrap: anywhere;
}
.user-bubble p { white-space: pre-wrap; }
.fork-label { float: left; display: flex; align-items: center; margin: 3px 8px 0 0; color: var(--accent-strong); }
.fork-label svg { width: 13px; height: 13px; }
.user-reference { border-left: 2px solid var(--accent); padding-left: 9px; margin: 0 0 9px 22px; color: var(--muted); font-size: 12.5px; font-weight: 400; max-height: 88px; overflow: auto; }
.new-fork { animation: fork-arrival .4s ease-out; }
@keyframes fork-arrival { from { opacity: .5; translate: 0 5px; } to { opacity: 1; translate: 0 0; } }
.response-text { color: var(--text); font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.response-text > * + * { margin-top: 14px; }
.response-text p { white-space: pre-line; }
.response-text strong { color: var(--ink); font-weight: 700; }
.response-text h3 { font-size: 15.5px; line-height: 1.4; font-weight: 730; color: var(--ink); letter-spacing: -.15px; }
.response-text ol, .response-text ul { margin: 9px 0 0; padding-left: 23px; }
.response-text li { padding-left: 3px; margin-bottom: 6px; }
.response-text li::marker { color: var(--accent); font-variant-numeric: tabular-nums; font-size: .88em; font-weight: 700; }
.response-text code { font: .91em/1.5 "Cascadia Code", "Consolas", monospace; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }
.response-text pre { max-width: 100%; overflow: auto; background: var(--surface); border: 1px solid var(--line); padding: 12px; border-radius: 8px; }
.response-text pre code { background: none; border: 0; padding: 0; }
.response-text .math-expression { white-space: normal; overflow-wrap: normal; }
.response-text .math-display { overflow-x: auto; overflow-y: hidden; padding: 5px 0; max-width: 100%; }
.response-text .katex { font-size: 1.12em; }
.response-text .katex-display { margin: .6em 0; }
.response-text .code-block { overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.code-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.code-copy { display: flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); font-size: 11px; padding: 3px 0 3px 8px; }
.code-copy:hover { color: var(--accent); }
.code-copy svg { width: 14px; height: 14px; }
.response-text .code-block pre { margin: 0; border: 0; border-radius: 0; padding: 14px; line-height: 1.6; }
.response-text pre code.hljs { display: block; white-space: pre; overflow-wrap: normal; color: var(--ink); font-size: 12px; tab-size: 2; }
.hljs-comment, .hljs-quote { color: #6b7b79; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal { color: #963caf; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #217448; }
.hljs-number, .hljs-symbol, .hljs-attr { color: #98601d; }
.hljs-title, .hljs-section, .hljs-built_in, .hljs-type { color: #175eaf; }
.hljs-variable, .hljs-template-variable, .hljs-tag, .hljs-name, .hljs-deletion { color: #b13946; }
[data-theme="dark"] .hljs-comment, [data-theme="dark"] .hljs-quote { color: #8caaa4; }
[data-theme="dark"] .hljs-keyword, [data-theme="dark"] .hljs-selector-tag, [data-theme="dark"] .hljs-literal { color: #d9a0ed; }
[data-theme="dark"] .hljs-string, [data-theme="dark"] .hljs-regexp, [data-theme="dark"] .hljs-addition { color: #9bcea6; }
[data-theme="dark"] .hljs-number, [data-theme="dark"] .hljs-symbol, [data-theme="dark"] .hljs-attr { color: #e8be89; }
[data-theme="dark"] .hljs-title, [data-theme="dark"] .hljs-section, [data-theme="dark"] .hljs-built_in, [data-theme="dark"] .hljs-type { color: #91bff4; }
[data-theme="dark"] .hljs-variable, [data-theme="dark"] .hljs-template-variable, [data-theme="dark"] .hljs-tag, [data-theme="dark"] .hljs-name, [data-theme="dark"] .hljs-deletion { color: #eea6ac; }
.message-actions { display: flex; align-items: center; gap: 2px; margin: 8px 0 0 -5px; }
.incomplete { color: var(--muted); font-size: 12px; margin-top: 8px; }
.inherited { padding: 8px 12px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.inherited summary { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); line-height: 26px; font-size: 12px; font-weight: 650; list-style: none; }
.inherited summary::-webkit-details-marker { display: none; }
.inherited summary::after { content: "⌄"; margin-left: auto; color: var(--accent); font-size: 16px; line-height: 1; }
.inherited[open] summary::after { transform: rotate(180deg); }
.inherited summary svg { width: 15px; height: 15px; color: var(--accent); }
.inherited summary small { color: var(--subtle); font-size: 11px; font-weight: 450; }
.inherited .message { margin: 18px 0 10px; }
.pending { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.pending-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease infinite; }
.typing-caret { display: inline-block; width: 2px; height: .9em; margin-left: 2px; vertical-align: -.07em; background: var(--accent); border-radius: 2px; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.75); } }
.ask-selection {
  position: fixed;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 8px;
  padding: 8px 11px;
  box-shadow: 0 4px 14px #0005;
  font-size: 12px;
  font-weight: 650;
}
.ask-selection svg { width: 15px; height: 15px; }

.composer-area { flex: none; padding: 8px 38px 14px; }
.composer-inner { position: relative; width: 100%; max-width: 800px; margin: 0 auto; }
.chat-empty .chat-scroll { display: none; }
.chat-empty .composer-area { flex: 1; min-height: 0; display: grid; place-items: center; padding-block: 0; }
.composer-intro { position: absolute; inset-inline: 0; bottom: calc(100% + 25px); text-align: center; }
.composer-intro h2 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .28em;
  color: var(--ink);
  font: 400 clamp(26px, 3vw, 43px)/1.12 "Instrument Serif", Georgia, serif;
  letter-spacing: -.025em;
}
.composer-intro h2 span { display: grid; place-items: center; flex: none; color: var(--accent); }
.composer-intro svg { width: .9em; height: .9em; }
.composer-intro p { margin-top: 5px; color: var(--muted); font-size: 12px; }
.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  row-gap: 4px;
  padding: 10px 13px 10px 18px;
  background: var(--composer-fill);
  border: 1px solid var(--composer-border);
  border-radius: 18px;
  transition: border-color .2s ease;
}
.composer:focus-within { border-color: var(--accent-line); }
.composer textarea { grid-column: 1 / -1; display: block; width: 100%; resize: none; border: 0; background: transparent; outline: none; min-height: 42px; max-height: 132px; padding: 5px 0; line-height: 24px; font-size: 16px; }
.chat-empty .composer textarea { min-height: 69px; }
.composer textarea::placeholder { color: var(--subtle); }
.composer-tools { display: flex; justify-content: flex-end; padding: 3px 6px 0; }
.chat-empty .composer-tools { position: absolute; inset: 100% 0 auto; padding-top: 7px; }
.send { grid-column: 2; display: grid; place-items: center; padding: 0; border: 0; width: 34px; height: 34px; border-radius: 10px; color: #fff; background: var(--brand); transition: background-color .18s ease, color .18s ease; }
.send:hover { background: var(--brand-hover); }
.send:disabled { background: transparent; color: var(--subtle); }
.send svg { width: 17px; height: 17px; stroke-width: 2.25; }
.composer-quote { grid-column: 1 / -1; display: flex; align-items: center; gap: 9px; padding: 5px 7px 5px 0; color: var(--accent); }
.composer-quote > span svg { width: 16px; height: 16px; }
.composer-quote > div { flex: 1; min-width: 0; border-left: 2px solid var(--accent); padding-left: 9px; }
.composer-quote strong { display: block; font-size: 11px; }
#composer-excerpt { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 12px; }
.chat-error { display: flex; gap: 8px; align-items: center; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12px; color: var(--text); margin-bottom: 7px; }
.chat-error svg { width: 16px; height: 16px; color: var(--accent); }
.chat-error p { flex: 1; }
.text-button { color: var(--accent-strong); border: 0; background: transparent; font-size: 12px; font-weight: 700; padding: 3px; white-space: nowrap; }
.text-button:hover { text-decoration: underline; }

.map-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--map);
  border-left: 1px solid var(--line);
  transition: opacity var(--panel-duration) var(--panel-ease), translate var(--panel-duration) var(--panel-ease), visibility 0s;
}
.map-hidden .map-panel { opacity: 0; translate: 16px 0; visibility: hidden; transition-delay: 0s, 0s, var(--panel-duration); }
.workspace.map-expanded { --map-track: 0px; }
.map-expanded .scrim { z-index: 11; background: color-mix(in srgb, var(--paper) 28%, transparent); backdrop-filter: blur(12px) saturate(130%); }
.workspace.map-expanded .map-panel {
  position: fixed; inset: clamp(16px, 4vw, 52px); z-index: 12;
  width: auto; height: auto; border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 24px; overflow: hidden;
  box-shadow: 0 24px 100px #0005, 0 0 0 1px #ffffff0a;
  background: color-mix(in srgb, var(--map) 94%, transparent);
  animation: map-dialog-entry .3s var(--panel-ease);
}
@keyframes map-dialog-entry { from { opacity: .4; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.map-expanded .map-resize { display: none; }
.map-expanded .map-stage { animation: map-fullscreen-entry .25s ease-out both; }
@keyframes map-fullscreen-entry { from { opacity: .55; } to { opacity: 1; } }
.map-header { padding: 0 16px 0 18px; background: var(--paper); }
.map-heading { gap: 9px; }
.map-heading > div { min-width: 0; }
.map-heading h2 { overflow: hidden; text-overflow: ellipsis; }
.map-header h2 { font-size: 14px; font-weight: 740; white-space: nowrap; letter-spacing: -.25px; }
.map-header p { font-size: 11.5px; color: var(--muted); }
.map-mark { width: 34px; height: 34px; border-radius: 9px; }
.map-actions .icon-button { width: 31px; height: 31px; }
.map-resize { position: absolute; z-index: 3; top: 0; bottom: 0; left: -4px; width: 7px; cursor: ew-resize; touch-action: none; }
.map-resize:hover, .map-resize:focus-visible, .resizing .map-resize { background: var(--accent-line); }
.resizing, .resizing * { cursor: ew-resize !important; user-select: none; }
.map-stage {
  position: relative;
  overflow: hidden;
  flex: 1;
  isolation: isolate;
  background-color: var(--map);
  background-image: radial-gradient(circle, var(--dot) .9px, transparent 1.25px);
  background-position: center;
  background-size: 17px 17px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.map-stage.has-graph { cursor: grab; }
.map-stage.dragging { cursor: grabbing; }
.map-scene { position: absolute; inset: 0; transform-origin: top left; }
#map-lines { position: absolute; left: 0; top: 0; pointer-events: none; }
.node-wrap { position: absolute; width: 118px; height: 79px; }
.map-node {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 4px;
  background: var(--paper);
  color: var(--text);
  text-align: left;
  border: 1px solid var(--node-stroke);
  border-radius: 9px;
  padding: 6px 8px;
  box-shadow: 0 2px 4px color-mix(in srgb, var(--shade) 8%, transparent);
}
.map-node:hover { border-color: var(--accent); transform: translateY(-1px); }
.map-node .node-glyph { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 4px; background: var(--accent-wash); color: var(--accent); }
.node-glyph svg { width: 13px; height: 13px; }
.node-question { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; overflow-wrap: anywhere; font-size: 12px; line-height: 1.22; font-weight: 670; }
.depth-2 .map-node { border-color: var(--sub-stroke); }
.depth-2 .node-glyph { background: var(--sub-wash); color: var(--sub-ink); }
.map-node[aria-current] { background: var(--accent-wash); border: 1.5px solid var(--accent); color: var(--accent-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 11%, transparent); }
.map-node[aria-current] .node-glyph { background: var(--brand); color: #fff; }
.node-toggle { display: grid; place-items: center; position: absolute; right: -8px; top: calc(50% - 8px); z-index: 1; width: 16px; height: 16px; border: 1px solid var(--accent-line); background: var(--paper); border-radius: 50%; color: var(--accent); padding: 0; }
.node-toggle:hover { color: var(--paper); background: var(--accent); }
.node-toggle svg { width: 11px; height: 11px; stroke-width: 2; }
.map-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 24px; color: var(--muted); font-size: 13px; }
.map-empty span { color: var(--accent); }
.map-empty svg { width: 31px; height: 31px; }
.branch-preview {
  position: absolute;
  z-index: 5;
  padding: 13px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-line) transparent;
  overflow-wrap: anywhere;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  box-shadow: 0 8px 32px color-mix(in srgb, var(--shade) 48%, transparent);
  font-size: 12.5px;
  animation: preview-enter .14s ease-out both;
}
@keyframes preview-enter { from { opacity: .45; } to { opacity: 1; } }
.branch-preview-question { font-size: 14px; font-weight: 720; line-height: 1.35; color: var(--ink); }
.branch-preview-section { margin-top: 11px; }
.branch-preview-section h4 { margin: 0 0 3px; color: var(--accent-strong); font-size: 11px; font-weight: 670; }
.branch-preview blockquote { margin: 0; padding-left: 9px; border-left: 2px solid var(--accent); white-space: pre-wrap; }
.branch-preview-source { margin: 4px 0 0; color: var(--muted); }
.branch-preview-source summary { cursor: pointer; font-size: 11.5px; }
.branch-preview-source .response-text { margin-top: 6px; padding-left: 8px; border-left: 1px solid var(--accent-line); }
.branch-preview .response-text { font-size: inherit; line-height: 1.55; }
.branch-preview .response-text h3 { font-size: 13px; }
.branch-preview .response-text > * + * { margin-top: 7px; }
.branch-preview-empty { color: var(--muted); }
.map-tools { position: absolute; bottom: 17px; left: 16px; display: flex; align-items: center; gap: 6px; cursor: default; }
.zoom-group, .recenter { display: flex; align-items: center; gap: 2px; background: var(--paper); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 5px color-mix(in srgb, var(--shade) 7%, transparent); }
.zoom-group { padding: 2px; }
.zoom-group .icon-button { width: 27px; height: 27px; }
.zoom-group output { min-width: 40px; color: var(--text); text-align: center; font-size: 11px; font-weight: 660; font-variant-numeric: tabular-nums; }
.recenter { display: inline-grid; width: 33px; height: 33px; }
.recenter svg { width: 16px; height: 16px; }
.map-footer { display: flex; gap: 17px; align-items: center; flex: none; height: 47px; padding: 0 17px; border-top: 1px solid var(--line); color: var(--muted); background: var(--paper); font-size: 11px; }
.map-footer span { display: flex; align-items: center; gap: 6px; }
.map-footer i { display: block; width: 8px; height: 8px; border-radius: 50%; }
.legend-root { background: var(--accent); }
.legend-branch { background: var(--path); }
.legend-sub { background: var(--sub-dot); }

dialog {
  padding: 0;
  max-width: min(465px, calc(100vw - 28px));
  width: 465px;
  max-height: calc(100dvh - 28px);
  border: 1px solid var(--border);
  border-radius: 17px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 19px 70px #0008;
  opacity: 0;
  transform: translateY(8px) scale(.985);
  transition: opacity .22s ease, transform .22s var(--panel-ease), display .22s allow-discrete, overlay .22s allow-discrete;
}
dialog[open] { opacity: 1; transform: none; }
dialog::backdrop {
  background: #0008;
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .22s ease, display .22s allow-discrete, overlay .22s allow-discrete;
}
dialog[open]::backdrop { opacity: 1; }
@starting-style {
  dialog[open] { opacity: 0; transform: translateY(8px) scale(.985); }
  dialog[open]::backdrop { opacity: 0; }
}
.settings-form { padding: 21px; }
.settings-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.settings-heading h2 { font-size: 17px; letter-spacing: -.3px; }
.settings-heading p { font-size: 12px; color: var(--muted); }
.settings-heading button { align-self: start; margin-left: auto; }
.settings-form fieldset { display: grid; padding: 0; margin: 0; border: 0; gap: 7px; }
.settings-form .provider-options { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 15px; }
.settings-form legend, .personal-fields > label { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.mode-option { display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 9px; padding: 9px 10px; cursor: pointer; }
.mode-option:has(input:checked) { background: var(--accent-wash); border-color: var(--accent-line); }
.mode-option input { accent-color: var(--accent); margin: 0 3px 0 0; }
.mode-option strong, .mode-option small { display: block; }
.mode-option strong { font-size: 13px; font-weight: 680; }
.mode-option small, .personal-fields small { font-size: 11.5px; color: var(--muted); }
.personal-fields { display: grid; gap: 3px; margin-top: 15px; }
.key-entry { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px 3px; }
.key-entry input { flex: 1; min-width: 0; border: 0; padding: 8px; border-radius: 5px; background: transparent; }
.settings-error { color: var(--danger); font-size: 12px; margin-top: 7px; }
.settings-footer { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-top: 19px; padding-top: 15px; border-top: 1px solid var(--line); }
.settings-preferences { padding: 20px 21px; border-top: 1px solid var(--line); }
.settings-preferences h3 { font-size: 12px; font-weight: 700; margin-bottom: 14px; }
.preference-option { display: flex; align-items: center; justify-content: space-between; gap: 20px; cursor: pointer; }
.preference-option strong, .preference-option small { display: block; }
.preference-option strong { font-size: 12px; font-weight: 550; }
.preference-option small, .settings-preferences > p { font-size: 11px; color: var(--subtle); }
.settings-preferences > p { margin-top: 13px; }
.preference-option input { appearance: none; flex: none; width: 32px; height: 19px; border-radius: 20px; background: var(--border); border: 1px solid var(--border); padding: 2px; margin: 0; cursor: pointer; transition: background .18s; }
.preference-option input::before { content: ''; display: block; width: 13px; height: 13px; background: var(--paper); border-radius: 50%; transition: translate .18s; box-shadow: 0 1px 2px #0003; }
.preference-option input:checked { background: var(--brand); border-color: var(--brand); }
.preference-option input:checked::before { translate: 13px 0; background: white; }
#model-label { font-size: 11.5px; color: var(--muted); }
.primary-button { background: var(--brand); color: #fff; padding: 8px 13px; border: 0; border-radius: 8px; font-weight: 650; font-size: 13px; transition: background-color .18s ease; }
.toast { display: flex; align-items: center; gap: 14px; position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); border: 1px solid var(--border); border-radius: 9px; background: var(--paper); color: var(--text); box-shadow: 0 5px 20px #0005; padding: 7px 14px; max-width: calc(100% - 24px); z-index: 20; font-size: 12px; }

.auth-screen { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; background: radial-gradient(ellipse at 50% 0%, var(--accent-wash), transparent 65%), var(--paper); }
.auth-card { width: min(100%, 380px); }
.auth-card > .brand { margin-bottom: 44px; }
.auth-eyebrow { font-size: 10px; font-weight: 650; letter-spacing: .15em; color: var(--accent); margin-bottom: 12px; }
.auth-card h1 { font-size: clamp(26px, 4vw, 32px); line-height: 1.2; font-weight: 650; letter-spacing: -1px; }
.auth-description { color: var(--muted); font-size: 13px; margin: 12px 0 26px; }
.auth-form { display: grid; gap: 17px; }
.auth-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 550; }
.auth-form input { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 12px; font-size: 14px; }
.auth-form input::placeholder { color: var(--subtle); font-size: 13px; }
.auth-password-entry { position: relative; margin-top: -10px; }
.auth-password-entry input { padding-right: 48px; }
.auth-password-entry button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.usage-note { margin-top: 12px; font-size: 11px; color: var(--muted); line-height: 1.6; }
.usage-note.exhausted { color: var(--accent-strong); }
.mode-option:has(input:disabled) { opacity: .55; }
.auth-submit { min-height: 43px; margin-top: 5px; }
.auth-submit:disabled { opacity: .6; }
.auth-switch { text-align: center; font-size: 12px; color: var(--muted); }
.auth-switch button { color: var(--accent); border: 0; background: transparent; padding: 0; font-size: inherit; font-weight: 600; }
.auth-note { color: var(--subtle); font-size: 11px; text-align: center; line-height: 1.8; margin-top: 8px; }
.auth-error { color: var(--danger); font-size: 12px; }
.sync-alert { position: fixed; z-index: 25; left: 50%; bottom: 20px; translate: -50% 0; width: max-content; max-width: calc(100% - 28px); display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--paper); box-shadow: 0 8px 35px #0004; font-size: 12px; }
.sync-alert > span { flex-basis: 100%; color: var(--danger); }
.sync-alert button { background: var(--surface); border: 0; border-radius: 6px; padding: 5px 8px; }

dialog.conversation-search { width: 620px; max-width: calc(100vw - 32px); max-height: min(76dvh, 660px); border-radius: 20px; }
.conversation-search[open] { display: flex; flex-direction: column; }
.conversation-search::backdrop { background: color-mix(in srgb, var(--paper) 28%, transparent); backdrop-filter: blur(12px) saturate(130%); }
.search-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 22px 16px; }
.search-heading h2 { font-size: 17px; font-weight: 650; letter-spacing: -.3px; }
.search-heading p { margin-top: 4px; color: var(--subtle); font-size: 12px; }
.search-input-wrap { display: flex; align-items: center; gap: 10px; margin: 0 22px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.search-input-wrap:focus-within { border-color: var(--accent); }
.search-input-wrap > span { color: var(--subtle); }
.search-input-wrap svg { width: 18px; height: 18px; }
.search-input-wrap input { width: 100%; min-width: 0; background: transparent; border: 0; padding: 0; font-size: 14px; outline: none; }
.search-input-wrap input::placeholder { color: var(--subtle); }
.search-input-wrap kbd { font: 10px var(--font); color: var(--subtle); border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px; }
.search-status { flex: none; padding: 15px 24px 8px; color: var(--subtle); font-size: 11px; }
.search-results { min-height: 120px; overflow-y: auto; overscroll-behavior: contain; padding: 0 12px 12px; scrollbar-width: thin; }
.search-group + .search-group { margin-top: 14px; }
.search-group-title { display: flex; align-items: center; gap: 7px; margin: 9px 10px 7px; font-size: 11px; font-weight: 650; color: var(--subtle); }
.search-group-title > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-group-title svg { width: 14px; height: 14px; }
.search-result { display: grid; width: 100%; gap: 5px; padding: 12px; border: 0; background: transparent; border-radius: 10px; text-align: left; }
.search-result:hover, .search-result:focus-visible { background: var(--surface); }
.search-result:focus-visible { outline-offset: -2px; }
.search-result-heading { display: flex; align-items: center; gap: 8px; min-width: 0; }
.search-result-heading svg { width: 15px; height: 15px; color: var(--accent); }
.search-result-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; }
.search-result-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--subtle); padding-left: 23px; }
.search-result-excerpt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; font-size: 12px; line-height: 1.65; color: var(--muted); overflow-wrap: anywhere; }
.search-result mark { background: var(--accent-wash); color: var(--accent-strong); border-radius: 2px; font-weight: 600; }
.search-result-count { color: var(--subtle); font-size: 10px; }
.search-empty { padding: 32px 16px; display: grid; justify-items: center; gap: 8px; text-align: center; color: var(--muted); }
.search-empty > span { color: var(--subtle); margin-bottom: 5px; }
.search-empty strong { font-size: 13px; font-weight: 550; }
.search-empty p { font-size: 12px; }
.search-footer { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding: 11px 23px; font-size: 10px; color: var(--subtle); }
.search-arrival { animation: search-arrival 1.8s ease-out; border-radius: 10px; }
@keyframes search-arrival { from { background: var(--accent-wash); } to { background: transparent; } }

@media (min-width: 1500px) {
  :root { --sidebar-width: 249px; }
  .messages { padding-top: 42px; }
}
@media (max-width: 1190px) {
  :root { --sidebar-width: 204px; }
  .chat-header { padding-inline: 15px; }
  .messages, .composer-area { padding-inline: 23px; }
}
@media (max-width: 1050px) {
  .workspace { grid-template-columns: var(--sidebar-track) minmax(0, 1fr); }
  .map-panel { position: fixed; z-index: 10; inset: 0 0 0 auto; width: min(92vw, 450px); }
  .map-hidden .map-panel { translate: 100% 0; }
  .map-resize { display: none; }
  #map-expand { display: none; }
}
@media (max-width: 730px) {
  :root { --header-height: 56px; --sidebar-rail: 0px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .chat { grid-column: 1; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 280px); z-index: 10; padding-top: 13px; transition: translate var(--panel-duration) var(--panel-ease), visibility 0s; }
  .sidebar-hidden .sidebar { width: min(86vw, 280px); translate: -100% 0; visibility: hidden; transition-delay: 0s, var(--panel-duration); }
  .chat-header { padding-inline: 12px; gap: 8px; border-bottom-color: transparent; }
  .mobile-menu-slot { display: flex; align-items: center; flex: none; }
  .mobile-menu-slot .sidebar-open.icon-button { position: static; width: 34px; height: 34px; opacity: 1; visibility: visible; transition: background-color .16s ease; }
  .chat-empty .chat-identity { visibility: hidden; }
  .chat-empty .chat-scroll { display: flex; align-items: center; justify-content: center; }
  .chat-empty .messages { display: none; }
  .chat-empty .mobile-welcome-slot { display: block; width: 100%; padding: 24px; }
  .mobile-welcome-slot .composer-intro { position: static; }
  .mobile-welcome-slot .composer-intro h2 { font-size: clamp(27px, 7vw, 36px); }
  .chat-empty .composer-area { flex: none; display: block; padding-block: 5px max(10px, env(safe-area-inset-bottom)); }
  .chat-empty .composer-tools { position: static; padding-top: 3px; }
  .shortcut-tooltip { display: none; }
  .chat-symbol { display: none; }
  .chat-identity h1 { font-size: 13.5px; }
  .chat-subtitle { font-size: 10px; }
  .history-delete.icon-button { opacity: 1; pointer-events: auto; }
  .connection { min-height: 32px; gap: 6px; padding-inline: 6px; font-size: 12px; }
  .header-actions { gap: 7px; }
  .messages { padding: 22px 14px 14px; gap: 22px; }
  .composer-area { padding: 5px 12px max(9px, env(safe-area-inset-bottom)); }
  .composer { padding-inline: 13px 10px; }
  .chat-empty .composer textarea { min-height: 61px; }
  .map-header { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  :root { --panel-duration: 0s; }
  *, *::before, *::after, dialog::backdrop { animation-duration: .01ms !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}
