/* Night chat uses a stable, quiet reading surface inside the continuous blue sky. */
body.private-view.dark .ps-app.ps-workspace-mode {
  --ps-bg: transparent;
  --ps-paper: var(--paper);
  --ps-text: #dce5ee;
  --ps-muted: #adbdcf;
  --ps-line: #7194bd38;
  --ws-chat-bg: var(--bg);
  --ws-assistant-bg: transparent;
  --ws-user-bg: #233e5d;
  background: transparent;
  color-scheme: dark;
}
body.private-view.dark .ps-workspace-mode > .ps-sidebar { background: #06132666; }
body.private-view.dark .ps-workspace-mode .ws-panel { border-color: var(--ps-line); box-shadow: none; }
body.private-view.dark .ps-workspace-mode :is(.ws-research,.ws-sources,.ws-artifacts) { background:var(--ws-chat-bg); background-image:none; }
body.private-view.dark .ps-workspace-mode .ws-chat { background:var(--ws-chat-bg); color:var(--ps-text); border:0; }
body.private-view.dark .ps-workspace-mode .ws-chat .ws-panel-header { border-bottom:0!important; }
body.private-view.dark .ps-workspace-mode :is(.ws-upload-zone,.ws-source-preview) { background:#192d4477; border-color:var(--ps-line); }
body.private-view.dark .ps-workspace-mode .ws-grid button:not(.ps-primary) { color:#a7ccf1; }
body.private-view.dark .ps-workspace-mode .ws-grid :is(.ws-file-row>button,.ws-artifact-row,.ws-tools button,.ws-prompts button) { color:var(--ps-text); }
body.private-view.dark .ps-workspace-mode .ws-grid button.ps-primary { background:#3078c4; border-color:#3078c4; color:#fff; }
body.private-view.dark .ps-workspace-mode .ws-chat :is(h1,h2,h3) { color:var(--ps-text); }
body.private-view.dark .ps-workspace-mode .ws-chat .ws-message-meta b { color:#9bc6f0; }
body.private-view.dark .ps-workspace-mode .ws-chat .ws-composer { background:var(--ps-paper); border:1px solid var(--ps-line); box-shadow:none; }
body.private-view.dark .ps-workspace-mode .ws-chat textarea { color:var(--ps-text); }
body.private-view.dark .ps-workspace-mode .ws-chat textarea::placeholder { color:var(--ps-muted); }
body.private-view.dark .ps-workspace-mode .ws-preferences { background:transparent; }
body.private-view.dark .ps-workspace-mode .ws-tools button { background:#243d5755; }
body.private-view.dark .ps-workspace-mode .ws-prompts button { background:#1c314977; }

/* Apply the same light language to the existing reader's night appearance.
   Daytime paper choices, saved content and all reader interactions are untouched. */
body #calm-reader[data-paper="night"] {
  --cr-bg: #172a3c;
  --cr-text: #dce5ee;
  --cr-muted: #afbbc7;
  --cr-line: #81909c55;
  --cr-chrome: #20374c;
  --cr-accent: #7db5ef !important;
  background: #0e1f30;
}
body #calm-reader[data-paper="night"] .cr-bar {
  --cr-bg: #112235;
  background: var(--cr-bg);
}
body #calm-reader[data-paper="night"] .cr-toc {
  background: radial-gradient(ellipse at 100% 32%, #edc88a2e, transparent 78%),
    linear-gradient(270deg, #d9b47a36, transparent 95%), #162a3c;
}
body #calm-reader[data-paper="night"] .cr-panel {
  --cr-bg: #172a3c;
  background: radial-gradient(ellipse at 0% 32%, #edc88a2e, transparent 78%),
    linear-gradient(90deg, #d9b47a36, transparent 95%), #162a3c;
}
body #calm-reader[data-paper="night"] .cr-panel-heading {
  background: transparent;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
/* Let the sidebar reflection continue through its headings and controls. */
body #calm-reader[data-paper="night"] #cr-panel .cr-margin-heading button {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  border-bottom: 2px solid transparent;
}
body #calm-reader[data-paper="night"] #cr-panel .cr-margin-heading [aria-selected="true"] {
  background: transparent;
  border-bottom-color: var(--cr-accent);
  color: var(--cr-accent);
  font-weight: 500;
}
body #calm-reader[data-paper="night"] #cr-panel #cr-note-filter {
  background: transparent;
  box-shadow: none;
  color: var(--cr-text);
  border: 0;
  color-scheme: dark;
}
body #calm-reader[data-paper="night"] #cr-panel #cr-note-filter option {
  background: #172a3c;
  color: #dce5ee;
}
body #calm-reader[data-paper="night"] .cr-scroll {
  --cr-bg: #bdbab2;
  --cr-text: #253142;
  --cr-ink: #253142;
  --cr-muted: #505c68;
  --cr-line: #65748866;
  --cr-chrome: #aeb6bd80;
  --cr-accent: #315d8b;
  color: var(--cr-text);
  background: radial-gradient(ellipse at 88% 6%, #e5d3b9a8, transparent 78%),
    linear-gradient(145deg, #c1bdb4, #afb5bb);
  color-scheme: light;
}
body #calm-reader[data-paper="night"] .cr-prose a { color: #244f7d; }
body #calm-reader[data-paper="night"] :is(.cr-toc button.cr-current, .cr-is-active) {
  color: #b9d8fa;
}
body #calm-reader[data-paper="night"] .cr-prose ::selection { background: #8cbae3; color: #152a40; }
@media (max-width: 1050px) {
  /* Each mobile tab is independent; keep a quiet residual reflection. */
  body.private-view.dark .ps-workspace-mode :is(.ws-sources, .ws-artifacts) {
    background-size: 100% 100%;
  }
}
