/* Account-local appearance shared by chat, workbench, lock screen and shield. */
.chat-nav .chat-theme-button { width:36px; padding:0; flex:none; color:var(--muted); }
.chat-nav .chat-theme-button[aria-pressed="true"] { color:var(--primary); background:var(--primary-soft); }
.chat-theme-button [hidden] { display:none !important; }

body[data-chat-theme="dark"],
body[data-chat-theme="dark"] :is(.conversation,.rail,.low-key-workbench,.dialog) {
  color-scheme:dark;
  --bg:oklch(.215 .012 264); --surface:oklch(.255 .015 264); --surface-strong:oklch(.31 .018 264);
  --line:oklch(.39 .021 264); --ink:oklch(.94 .012 264); --muted:oklch(.80 .018 264);
  --primary:oklch(.80 .105 264); --primary-hover:oklch(.88 .065 264); --primary-soft:oklch(.35 .066 260);
  --focus:oklch(.80 .105 264); --success:oklch(.77 .10 170); --danger:oklch(.78 .12 20);
  --chat-bg:var(--bg); --bubble-in:oklch(.29 .014 264); --bubble-out:oklch(.40 .083 260);
  color:var(--ink);
}
body[data-chat-theme="dark"] .app-shell { background:var(--bg); }
body[data-chat-theme="dark"] .rail { background:var(--surface); border-color:var(--line); }
body[data-chat-theme="dark"] .rail .rail-header { border-color:var(--line); }
body[data-chat-theme="dark"] .rail .brand-mark { background:var(--primary-soft); }
body[data-chat-theme="dark"] .rail .brand-mark i { background:var(--primary); }
body[data-chat-theme="dark"] .rail .rail-tabs button.is-active { color:var(--primary); }
body[data-chat-theme="dark"] :is(.rail,.conversation) :is(.primary-button,.danger-button,.request-actions button:first-child,.rail-tabs button span) { color:var(--bg); }
body[data-chat-theme="dark"] .rail .unread-badge { background:var(--danger); color:var(--bg); }
body[data-chat-theme="dark"] .conversation .message-select:checked::after { border-color:var(--bg); }
body[data-chat-theme="dark"] .conversation :is(.conversation-header,.composer) { background:var(--surface); border-color:var(--line); }
body[data-chat-theme="dark"] .conversation .message-viewport { background:var(--chat-bg); }
body[data-chat-theme="dark"] .conversation :is(.composer-main,.composer .message-editor) { background:var(--bg); border-color:var(--line); color:var(--ink); caret-color:var(--ink); }
body[data-chat-theme="dark"] .conversation .composer-main:focus-within { border-color:var(--focus); }
body[data-chat-theme="dark"] .conversation :is(.conversation-actions .icon-button,.composer .icon-button,.message .message-meta,.day-divider,.chat-layout-button) { color:var(--muted); }
body[data-chat-theme="dark"] .conversation :is(.icon-button:hover,.chat-more-menu[open] summary,.chat-nav button:hover) { background:var(--surface-strong); color:var(--ink); }
body[data-chat-theme="dark"] .conversation .chat-nav button { color:var(--ink); }
body[data-chat-theme="dark"] .conversation .chat-nav :is(button.is-active,button[aria-pressed="true"]) { background:var(--primary-soft); color:var(--primary); }
body[data-chat-theme="dark"] .conversation .chat-nav .nav-image-icon { color:var(--primary); }
body[data-chat-theme="dark"] .conversation .chat-nav .nav-pin-icon { color:var(--success); }
body[data-chat-theme="dark"] .conversation .chat-more-panel { background:var(--surface-strong); border-color:var(--line); box-shadow:none; }
body[data-chat-theme="dark"] .conversation .quoted-message { background:var(--surface-strong); color:var(--muted); }
body[data-chat-theme="dark"] .conversation .message-payload.has-quote > .quoted-message { background:transparent; border-color:var(--line); }
body[data-chat-theme="dark"] .conversation .message-payload.has-quote > .quoted-message:hover { color:var(--primary-hover); }
body[data-chat-theme="dark"] .conversation .message-reaction-chip,
body[data-chat-theme="dark"] .conversation .message.is-mine .message-reaction-chip { color:var(--ink); background:var(--surface-strong); border-color:var(--line); }
body[data-chat-theme="dark"] .conversation .message-reaction-chip.is-mine { background:var(--primary-soft); border-color:var(--primary); }
body[data-chat-theme="dark"] .conversation .message-edited { color:var(--muted); }
body[data-chat-theme="dark"] .conversation .message .message-meta .read-state { border-color:var(--muted); }
body[data-chat-theme="dark"] .conversation .message.is-mine .read-state.is-read,
body[data-chat-theme="dark"] .conversation .message.is-mine .read-state.is-read::after { border-color:var(--success); }
body[data-chat-theme="dark"] .conversation #sendButton { color:var(--primary); }
body[data-chat-theme="dark"] .conversation #sendButton:hover { background:var(--primary-soft); }
body[data-chat-theme="dark"] .conversation #sendButton:disabled { color:var(--muted); }
body[data-chat-theme="dark"] .conversation .return-to-latest { background:var(--surface-strong); color:var(--primary); border-color:var(--line); box-shadow:none; }
body[data-chat-theme="dark"] .conversation .reply-bar { background:var(--surface-strong); }
body[data-chat-theme="dark"] .conversation .sticker-grid.is-managing button { background:var(--surface-strong); }
body[data-chat-theme="dark"] :is(.conversation,.rail,.dialog) input::placeholder { color:var(--muted); opacity:1; }
body[data-chat-theme="dark"] .conversation :is(button,summary):focus-visible { outline-color:var(--focus); }

