/* One palette contract for every route. Physical artwork colors stay unchanged. */
:root[data-theme]{
  --theme-bg:#fff;--theme-surface:#fff;--theme-raised:#fff;
  --theme-fg:#11130f;--theme-heading:#11130f;--theme-muted:#585b50;
  --theme-line:#d5d6cb;--theme-input-line:#848879;--theme-strong:#11130f;
  --theme-soft:#fff5c8;--theme-action:#11130f;--theme-action-fg:#fff;
  --theme-error:#962b1e;--theme-success:#2c6528;--theme-success-bg:#e1efdc;
  color-scheme:light;background:var(--theme-bg);color:var(--theme-fg);scrollbar-color:var(--theme-input-line) var(--theme-bg);
}
:root[data-theme=dark]{
  --theme-bg:#11130f;--theme-surface:#11130f;--theme-raised:#1b1e17;
  --theme-fg:#eef0e8;--theme-heading:#f7c600;--theme-muted:#bdc2b2;
  --theme-line:#454b3c;--theme-input-line:#7f8972;--theme-strong:#d8bd54;
  --theme-soft:#2d2b18;--theme-action:#f7c600;--theme-action-fg:#11130f;
  --theme-error:#ffb5a7;--theme-success:#b5dca5;--theme-success-bg:#263920;
  color-scheme:dark;
}
:root[data-theme] body{background:var(--theme-bg);color:var(--theme-fg);color-scheme:inherit}
:root[data-theme] ::selection{background:var(--yellow);color:var(--ink)}
:root[data-theme] body{scrollbar-color:var(--theme-input-line) var(--theme-bg)}
:root[data-theme] :is(button,input,textarea,select){caret-color:var(--theme-fg)}
:root[data-theme] :is(a,button,input,textarea,select,summary,[tabindex]):focus-visible{
  outline:3px solid var(--theme-action);outline-offset:4px;box-shadow:0 0 0 7px var(--theme-bg);
}
:root[data-theme] :is(input[type=radio],input[type=checkbox],input[type=range]){accent-color:var(--theme-action)}
:root[data-theme] :is(input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea,select){
  background:var(--theme-raised);color:var(--theme-fg);border-color:var(--theme-input-line);
}
:root[data-theme] :is(input,textarea)::placeholder{color:var(--theme-muted);opacity:1}
:root[data-theme] :is(h1,h2,h3,.poster-logo,.series-values dd){color:var(--theme-heading)}

