/* Neutral workspace. No tinted surface colors. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --bg: #ffffff;
  --surface: #ffffff;
  --sidebar: #f6f6f6;
  --ink: #252525;
  --muted: #737373;
  --line: #e3e3e3;
  --accent: #252525;
  --accent-soft: #ebebeb;
  --control: #ffffff;
  --subtle: #f8f8f8;
  --hover: #f0f0f0;
  --focus: #5f83c5;
}
html[data-theme=dark] {
  --bg: #181818;
  --surface: #1c1c1c;
  --sidebar: #121212;
  --ink: #e5e5e5;
  --muted: #999999;
  --line: #303030;
  --accent: #ededed;
  --accent-soft: #2a2a2a;
  --control: #202020;
  --subtle: #202020;
  --hover: #272727;
  --focus: #8da9dd;
}
body { font: 14px/1.55 var(--font); letter-spacing: 0; }
::selection { background: #a7bce34d; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sidebar { width: 224px; padding: 24px 12px 0; }
.brand { padding: 0 14px; gap: 0; font-size: 18px; font-weight: 650; letter-spacing: 1px; }
.brand-mark { display: none; }
.brand small { font-size: 11px; font-weight: 400; letter-spacing: 0; margin-top: 4px; color: var(--muted); }
.workspace-picker { display: none; }
.nav-label { font-size: 10px; letter-spacing: .5px; padding: 0 14px; margin: 34px 0 9px; color: var(--muted); }
.nav-label.second { margin: 26px 0 9px; }
nav a { min-height: 36px; padding: 8px 12px; margin: 3px 0; gap: 10px; border-radius: 4px; font-size: 12px; }
html[data-theme] nav a { color: var(--muted); }
html[data-theme] nav a.active { background: var(--accent-soft); color: var(--ink); font-weight: 550; }
html[data-theme] nav a:hover { background: var(--hover); color: var(--ink); }
nav a svg { width: 16px; height: 16px; }
html[data-theme] .nav-count { background: transparent; color: var(--muted); padding: 0; font-size: 10px; }
html[data-theme] .connection-card { background: transparent; border: 1px solid var(--line); border-radius: 4px; margin: 12px 0; padding: 11px 10px; font-size: 11px; color: var(--ink); }
html[data-theme] .connection-card small { color: var(--muted); font-size: 10px; }
html[data-theme] .connection-symbol { color: var(--muted); }
html[data-theme] .connection-card.is-connected { border-color: transparent; }
.profile { padding: 16px 7px; border-color: var(--line); font-size: 11px; }
html[data-theme] .profile-avatar, html[data-theme] .top-avatar { background: var(--accent-soft); color: var(--muted); font: 11px var(--font); width: 28px; height: 28px; }
.profile small { font-size: 10px; }
.page-shell { margin-left: 224px; }
html[data-theme] .topbar { height: 56px; padding: 0 28px; background: var(--bg); border-color: var(--line); }
.breadcrumb { font-size: 12px; gap: 10px; }
.breadcrumb > span { display: none; }
html[data-theme] .breadcrumb strong { color: var(--ink); font-weight: 500; }
.topbar-right { gap: 20px; }
.top-avatar { display: none; }
.jurisdiction { color: var(--muted); font-size: 11px; }
.jurisdiction .small-dot { display: none; }
.topbar-help { font-size: 11px; color: var(--muted); }
.theme-toggle { font-size: 19px; }
main { padding: 28px 32px 32px; max-width: 1600px; }
.page-heading { margin-bottom: 24px; }
.page-heading h1, .chat-page-header h1 { font: 600 24px/1.3 var(--font); letter-spacing: -.5px; margin: 0; }
.page-heading p { font-size: 12px; line-height: 1.6; color: var(--muted); margin: 8px 0 0; }
.eyebrow, .date-pill { display: none; }
.app-footer { display: none; }
.card { border-radius: 5px; box-shadow: none; border-color: var(--line); }
html[data-theme] .card { background: var(--surface); }
html[data-theme] .btn { min-height: 34px; padding: 7px 11px; border-radius: 4px; box-shadow: none; font-size: 12px; font-weight: 450; border-color: var(--line); background: var(--control); color: var(--ink); }
html[data-theme] .btn:hover { background: var(--hover); }
html[data-theme] .btn.primary { color: var(--bg); background: var(--accent); border-color: var(--accent); font-weight: 500; }
html[data-theme] .btn.primary:hover { opacity: .86; }
html[data-theme] .btn.text { color: var(--muted); border-color: transparent; background: transparent; }
html[data-theme] .btn.text:hover { color: var(--ink); background: var(--hover); }
.btn svg { width: 15px; height: 15px; }
html[data-theme] .icon-button { color: var(--muted); }
html[data-theme] .icon-button:hover { color: var(--ink); background: var(--hover); }
html[data-theme] .chip { border-radius: 3px; color: var(--muted); background: var(--accent-soft); font-size: 10px; padding: 3px 7px; }
.dashboard-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.toolbar-actions { gap: 8px; }
html[data-theme] .compact-upload { min-height: 104px; flex-direction: row; align-items: center; justify-content: flex-start; text-align: left; gap: 17px; padding: 22px 24px; margin-bottom: 36px; border: 1px dashed var(--line); border-radius: 5px; background: var(--subtle); }
.compact-upload > svg { width: 21px; height: 21px; color: var(--muted); }
.compact-upload strong { font-size: 13px; font-weight: 500; }
.compact-upload p { font-size: 11px; color: var(--muted); margin: 4px 0 0; }
.compact-upload .btn { margin-left: auto; }
html[data-theme] .drop-zone.dragging { border-color: var(--focus); background: var(--hover); }
.section-row { margin-bottom: 12px; }
.section-row h2 { font-size: 14px; font-weight: 600; }
.document-empty { padding: 42px 16px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: 13px; }
.document-empty p { margin: 7px 0 0; font-size: 12px; }
.document-table { border-radius: 4px; }
.table-header, .document-row { padding: 13px 17px; }
html[data-theme] .table-header { background: var(--subtle); border-color: var(--line); color: var(--muted); font-size: 11px; }
html[data-theme] .document-row { background: var(--surface); border-color: var(--line); }
html[data-theme] .document-row:hover { background: var(--hover); }
.document-name { gap: 12px; }
.document-name strong { font-size: 12px; font-weight: 500; }
.document-name small, .document-task, .document-date { color: var(--muted); font-size: 11px; }
html[data-theme] .file-icon { width: 24px; height: 29px; background: transparent; border: 0; color: var(--muted); }
html[data-theme] .status, html[data-theme] .status.green, html[data-theme] .status.neutral { background: var(--accent-soft); color: var(--muted); font-size: 10px; }
.status:before { display: none; }
.page-toolbar { margin-bottom: 20px; }
html[data-theme] .search-input, html[data-theme] .chat-search { height: 35px; min-height: 35px; font-size: 12px; background: var(--control); border: 1px solid var(--line); color: var(--ink); border-radius: 4px; }
.empty-state { border: 0; border-top: 1px solid var(--line); padding: 60px 24px; box-shadow: none; }
.empty-state > svg { width: 24px; height: 24px; color: var(--muted); margin-bottom: 14px; }
.empty-state h3 { font: 500 16px var(--font); color: var(--ink); margin-bottom: 6px; }
.empty-state p { color: var(--muted); font-size: 12px; }
.empty-state .btn { display: none; }
.demo-note, .label-plain, .paper-heading small, .paper-footer { font-size: 11px; color: var(--muted); }
.demo-note { margin-top: 14px; }
.work-grid { gap: 22px; grid-template-columns: minmax(0,1fr) 320px; }
.paper-heading { padding: 15px 19px; font-size: 12px; border-color: var(--line); }
.paper-heading > span { display: flex; align-items: center; gap: 8px; }
.paper-heading svg { width: 15px; height: 15px; color: var(--muted); }
html[data-theme] .editor { min-height: 440px; padding: 25px 27px; font: 14px/1.85 var(--font); background: var(--surface); color: var(--ink); border-radius: 4px; }
.paper-footer { padding: 12px 18px; border-color: var(--line); }
.form-card { padding: 22px; }
.field > label { font-size: 12px; font-weight: 450; color: var(--muted); }
html[data-theme] .field input, html[data-theme] .field textarea, html[data-theme] .field select { background: var(--control); color: var(--ink); border: 1px solid var(--line); border-radius: 4px; font-size: 13px; }
.field { margin-bottom: 18px; gap: 7px; }
html[data-theme] input::placeholder, html[data-theme] textarea::placeholder { color: var(--muted); opacity: .8; }
.checkbox { font-size: 11px; color: var(--muted); }
.side-panel { padding: 19px; }
.side-panel h2 { font-size: 13px; }
.side-panel p, .risk-card p { color: var(--muted); font-size: 12px; line-height: 1.7; }
.checklist li { font-size: 12px; line-height: 1.7; color: var(--muted); }
.checklist svg { color: var(--muted); }
html[data-theme] .risk-card { border: 1px solid var(--line); border-left: 2px solid #a78d62; border-radius: 3px; padding: 14px; }
html[data-theme] .risk-card.high { border-left-color: #b87272; }
html[data-theme] .risk-card.low { border-left-color: #909090; }
html[data-theme] .risk-level { color: #a78d62; font-size: 9px; }
html[data-theme] .risk-card.high .risk-level { color: #b87272; }
html[data-theme] .risk-card.low .risk-level { color: var(--muted); }
.risk-card h3 { font-size: 13px; margin: 9px 0; }
html[data-theme] .risk-card blockquote { background: var(--subtle); border-color: var(--line); font: 12px/1.8 var(--font); color: var(--ink); }
.risk-card .btn { font-size: 10px; }
html[data-theme] .notice { background: var(--subtle); border-color: var(--line); border-radius: 4px; color: var(--muted); font-size: 11px; }
html[data-theme] .notice button { color: var(--ink); }
.panel-empty { padding: 26px 4px; }
.panel-empty > svg { color: var(--muted); width: 25px; height: 25px; }
.panel-empty strong { font-size: 13px; }
.panel-empty p { font-size: 12px; }
.template-list { border-top: 1px solid var(--line); }
.template-row { display: flex; align-items: center; gap: 17px; padding: 21px 8px; border-bottom: 1px solid var(--line); }
.template-row > svg { width: 20px; color: var(--muted); }
.template-row > div { flex: 1; }
.template-row h3 { font-size: 13px; font-weight: 550; margin: 0 0 5px; }
.template-row p { font-size: 12px; color: var(--muted); margin: 0; }
.source-card { box-shadow: none; padding: 21px 18px; border-radius: 4px; }
.source-number { display: none; }
.source-card h3 { font-size: 13px; }
.source-card p, .source-card .label-plain { font-size: 11px; color: var(--muted); }
.preview-output, .diff-result { font: 13px/1.9 var(--font); }
html[data-theme] .code-info { background: var(--subtle); border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
html[data-theme] dialog { background: var(--surface); color: var(--ink); border-color: var(--line); border-radius: 7px; box-shadow: 0 20px 80px #0003; }
.modal-head h2 { font: 550 19px var(--font); }
html[data-theme] #modal-content p, html[data-theme] #modal-content li { color: var(--muted); font-size: 12px; }
html[data-theme] #modal-content a { color: var(--ink); }
html[data-theme] #toast { background: var(--ink); color: var(--bg); border: 1px solid var(--line); box-shadow: 0 6px 24px #0002; border-radius: 5px; }
.chat-page-header { margin-bottom: 20px; min-height: 32px; }
.chat-page-header h1 { margin: 0; }
.chat-page-header p { display: none; }
.chat-workspace { grid-template-columns: 225px minmax(0,1fr); min-height: 440px; height: calc(100dvh - 165px); max-height: none; border-radius: 5px; box-shadow: none; }
html[data-theme] .chat-list-panel { background: var(--sidebar); padding: 14px 10px; border-color: var(--line); }
.new-chat-button { margin-bottom: 12px; }
html[data-theme] .chat-list-item { padding: 11px 9px; border-radius: 4px; color: var(--ink); }
html[data-theme] .chat-list-item.selected { background: var(--accent-soft); border-color: transparent; }
html[data-theme] .chat-list-item:hover { background: var(--hover); }
.chat-list-item strong { font-size: 12px; font-weight: 500; }
.chat-list-item small { font-size: 10px; margin-top: 4px; }
html[data-theme] .chat-list-item svg { color: var(--muted); }
.chat-list-tabs { margin: 15px 5px 7px; }
html[data-theme] .chat-list-tabs button { font-size: 11px; color: var(--muted); }
html[data-theme] .chat-list-tabs button.selected { color: var(--ink); border-color: var(--muted); }
.chat-storage-note { font-size: 9px; line-height: 1.5; }
.chat-list-empty { font-size: 12px; }
.conversation-header { min-height: 62px; padding: 15px 21px; }
.conversation-header strong { font-size: 13px; font-weight: 550; }
.conversation-header small { font-size: 10px; margin-top: 3px; }
.conversation-tools .icon-button { height: 29px; width: 29px; }
.conversation-messages { padding: 26px; scrollbar-color: var(--line) transparent; }
.conversation-welcome { display: flex; height: 100%; min-height: 100px; align-items: center; justify-content: center; margin: 0; }
.conversation-welcome p { color: var(--muted); font: 13px/1.8 var(--font); margin: 0; display: block !important; }
.chat-message { gap: 13px; margin-bottom: 30px; }
html[data-theme] .message-avatar, html[data-theme] .chat-message.user .message-avatar { color: var(--muted); background: var(--accent-soft); border-radius: 4px; font-size: 8px; }
.message-name { font-size: 11px; margin-bottom: 9px; }
.message-content { font-size: 13px; line-height: 1.9; }
html[data-theme] .chat-message.user .message-content { background: var(--subtle); border-color: var(--line); border-radius: 0 5px 5px 5px; padding: 12px 15px; }
.message-status { font-size: 10px; color: var(--muted); }
.chat-compose-area { padding: 0 22px 16px; }
html[data-theme] .chat-compose { padding: 12px 13px 9px; box-shadow: none; border-color: var(--line); background: var(--control); border-radius: 6px; }
html[data-theme] .chat-compose:focus-within { border-color: var(--muted); }
.chat-compose textarea { font-size: 13px; min-height: 68px; line-height: 1.7; }
.web-search-switch { font-size: 10px; }
html[data-theme] .web-search-switch input, html[data-theme] .checkbox input { accent-color: var(--muted); }
html[data-theme] .chat-send { background: var(--accent); color: var(--bg); border-radius: 4px; width: 31px; height: 29px; }
.chat-bottom-bar { gap: 10px; padding-top: 10px; }
.account-pill { font-size: 10px; }
html[data-theme] .small-dot, html[data-theme] .small-dot.connected { background: var(--muted); }
.chat-model-select { font-size: 10px; }
.chat-footnote { font-size: 9px; color: var(--muted); }
html[data-theme] .chat-attachment { background: var(--subtle); border-color: var(--line); color: var(--muted); border-radius: 4px; }
.message-sources a { color: var(--ink); }
html[data-theme] .account-avatar { background: var(--accent-soft); color: var(--muted); }
html[data-theme] .account-list-empty { background: var(--subtle); }
@media(min-width:1500px) { main { padding-top: 28px; } }
@media(max-width:1180px) {
  .sidebar { width: 210px; }
  .page-shell { margin-left: 210px; }
  main { padding: 26px; }
  .chat-workspace { grid-template-columns: 200px minmax(0,1fr); }
  .page-heading h1, .chat-page-header h1 { font-size: 23px; }
  .work-grid { grid-template-columns: minmax(0,1fr) 290px; }
}
@media(max-width:960px) {
  .sidebar { width: 224px; }
  .page-shell { margin-left: 0; }
  .topbar { padding: 0 20px; }
}
@media(max-width:640px) {
  html[data-theme] .topbar { height: 52px; padding: 0 13px; }
  main { padding: 22px 16px; }
  .page-heading { margin-bottom: 22px; }
  .page-heading h1, .chat-page-header h1 { font-size: 22px; }
  .page-heading p { font-size: 12px; }
  .topbar-right { gap: 11px; }
  .dashboard-toolbar { gap: 8px; align-items: flex-start; }
  .dashboard-toolbar > .btn.text { display: none; }
  html[data-theme] .btn { font-size: 11px; padding: 7px 9px; }
  html[data-theme] .compact-upload { padding: 19px 15px; min-height: 108px; gap: 12px; margin-bottom: 28px; flex-wrap: wrap; }
  .compact-upload > svg { width: 18px; }
  .compact-upload strong { font-size: 12px; }
  .compact-upload p { font-size: 10px; }
  .compact-upload .btn { display: none; }
  .work-grid { grid-template-columns: 1fr; }
  .document-row { padding: 14px 10px; }
  .document-name strong { font-size: 12px; }
  .document-name small { font-size: 10px; }
  .file-icon { display: none !important; }
  .template-row { gap: 11px; padding: 17px 2px; }
  .template-row h3 { font-size: 12px; }
  .template-row p { font-size: 11px; }
  .template-row > svg { display: none; }
  .source-card { padding: 16px 14px; }
  .chat-page-header { margin-bottom: 16px; align-items: center; min-height: 34px; }
  .chat-mobile-button { margin: 0; }
  .chat-workspace { min-height: 460px; height: calc(100dvh - 160px); }
  .conversation-header { padding: 14px; min-height: 62px; }
  .conversation-header strong { max-width: 180px; font-size: 12px; }
  .conversation-header small { font-size: 9px; }
  .conversation-messages { padding: 19px 14px; }
  .chat-compose-area { padding: 0 12px 13px; }
  .message-content { font-size: 12px; }
  .chat-list-item strong { font-size: 12px; }
  .chat-list-panel { padding: 13px !important; }
  .chat-storage-note { font-size: 10px; }
  .web-search-switch { font-size: 10px; }
  .account-pill, .chat-model-select { font-size: 9px; }
  .chat-footnote { display: none; }
}

/* Keep conversation history alongside the active chat at every window width. */
.chat-workspace { display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.chat-workspace .chat-list-panel { display: flex; width: auto; min-height: 0; }
.chat-workspace .conversation-panel { display: flex; width: auto; }
.chat-list-heading { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 12px; }
.chat-list-heading h2 { margin: 0; font: 600 13px/1.4 var(--font); }
.chat-list-heading span { color: var(--muted); font-size: 11px; }
.chat-list { min-height: 0; }
.chat-list-item { flex-shrink: 0; }
.chat-mobile-button { display: none; }
@media (max-width: 1180px) {
  .chat-workspace { grid-template-columns: 210px minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .chat-workspace { display: grid; grid-template-columns: clamp(120px, 30vw, 180px) minmax(0, 1fr); }
  html[data-theme] .chat-list-panel { padding: 12px 8px !important; }
  .chat-list-heading { padding: 0 3px 10px; }
  .chat-list-heading h2 { font-size: 12px; }
  .chat-list-heading span { font-size: 10px; }
  html[data-theme] .new-chat-button { font-size: 11px; padding: 7px 4px; min-height: 33px; margin-bottom: 10px; }
  html[data-theme] .chat-search { font-size: 11px; padding: 8px; height: 32px; min-height: 32px; }
  .chat-list-tabs { gap: 12px; margin: 13px 3px 7px; }
  html[data-theme] .chat-list-tabs button { font-size: 10px; }
  html[data-theme] .chat-list-item { padding: 10px 7px; gap: 0; }
  .chat-list-item > span:first-child, .chat-list-item small { display: none; }
  .chat-list-item strong { font-size: 12px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .chat-list-empty { padding: 22px 3px; font-size: 11px; line-height: 1.6; }
  .chat-storage-note { font-size: 9px; align-items: flex-start; gap: 5px; padding-top: 12px; }
  .chat-storage-note svg { flex-shrink: 0; margin-top: 1px; }
  .conversation-header { flex-direction: column; align-items: flex-start; gap: 7px; padding: 12px; }
  .conversation-header > div:first-child { min-width: 0; max-width: 100%; }
  .conversation-header strong { white-space: normal; overflow-wrap: anywhere; max-width: none; line-height: 1.5; }
  .conversation-header small { max-width: none; line-height: 1.5; }
  .conversation-tools { align-self: flex-end; flex-wrap: wrap; }
  .conversation-messages { padding: 16px 12px; }
  .conversation-welcome p { font-size: 12px; }
  .chat-compose-area { padding: 0 10px 12px; }
  html[data-theme] .chat-compose { padding: 9px; }
  .chat-compose textarea { min-height: 86px; font-size: 12px; resize: none; }
  .chat-compose-tools { align-items: flex-end; gap: 5px; }
  .chat-compose-left { flex-wrap: wrap; gap: 4px; min-width: 0; }
  .web-search-switch { font-size: 9px; }
  .chat-send { flex-shrink: 0; }
  .chat-message { gap: 6px; }
  .message-avatar { display: none !important; }
  .message-content { font-size: 12px; }
  .chat-attachment { margin: 0 10px 10px; overflow-wrap: anywhere; }
}
@media (max-width: 380px) {
  .chat-workspace { grid-template-columns: 108px minmax(0, 1fr); }
  html[data-theme] .chat-list-panel { padding: 10px 6px !important; }
  .chat-list-tabs { gap: 9px; }
  .chat-list-item strong { font-size: 11px; }
  .conversation-header { padding: 10px; }
  .chat-compose-area { padding: 0 7px 9px; }
}

/* Dismissible navigation drawer. */
.sidebar-close, .sidebar-backdrop { display: none; }
@media (max-width: 960px) {
  .sidebar-close { display: grid; position: absolute; top: 20px; right: 10px; z-index: 1; width: 30px; height: 30px; font-size: 23px; }
  .sidebar .brand { padding-right: 28px; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0; background: #0007; z-index: 19; cursor: default; }
  body.sidebar-open { overflow: hidden; }
}

.pwa-install-block { border-top: 1px solid var(--line); margin: 20px 0; padding-top: 16px; }
.pwa-install-block h3 { font: 550 14px/1.5 var(--font); margin: 0; }
.pwa-install-block p { margin: 6px 0 12px; }
@media (display-mode: standalone) { .topbar { padding-top: env(safe-area-inset-top); } .chat-compose-area { padding-bottom: max(16px, env(safe-area-inset-bottom)); } }
.chat-sync-status{appearance:none;border:0;background:none;color:inherit;font:inherit;text-align:left;padding:0;cursor:pointer;line-height:1.5}
.chat-sync-status:hover{text-decoration:underline}
