/* Loaded after each layout. Light mode retains the existing palette. */
:root { color-scheme: light; }
.theme-toggle { display: inline-grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--green); cursor: pointer; }
.theme-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle:hover { background: var(--mint,var(--green-soft)); }
.theme-toggle:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.desktop-view .header > .theme-toggle { margin-left: auto; }
.desktop-view .header > .avatar { margin-left: 10px; }
.search-row:has(.theme-toggle) { grid-template-columns: minmax(0,1fr) 44px 44px; gap: 5px; }
.search-row > #next-summary-open { padding: 0 5px; white-space: nowrap; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111a17; --surface: #19251f; --surface-soft: #202e27;
  --ink: #e0ece5; --text: #e0ece5; --muted: #a2b5aa;
  --line: #34473c; --line-strong: #4b6254;
  --green: #81d7ae; --green-dark: #9de5be; --green-soft: #243f32;
  --mint: #243f32; --orange: #efb07c; --amber: #edc17b; --danger: #ffaca0;
  --white: #19251f; --shadow: 0 12px 40px #0005;
  background: var(--bg);
}
:root[data-theme="dark"] body, :root[data-theme="dark"] dialog { color: var(--text); }
:root[data-theme="dark"] input::placeholder, :root[data-theme="dark"] textarea::placeholder { color: var(--muted); opacity: 1; }
:root[data-theme="dark"] :is(input,select,textarea,.login-card,.secondary,.searchbar,.searchbar button,.product-card,.listing,.pager button,.attr-table>div,.detail-tools,.item-sources,.equipment-meta span,.admin-card,.filter-record,.pc-view-switch,.pc-product) { background: var(--surface); color: var(--text); }
:root[data-theme="dark"] .desktop-view #product-grid { background: var(--surface); }
:root[data-theme="dark"] .desktop-view[data-product-view="card"] #product-grid { background: transparent; }
:root[data-theme="dark"] :is(.avatar,.profile-note,.condition button,.saved-row button,.large-avatar,.detail-condition button,.detail-heading .item-icon,.filter-rename,.chips button,.source-group li,.seller strong,.attributes span) { background: var(--surface-soft); color: var(--text); }
:root[data-theme="dark"] .pc-product-open:hover { background: var(--surface-soft); }
:root[data-theme="dark"] :is(.welcome,.product-visual) { background: linear-gradient(120deg,var(--surface-soft),var(--green-soft)); }
:root[data-theme="dark"] :is(.welcome p,label,.feature-strip,.stats span,.market-summary>p,.tabs button,.product-info .meta,.price small,.market-footnote,.listing-date,.description,.equipment-note) { color: var(--muted); }
:root[data-theme="dark"] :is(.tabs button.active,.bottom-nav button.active,.chips button.active) { color: var(--green); }
:root[data-theme="dark"] .chips button.active { background: var(--green-soft); }
:root[data-theme="dark"] :is(.bottom-nav,.market-sticky,.sticky-actions) { background: #19251ff7; }
:root[data-theme="dark"] :is(.scope-toolbar,#history-detail-scope) { background: #202e27f7; }
:root[data-theme="dark"] :is(.equipment-summary,.stats>div,.view-label) { border-color: var(--line); }
:root[data-theme="dark"] .equipment-summary .attr-table>button { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
:root[data-theme="dark"] .equipment-summary .attr-table>button:hover { background: var(--surface-soft); }
:root[data-theme="dark"] :is(.equipment-summary .attr-table>button[aria-pressed="true"],.listing .attributes .attribute-highlight) { background: #4a3c1d; color: #ffe0a0; border-color: #bc9645; box-shadow: inset 0 0 0 1px #bc9645; }
:root[data-theme="dark"] .listing .attribute-highlight b { color: #ffe0a0; }
:root[data-theme="dark"] :is(.primary,.scope-expand[aria-pressed="true"],.session-mark,.brand-icon) { background: #246b52; color: #fff; }
:root[data-theme="dark"] .primary:active { background: #2c7b60; }
:root[data-theme="dark"] .mobile-admin .admin-table tr { background: var(--surface); }
:root[data-theme="dark"] :is(.notice,.status-badge.error) { background: #3b2d21; color: #ffcb93; }
:root[data-theme="dark"] :is(.error,.admin-error,.disabled-label,.danger-action) { color: var(--danger); }
:root[data-theme="dark"] .equipment-flags { color: var(--amber); }
:root[data-theme="dark"] .inline-link { color: #ff92a3; }
:root[data-theme="dark"] :is(.pc-star.is-selected,.favorite-symbol.is-selected,.filter-record.is-saved .filter-heart,[data-next-favorite][aria-pressed="true"],#detail-favorite[aria-pressed="true"]) { color: #ff92a3; }
:root[data-theme="dark"] :is(.pc-favorite,.quote-row>.favorite,.filter-heart) { color: var(--muted); }
:root[data-theme="dark"] :is(#toast,#admin-feedback) { color: #e0ece5; background: #293e33; border: 1px solid var(--line-strong); }
:root[data-theme="dark"] dialog::backdrop { background: #020805b3; }
:root[data-theme="dark"] .hero-items img { background: #ffffff0a; }
