/* Last stylesheet on every page. Dark mode changes colors, never content,
   source images, layout, visibility, or the account/AI state. */
:root { --accent:#79372c; --action:#77392e; --action-hover:#542a24; --on-action:#fff3d9; }
html:not([data-theme="dark"]) { color-scheme:light; }
html[data-theme="dark"] {
  color-scheme:dark;
  --bg:#171815; --panel:#22231f; --panel-2:#2d2f28; --border:#777261;
  --text:#eee7d6; --muted:#c0b8a7; --gold:#d8b679; --gold-bright:#e4c58a;
  --danger:#ffb1a2; --ok:#a3cda6; --accent:#edb09a;
  --action:#713b31; --action-hover:#8a473a; --on-action:#fff3d9;
}
.theme-toggle { display:inline-flex; align-items:center; justify-content:center; flex:0 0 44px; width:44px; height:44px; min-height:44px; padding:10px; border:1px solid var(--border,#c7b797); border-radius:0; background:var(--panel,#fcf9f2); color:var(--gold-bright,#795125); cursor:pointer; touch-action:manipulation; }
.theme-toggle:hover { background:var(--panel-2,#eae1cf); border-color:var(--gold,#976b32); }
.theme-toggle:focus-visible { outline:2px solid var(--gold,#976b32); outline-offset:3px; }
.theme-toggle svg { width:22px; height:22px; flex-shrink:0; }
/* Overflow must start at a reachable item, not clip half of a centred row. */
header .tabs { justify-content:safe center; }
.theme-toggle .theme-sun,html[data-theme="dark"] .theme-toggle .theme-moon { display:none; }
html[data-theme="dark"] .theme-toggle .theme-sun { display:block; }
body > .theme-toggle { position:fixed; top:12px; right:122px; z-index:30; }
.legal-modal > .theme-toggle,.maintenance-card > .theme-toggle { margin:16px 0 0 10px; vertical-align:bottom; }
/* The owner page previously had independent hard-coded dark colors. Share
   the selected palette, including its maintenance editor and previews. */
html .admin-page { background:var(--bg); color:var(--text); }
html .admin-page #panel > header { background:transparent; color:var(--text); border-color:var(--border); }
html .admin-page :is(.sub,label,.card span,th,.a,.meta,summary,.empty,.foot,.who .sub) { color:var(--muted); }
html .admin-page a { color:var(--gold-bright); }
html .admin-page :is(button,input,select,textarea,.card,.user-card) { background:var(--panel); color:var(--text); border-color:var(--border); }
html .admin-page :is(th,td,.foot,nav.tabs) { border-color:var(--border); }
html .admin-page :is(.q,nav.tabs button[aria-selected="true"]) { color:var(--text); }
html .admin-page nav.tabs button[aria-selected="true"] { border-bottom-color:var(--gold); }
html .admin-page .warn { background:var(--panel-2); border-color:var(--gold); }
html .admin-page :is(.warn.bad,.card.alarm,tr.crisis) { background:var(--panel-2); border-color:var(--danger); }
html .admin-page :is(.err,.failed,.tag.crisis,.card.alarm b) { color:var(--danger); }
html .admin-page .saved { color:var(--ok); }
html .admin-page :is(.tag,.badge-toggle) { color:var(--muted); border-color:var(--border); }
html .admin-page .tag.guest { color:var(--gold-bright); }
html .admin-page .tag.member { color:var(--ok); }
html .maintenance-editor :is(.maintenance-hero,.maintenance-switch,.maintenance-preview) { background:var(--panel); color:var(--text); border-color:var(--border); box-shadow:5px 5px 0 var(--panel-2); }
html .maintenance-editor :is(h2,.maintenance-fields label) { color:var(--text); }
html .maintenance-editor :is(.maintenance-kicker,.maintenance-hint,.maintenance-preview p,.maintenance-feedback) { color:var(--muted); }
html .maintenance-editor :is(input,select,textarea) { background:var(--panel); color:var(--text); border-color:var(--border); }
html .maintenance-preview .preview-end { border-color:var(--border); }
html .maintenance-editor .maintenance-switch[aria-checked="true"] { color:var(--gold-bright); background:var(--panel-2); border-color:var(--gold); }
html .admin-page .theme-toggle { color:var(--gold-bright); }
/* Main website, reader, account, forum, legal pages and auxiliary panels. */
html[data-theme="dark"] body { background:radial-gradient(ellipse at 15% 10%,#d8b67908,transparent 60%),var(--bg); color:var(--text); }
html[data-theme="dark"] body::before { border-color:var(--accent); }
html[data-theme="dark"] header,html[data-theme="dark"] footer { background:#1c1d19; border-color:var(--border); }
html[data-theme="dark"] :is(.brand,.welcome h1,.tabhead h2,.prayer-text .prayer-title,.explain-ref,.legal-page h1,.legal-modal h2) { color:var(--text); }
html[data-theme="dark"] :is(.brand .cross,.brand>span,.welcome h1 em,.eyebrow,.tabs button.active,.tabs button:hover,.tabs a:hover,.tabs a[aria-current="page"],.text-link,.calendar-step,.calendar-suggestion-help summary,.calendar-selection,.calendar-edition,.calendar-foodlists h4,.prayer-lang-note,.ornament-rule i,.legal-page h2) { color:var(--accent); }
html[data-theme="dark"] .legal-modal #legalTitle::before { color:var(--accent); }
html[data-theme="dark"] .tabs button::after,html[data-theme="dark"] .tabs a[aria-current="page"]::after { background:var(--accent); }
html[data-theme="dark"] :is(.ghost,header a.back,.forum-page header .ghost) { color:var(--muted); border-color:var(--border); }
html[data-theme="dark"] :is(.ghost:hover,header a.back:hover,.forum-page header .ghost:hover,.bible-verse .ghost:hover,.bible-verse .ghost:focus-visible) { color:var(--text); background:var(--panel-2); border-color:var(--gold); }
html[data-theme="dark"] :is(.chip,.composer,.passage,.prayer-text,.calendar-shell .calendar-card,.legal-modal,.explain-modal,.language-control select,.calendar-tradition-label select,.calendar-grid button,.findrow input) { background:var(--panel); border-color:var(--border); color:var(--text); }
html[data-theme="dark"] :is(.chip small,.illumination figcaption,.source-note,.explain-sources,.legal-sub,.legal-points,.legal-page p,.legal-page li) { color:var(--muted); }
html[data-theme="dark"] .chip:hover { background:var(--panel-2); color:var(--text); border-color:var(--gold); }
html[data-theme="dark"] :is(.chip,.composer,.passage,.prayer-text) { box-shadow:3px 3px 0 #0e0f0d; }
html[data-theme="dark"] .composer:focus-within { border-color:var(--gold); box-shadow:0 0 0 2px var(--gold); }
html[data-theme="dark"] :is(input,textarea)::placeholder { color:var(--muted); opacity:1; }
html[data-theme="dark"] :is(input,select,textarea) { accent-color:var(--gold); }
html[data-theme="dark"] .msg.user .bubble { background:var(--panel-2); color:var(--text); border-color:var(--border); }
html[data-theme="dark"] .msg.bot .bubble { background:var(--panel); color:var(--text); border-color:var(--border); border-left-color:var(--gold); }
html[data-theme="dark"] :is(.msg.bot .bubble.error,.explain-err) { color:var(--danger); }
html[data-theme="dark"] :is(.bubble blockquote,.explain-body.bubble blockquote,.bubble code,.bubble pre,.legal-page code,.legal-check,.legal-page .notice,.calendar-fast-summary) { background:var(--panel-2); color:var(--text); border-color:var(--border); }
html[data-theme="dark"] .explain-head { background:#22231ff2; }
html[data-theme="dark"] .explain-body.bubble { color:var(--text); }
html[data-theme="dark"] .explain-modal::before { opacity:.035; }
html[data-theme="dark"] :is(.legal-check a,.source-note span) { color:var(--gold-bright); }
html[data-theme="dark"] .chip::after { color:var(--gold-bright); }
html[data-theme="dark"] :is(.footer-glyph,.ornament-rule) { color:var(--gold); }
html[data-theme="dark"] :is(.crisis,.app-notice) { background:#39251f; color:#ffd6c8; border-color:var(--danger); }
html[data-theme="dark"] :is(.composer button,.findrow button,#legalAccept,.primary-link,.discord-link,.install-btn) { background:var(--action); color:var(--on-action); border-color:var(--accent); box-shadow:none; }
html[data-theme="dark"] :is(.composer button:hover,.findrow button:hover,#legalAccept:hover:not(:disabled),.primary-link:hover,.discord-link:hover,.install-btn:hover) { background:var(--action-hover); color:var(--on-action); }
html[data-theme="dark"] :is(.prayer-topic:hover,.prayer-topic.active,.prayer-item:hover,.prayer-item.active,.calendar-grid button:hover) { background:var(--panel-2); border-color:var(--gold); }
html[data-theme="dark"] .calendar-grid button[aria-pressed="true"] { background:var(--action); color:var(--on-action); border-color:var(--accent); outline-color:var(--accent); }
html[data-theme="dark"] .calendar-grid button[aria-pressed="true"][data-level] .calendar-badge { color:var(--on-action); }
html[data-theme="dark"] :is(.calendar-setup,#calendarDay,#calendarTraditionNote,.calendar-fast-summary) { border-color:var(--accent); }
html[data-theme="dark"] :is(.prayer-item-flag,.badge-knowledgeable,[data-badge="knowledgeable"]) { color:#d2b8ff!important; }
html[data-theme="dark"] :is(.badge-admin,[data-badge="admin"]) { color:#e1b6f5!important; }
html[data-theme="dark"] :is(.badge-owner,[data-badge="owner"]) { color:#f0d38e!important; }
html[data-theme="dark"] :is(.badge-moderator,[data-badge="moderator"]) { color:#a8dfce!important; }
html[data-theme="dark"] :is(.lp-support-conv-status.status-open,.lp-support-conv-status.status-resolved) { background:#365a40; color:#fff; }
html[data-theme="dark"] .lp-support-conv-status.status-resolved { background:#54544a; }
html[data-theme="dark"] .lp-support-conv-status.status-closed { background:var(--panel-2); color:var(--muted); }
html[data-theme="dark"] .lp-support-message-time { opacity:1; }
html[data-theme="dark"] :is(.lp-support-badge,.lp-admin-tab-badge) { background:#893b32; color:#fff; }
html[data-theme="dark"] .lp-support-close:hover,html[data-theme="dark"] .lp-support-close-conv:hover:not(:disabled) { background:#893b32; color:#fff; }
/* Standalone/overlay maintenance pages must not retain a forced light scheme. */
html[data-theme="dark"] .maintenance-overlay { color-scheme:dark; background:var(--bg); color:var(--text); }
html[data-theme="dark"] .maintenance-card { background:var(--panel); border-color:var(--border); box-shadow:8px 8px 0 #0e0f0d; }
html[data-theme="dark"] .maintenance-overlay::before,html[data-theme="dark"] .maintenance-return { border-color:var(--border); }
html[data-theme="dark"] :is(.maintenance-eyebrow,.maintenance-message,.maintenance-return span,.maintenance-foot) { color:var(--muted); }
html[data-theme="dark"] :is(.maintenance-overlay a,.maintenance-seal) { color:var(--gold-bright); }
html[data-theme="dark"] :focus-visible { outline-color:var(--gold); }
@media (min-width:1001px) and (max-width:1600px) { header:has(.theme-toggle) { gap:8px; } header:has(.theme-toggle) .tabs { gap:3px; } }
/* Colorways preserve reading surfaces, source images and all application state. */
html[data-palette] body { background:var(--bg); color:var(--text); }
html[data-palette] body::before { border-color:var(--accent); }
html[data-palette] :is(header,footer,.explain-head) { background:var(--panel); border-color:var(--border); }
html[data-palette] :is(.brand,.welcome h1,.tabhead h2,.prayer-text .prayer-title,.explain-ref,.legal-page h1,.legal-modal h2,.explain-body.bubble) { color:var(--text); }
html[data-palette] :is(.brand .cross,.brand>span,.welcome h1 em,.eyebrow,.tabs button.active,.tabs button:hover,.tabs a:hover,.tabs a[aria-current="page"],.text-link,.calendar-step,.calendar-suggestion-help summary,.calendar-selection,.calendar-edition,.calendar-foodlists h4,.prayer-lang-note,.ornament-rule i,.legal-page h2,.legal-check a,.source-note span,.footer-glyph,.ornament-rule) { color:var(--accent); }
html[data-palette] :is(.tabs button::after,.tabs a[aria-current="page"]::after) { background:var(--accent); }
html[data-palette] :is(.ghost,header a.back) { color:var(--muted); border-color:var(--border); }
html[data-palette] :is(.ghost:hover,header a.back:hover,.chip:hover,.prayer-topic:hover,.prayer-topic.active,.prayer-item:hover,.prayer-item.active) { color:var(--text); background:var(--panel-2); border-color:var(--accent); }
html[data-palette] :is(.chip,.composer,.passage,.prayer-text,.calendar-shell .calendar-card,.legal-modal,.explain-modal,.language-control select,.calendar-tradition-label select,.calendar-grid button,.findrow input,.msg.bot .bubble) { background:var(--panel); border-color:var(--border); color:var(--text); }
html[data-palette] :is(.chip small,.illumination figcaption,.source-note,.explain-sources,.legal-sub,.legal-points,.legal-page p,.legal-page li) { color:var(--muted); }
html[data-palette] :is(.msg.user .bubble,.bubble blockquote,.explain-body.bubble blockquote,.bubble code,.bubble pre,.legal-check,.legal-page .notice,.calendar-fast-summary) { background:var(--panel-2); color:var(--text); border-color:var(--border); }
html[data-palette] :is(.composer button,.findrow button,#legalAccept,.primary-link,.discord-link,.install-btn) { background:var(--action); color:var(--on-action); border-color:var(--accent); }
html[data-palette] :is(.composer button:hover,.findrow button:hover,#legalAccept:hover:not(:disabled),.primary-link:hover,.discord-link:hover,.install-btn:hover) { background:var(--action-hover); color:var(--on-action); }
html[data-palette] :is(input,textarea)::placeholder { color:var(--muted); opacity:1; }
html[data-palette] .calendar-grid button[aria-pressed="true"] { background:var(--action); color:var(--on-action); border-color:var(--accent); outline-color:var(--accent); }
html[data-palette] .calendar-grid button[aria-pressed="true"] .calendar-badge { color:var(--on-action); }
html[data-palette] :focus-visible { outline-color:var(--accent); }
/* Original, quiet architectural patterns. No photos or new network requests. */
html[data-texture="arches"] body { background-image:radial-gradient(ellipse at 50% 100%,transparent 65%,color-mix(in srgb,var(--accent) 7%,transparent) 66%,transparent 67%); background-size:160px 240px; }
html[data-texture="mosaic"] body { background-image:linear-gradient(45deg,color-mix(in srgb,var(--accent) 4%,transparent) 25%,transparent 25%,transparent 75%,color-mix(in srgb,var(--accent) 4%,transparent) 75%),linear-gradient(45deg,color-mix(in srgb,var(--accent) 4%,transparent) 25%,transparent 25%,transparent 75%,color-mix(in srgb,var(--accent) 4%,transparent) 75%); background-size:36px 36px; background-position:0 0,18px 18px; }
#siteAppearance { position:static; display:inline-flex; align-items:center; justify-content:center; flex:0 0 44px; width:44px; height:44px; min-height:44px; padding:10px; border:1px solid var(--border); border-radius:0; background:var(--panel); color:var(--gold-bright); cursor:pointer; touch-action:manipulation; }
#siteAppearance svg { width:22px; height:22px; }
#siteAppearance:hover { background:var(--panel-2); border-color:var(--gold); }
#siteAppearance:focus-visible { outline:2px solid var(--gold); outline-offset:3px; }
body > #siteAppearance { position:fixed; top:12px; right:70px; z-index:30; }
#themeGallery { box-sizing:border-box; width:min(700px,calc(100vw - 24px)); max-height:85svh; overflow:auto; padding:24px; background:var(--panel); color:var(--text); border:1px solid var(--border); border-top:4px solid var(--accent); border-radius:12px; box-shadow:0 24px 80px #0006; }
#themeGallery::backdrop { background:#0009; }
.theme-gallery-head { display:flex; justify-content:space-between; align-items:center; gap:16px; margin-bottom:20px; }
.theme-gallery-head h2 { margin:0; font:28px/1.2 Georgia,serif; }
#themeGallery fieldset { min-width:0; margin:0; padding:0; border:0; }
#themeGallery legend { margin-bottom:12px; color:var(--muted); }
#themeGallery p { font:13px/1.7 Arial,sans-serif; color:var(--muted); margin-bottom:0; }
.theme-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.theme-option { display:grid; grid-template-columns:20px minmax(0,1fr); align-items:center; gap:8px; padding:12px; border:1px solid var(--border); border-radius:6px; background:var(--panel); color:var(--text); cursor:pointer; font:13px/1.5 Arial,sans-serif; }
.theme-option:has(input:checked) { outline:2px solid var(--accent); outline-offset:1px; background:var(--panel-2); }
.theme-option input { width:16px; height:16px; margin:0; accent-color:var(--accent); }
.theme-swatch { grid-column:1/-1; grid-row:1; height:42px; border-radius:3px; border:1px solid var(--border); }
@media (max-width:500px) { #themeGallery { padding:18px; } .theme-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media print {
  html[data-theme] { color-scheme:light; --bg:white; --panel:white; --panel-2:#f3f3f3; --text:#111; --muted:#333; --gold:#61481c; --gold-bright:#61481c; --accent:#61481c; --danger:#78221c; --ok:#285334; --border:#777; }
  html[data-theme] body { background:white; color:#111; }
  html[data-theme] :is(.theme-toggle,.appearance-open,.language-control,#themeGallery) { display:none!important; }
  html[data-palette] { --bg:white!important; --panel:white!important; --panel-2:#f3f3f3!important; --text:#111!important; --muted:#333!important; --accent:#61481c!important; --gold:#61481c!important; --gold-bright:#61481c!important; --border:#777!important; }
  html[data-palette] body { background:white; }
  html[data-theme="dark"] :is(.crisis,.app-notice) { background:white; color:#111; }
}
