.theme-actions {
  display: flex;
  align-items: center;
  gap: clamp(.35rem, 1vw, .65rem);
}

.theme-toggle {
  position: relative;
  display: inline-block;
  flex: 0 0 50px;
  width: 50px;
  min-height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #e5d5cb;
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #69452f;
  background: #fffaf5;
  font: .78rem/1 system-ui, sans-serif;
  transition: transform .2s ease;
}

.theme-toggle[aria-checked="true"] { background: #80573f; }
.theme-toggle-thumb::before { content: "☀"; }
.theme-toggle[aria-checked="true"] .theme-toggle-thumb::before { content: "☾"; }
.theme-toggle[aria-checked="true"] .theme-toggle-thumb { transform: translateX(22px); }
.theme-toggle:hover { border-color: var(--copper); }
.theme-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

@media (max-width: 760px) {
  .site-header .theme-toggle { flex-basis: 44px; width: 44px; }
  .site-header .theme-toggle[aria-checked="true"] .theme-toggle-thumb { transform: translateX(16px); }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle-thumb { transition: none; }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0c0c0d;
  --ink: #f1f0ee;
  --muted: #aaa9a7;
  --line: #343435;
  --cream: #dedbd7;
  --copper: #c1b6ab;
  --forest: #303332;
  --green: #b6c8a9;
  --mist: #2c302c;
  --white: #1d1d1e;
  --shadow: 0 24px 70px #00000066;
  --theme-surface: #171718;
  --theme-hover: #262627;
  --theme-accent: #c7b9ac;
  --theme-button: #363637;
  --theme-rule: #303031;
}

[data-theme="dark"] .site-header,
[data-theme="dark"] .dash-top {
  background: #121213f5;
  border-color: var(--line);
}

[data-theme="dark"] :is(.intro, .inner-page, .detail-page, .checkout-page) { background: var(--paper); }
[data-theme="dark"] :is(.featured, .woodcarving-guide) { background: var(--theme-surface); color: var(--ink); }
[data-theme="dark"] .woodcarving-guide,
[data-theme="dark"] .woodcarving-guide-points,
[data-theme="dark"] .woodcarving-guide-points li { border-color: var(--theme-rule); }
[data-theme="dark"] .woodcarving-symbol { background: var(--theme-hover); color: var(--theme-accent); }
[data-theme="dark"] :is(.woodcarving-guide-copy > p, .woodcarving-guide-points div span, .collection-banner p, .collection-image-note, #chatMessages > p) { color: var(--muted); }

[data-theme="dark"] :is(.profile-btn, .btn.primary, .cart-btn b, .toast) { background: var(--theme-button); color: #fff6ef; }
[data-theme="dark"] :is(.link-btn, .section-kicker, .detail-overline, .checkout-back) { color: var(--theme-accent); }
[data-theme="dark"] :is(.site-header .brand, .site-header nav, .site-header .cart-btn, .site-header .icon-btn) { color: var(--ink); }

[data-theme="dark"] #shop {
  --collection-ink: var(--ink);
  --collection-line: var(--theme-rule);
  --collection-accent: var(--theme-accent);
}

[data-theme="dark"] :is(.collection-categories button, .collection-sidebar summary, .collection-sidebar form, .collection-controls input, .collection-controls select, .collection-controls button, .collection-empty) {
  background: var(--theme-surface);
  border-color: var(--theme-rule);
  color: var(--ink);
}

[data-theme="dark"] .collection-categories button[aria-pressed="true"],
[data-theme="dark"] .collection-controls button[aria-pressed="true"] {
  background: var(--theme-button);
  border-color: var(--theme-button);
  color: #fff6ef;
}

[data-theme="dark"] #homeFeaturedProducts { --paper: var(--theme-surface); }
[data-theme="dark"] #product-detail {
  --product-line: var(--theme-rule);
  --product-muted: var(--muted);
  color: var(--ink);
}

[data-theme="dark"] :is(.product-gallery-arrow, .product-mobile-back, .product-order .product-favorite:not([aria-pressed="true"])) { color: var(--ink); }
[data-theme="dark"] :is(.product-gallery-arrow::before, .product-mobile-back) { background: var(--theme-surface); border-color: var(--line); }
[data-theme="dark"] .product-gallery-arrow:hover::before { background: var(--theme-hover); }
[data-theme="dark"] .product-order .product-favorite[aria-pressed="true"] { color: #ff8192; }

[data-theme="dark"] :is(#events, #event-detail) {
  --agenda-ink: var(--ink);
  --agenda-muted: var(--muted);
  --agenda-accent: var(--theme-accent);
  --agenda-surface: var(--theme-surface);
  --agenda-line: var(--theme-rule);
  background: var(--paper);
}

[data-theme="dark"] :is(.agenda-tools, .agenda-detail-facts > div, .agenda-reservation, #eventDetailType, .agenda-row-action a:hover) {
  background: var(--theme-hover);
  border-color: var(--line);
}

[data-theme="dark"] #events .event-tabs button.active,
[data-theme="dark"] #eventDetailRegister {
  background: var(--theme-button);
  border-color: var(--theme-button);
  color: #fff6ef;
}

[data-theme="dark"] .agenda-search input { border-color: var(--line); }
[data-theme="dark"] :is(.status.paid, .status.live, .agenda-status[data-status="active"], .agenda-status[data-status="reserved"]) {
  background: #303e2e;
  color: #c5ddb9;
}
[data-theme="dark"] :is(.status.pending, .agenda-status) { background: #4a3628; color: #f1c7a8; }
[data-theme="dark"] .status.shipping { background: #2b3c44; color: #bfdae9; }

[data-theme="dark"] :is(.dashboard-page, .dash-main) { background: var(--paper) !important; }
[data-theme="dark"] #dashboard {
  --account-ink: var(--ink);
  --account-muted: var(--muted);
  --account-accent: var(--theme-accent);
  --account-line: var(--theme-rule);
  --account-card: var(--theme-surface);
}

[data-theme="dark"] .account-top-support:hover { background: var(--theme-hover); }
[data-theme="dark"] :is(.panel, .stat-grid > div, .drawer, .chat-drawer, .order-summary, .shipping-card, .payment-card, .message:not(.user), .chat-drawer form, .admin-event-card, .event-flow-card, .product-modal-card) {
  background: var(--theme-surface);
  border-color: var(--theme-rule);
  color: var(--ink);
}

[data-theme="dark"] :is(.event-facts, .event-order-review, .payment-notice, .payment-notice > span, .craft-note, .shipping-icon, .order-code, .discount-box button, .payment-card.selected) {
  background: var(--theme-hover);
  color: var(--ink);
}

[data-theme="dark"] :is(.account-form, .checkout-form, .admin-event-form, .event-flow-step form, .discount-box) :is(input:not([type="checkbox"]), select, textarea) {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
}

[data-theme="dark"] :is(.admin-event-actions button, .chat-drawer form button, .modal-close) {
  border-color: var(--line);
  background: var(--theme-hover);
  color: var(--ink);
}

[data-theme="dark"] .admin-event-actions .danger { color: #ffa89d; }
[data-theme="dark"] :is(.positive, .summary-totals .discount-line b) { color: #b9d1a9 !important; }
[data-theme="dark"] .collection-banner::before { mix-blend-mode: screen; opacity: .20; }

[data-theme="dark"] :is(input, textarea)::placeholder { color: #949493; }

@media (max-width: 360px) {
  .site-header { padding-inline: 10px; }
  .site-header .brand small { display: none; }
}


[data-theme="dark"] :is(.darmag-hero, .darmag-portrait-media, .darmag-slide-media) { background: #111112; }
[data-theme="dark"] .darmag-hero { color: var(--ink); }
[data-theme="dark"] .darmag-slide h1 span,
[data-theme="dark"] .darmag-slide-link { color: var(--theme-accent); }
[data-theme="dark"] .darmag-hero-controls button { border-color: #ffffff33; color: var(--ink); }
[data-theme="dark"] .darmag-hero-controls button:hover { background: var(--theme-hover); border-color: #ffffff66; }
[data-theme="dark"] .mah-compare-divider span { background: #111112b3; }
[data-theme="dark"] .woodcarving-guide-points { background: none; }
html[data-theme="dark"] .woodcarving-guide-points .woodcarving-symbol { color: var(--theme-accent); }
[data-theme="dark"] .woodcarving-guide-copy .woodcarving-label { color: var(--theme-accent); }
[data-theme="dark"] .workshop-story-actions a:first-child { background: var(--theme-button); border-color: var(--theme-rule); }
[data-theme="dark"] .instructor-portrait { --instructor-background: #151516; }
[data-theme="dark"] .instructor-portrait-copy a { background: #d7d4d0; color: #171718; border-color: #d7d4d0; }
[data-theme="dark"] .home-academy-programs a { background: #141415; }
[data-theme="dark"] .home-academy-programs a::after { background: linear-gradient(0deg, #0c0c0dfb, #0c0c0dca 46%, #0c0c0d33); }
[data-theme="dark"] .home-academy-feature a::after { background: linear-gradient(0deg, #0c0c0dfa, #0c0c0d93 45%, transparent 85%); }
[data-theme="dark"] .home-academy-meta,
[data-theme="dark"] .home-academy-event-info,
[data-theme="dark"] .home-academy-feature p { color: #dedbd7; }
[data-theme="dark"] .home-academy-next { background: #d7d4d0; color: #171718; }
[data-theme="dark"] :is(.site-footer, .work-gallery-dialog) { background: #111112; color: var(--ink); border-color: var(--line); }
[data-theme="dark"] :is(.site-footer-identity p, .site-footer li a, .site-footer-bottom) { color: #b9b8b6; }
[data-theme="dark"] .site-footer-bottom,
[data-theme="dark"] #footerTop span { border-color: var(--line); }
[data-theme="dark"] #footerChat { background: #d7d4d0; color: #171718; border-color: #d7d4d0; }
[data-theme="dark"] .work-gallery-dialog button { background: var(--theme-surface); border-color: var(--line); }
[data-theme="dark"] .work-gallery-dialog button:hover { background: var(--theme-hover); }
[data-theme="dark"] .work-gallery-dialog::backdrop { background: #000000db; }
[data-theme="dark"] .theme-toggle[aria-checked="true"] { background: #484849; }
[data-theme="dark"] .theme-toggle-thumb { background: #eeece9; color: #202021; }
[data-theme="dark"] :is(.collection-quick-buy .shop-add-button, #pageProductAdd) { background: var(--theme-button); color: var(--ink); }
[data-theme="dark"] :is(.collection-quick-buy .shop-add-button, #pageProductAdd):hover { background: #454546; }
