/* Shared theme layer. Keep brand/illustration colors separate from UI colors.
   Loaded after all page CSS; screen-only so article print styles stay intact. */
@media screen {
  :root {
    color-scheme: light;
    --theme-bg: #fff8ed;
    --theme-fg: #2b2036;
    --theme-muted: #63516f;
    --theme-surface: #fffdf7;
    --theme-raised: #f0e5f6;
    --theme-inset: #ead8f4;
    --theme-border: #aa91b9;
    --theme-accent: #a94400;
    --theme-link: #65318a;
    --theme-focus: #672db3;
    --theme-dot: #56396515;
    --theme-shadow: #dbcfde;
    --theme-title-shadow: #d6b6f0;
    --theme-green: #e5ecce;
    --theme-green-fg: #284431;
    --theme-warm: #ffe1d4;
    --theme-warm-fg: #693200;
    --theme-chrome: #d9c1ee;
    --theme-chrome-fg: #291637;
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --theme-bg: #241e2e;
    --theme-fg: #fff1d4;
    --theme-muted: #d7c9e1;
    --theme-surface: #2f253a;
    --theme-raised: #3b2d49;
    --theme-inset: #483456;
    --theme-border: #9576a9;
    --theme-accent: #ff9b42;
    --theme-link: #d6b4ff;
    --theme-focus: #c8ffad;
    --theme-dot: #fff1d412;
    --theme-shadow: #110b1b;
    --theme-title-shadow: #6a00ff;
    --theme-green: #2b3b2f;
    --theme-green-fg: #d7efc7;
    --theme-warm: #493125;
    --theme-warm-fg: #ffe0b5;
    --theme-chrome: #513a64;
    --theme-chrome-fg: #f4e9ff;
  }
  /* The same device default remains available without JavaScript. */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
      color-scheme: dark;
      --theme-bg: #241e2e; --theme-fg: #fff1d4; --theme-muted: #d7c9e1;
      --theme-surface: #2f253a; --theme-raised: #3b2d49; --theme-inset: #483456;
      --theme-border: #9576a9; --theme-accent: #ff9b42; --theme-link: #d6b4ff;
      --theme-focus: #c8ffad; --theme-dot: #fff1d412; --theme-shadow: #110b1b;
      --theme-title-shadow: #6a00ff; --theme-green: #2b3b2f; --theme-green-fg: #d7efc7;
      --theme-warm: #493125; --theme-warm-fg: #ffe0b5;
      --theme-chrome: #513a64; --theme-chrome-fg: #f4e9ff;
    }
  }
  :root body { background-color:var(--theme-bg); color:var(--theme-fg); background-image:radial-gradient(var(--theme-dot) .8px,transparent .8px); }
  :root .header { background:var(--theme-bg); color:var(--theme-fg); border-color:var(--theme-border); }
  :root .footer { border-color:var(--theme-border); }
  :root .menu { color:var(--theme-fg); border-color:var(--theme-border); }
  :root :is(.brand span span,.hero h1 span,.orange-accent,.personal-page .personal-intro h1 span,.personal-note-arrow,.shop-hero h1 span,.product-info #product-price) { color:var(--theme-accent); }
  :root .hero h1 span { text-shadow:3px 4px 0 var(--theme-title-shadow); }
  :root :is(.page-intro h1 span,.blog-intro h1 span,.hello,.hero .hand-note,.dock-caption,.stream-note,.personal-page .personal-eyebrow,.personal-art-note,.personal-next>.hand,.shop-hero .eyebrow,.shop-hero .hand,.shop-hero .shop-eyebrow) { color:var(--theme-link); }
  :root :is(.intro,.hero-purpose,.hangout-copy>p,.social-afterthought,.latest-video,.latest-card time,.latest-card p,.video-consent,.video-copy time,.video-description,.video-status,.feed-note,.social-directory p,.page-intro>p:last-child,.policy-intro,.personal-page .personal-intro>p:last-child,.personal-page .personal-intro>div>p:last-child,.personal-broken-note p,.personal-page .contact-footnote,.contact-footnote,.blog-intro p:last-child,.recent-posts>.eyebrow,.blog-pagination,.archive-end,.post-copy>p,.blog-meta,.post-copy .post-state,.shop-intro,.shop-hero .shop-intro,.shop-notice,.product-description,.product-info details p,#variant-status,#shop-status) { color:var(--theme-muted); }
  :root :is(.slogan em,.personal-slogan em,.personal-desk li strong) { color:var(--theme-link); }
  :root :is(.personal-next,.personal-page .contact-footnote,.personal-desk,.shop-toolbar,.shop-catalog-controls,.product-info details) { border-color:var(--theme-border); }
  :root .personal-broken-note h2 { color:var(--theme-fg); }
  :root .header #nav a[aria-current], :root body .header nav a:not(.nav-chat):hover { text-decoration-color:var(--theme-link); }

  /* Neutral cards and controls share surfaces; orange actions stay orange. */
  :root :is(.dock a,.latest-card,.video-card,.social-directory>a,.project-window,.policy-sheet,.post-card,.shop-empty,.shop-error,#product-form,.cart-summary,.cart-item,.product-card,.personal-page .personal-story) { background:var(--theme-surface); color:var(--theme-fg); }
  :root :is(.dock a,.social-directory>a,#product-form,.shop-empty,.shop-error,.cart-summary) { border-color:var(--theme-border); }
  :root :is(.dock a:hover,.social-directory>a:hover,.post-featured) { background:var(--theme-raised); }
  :root .elsewhere { background:var(--theme-surface); border-color:var(--theme-border); }
  :root .video-thumbnail.thumbnail-fallback { background:var(--theme-raised); }
  :root :is(.latest-label,.stock-label,.video-unload) { color:var(--theme-link); border-color:var(--theme-border); }
  :root :is(.nav-chat,.button.secondary,.video-play,.shop-toolbar [data-cart-link],#cart-root button:not(.button):not(.cart-item button)) { background:var(--theme-raised); color:var(--theme-fg); border-color:var(--theme-border); }
  :root .video-play:hover { background:var(--theme-inset); }
  :root :is(.window-title,.video-card>.window-title,.latest-card>.window-title,.post-card .window-title,.personal-page .window-title,.personal-page .personal-story .window-title,.personal-page .personal-instagram .window-title,.personal-page .personal-twitch .window-title,.product-card .product-card-heading,.image-window .image-titlebar) { background:var(--theme-chrome); color:var(--theme-chrome-fg); }
  :root :is(.youtube-card,.personal-page .personal-instagram) { background:var(--theme-warm); color:var(--theme-fg); }
  :root :is(.instagram-card,.sticky,.personal-sticky,.contact-page .personal-twitch) { background:var(--theme-green); color:var(--theme-green-fg); }
  :root :is(.youtube-card .window-title,.instagram-card>.window-title,.contact-page .personal-instagram .window-title,.product-card:nth-child(2) .product-card-heading,.product-card:nth-child(3) .product-card-heading) { background:var(--theme-chrome); color:var(--theme-chrome-fg); }
  :root :is(.portrait-window,.personal-portrait-window,.stream-window,.personal-page .personal-twitch) { background:var(--theme-inset); color:var(--theme-fg); }
  :root .contact-page .personal-twitch { background:var(--theme-green); }
  :root :is(.portrait-caption,.portrait-canvas .speech,.lion-answer,.paper-band,.stream-bottom,.little-letter,.personal-caption,.personal-greeting .hand,.contact-page .personal-instagram,.shop-creator-note) { background:var(--theme-surface); color:var(--theme-fg); }
  :root :is(.portrait-canvas,.personal-portrait-canvas) { background-image:linear-gradient(var(--theme-dot) 1px,transparent 1px),linear-gradient(90deg,var(--theme-dot) 1px,transparent 1px); }
  :root .stream-poster { background:repeating-conic-gradient(var(--theme-inset) 0% 25%,var(--theme-raised) 0% 50%) 50%/48px 48px; }
  :root :is(.sticky::before,.personal-sticky::before,.contact-page .personal-twitch::before) { background:var(--theme-chrome); opacity:.65; }
  :root :is(.paper-band b,.portrait-canvas .star,.personal-spark,.little-letter .signature,.prose-panel h2,.personal-page .prose-panel h2,.prose-panel a:not(.button),.policy-sheet h2,.policy-sheet a,.personal-page .personal-platform-heading .hand) { color:var(--theme-link); }
  :root .social-cta { border-color:currentColor; }
  :root :is(.personal-platform-icon,.contact-page .personal-instagram .personal-platform-icon) { background:var(--theme-raised); border-color:var(--theme-border); }
  :root .personal-page .personal-contact-card .contact-note { color:var(--theme-muted); }
  :root .contact-page .personal-twitch :is(.window-title,.contact-note,.button,.button:hover) { background:transparent; color:var(--theme-green-fg); border-color:currentColor; }
  :root .shop-hero .shop-creator-note .hand { color:var(--theme-fg); }
  :root .stream-state { color:var(--theme-fg); border-color:var(--theme-border); }
  :root .stream-state[data-state=live] { background:var(--theme-green); color:var(--theme-green-fg); }
  :root .stream-state[data-state=offline] { background:var(--theme-raised); color:var(--theme-muted); }

  /* Archive, reading surface, contents rail and article furniture. */
  :root :is(.blog-categories a,.collection-nav a,.shop-catalog-controls .collection-nav a) { background:var(--theme-surface); color:var(--theme-fg); border-color:var(--theme-border); }
  :root :is(.blog-categories a[aria-current],.blog-categories a:hover,.collection-nav a:hover,.collection-nav a[aria-current],.shop-catalog-controls .collection-nav a[aria-current],.shop-catalog-controls .collection-nav a:hover) { background:var(--theme-inset); color:var(--theme-fg); border-color:var(--theme-link); }
  :root .blog-article { color:var(--theme-fg); }
  :root .blog-article>.window-title { background:transparent; color:var(--theme-muted); border-color:var(--theme-border); }
  :root .blog-article-header h1 { color:var(--theme-fg); text-shadow:3px 4px 0 var(--theme-title-shadow); }
  :root .blog-article-header .blog-meta { color:var(--theme-muted); }
  :root .blog-article-header .blog-meta>span { background:var(--theme-raised); color:var(--theme-fg); border-color:var(--theme-border); }
  :root :is(.blog-page .blog-back,.editorial-rail,.blog-article .editorial-rail .article-toc) { color:var(--theme-fg); border-color:var(--theme-border); }
  :root :is(.editorial-rail .rail-label,.editorial-rail .article-toc a:hover) { color:var(--theme-accent); }
  :root :is(.editorial-rail .article-toc a,.blog-article .article-toc summary:before) { color:var(--theme-link); border-color:var(--theme-border); }
  :root .blog-content { background:var(--theme-surface); color:var(--theme-fg); }
  :root :is(.blog-content>p:first-child:not(:has(img)),.blog-content strong) { color:var(--theme-fg); }
  :root :is(.blog-content h1,.blog-content h2,.blog-content h3,.blog-content h4,.blog-content h5,.blog-content h6,.blog-content a,.blog-content li::marker) { color:var(--theme-link); }
  :root .blog-content>h2 { background:linear-gradient(90deg,var(--theme-inset),transparent); }
  :root .blog-content a:hover { color:var(--theme-fg); }
  :root :is(.blog-content figcaption,.blog-content caption,.blog-cover figcaption) { color:var(--theme-muted); }
  :root .blog-content blockquote { background:var(--theme-raised); color:var(--theme-fg); border-color:var(--theme-link); box-shadow:5px 6px 0 var(--theme-shadow); }
  :root .blog-content .callout { background:var(--theme-green); color:var(--theme-green-fg); border-color:#709765; }
  :root .blog-content .callout-warning { background:var(--theme-warm); color:var(--theme-warm-fg); border-color:#c48240; }
  :root .blog-content :not(pre)>code { background:var(--theme-inset); color:var(--theme-fg); border-color:var(--theme-border); }
  :root .blog-content pre { background:#241b30; color:#f5ecff; box-shadow:4px 5px 0 var(--theme-shadow); }
  :root .blog-content th { background:var(--theme-inset); color:var(--theme-fg); }
  :root .blog-content td { background:var(--theme-surface); }
  :root .blog-content tbody tr:nth-child(even) td { background:var(--theme-raised); }
  :root :is(.table-scroll,.blog-content th,.blog-content td) { border-color:var(--theme-border); }
  :root .blog-content .image-window { background:var(--theme-raised); border-color:var(--theme-border); box-shadow:6px 7px 0 var(--theme-shadow); }
  :root .blog-content img:not(.image-window img) { background:var(--theme-raised); border-color:var(--theme-border); box-shadow:4px 5px 0 var(--theme-shadow); }
  :root .image-window figcaption { background:var(--theme-surface); color:var(--theme-muted); border-color:var(--theme-border); }
  :root .blog-article .blog-tags { color:var(--theme-muted); border-color:var(--theme-border); }
  :root :is(.blog-article .blog-tags a,.blog-article .blog-tags span,.blog-page .article-neighbours>a) { background:var(--theme-raised); color:var(--theme-fg); border-color:var(--theme-border); }
  :root .blog-page .article-neighbours>a:hover { background:var(--theme-inset); border-color:var(--theme-link); }
  :root .article-neighbours .eyebrow { color:var(--theme-muted); }

  /* Product photography retains its original pixels and neutral backdrop. */
  :root :is(.product-card .product-image-wrap,.product-card:nth-child(2) .product-image-wrap,.product-card:nth-child(3) .product-image-wrap,.product-gallery>.product-image-wrap) { background:var(--theme-raised); }
  :root :is(.image-fallback,.product-card-hint) { color:var(--theme-fg); }
  :root .product-card-hint span { border-color:var(--theme-border); }
  :root :is(#product-form select,#product-form input,.cart-item input,.cart-item button,[data-product-image]) { background:var(--theme-raised); color:var(--theme-fg); border-color:var(--theme-border); }
  :root .cart-item .cart-remove { background:transparent; }

  /* Accessible controls outside the collapsing navigation. */
  :root .header .wrap { column-gap:1rem; }
  .theme-toggle { display:inline-flex; flex-shrink:0; align-items:center; justify-content:center; gap:.4rem; min-width:44px; min-height:44px; padding:.5rem .7rem; border:2px solid var(--theme-border); border-radius:10px; background:var(--theme-raised); color:var(--theme-fg); font-size:.8rem; line-height:1; }
  .theme-toggle:hover { border-color:var(--theme-link); }
  .theme-toggle svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
  .theme-toggle .theme-sun { display:none; }
  [data-theme="dark"] .theme-toggle .theme-sun { display:block; }
  [data-theme="dark"] .theme-toggle .theme-moon { display:none; }
  .theme-reset { background:transparent; color:var(--theme-muted); border:0; padding:.5rem 0; min-height:44px; font-size:.75rem; text-decoration:underline; text-underline-offset:4px; }
  .theme-reset:disabled { cursor:default; text-decoration:none; opacity:1; }
  :root .footer .wrap { flex-wrap:wrap; }
  :root .footer .theme-reset { flex-basis:100%; text-align:left; }
  :root :is(a,button,summary,input,select):focus-visible { outline:3px dashed var(--theme-focus); outline-offset:4px; }
  :root :is(.project-window,.personal-page .project-window,.policy-sheet,.blog-article,.post-card) :focus-visible,
  :root :is(.blog-content pre,.table-scroll,.video-play,.latest-card>.window-title a,.shop-catalog-cart):focus-visible { outline-color:var(--theme-focus); }
  :root .blog-content pre button:focus-visible { outline-color:#c8ffad; }
  :root .video-frame:has(.video-play:focus-visible) { outline-color:var(--theme-focus); }
  @media (min-width:1001px) {
    :root .header #nav { margin-left:auto; }
    .theme-toggle { order:3; }
  }
  @media (max-width:1000px) {
    :root:not([data-theme]) .header { position:static; }
    :root:not([data-theme]) main { padding-top:0; }
    :root:not([data-theme]) .header #nav { display:flex; }
    .theme-toggle { margin-left:auto; }
    :root .header #nav { order:4; }
  }
  @media (max-width:600px) {
    :root .header .wrap { column-gap:8px; }
    .theme-toggle { width:44px; padding:8px; }
    .theme-toggle [data-theme-label] { display:none; }
  }
  @media (max-width:360px) {
    :root .header .brand { font-size:1.45rem; gap:6px; }
    :root .header .brand img { width:32px; height:32px; }
    :root .header .menu { min-width:54px; padding-inline:5px; }
  }
}
@media print {
  .theme-toggle,.theme-reset { display:none; }
  html,body { color-scheme:light; background:white; color:#111; }
}
