/* Workspace appearance never changes the colors of a publishable article. */
:root[data-appearance="dark"] {
  color-scheme:dark;
  --brand-primary:#79cdb8;
  --brand-primary-text:#99dfcd;
  --brand-primary-hover:#91dac7;
  --brand-primary-active:#62bda6;
  --brand-accent:#d2ae77;
  --brand-accent-ink:#e6c58e;
  --brand-accent-soft:#352d20;
  --brand-ink:#e2eae6;
  --brand-paper:#111917;
  --brand-white:#182320;
  --brand-soft:#253f36;
  --brand-muted:#a3b4ad;
  --brand-line:#374a43;
  --brand-canvas:#0e1513;
  --brand-hover:#25352f;
  --control-line:#71877d;
  --warning-ink:#e9c18b;
  --warning-soft:#30291f;
  --warning-line:#725e3b;
  --error-ink:#ffab97;
  --focus-soft:#79cdb860;
  --shadow:0 12px 36px #0006;
}
:root[data-appearance="dark"] .brand-logo {
  content:url('/brand/logo/final/lockup-horizontal-dark.svg?v=1');
}
:root[data-appearance="dark"] img.icon { filter:invert(.9); }
:root[data-appearance="dark"] .primary-button { color:#10251f; }
:root[data-appearance="dark"] .is-done { box-shadow:0 0 0 3px #79cdb829; }
:root[data-appearance="dark"] :is(.popup-menu,.confirm-card,.history-card,.copy-drawer-card,.theme-compare-dialog,.feedback-toast) {
  --panel:#202d28;
  background:var(--panel);
}
:root[data-appearance="dark"] .modal-backdrop { background:#0009; }
:root[data-appearance="dark"] :is(.confirm-card,.history-card,.copy-drawer-card,.theme-compare-dialog) { box-shadow:0 24px 80px #0008; }
:root[data-appearance="dark"] :is(input,textarea,select) { color:var(--text); }
:root[data-appearance="dark"] :is(input,textarea)::placeholder { color:var(--muted); opacity:1; }
:root[data-appearance="dark"] :is(#editor,.source-details textarea)::selection { color:#e2eae6; background:#355f50; }
:root[data-appearance="dark"] :is(.side-panel,.check-panel) { box-shadow:-4px 0 18px #0002; }
:root[data-appearance="dark"] #copyBtn { box-shadow:0 2px 4px #0003; }

/* Light islands: keep the paper, miniature samples and manual copy faithful.
   The values also isolate inherited UI tokens from future article styling. */
:is(.wechat-preview,.theme-sample,.theme-compare-paper,.manual-copy-output) {
  color-scheme:light;
  --bg:#f5f6f3;
  --panel:#fff;
  --text:#20332f;
  --muted:#606e68;
  --line:#d5dfda;
  --accent:#146c62;
  --accent-text:#125d54;
  --selected:#e0efeb;
  --surface-muted:#e8eeec;
  --surface-hover:#edf4f1;
  color:var(--text);
}
:root[data-appearance="dark"] :is(.theme-sample,.theme-compare-paper) { background:#fff; }
.appearance-control {
  margin-left:auto;
  flex:none;
  display:flex;
  align-items:center;
  gap:6px;
  color:var(--muted);
}
.appearance-control select {
  min-width:94px;
  height:28px;
  padding:2px 5px;
  border:1px solid var(--line);
  border-radius:5px;
  background:var(--panel);
  color:var(--text);
  font:inherit;
  cursor:pointer;
}
.statusbar #copyStatus { margin-left:0; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.appearance-control select:focus-visible { outline-offset:1px; }
@media(max-width:760px) {
  .statusbar { height:46px; gap:8px; padding:0 12px; }
  .appearance-control label { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  .appearance-control select { height:36px; min-width:88px; }
  .statusbar .content-metrics { min-width:0; overflow:hidden; text-overflow:ellipsis; }
  .statusbar .mobile-save-status { flex:none; }
}
@media(max-width:374px) {
  :root[data-appearance="dark"] .brand-logo { content:url('/brand/logo/responsive-system/favicon-dark.svg?v=1'); }
}

/* Preview-only reading colors. Inline article markup, images, samples and exports
   remain untouched; only paint properties are overridden, never layout or type. */
.preview-reading-tools {
  flex:none;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
  min-height:44px;
  padding:0 var(--preview-gutter) 8px;
}
:root:not([data-appearance="dark"]) .preview-reading-tools { display:none; }
.preview-reading-tools p { margin:0; color:var(--muted); font-size:12px; }
.preview-reading-tools select {
  min-height:34px;
  max-width:132px;
  padding:4px 8px;
  border:1px solid var(--line);
  border-radius:5px;
  background:var(--panel);
  color:var(--text);
  font:inherit;
  font-size:12px;
  cursor:pointer;
}
:root[data-preview-appearance="night"] #preview {
  --reading-paper:#182320;
  --reading-raised:#22332c;
  --reading-text:#dce5df;
  --reading-heading:#edf3ef;
  --reading-muted:#b2c2b9;
  --reading-accent:#93d8c2;
  --reading-border:#648879;
  color-scheme:dark;
  background:var(--reading-paper)!important;
  color:var(--reading-text)!important;
  border-color:#374a43!important;
  box-shadow:0 3px 14px #0002;
}
:root[data-preview-appearance="night"] #preview :is(section,p,h1,h2,h3,span,strong,blockquote,ul,ol,li,pre,code,a,div:where([data-ziju-block="quote"])) {
  color:var(--reading-text)!important;
  background-color:transparent!important;
  border-color:var(--reading-border)!important;
}
:root[data-preview-appearance="night"] #preview :is(h1,h2,h3,h1 *,h2 *,h3 *) { color:var(--reading-heading)!important; }
/* Convert existing fills without boxing ordinary paragraphs, leads or sources. */
:root[data-preview-appearance="night"] #preview :is(p,h1,h2,h3,span,strong,blockquote,ul,ol,li,section>section,div[data-ziju-block="quote"]):is([style*="background:#"],[style*="background-color:#"]),
:root[data-preview-appearance="night"] #preview pre { background-color:var(--reading-raised)!important; }
:root[data-preview-appearance="night"] #preview h2 span[data-ziju-decoration][style*="background:#"] {
  background-color:var(--reading-accent)!important;
}
/* Geometry and borders come from shared inline article styles. Night reading
   changes only surface colors, retaining the same insets as light and copy. */
:root[data-preview-appearance="night"] #preview section>section:not([data-ziju-block]) {
  background-color:var(--reading-raised)!important;
}
:root[data-preview-appearance="night"] .app-shell[data-platform="wechat"] #preview :is(p[data-ziju-block="quote"],blockquote):is([data-ziju-block],blockquote) {
  background-color:#1e2e27!important;
}
:root[data-preview-appearance="night"] #preview :is(blockquote,blockquote p,[data-ziju-block="quote"],p>span) { color:var(--reading-muted)!important; }
:root[data-preview-appearance="night"] #preview :is(a,section>section>strong) { color:var(--reading-accent)!important; }
:root[data-preview-appearance="night"] #preview code { background-color:var(--reading-raised)!important; color:#e6c58e!important; }
:root[data-preview-appearance="night"] #preview pre code { background-color:transparent!important; color:var(--reading-text)!important; }
:root[data-preview-appearance="night"] #preview ::selection { background:#355f50; color:#edf3ef; }

/* Keep native select interaction, with a consistently inset shared chevron. */
.appearance-select {
  position:relative;
  display:inline-flex;
  flex:none;
  color:var(--muted);
}
.appearance-select::after {
  content:"";
  position:absolute;
  right:10px;
  top:50%;
  width:14px;
  height:14px;
  transform:translateY(-50%);
  background:currentColor;
  -webkit-mask:url('/brand/icons/chevron-down.svg') center/contain no-repeat;
  mask:url('/brand/icons/chevron-down.svg') center/contain no-repeat;
  pointer-events:none;
}
.appearance-select select {
  -webkit-appearance:none;
  appearance:none;
  padding-left:12px;
  padding-right:32px;
}
.appearance-select select:focus-visible { outline-offset:1px; }
@media (forced-colors:active) {
  .appearance-select::after { display:none; }
  .appearance-select select { appearance:auto; padding-right:8px; }
}

#chapterStyleControl:not([hidden]) { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:12px 0; }
#chapterStyleControl label { margin:0; }
#chapterStyleControl select { width:100%; min-height:34px; }

.catalog-chapter-style { display:grid; gap:4px; padding:8px; border-top:1px solid var(--line); }
.catalog-chapter-style label { margin:0; font-size:12px; }
.catalog-chapter-style .appearance-select { min-width:0; }
.catalog-chapter-style select { width:100%; min-width:0; min-height:36px; font-size:12px; }
