/* Shared palette for application chrome. Artwork and editable paper keep their own colors. */
html[data-wv-theme="daylight"] {
  color-scheme: light;
  --theme-bg:#f4f2ee; --theme-panel:#fffdf9; --theme-field:#eeebe7;
  --theme-ink:#292630; --theme-muted:#5e5668; --theme-line:#cfc8d1;
  --theme-accent:#635288; --theme-on-accent:#fff; --theme-selected:#e9e1f1;
  --theme-danger:#a53249; --theme-success:#306b4a;
}
html[data-wv-theme="amber-paper"] {
  color-scheme: light;
  --theme-bg:#f8efdc; --theme-panel:#fffaed; --theme-field:#f3e8d1;
  --theme-ink:#392c1a; --theme-muted:#68563b; --theme-line:#d4c29e;
  --theme-accent:#80541e; --theme-on-accent:#fff; --theme-selected:#eeddb7;
  --theme-danger:#a13b37; --theme-success:#45642e;
}
html[data-wv-theme="sea-glass"] {
  color-scheme: light;
  --theme-bg:#eaf3ed; --theme-panel:#f7fcf8; --theme-field:#e7f0e9;
  --theme-ink:#23382e; --theme-muted:#4e6659; --theme-line:#b9cfc0;
  --theme-accent:#306b53; --theme-on-accent:#fff; --theme-selected:#d9ebe0;
  --theme-danger:#9e354a; --theme-success:#306b53;
}
html[data-wv-theme="noir"] {
  color-scheme: dark;
  --theme-bg:#121019; --theme-panel:#201c2b; --theme-field:#2a2438;
  --theme-ink:#f4eff9; --theme-muted:#c3b8d0; --theme-line:#514461;
  --theme-accent:#c7b9ff; --theme-on-accent:#23183b; --theme-selected:#3c3055;
  --theme-danger:#ffa2aa; --theme-success:#a8e3bf;
}
html[data-wv-theme="abyss"] {
  color-scheme: dark;
  --theme-bg:#0c1826; --theme-panel:#15283b; --theme-field:#1b344a;
  --theme-ink:#edf7ff; --theme-muted:#adc6dc; --theme-line:#365874;
  --theme-accent:#83cfff; --theme-on-accent:#0c273b; --theme-selected:#214561;
  --theme-danger:#ffabb3; --theme-success:#9ce2ce;
}
html[data-wv-theme] {
  --theme-hover:color-mix(in srgb,var(--theme-panel),var(--theme-selected) 68%);
  --theme-edge:color-mix(in srgb,var(--theme-line) 76%,transparent);
}

/* World navigation, editing cards, dialogs and wiki. */
html[data-theme-page="world"][data-wv-theme] :is(.wv-root,.wv-d-worlds,.vvd-mask,.wv-menu-pop) {
  --fg:var(--theme-ink); --muted:var(--theme-muted); --accent:var(--theme-accent);
  --surface:var(--theme-bg); --surface-raised:var(--theme-panel);
  --glass:color-mix(in srgb,var(--theme-panel) 91%,transparent);
  --glass-raised:var(--theme-panel); --edge:var(--theme-edge);
  --edge2:var(--theme-edge); --divider:var(--theme-edge); --field:var(--theme-field);
  --hover:var(--theme-hover); --selected:var(--theme-selected); --accent-soft:var(--theme-selected);
  --danger:var(--theme-danger);
}
html[data-wv-theme="abyss"][data-theme-page="world"] .wv-root {
  --glass:color-mix(in srgb,var(--theme-panel) 88%,transparent);
}
html[data-wv-theme] .wv-d-window { background:var(--glass); }
html[data-wv-theme] :is(.wv-d-worlds,.wv-showcase-page) { background-color:var(--theme-bg); }
html[data-wv-theme] :is(.wv-d-brand small,.wv-build-badge,.wv-d-sub,.wv-wiki-meta span,.wv-wiki-book .bk-t small) { color:var(--theme-muted) !important; }
html[data-wv-theme] .wv-d-worldstats .likes b { color:var(--theme-danger); }
html[data-wv-theme] :is(.wv-menu-pop,.vvd-mask .vvd-dlg,.wv-cs-menu) {
  background:var(--theme-panel) !important;
  color:var(--theme-ink) !important;
  border-color:var(--theme-line) !important;
}
html[data-wv-theme] :is(.vvd-dlg label,.wv-cs-opt small,.wv-theme-card small) { color:var(--theme-muted) !important; }
html[data-wv-theme] :is(.vvd-dlg :is(input,select,textarea),.wv-cs-btn) {
  background:var(--theme-field) !important;
  color:var(--theme-ink) !important;
  border-color:var(--theme-line) !important;
}
html[data-wv-theme] :is(.wv-theme-card,.wv-wiki-book) {
  color:var(--theme-ink) !important;
  background:var(--theme-panel) !important;
  border-color:var(--theme-line) !important;
}
html[data-wv-theme] .wv-theme-card b { color:var(--theme-ink) !important; }
html[data-wv-theme] .wv-theme-card.on::after { color:var(--theme-on-accent) !important; }
html[data-wv-theme] .wv-root .wv-wiki-book :is(.bk-go,.bk-ico) {
  color:var(--theme-accent) !important;
}
html[data-wv-theme] .wv-root .wv-wiki-book .bk-ico { background:var(--theme-selected); }