/* Dialogs retain the same palette when opened from the workbench. */
body[data-chat-theme="dark"] .dialog::backdrop { background:oklch(.10 .01 264 / .65); }
body[data-chat-theme="dark"] .dialog :is(.primary-button,.danger-button,.search-row button:not([disabled])) { color:var(--bg); }
body[data-chat-theme="dark"] .chat-library-dialog,
body[data-chat-theme="dark"] .chat-library-dialog > header { border-color:var(--line); }
body[data-chat-theme="dark"] .chat-library-dialog :is(header p,.chat-library-copy small,.chat-library-status) { color:var(--muted); }
body[data-chat-theme="dark"] .chat-library-dialog .chat-library-item { border-color:var(--line); }
body[data-chat-theme="dark"] .chat-library-dialog .chat-library-item > button { color:var(--ink); }
body[data-chat-theme="dark"] .chat-library-dialog :is(.chat-library-item a,.chat-library-item > button:hover) { color:var(--primary); }
body[data-chat-theme="dark"] .chat-library-dialog .chat-library-kind { background:var(--primary-soft); color:var(--primary); }

/* Business workbench: preserve blue sent counts and red received counts. */
body[data-chat-theme="dark"] .low-key-workbench { background:var(--bg); color:var(--ink); }
body[data-chat-theme="dark"] :is(.low-key-body,.low-key-composer) { background:var(--bg); }
body[data-chat-theme="dark"] :is(.low-key-header,.low-key-tabs,.low-key-metrics,.low-key-trend,.low-key-rank,.low-key-ledger,.business-panel,.low-key-response-panel) { background:var(--surface); border-color:var(--line); }
body[data-chat-theme="dark"] :is(.low-key-workbench,#privacyView) .brand-mark { background:var(--primary-soft); }
body[data-chat-theme="dark"] :is(.low-key-workbench,#privacyView) .brand-mark i { background:var(--primary); }
body[data-chat-theme="dark"] :is(.low-key-lockup span,.low-key-tabs button,.low-key-metrics span,.low-key-metrics small,.low-key-panel-head span,.trend-summary span,.low-key-page-title span,.low-key-page-title time,.low-key-live-lock,.low-key-response-panel>span) { color:var(--muted); }
body[data-chat-theme="dark"] :is(.low-key-tabs button.is-active,.trend-summary strong,.low-key-table-wrap td,.low-key-row.is-local td:nth-child(4),.low-key-row.is-external td:nth-child(4)) { color:var(--ink); }
body[data-chat-theme="dark"] :is(.low-key-panel-head,.trend-summary,.low-key-ledger-head,.low-key-table-wrap th,.low-key-table-wrap td,.low-key-response-all) { border-color:var(--line); }
body[data-chat-theme="dark"] .low-key-metrics article { box-shadow:inset -1px 0 0 var(--line); }
body[data-chat-theme="dark"] .low-key-metrics article:last-child { box-shadow:none; }
body[data-chat-theme="dark"] .low-key-metrics [data-daily-count="sentCount"] { color:var(--primary); }
body[data-chat-theme="dark"] .low-key-metrics [data-daily-count="receivedCount"] { color:var(--danger); }
body[data-chat-theme="dark"] :is(.low-key-sync,.low-key-table-wrap th,.low-key-rank-row i,.low-key-reaction-summary button,.low-key-response-panel div button) { background:var(--surface-strong); color:var(--muted); }
body[data-chat-theme="dark"] :is(.low-key-sync:hover,.low-key-reaction-summary button:hover,.low-key-response-panel div button:hover) { background:var(--primary-soft); color:var(--ink); }
body[data-chat-theme="dark"] :is(.low-key-fill-button,.low-key-attach,.low-key-composer input) { background:var(--surface); border-color:var(--line); color:var(--ink); }
body[data-chat-theme="dark"] .low-key-composer input::placeholder { color:var(--muted); }
body[data-chat-theme="dark"] :is(.low-key-fill-button:hover,.low-key-fill-button.is-active,.low-key-attach:hover,.low-key-link-draft,.low-key-row.is-linked-target td) { background:var(--primary-soft); border-color:var(--primary); color:var(--ink); }
body[data-chat-theme="dark"] .low-key-composer>.low-key-submit { background:var(--primary); color:var(--bg); }
body[data-chat-theme="dark"] :is(.low-key-attachment,.low-key-response-button,.low-key-link-button,.low-key-linked-record,.low-key-response-expand,.low-key-response-close,.low-key-link-draft span,.low-key-link-clear,.low-key-return-chat:hover,.low-key-return-chat:focus-visible,.low-key-row.is-external .low-key-source) { color:var(--primary); }
body[data-chat-theme="dark"] .low-key-link-draft p { color:var(--muted); }
body[data-chat-theme="dark"] .low-key-link-draft>.low-key-link-clear:hover { background:var(--surface-strong); }
body[data-chat-theme="dark"] .low-key-row.is-local .low-key-source { color:oklch(.82 .10 70); }
body[data-chat-theme="dark"] .low-key-state.is-pending { color:oklch(.85 .10 70); background:oklch(.32 .04 70); }
body[data-chat-theme="dark"] .low-key-state.is-verified { color:var(--primary); background:var(--primary-soft); }
body[data-chat-theme="dark"] .low-key-state.is-external { color:var(--danger); background:oklch(.32 .04 20); }
body[data-chat-theme="dark"] .low-key-state.is-system { color:var(--success); background:oklch(.30 .035 170); }
body[data-chat-theme="dark"] .trend-grid { stroke:var(--line); }
body[data-chat-theme="dark"] :is(.trend-axis,.trend-tick,.business-previous) { stroke:var(--muted); }
body[data-chat-theme="dark"] :is(.trend-axis-label,.trend-axis-title) { fill:var(--muted); }
body[data-chat-theme="dark"] .trend-value { fill:var(--ink); }
body[data-chat-theme="dark"] .trend-area { fill:var(--primary-soft); }
body[data-chat-theme="dark"] .trend-line { stroke:var(--primary); }
body[data-chat-theme="dark"] .trend-point { fill:var(--surface); stroke:var(--primary); }

/* Both the locked page and the background privacy cover use this mounted view. */
body[data-chat-theme="dark"] .dashboard-mode {
  --dash-bg:var(--bg); --dash-panel:var(--surface); --dash-line:var(--line);
  --dash-text:var(--ink); --dash-muted:var(--muted);
  --dash-cyan:oklch(.79 .10 225); --dash-green:var(--success); --dash-amber:oklch(.82 .10 70);
}
body[data-chat-theme="dark"] .dashboard-mode :is(.head,.unlock-dock) { background:var(--dash-panel); }
body[data-chat-theme="dark"] #privacyView .privacy-logo-button,
body[data-chat-theme="dark"] .dashboard-mode .dash-track { background:var(--surface-strong); }
body[data-chat-theme="dark"] .dashboard-mode .dash-unread-count { color:var(--danger); }
body[data-chat-theme="dark"] .dashboard-mode .dash-chart .area { fill:oklch(.32 .038 225); }
body[data-chat-theme="dark"] .dashboard-mode .dash-platform:nth-child(4) i { background:oklch(.76 .10 285); }
body[data-chat-theme="dark"] .dashboard-mode .dash-ring { background:conic-gradient(var(--dash-green) 0 var(--coverage),var(--surface-strong) var(--coverage) 100%); }
@media(max-width:760px) {
  body[data-chat-theme="dark"] .low-key-metrics article { box-shadow:inset -1px -1px 0 var(--line); }
  body[data-chat-theme="dark"] .low-key-metrics article:nth-child(2n) { box-shadow:inset 0 -1px 0 var(--line); }
  body[data-chat-theme="dark"] .low-key-metrics article:nth-last-child(-n+2) { box-shadow:inset -1px 0 0 var(--line); }
  body[data-chat-theme="dark"] .low-key-metrics article:nth-child(2n):nth-last-child(-n+2) { box-shadow:none; }
}