/* Shared, keyboard-operable action bar; the icon shows the destination mode. */
:root[data-theme] .site-header{background:var(--theme-bg);color:var(--theme-heading);border-bottom:1px solid var(--theme-line);grid-template-columns:150px minmax(0,1fr) auto}
:root[data-theme] :is(.wordmark,.nav-links a,.brand,.back-link){color:var(--theme-heading)}
:root[data-theme] .brand span{color:var(--theme-heading)}
:root[data-theme] .header-actions{display:flex;align-items:center;gap:8px;justify-content:flex-end}
:root[data-theme] :is(.account-link,.lang-button,.theme-toggle){height:44px;border:1px solid var(--theme-heading);border-radius:0}
:root[data-theme] .account-link{min-width:142px;padding:0 12px;color:var(--theme-heading);background:transparent}
:root[data-theme] .lang-button{width:48px;flex:0 0 48px;background:var(--theme-action);color:var(--theme-action-fg)}
:root[data-theme] .account-link:hover{background:var(--theme-action);color:var(--theme-action-fg)}
.account-short{display:none}
.theme-toggle{display:inline-grid;place-items:center;width:44px;flex:0 0 44px;padding:0;cursor:pointer;background:transparent;color:inherit}
.theme-icon{display:block;width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.theme-icon-sun{display:none}
:root[data-theme=dark] .theme-icon-moon{display:none}
:root[data-theme=dark] .theme-icon-sun{display:block}
:root[data-theme] .theme-toggle:hover{background:var(--theme-soft)}
:root[data-theme] .theme-toggle{color:var(--theme-heading)}
:root[data-theme] .site-header .nav-links{border-color:var(--theme-line);scrollbar-color:var(--theme-input-line) var(--theme-bg)}
:root[data-theme] .nav-links a:is(:hover,[aria-current=page]){border-bottom-color:var(--theme-action)}
:root[data-theme] .site-footer{background:var(--theme-bg);color:var(--theme-heading);border-top:1px solid var(--theme-line)}
:root[data-theme] .site-footer a{color:inherit}
:root[data-theme] .skip-link{background:var(--theme-action);color:var(--theme-action-fg)}

/* Canvas, supporting chapters and operational surfaces. */
:root[data-theme] :is(.poster-hero,.project-main,.project-intro,.showcase-section,.experience-main,.inner-main){background:var(--theme-bg);color:var(--theme-fg)}
:root[data-theme] :is(.master-preview,.collection-invite,.roadmap,.experience-next){background:var(--theme-soft);color:var(--theme-fg)}
:root[data-theme] .rewards-section{background:var(--theme-bg)}
:root[data-theme] .series-section{background:var(--theme-surface);color:var(--theme-fg)}
:root[data-theme] :is(.series-note,.fine-print,.field-note,.muted,.stat-grid span,.atlas-sample-note){color:var(--theme-muted)}
:root[data-theme] :is(.panel,.owned-card,.gallery-card,.stat-grid article,.about-columns section,.market-card){background:var(--theme-surface);color:var(--theme-fg);border-color:var(--theme-line)}
:root[data-theme] :is(.panel,.owned-card,.gallery-card,.stat-grid article,.about-columns section,.market-card){border-radius:var(--radius-md,14px)}
:root[data-theme] :is(.panel.create-form-panel,.panel.generated-panel,.mint-panel){background:transparent}
:root[data-theme] :is(.notice-card,.market-note,.generation-cost,.inline-status,.agent-guide,.bstar-link-note){background:var(--theme-soft);color:var(--theme-fg);border-color:var(--yellow)}
:root[data-theme] :is(.agent-confirm,.bstar-link-code,.batch-item,.batch-verify-item,.creation-list li,.generated-thumb,.page-motion){background:var(--theme-surface);color:var(--theme-fg);border-color:var(--theme-line)}
:root[data-theme] :is(.batch-panel,.mint-panel,.section-head,.roadmap-list li,.project-help details,.agent-connect-step,.agent-manual){border-color:var(--theme-line)}
:root[data-theme] .generation-mode label{background:var(--theme-raised);color:var(--theme-fg);border-color:var(--theme-input-line)}
:root[data-theme] .generation-mode label:has(input:checked){background:var(--theme-soft);border-color:var(--theme-action)}
:root[data-theme] :is(.button-dark,.plan-tag){background:var(--theme-action);color:var(--theme-action-fg);border-color:var(--theme-action)}
:root[data-theme] :is(.button-yellow,.primary){background:var(--yellow);color:var(--ink);border-color:var(--ink)}
:root[data-theme] :is(.button-outline,.text-button,.secondary,.ghost,.market-card-info button){color:var(--theme-fg);background:transparent;border-color:var(--theme-input-line)}
:root[data-theme] :is(.button-outline,.secondary,.ghost,.market-card-info button):hover{background:var(--theme-soft)}
:root[data-theme] :is(.generated-thumb.is-active,.owned-card,.gallery-card){border-color:var(--theme-strong)}
:root[data-theme] .generated-thumb.empty-slot{color:var(--theme-muted)}

/* Yellow artwork stages and emphasis regions always use real ink. */
:root[data-theme] :is(.agent-intro,.bstar-link-check,.bstar-link-review,.generated-preview-frame,.generated-empty){background:var(--yellow);color:var(--ink);border-color:var(--ink)}
:root[data-theme] :is(.agent-intro,.generated-empty) :is(h1,h2,h3,dt){color:var(--ink)}
:root[data-theme] .agent-intro .button-dark{background:var(--ink);color:var(--white);border-color:var(--ink)}
:root[data-theme] .atlas-bubble-card{background:#fff;color:var(--ink);border-color:#d7c679}
:root[data-theme=dark] .atlas-bubble-card{background:var(--ink);color:var(--yellow);border-color:#4b431d;box-shadow:0 6px 16px #30250035}
:root[data-theme] .atlas-stage{background:var(--yellow)}
:root[data-theme] :is(.experience-heading h1,.experience-heading>p,.atlas-control-line p){color:var(--theme-heading)}
:root[data-theme] .atlas-arrows button{border-color:var(--theme-heading);color:var(--theme-heading);background:transparent}
:root[data-theme] .atlas-arrows button:hover:enabled{background:var(--theme-action);color:var(--theme-action-fg)}
:root[data-theme] .atlas-scrubber input[type=range]::-webkit-slider-runnable-track{background:var(--theme-input-line)}
:root[data-theme] .atlas-scrubber input[type=range]::-moz-range-track{background:var(--theme-input-line)}
:root[data-theme] .atlas-scrubber input[type=range]::-webkit-slider-thumb{background:var(--yellow);border:2px solid var(--ink)}
:root[data-theme] .atlas-scrubber input[type=range]::-moz-range-thumb{background:var(--yellow);border:2px solid var(--ink)}

/* Dialogs and genuine loading/error feedback. */
:root[data-theme] :is(.art-detail,.agent-connect-dialog){background:var(--theme-bg);color:var(--theme-fg);border-color:var(--theme-input-line)}
:root[data-theme] .dialog-close{background:var(--theme-surface);color:var(--theme-fg);border-color:var(--theme-input-line)}
:root[data-theme] dialog::backdrop{background:rgb(0 0 0 / 70%)}
:root[data-theme] :is(.motion-status[data-phase=error],[data-error=true],.status){color:var(--theme-error)}
:root[data-theme] .status[data-error=false]{color:var(--theme-success)}
:root[data-theme=dark] .motion-status:not([data-phase=complete]) :is(.motion-symbol,.motion-star){filter:invert(1)}
:root[data-theme=dark] .generated-empty .motion-status :is(.motion-symbol,.motion-star){filter:none}

/* Protected admin inherits the same choice; data and auth remain untouched. */
:root[data-theme] :is(.topbar,.admin-nav,th,td){border-color:var(--theme-line)}
:root[data-theme] :is(.login-card,.card,.stat-card){background:var(--theme-surface);color:var(--theme-fg)}
:root[data-theme] :is(.stat-card>span,.stat-card small,.detail-label,.chain-grid small,.field-hint,.field-state,.enable-box small,th,.empty){color:var(--theme-muted)}
:root[data-theme] :is(.enable-box,.chain-grid>div,.state-pill,.record-status,.notice){background:var(--theme-soft);color:var(--theme-fg);border-color:var(--theme-line)}
:root[data-theme] :is(.record-status[data-status=minted],[data-enabled=true]){background:var(--theme-success-bg);color:var(--theme-success)}
:root[data-theme] .record-status[data-status=failed]{background:var(--theme-soft);color:var(--theme-error)}
:root[data-theme] .record-link{color:var(--theme-heading)}
:root[data-theme] .topbar .theme-toggle{margin-left:0}

@media(max-width:1100px){:root[data-theme] .site-header{grid-template-columns:100px minmax(0,1fr) auto;gap:12px}}
@media(max-width:1000px){
  :root[data-theme] .site-header{height:112px;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:60px 50px;padding:0 18px;gap:0 12px}
  :root[data-theme] .wordmark{grid-column:1;grid-row:1}
  :root[data-theme] .header-actions{grid-column:2;grid-row:1}
  :root[data-theme] .site-header .nav-links{grid-column:1/-1;grid-row:2;min-width:0;max-width:100%;overflow-x:auto;justify-content:center;gap:24px;scrollbar-width:thin;overscroll-behavior-inline:contain;border-top:1px solid var(--theme-line)}
  :root[data-theme] .site-header .nav-links a{flex:0 0 auto}
}
@media(max-width:600px){
  :root[data-theme] .site-header{padding:0 14px;gap:0 8px}
  :root[data-theme] .header-actions{gap:6px}
  :root[data-theme] .account-link{min-width:62px;padding:0 8px}
  :root[data-theme] [data-my-link]{min-width:44px}
  :root[data-theme] .lang-button{width:44px;flex-basis:44px}
  .account-short{display:inline}
  .account-label{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
  :root[data-theme] .site-header .nav-links{justify-content:flex-start;gap:18px}
  :root[data-theme] .wordmark{font-size:32px}
  :root[data-theme] .topbar{flex-wrap:wrap;height:auto;min-height:76px;padding:12px 0;gap:10px}
  :root[data-theme] .topbar .brand{font-size:32px}
  :root[data-theme] .topbar .admin-tag{display:none}
}