html[data-wv-theme] :is(.wv-root,.wv-d-worlds,.vvd-dlg) :is(
  .wv-viewtab.on, .wv-doc.on, .wv-tabmain.on, .wv-d-railbtn.on, .wv-d-seg button.on,
  .wv-cs-opt.on, .wv-gv-tabs button.on, .wv-wiki-rail button[aria-pressed="true"],
  .wv-vvd-devices button[aria-pressed="true"],
  .wvc-bookitem.on, .wvc-bookshow.on, .wvc-ch.on, .wv-wiki-book:active, .wv-wiki-book:focus-visible
) {
  color:var(--theme-accent) !important;
  background:var(--theme-selected) !important;
  border-color:var(--theme-accent) !important;
  box-shadow:inset 0 0 0 1px var(--theme-accent) !important;
}
html[data-wv-theme] :is(.wv-root,.vvd-dlg) :is(.wv-viewtab.on,.wv-doc.on,.wv-tabmain.on,.wv-cs-opt.on) :is(b,span,.nm,.wvi) {
  color:inherit !important;
}
html[data-wv-theme] .vvd-mask .vvd-dlg .wv-theme-card.on {
  background:var(--theme-selected) !important;
  border-color:var(--theme-accent) !important;
  box-shadow:inset 0 0 0 1px var(--theme-accent) !important;
}
html[data-wv-theme] .wv-preview-devices button[aria-pressed="true"] {
  background:var(--theme-selected);
  color:var(--theme-accent);
  border-color:var(--theme-accent);
  box-shadow:inset 0 0 0 1px var(--theme-accent);
}
/* Photo controls need contrast independent of the cover art. */
html[data-wv-theme] .wv-root .wv-vvd-page .wv-vvd-heroinfo {
  width:fit-content;
  max-width:calc(100% - 44px);
  padding:8px 11px;
  border-radius:9px;
  background:#17141eeb;
}
html[data-wv-theme] .wv-root .wv-vvd-page :is(.wv-vvd-heroinfo b,.wv-vvd-arrow,.wv-hero-replace) { color:#fff !important; }
html[data-wv-theme] .wv-root .wv-vvd-page .wv-vvd-heroinfo span { color:#f3ebf7 !important; }
html[data-wv-theme] .wv-root .wv-vvd-page .wv-hero-replace {
  background:#252031;
  border-color:#a99ab9;
}
html[data-wv-theme] .wv-root .wv-vvd-page .wv-hero-replace:hover { background:#423653; }
html[data-wv-theme] .wv-root .wv-vvd-page :is(.wv-wiki-done,.wv-vvd-bottom button.pub) {
  color:var(--theme-on-accent) !important;
  background:var(--theme-accent) !important;
}
html[data-wv-theme] .wv-root .wv-vvd-page .wv-layout-controls :is(select,button) {
  background:var(--theme-panel); color:var(--theme-ink); border-color:var(--theme-line);
}
html[data-wv-theme] .wv-vvd-page .wv-layout-switch[aria-checked="true"] {
  background:var(--theme-selected);
  color:var(--theme-accent);
  border-color:var(--theme-accent);
}
html[data-wv-theme] .wv-vvd-page .wv-layout-switch[aria-checked="true"] .wv-switch-track::after { background:var(--theme-on-accent); }
html[data-wv-theme] .wv-root :is(.wv-wiki-book,.wv-layout-card) :is(strong,.bk-t b) { color:var(--theme-ink) !important; }
html[data-wv-theme] :is(.wv-root,.vvd-dlg) :is(.wvc-btn.primary,.wv-share-actions .create,.vvd-dlg-ft .primary) {
  background:var(--theme-accent) !important;
  color:var(--theme-on-accent) !important;
  border-color:var(--theme-accent) !important;
}
html[data-wv-theme] .wv-root :is(.wv-search,.wv-wiki-search,.wvc-search,.wvc-title)::placeholder {
  color:var(--theme-muted) !important; opacity:1;
}
html[data-wv-theme] .wv-root :is(.wvc-bookitem small,.wvc-ch .ee,.wvc-meta,.wvc-count) { color:var(--theme-muted); }

/* Chat and its floating window use the same palette as the world workspace. */
html[data-wv-theme][data-theme-page] {
  --zc-bg:var(--theme-bg); --zc-panel:var(--theme-panel); --zc-line:var(--theme-line);
  --zc-ink:var(--theme-ink); --zc-mut:var(--theme-muted);
  --zc-brand:var(--theme-accent); --zc-brand2:var(--theme-accent);
  --zc-side:var(--theme-panel); --zc-side2:var(--theme-field);
  --zc-msg1:var(--theme-bg); --zc-msg2:var(--theme-field); --zc-field:var(--theme-field);
  --zc-hover:var(--theme-hover); --zc-hover2:var(--theme-hover); --zc-hover3:var(--theme-hover);
  --zc-selected:var(--theme-selected); --zc-bubble:var(--theme-panel); --zc-bubbleink:var(--theme-ink);
  --zc-input:var(--theme-field); --zc-btn:var(--theme-field); --zc-chip:var(--theme-selected);
  --zc-av:var(--theme-selected); --zc-avink:var(--theme-accent); --zc-online:var(--theme-success);
  --zc-accentink:var(--theme-accent); --zc-profileink:var(--theme-ink); --zc-bio:var(--theme-muted);
  --zc-time:var(--theme-muted);
}
html[data-wv-theme] :is(.zc-panel,.zc-theme-modal,.zc-shell) :is(.zc-conv.on,.zc-theme-card.on,button[data-filter][aria-pressed="true"]) {
  background:var(--theme-selected);
  box-shadow:inset 0 0 0 1px var(--theme-accent);
}
html[data-wv-theme][data-theme-page] :is(.zc-msg.mine .zc-bubble,.zc-conv em,.zc-compose button,.zc-exit-main,.zc-topexit),
html[data-wv-theme] .zc-theme-card.on::after {
  background:var(--theme-accent);
  color:var(--theme-on-accent);
}
html[data-wv-theme] .zc-topfeedback {
  color:var(--theme-accent) !important;
  border-color:var(--theme-line) !important;
  background:var(--theme-panel) !important;
}
html[data-wv-theme] .zc-topfeedback:hover { background:var(--theme-hover) !important; }

/* Independent editors and dialogs. */
html[data-theme-page="write"][data-wv-theme] {
  --w-bg:var(--theme-bg); --w-panel:var(--theme-panel); --w-panel2:var(--theme-field);
  --w-fg:var(--theme-ink); --w-dim:var(--theme-muted); --w-dim2:var(--theme-muted);
  --w-acc:var(--theme-accent); --w-acc-soft:var(--theme-selected);
  --w-input:var(--theme-field); --w-line:var(--theme-line); --w-bad:var(--theme-danger);
}
html[data-theme-page="write"] :is(.bookpop button[aria-current="true"],.item.on) {
  background:var(--theme-selected);
  color:var(--theme-accent);
  box-shadow:inset 2px 0 var(--theme-accent);
}
html[data-theme-page="write"] .bookpop button small { color:var(--theme-muted); }
html[data-theme-page="write"] .cover .hint { background:#211a29; }
html[data-theme-page="journal"][data-wv-theme] {
  --ink:var(--theme-ink); --quiet:var(--theme-muted); --line:var(--theme-line);
  --chrome:var(--theme-panel); --workbench:var(--theme-bg);
  --plum:var(--theme-accent); --selected:var(--theme-selected);
}
html[data-theme-page="journal"] .workbench {
  background:radial-gradient(ellipse at 46% 43%,var(--theme-field),var(--theme-bg) 78%);
}
html[data-theme-page="journal"] :is(.editor select,.inspector input:not([type="range"]),.pager button) {
  background:var(--theme-field); color:var(--theme-ink); border-color:var(--theme-line);
}
html[data-theme-page="journal"] .pager output { color:var(--theme-muted); }
html[data-theme-page="journal"] .editor button:hover:not(:disabled) {
  background:var(--theme-hover); border-color:var(--theme-accent);
}
html[data-theme-page="journal"] .editor .ink-colors button:hover:not(:disabled) { background:var(--swatch); }
html[data-theme-page="journal"] .editor button.primary,
html[data-theme-page="journal"] .editor button.primary:hover:not(:disabled) {
  background:var(--theme-accent); color:var(--theme-on-accent); border-color:var(--theme-accent);
}
html[data-theme-page="journal"] :is(.toolbar button[aria-pressed="true"],.toolbar button[aria-expanded="true"],#page-list button[aria-current="page"]) {
  color:var(--theme-accent); background:var(--theme-selected); border-color:var(--theme-accent);
}
html[data-wv-theme] .zeaa-dialog {
  --asset-surface:var(--theme-panel); --asset-ink:var(--theme-ink); --asset-muted:var(--theme-muted);
  --asset-line:var(--theme-line); --asset-field:var(--theme-field); --asset-accent:var(--theme-accent);
}
html[data-wv-theme] .zeaa-dialog button[aria-pressed="true"] {
  background:var(--theme-selected);
  color:var(--theme-accent);
}
html[data-wv-theme] .zea-release-notice {
  background:var(--theme-panel); color:var(--theme-ink); border-color:var(--theme-line);
}
html[data-wv-theme] .zea-release-copy p { color:var(--theme-muted); }
html[data-wv-theme] .zea-release-actions button[data-reload] {
  background:var(--theme-accent); color:var(--theme-on-accent); border-color:var(--theme-accent);
}

html[data-theme-page="share"][data-wv-theme] {
  --paper:var(--theme-bg); --surface:var(--theme-panel); --ink:var(--theme-ink);
  --muted:var(--theme-muted); --line:var(--theme-line);
  --accent:var(--theme-accent); --accent-soft:var(--theme-selected);
}
html[data-theme-page="share"],
html[data-theme-page="share"] body { height:auto; min-height:100%; overflow:visible; background:var(--theme-bg); }
html[data-theme-page="share"] :is(.share-brand a span,.share-entry-body blockquote,.share-chapter-body blockquote) { color:var(--theme-muted); }
html[data-theme-page="share"] :is(.share-entry-body pre,.share-chapter-body pre) { background:var(--theme-field); }
html[data-theme-page="share"] :is(.share-action,.share-chapter-nav button[aria-current="true"]) {
  background:var(--theme-selected); color:var(--theme-accent); border-color:var(--theme-accent);
}
html[data-theme-page="share"] .share-reader { background:var(--theme-bg); color:var(--theme-ink); }
html[data-theme-page="share"] .share-reader :is(.reader-head button,.reader-footer button,.turn) {
  background:var(--theme-panel); color:var(--theme-ink); border-color:var(--theme-line);
}
html[data-theme-page="share"] .share-reader :is(.book-status,.reading-count) { color:var(--theme-muted); }
html[data-theme-page="index"][data-wv-theme] .card {
  --fg:var(--theme-ink); --muted:var(--theme-muted); --dim:var(--theme-muted);
  --edge:var(--theme-line); --glass:var(--theme-panel);
}
html[data-theme-page="index"] .card :is(.brand,.sub,.sub b,.captcha .q) { color:var(--theme-ink); }
html[data-theme-page="index"] .card :is(.tagline,.foot,.foot span) { color:var(--theme-muted); }
html[data-theme-page="index"] .card :is(.tabs,input,.captcha .q,.captcha button) {
  border-color:var(--theme-line); background:var(--theme-field);
}
html[data-theme-page="index"] .card input::placeholder { color:var(--theme-muted); opacity:1; }
html[data-theme-page="index"] .card :is(input:focus,.captcha button:hover) { border-color:var(--theme-accent); }
html[data-theme-page="index"] .card .tab-ind { background:var(--theme-selected); box-shadow:none; }
html[data-theme-page="index"] .card .tabs button[aria-selected="true"] { color:var(--theme-accent); }
html[data-theme-page="index"] .card .submit { background:var(--theme-accent); color:var(--theme-on-accent); }
html[data-theme-page="index"] .card .submit .spin { border-color:currentColor transparent currentColor currentColor; }
html[data-theme-page="index"] .card .msg.bad { color:var(--theme-danger); }
html[data-theme-page="index"] .card .msg.good { color:var(--theme-success); }
html[data-theme-page="admin"][data-wv-theme] {
  --paper:var(--theme-bg); --ink:var(--theme-ink); --card:var(--theme-panel);
  --line:var(--theme-line); --muted:var(--theme-muted); --accent:var(--theme-accent);
  --danger:var(--theme-danger); --ok:var(--theme-success);
}
html[data-theme-page="admin"] :is(.login-box,.side,.modal-card,.pv-head,.pv-read) {
  background:var(--theme-panel); color:var(--theme-ink); border-color:var(--theme-line);
}
html[data-theme-page="admin"] .login-art {
  background:radial-gradient(ellipse at 30% 32%,var(--theme-selected),var(--theme-bg) 72%);
  color:var(--theme-ink);
}
html[data-theme-page="admin"] :is(.login-art p,.login-panel .hint,.login-panel .eyebrow,.field label,.top .sub,.top .who,.kpi span,.kpi small,.section-head p,.meta,.empty,.modal-card p,.pv-title .eyebrow,.pv-meta,.pv-list .pv-entry span,.pv-entry-hd span,.side-foot,.brand small) {
  color:var(--theme-muted);
}
html[data-theme-page="admin"] :is(.login-art .mark,.brand .dot) { color:var(--theme-accent); }
html[data-theme-page="admin"] :is(.field :is(input,select,textarea),.tools input,th,.pv-list,.pv-books,.pv-cover) {
  background:var(--theme-field); color:var(--theme-ink); border-color:var(--theme-line);
}
html[data-theme-page="admin"] :is(td,.name,.kpi b,.pv-title h3,.pv-entry-hd h4,.pv-entry,.pv-text,.pv-books b,.top .logout,.side-foot b) {
  color:var(--theme-ink); border-color:var(--theme-line);
}
html[data-theme-page="admin"] :is(.btn:not(.danger,.primary),.pv-close) {
  background:var(--theme-panel); color:var(--theme-ink); border-color:var(--theme-line);
}
html[data-theme-page="admin"] :is(.btn.primary,.navbadge) {
  background:var(--theme-accent); color:var(--theme-on-accent); border-color:var(--theme-accent);
}
html[data-theme-page="admin"] .login-err { color:var(--theme-danger); }
html[data-theme-page="admin"] .nav button { color:var(--theme-muted); }
html[data-theme-page="admin"] .nav button i:not(.navbadge) { color:inherit; }
html[data-theme-page="admin"] :is(.nav button:hover,.pv-entry:hover,tbody tr:hover,.btn:not(.danger,.primary):hover) {
  background:var(--theme-hover); color:var(--theme-ink);
}
html[data-theme-page="admin"] :is(.nav button.on,.pv-entry.on) {
  background:var(--theme-selected); color:var(--theme-accent);
  box-shadow:inset 0 0 0 1px var(--theme-accent);
}

html[data-wv-theme] :is(button,a,input,select,textarea,[tabindex]):focus-visible {
  outline:2px solid var(--theme-accent);
  outline-offset:2px;
}
