/* Dark mode for every page (2026-10-13).
   ui/theme.js sets <html data-theme="light|dark"> before the page paints. Light mode is the pages'
   own :root colours, unchanged. Dark mode below re-points the same colour names, so every layout,
   radius, easing and animation is shared between the two looks; only the paint changes.
   Hard-coded light colours in the pages were rewritten as var(--th-*, original), so in light mode
   they fall back to the original value and here they get their dark twin.
   Palette: warm black ground, slightly lifted cards, the same gold hue made brighter for contrast. */
/* Tap highlight: disable default blue highlight box on click/touch across all interactive elements */
html, body, *, *::before, *::after {
  -webkit-tap-highlight-color: transparent;
}

/* Remove default blue tap/click highlight color across the entire web app */
html, body, *, *::before, *::after {
  -webkit-tap-highlight-color: transparent !important;
}
:focus:not(:focus-visible) {
  outline: none;
}

html[data-theme="dark"] {
  color-scheme: dark;

  /* twins of the rewritten hard-coded colours */
  --th-paper: #131511; --th-paper-rgb: 19, 21, 17; --th-paper-2: #181b15;
  --th-gold-tint: rgba(150, 204, 118, .12); --th-gold-tint-2: rgba(150, 204, 118, .24);
  --th-line: #252921; --th-line-2: #3c4535; --th-gold-line: #3c4e30;
  --th-ink: #ebf0e6; --th-ink-2: #ccd3c6; --th-muted: #99a192; --th-gold-text: #c7dd4a;
  --th-danger-bg: rgba(248, 113, 113, .12); --th-danger-line: rgba(248, 113, 113, .38); --th-danger-text: #fca5a5;
  --th-ok-bg: rgba(74, 222, 128, .10); --th-ok-line: rgba(74, 222, 128, .34); --th-ok-text: #86efac;
  --th-warn-bg: rgba(251, 191, 36, .10); --th-warn-line: rgba(251, 191, 36, .34); --th-warn-text: #fcd34d;
  --th-info-bg: rgba(148, 163, 184, .12); --th-info-text: #b9c3d3;
  --th-on-fill: #11160c;   /* text on a filled gold / status button */
  --th-on-ink: #131511;    /* text on an ink-filled toast or tooltip (ink is light here) */
  --th-sheen-rgb: 224, 239, 166;   /* button sweep and click ripple glow gold, not white */

  /* the pages' own colour names */
  --bg: #0a0b0a; --bg2: #0d0f0c; --ground: #0a0b0a;
  --surface: rgba(19, 21, 17, .86); --surface-solid: #131511; --surface-2: #181b15;
  --sunken: #181b15; --field: #131511; --soft: #181b15; --chip: #191d15;
  --line: #252921; --line-strong: #3c4535; --border: #252921; --border-strong: #3c4535;
  --ink: #ebf0e6; --ink-2: #ccd3c6; --text: #ebf0e6; --muted: #99a192; --faint: #737a6c;
  --accent: #96cc76; --accent-ink: #c7dd4a; --accent-text: #11160c;
  --gold: #96cc76; --gold-hover: #a9d78c; --gold-text: #c7dd4a; --gold-tint: rgba(150, 204, 118, .13); --gold-line: #3c4e30;
  --tone: #96cc76; --tone-hover: #a9d78c;
  --tone1: #c7dd4a; --tone2: #96cc76; --tone3: #5f8f3c;
  --btn: linear-gradient(135deg, #c7dd4a, #96cc76); --btn-hover: linear-gradient(135deg, #d3e66b, #a7d68a);
  --glow: rgba(150, 204, 118, .30);
  --danger: #f87171; --danger-bg: rgba(248, 113, 113, .12); --danger-line: rgba(248, 113, 113, .38);
  --ok: #4ade80; --ok-bg: rgba(74, 222, 128, .10); --ok-line: rgba(74, 222, 128, .34);
  --warn: #fbbf24; --err: #f87171; --err-bg: rgba(248, 113, 113, .12);
  --new: #fb923c; --new-bg: rgba(251, 146, 60, .12); --new-line: rgba(251, 146, 60, .36);
  --info: #a3b1c6; --info-bg: #181b15;
  --tile-a: #363a32; --tile-b: #0e0f0e;
  --aurora1: rgba(150, 204, 118, .10); --aurora2: rgba(110, 169, 71, .08);
  --shadow: 0 14px 34px -22px rgba(0, 0, 0, .85);
  --lift: 0 12px 28px -16px rgba(0, 0, 0, .8);
}
html[data-theme="dark"] body { background-color: var(--bg, var(--ground, #0a0b0a)); }
html[data-theme="dark"] ::selection { background: rgba(150, 204, 118, .32); color: #fff; }
html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color: #737a6c; }
/* product photos keep their own backgrounds; a hairline keeps a white photo from glaring on a dark card */
html[data-theme="dark"] .card img, html[data-theme="dark"] .mini img, html[data-theme="dark"] .bcard .img img { box-shadow: 0 0 0 1px rgba(255, 255, 255, .03); }
/* filled gold buttons get a soft glow, the dark-mode echo of the light-mode shadow */
html[data-theme="dark"] .primary:not(:disabled):hover, html[data-theme="dark"] .btn.primary:not(:disabled):hover { box-shadow: 0 8px 22px -12px rgba(150, 204, 118, .55) !important; }

/* ---------- design pictures: a lit studio backdrop, not flat black ----------
   Charcoal lit from just above the piece, falling to near-black at the edges, like a jewellery
   photo studio. No floor glow or shadow under the piece: a painted one never matches the
   piece's real reflection. (Pictures' own white backgrounds and floor shadows are removed by
   the server for dark mode: ui/theme.js asks for the dark version, cutout.py makes it.) */
html[data-theme="dark"] {
  --th-studio: radial-gradient(ellipse 78% 64% at 50% 40%, #3b4037 0%, #282b26 38%, #171916 72%, #0d0e0d 100%);
}
html[data-theme="dark"] :is(
    .card:not(.skeleton) .img, .cat-tile .img, .tile:not(.skeleton):has(> img), .tile .pic, .stage:has(> img, > video), .strip button,
    .thumbs button, .h-thumb, .banner img, .same img, .wframe, .pic, .mini img, .res img, .result img.sheet,
    .zoom img, .dz-preview img, .q-pic, .seen-row img, .input-preview img, .orow .design img, .orow .design .noimg,
    .brow img, .brow .noimg, .dfh-tile .dfh-img
  ) { background: var(--th-studio) !important; }

/* a picture swapped for its dark copy: no blurred copy of the white original glowing behind it */
html[data-theme="dark"] .wframe:has(> img[data-dark-src])::before { display: none; }
html[data-theme="dark"] dialog#photoDlg.photo-viewer { background: #0a0b0a !important; color: #ebf0e6; }
html[data-theme="dark"] dialog#photoDlg::backdrop { background: rgba(0, 0, 0, .92); }
html[data-theme="dark"] .pv-badge { background: rgba(19, 21, 17, .9); border-color: rgba(150, 204, 118, .45); color: var(--accent-ink, #c7dd4a); box-shadow: 0 4px 14px rgba(0, 0, 0, .4); }
html[data-theme="dark"] .pv-close { border-color: rgba(150, 204, 118, .35); background: rgba(19, 21, 17, .8); color: #ebf0e6; box-shadow: 0 4px 14px rgba(0, 0, 0, .4); }
html[data-theme="dark"] .pv-close:hover { background: rgba(150, 204, 118, .2); }
html[data-theme="dark"] .pv-nav { border-color: rgba(150, 204, 118, .35); background: rgba(19, 21, 17, .8); color: #ebf0e6; box-shadow: 0 4px 14px rgba(0, 0, 0, .4); }
html[data-theme="dark"] .pv-nav:hover { background: rgba(150, 204, 118, .25); border-color: var(--gold, #96cc76); }
html[data-theme="dark"] .pv-dot { background: rgba(255, 255, 255, .28); }
html[data-theme="dark"] .pv-dot.on { background: var(--gold, #96cc76); box-shadow: 0 0 12px rgba(150, 204, 118, .6); }
html[data-theme="dark"] .pv-body img { filter: drop-shadow(0 14px 35px rgba(0, 0, 0, .6)); }

/* ---------- the switch ---------- */
.th-toggle { box-sizing: border-box; flex: none; width: 40px; height: 40px; margin: 0; padding: 0; display: inline-grid; place-items: center; border-radius: 999px;
  border: 1px solid var(--th-gold-line, #cddba7); background: var(--th-paper, #fff); color: var(--th-gold-text, #47702a); cursor: pointer;
  box-shadow: none; min-height: 0; -webkit-tap-highlight-color: transparent;
  transition: border-color 150ms ease, background-color 300ms ease, transform 150ms cubic-bezier(.23, 1, .32, 1); }
.th-toggle:hover { border-color: var(--gold, #4e7a2e); }
.th-toggle:active { transform: scale(.94); }
.th-toggle:focus-visible { outline: 2px solid var(--gold, #4e7a2e); outline-offset: 2px; }
.th-toggle svg { grid-area: 1 / 1; width: 18px; height: 18px; transition: transform 500ms cubic-bezier(.23, 1, .32, 1), opacity 300ms ease; }
.th-toggle .th-moon { opacity: 0; transform: rotate(-90deg) scale(.4); }
html[data-theme="dark"] .th-toggle .th-sun { opacity: 0; transform: rotate(90deg) scale(.4); }
html[data-theme="dark"] .th-toggle .th-moon { opacity: 1; transform: none; }
.th-toggle.th-float { position: fixed; right: 16px; bottom: 16px; z-index: 80; box-shadow: 0 10px 24px -14px rgba(41, 37, 36, .4); }

/* the switch-over: a gold-edged circle grows from the button (view transitions), else a short cross-fade */
/* (scoped to the switch: page-to-page transitions in ui/motion.css use the same pseudo-elements) */
html.th-vt::view-transition-old(root), html.th-vt::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.th-anim, html.th-anim *, html.th-anim *::before, html.th-anim *::after {
  transition: background-color 350ms ease, border-color 350ms ease, color 350ms ease, fill 350ms ease, box-shadow 350ms ease !important; }
@media (prefers-reduced-motion: reduce) {
  .th-toggle svg { transition: none; }
  html.th-anim, html.th-anim * { transition: none !important; }
}

/* ---------- animated brand-mark loader (shared, icon only, no text, everywhere) ----------
   .splash-loader: a full-page splash for a page's very first paint — fixed and centred regardless
   of scroll or document flow, so it's centred even before anything else has rendered.
   .page-loader: the same mark, in-flow and centred within its own container — for loading a
   section of a page that is already visible (e.g. a product dialog's contents, switching between
   admin views). Both use the big cycling mark (ring/earrings/pendant/necklace/bracelet, same as
   the site header logo) so the loading state is always the thing a viewer's eye lands on, sized
   to the container.
   .mini-loader: a lighter single mark at icon size, for small inline spots (chips, buttons,
   list footers) where a big cycling mark would be visual noise. */
.splash-loader, .page-loader, .mini-loader { display: grid; place-items: center; }
.splash-loader { position: fixed; inset: 0; z-index: 2000; background: var(--ground, var(--bg, var(--surface, #fff))); }
.page-loader { padding: 48px 20px; }
.mini-loader { display: inline-grid; }
.pl-logo { color: var(--accent, var(--gold, #6f9f4a)); flex: none; animation: plBob 1.1s ease-in-out infinite; }
.mini-loader .pl-logo { width: 18px; height: 18px; }
.pl-logo .g { transform-box: fill-box; transform-origin: center; animation: plGem 1.1s ease-in-out infinite; }
@keyframes plBob { 0%, 100% { transform: rotate(-6deg) scale(1); } 50% { transform: rotate(6deg) scale(1.08); } }
@keyframes plGem { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .pl-logo, .pl-logo .g { animation: none !important; }
}

.pl-mark { overflow: visible; }
/* sized to the viewport: small on phones, growing up to the full desktop size on wider screens */
.splash-loader .pl-mark { width: clamp(88px, 26vw, 180px); height: clamp(88px, 26vw, 180px); }
.page-loader .pl-mark { width: clamp(56px, 16vw, 110px); height: clamp(56px, 16vw, 110px); }
.page-loader .pl-logo { width: clamp(56px, 16vw, 110px); height: clamp(56px, 16vw, 110px); }
.pl-items { transform-box: view-box; transform-origin: 24px 26px; }
.pl-item { opacity: 0; transform-box: view-box; transform-origin: 24px 26px; animation: plCycle 15s infinite; }
.pl-item.i1 { animation-delay: 3s; } .pl-item.i2 { animation-delay: 6s; }
.pl-item.i3 { animation-delay: 9s; } .pl-item.i4 { animation-delay: 12s; }
.pl-item .d { stroke-dasharray: 100; stroke-dashoffset: 100; animation: plTrace 15s infinite; animation-delay: inherit; }
.pl-item .g { transform-box: fill-box; transform-origin: center; animation: plGemAnim 15s infinite; animation-delay: inherit; }
@keyframes plCycle { 0% { opacity: 0; transform: scale(.7) rotate(-10deg); } 3% { opacity: 1; transform: none; } 17% { opacity: 1; transform: none; } 20% { opacity: 0; transform: scale(1.15) rotate(8deg); } 100% { opacity: 0; } }
@keyframes plTrace { 0% { stroke-dashoffset: 100; } 9% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; } }
@keyframes plGemAnim { 0%, 5% { opacity: 0; transform: scale(.2); } 10% { opacity: 1; transform: scale(1.12); } 12%, 100% { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .pl-item, .pl-item .d, .pl-item .g { animation: none !important; }
  .pl-item .d { stroke-dashoffset: 0; }
  .pl-item.i0 { opacity: 1; }
}

/* ---------- small phones: no sideways scrolling (2026-11-19) ----------
   Top-bar round buttons (theme, phone, favourites, profile) go to 34px at 380px and below, like the bell
   (notify.js) and apps icon (admin-rail.js) already do, so the top bar fits the screen. */
@media (max-width: 380px) {
  body > header :is(.th-toggle, .df-tb) { width: 34px; height: 34px; }
  body > header :is(.th-toggle, .df-tb) svg { width: 16px; height: 16px; }
  body > header .pd .pd-btn { height: 34px; padding: 0 1px; }
  body > header .pd .pd-av { width: 30px; height: 30px; }
  body > header .top-actions > :is(#favBtn, #histBtn) { width: 34px; height: 34px; }   /* Design Finder / AI tools: favourites, history */
}
/* phones and small tablets: the page itself never scrolls sideways. Wide parts (tables, tab strips) keep their own
   scroll boxes; "clip" (not "hidden") so sticky top bars keep working */
@media (max-width: 720px) { html, body { overflow-x: clip; } }
/* phones (480px and below): no "Continue on your phone" (QR) button in the top bar: already on a phone */
@media (max-width: 480px) { body > header .df-tb-phone { display: none; } }
/* 340px and below: the back link keeps only its arrow, and the logo gives way when the bar has a back link */
@media (max-width: 340px) {
  body > header.topbar #back.ghost > span { display: none; }
  body > header.topbar #back.ghost { padding-left: 12px; padding-right: 12px; }
  body > header.topbar:has(#back, a.top-btn) .brand { display: none; }
}
