/* bitmosh: dark take on the Taglet / Any Day Now system. Solid content under a floating glass control layer,
   capsules, one accent, Bricolage + Hanken + JetBrains Mono. The image lights the room behind the glass.
   Every value comes from the tokens in :root. */
/* ds-allow-hardcode:start (font declarations define the families the tokens name) */
@font-face { font-family: "Bricolage"; src: url("/fonts/bricolage.woff2") format("woff2-variations"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Hanken"; src: url("/fonts/hanken.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "JB Mono"; src: url("/fonts/jbmono.woff2") format("woff2"); font-weight: 500; font-display: swap; }
/* ds-allow-hardcode:end */

:root {
  color-scheme: dark;
  /* Ink: cool near-blacks, so the image and the accent carry the colour. */
  --ink-0: #08090c; --ink-1: #111318; --ink-2: #181b22; --ink-3: #232731;
  --black: #000000; --white: #ffffff;
  --line: rgba(236, 239, 245, .08); --line-strong: rgba(236, 239, 245, .16);
  --paper: #eceff5; --paper-2: #a7aebd; --paper-3: #8a92a2;
  /* Mosh: one hot pink accent. Text on it uses its own dark ink. */
  --accent: #ff5c8a; --accent-ink: #2b0714; --accent-soft: rgba(255, 92, 138, .14); --accent-glow: rgba(255, 92, 138, .25);
  --signal: #ffb547;
  --fill-1: rgba(255, 255, 255, .055); --fill-2: rgba(255, 255, 255, .07); --fill-3: rgba(255, 255, 255, .11); --fill-4: rgba(255, 255, 255, .15);
  --handle-fill: rgba(255, 255, 255, .3);
  --scrim: rgba(0, 0, 0, .55); --scrim-ink: rgba(8, 9, 12, .55);

  --glass-fill: rgba(24, 27, 34, .58);
  --glass-rim: rgba(255, 255, 255, .09);
  --glass-blur: blur(26px) saturate(1.9);
  --scrim-blur: blur(4px); --drop-blur: blur(10px); --room-blur: blur(20px);
  --aura: rgba(255, 92, 138, .22); --aura-2: rgba(92, 140, 255, .14);

  --shadow-glass: inset 0 1px 0 rgba(255, 255, 255, .07), 0 18px 50px -18px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .25);
  --shadow-frame: 0 40px 90px -36px rgba(0, 0, 0, .9), 0 0 0 1px var(--line);
  --shadow-sheet: 0 0 0 1px var(--line), 0 30px 80px -20px rgba(0, 0, 0, .8);
  --shadow-lens: 0 0 0 1.5px rgba(255, 255, 255, .85), 0 0 0 7px rgba(0, 0, 0, .18), 0 12px 30px rgba(0, 0, 0, .45);
  --shadow-thumb: 0 2px 10px rgba(0, 0, 0, .5);
  --shadow-seg: inset 0 1px 0 rgba(255, 255, 255, .12), 0 3px 10px rgba(0, 0, 0, .35);
  --shadow-preset: 0 0 0 1px var(--line);
  --shadow-preset-on: 0 0 0 2px var(--ink-0), 0 0 0 4px var(--accent);
  --shadow-drop: inset 0 0 0 2px var(--accent), 0 0 80px var(--accent-glow);
  --shadow-seg-track: inset 0 0 0 1px var(--line);
  --ring-thumb: 0 0 0 3px var(--accent);

  --font-display: "Bricolage", "Hanken", ui-sans-serif, system-ui, sans-serif;
  --font-text: "Hanken", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JB Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* Type: 12 / 13.5 / 15 / 16 / 21 / 22 */
  --t-xs: 12px; --t-sm: 13.5px; --t-md: 15px; --t-body: 16px; --t-lg: 20px; --t-xl: 22px; --t-mark: 21px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 18px; --s-6: 22px; --s-7: 24px;
  --r-sm: 8px; --r-md: 14px; --r-lg: 26px; --r-sheet: 28px; --r-full: 999px;
  --hair: 1px; --ring: 2px; --lift: 2px;
  --hit: 44px; --seg-h: 38px; --seg-pad: 3px; --icon: 20px; --icon-sm: 18px; --mark: 28px;
  --range-h: 30px; --track: 6px; --thumb: 26px; --thumb-offset: -10px;
  --handle-zone: 26px; --handle-w: 40px; --handle-h: 5px; --handle-top: 9px;
  --preset: 64px; --preset-sm: 58px; --blob: 220px; --sheet-w: 520px; --frame-start: 300px;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --dur-fast: 150ms; --dur: 200ms; --dur-mid: 250ms;
  --safe-top: max(var(--s-3), env(safe-area-inset-top));
  --safe-bottom: max(var(--s-3), env(safe-area-inset-bottom));
  --bar-h: 56px; --panel-w: 344px; --gap: 12px; --peek: 150px;
  --stage-top: calc(var(--safe-top) + var(--bar-h) + var(--gap));
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--ink-0); }
body {
  color: var(--paper); font: 400 var(--t-body)/1.5 var(--font-text); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
/* The room: the image's own colours glow behind the glass. */
body::before {
  content: ""; position: fixed; inset: -10%; z-index: -1; pointer-events: none; filter: var(--room-blur);
  background: radial-gradient(55% 45% at 40% 0%, var(--aura), transparent 70%), radial-gradient(40% 40% at 90% 100%, var(--aura-2), transparent 70%);
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 650; letter-spacing: -.022em; line-height: 1.1; margin: 0; }
p { margin: 0; text-wrap: pretty; }
b { font-weight: 600; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus { outline: none; }
:focus-visible { outline: var(--ring) solid var(--accent); outline-offset: var(--ring); border-radius: var(--r-sm); }
::selection { background: var(--accent); color: var(--accent-ink); }
.sr-only { position: absolute; width: var(--hair); height: var(--hair); overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--paper-2); }
.icon { width: var(--icon); height: var(--icon); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Liquid Glass: only the floating controls. */
.glass {
  background: var(--glass-fill); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: var(--hair) solid var(--glass-rim); box-shadow: var(--shadow-glass);
}

/* ── Bar ── */
.bar {
  position: fixed; z-index: 30; top: var(--safe-top); left: var(--gap); right: var(--gap); height: var(--bar-h);
  border-radius: var(--r-full); display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s-1) 0 var(--s-3);
}
.mark { display: flex; align-items: center; gap: var(--s-2); color: var(--paper); text-decoration: none; font: 650 var(--t-mark)/1 var(--font-display); letter-spacing: -.035em; }
.mark img { width: var(--mark); height: var(--mark); border-radius: var(--r-sm); }
.bar-actions { display: flex; align-items: center; gap: var(--hair); }
.btn-icon {
  width: var(--hit); height: var(--hit); border: 0; border-radius: var(--r-full); background: transparent; color: var(--paper-2);
  display: grid; place-items: center; transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur) var(--ease-out);
}
.btn-icon:hover { background: var(--fill-2); color: var(--paper); }
.btn-icon:active { transform: scale(.9); }
.btn {
  height: var(--hit); padding: 0 var(--s-5); border: 0; border-radius: var(--r-full); display: inline-flex; align-items: center; gap: var(--s-2);
  font-weight: 600; font-size: var(--t-md); transition: filter var(--dur-fast), transform var(--dur) var(--ease-out), background var(--dur-fast);
}
.btn:active { transform: scale(.95); }
.btn-primary { background: var(--accent); color: var(--accent-ink); margin-left: var(--s-1); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-quiet { background: var(--fill-2); color: var(--paper); }
.btn-quiet:hover { background: var(--fill-3); }

/* ── Stage ── */
.stage { position: fixed; top: var(--stage-top); left: 0; right: calc(var(--panel-w) + var(--gap) * 2); bottom: 0; display: grid; place-items: center; perspective: 1600px; /* ds-allow-hardcode: 3D depth, not a length on screen */ }
.frame {
  position: relative; width: var(--frame-start); height: var(--frame-start); border-radius: var(--r-md); overflow: hidden; background: var(--black);
  box-shadow: var(--shadow-frame); touch-action: none; cursor: crosshair; will-change: transform;
}
.frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#orig { clip-path: circle(var(--r, 0) at var(--x, 50%) var(--y, 50%)); }
.lens { position: absolute; left: 0; top: 0; width: 0; height: 0; border-radius: 50%; pointer-events: none; opacity: 0; box-shadow: var(--shadow-lens); }
.stage-hint { position: absolute; bottom: var(--s-3); left: var(--s-4); right: var(--s-4); text-align: center; font-size: var(--t-sm); color: var(--paper-3); }

/* ── Panel ── */
.panel {
  position: fixed; z-index: 20; top: var(--stage-top); right: var(--gap); bottom: var(--gap); width: var(--panel-w);
  border-radius: var(--r-lg); padding: var(--s-5); overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: var(--s-5);
}
.panel > * { flex: none; } /* scroll, never squash */
.panel-handle { display: none; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3) var(--s-2); }
.preset { border: 0; background: none; padding: 0; display: grid; justify-items: center; gap: var(--s-1); color: var(--paper-2); font-size: var(--t-xs); font-weight: 600; min-width: var(--preset); }
.preset canvas {
  width: var(--preset); height: var(--preset); border-radius: var(--r-md); background: var(--black); display: block;
  box-shadow: var(--shadow-preset); transition: box-shadow var(--dur), transform var(--dur-mid) var(--ease-out);
}
.preset:hover canvas { transform: translateY(calc(var(--lift) * -1)); }
.preset:active canvas { transform: scale(.92); }
.preset[aria-checked="true"] { color: var(--paper); }
.preset[aria-checked="true"] canvas { box-shadow: var(--shadow-preset-on); }
.more { display: grid; gap: var(--s-5); }
.field { display: grid; gap: var(--s-2); }
.field-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); }
.label { font-size: var(--t-sm); font-weight: 600; color: var(--paper-2); }
.value { font: 500 var(--t-sm) var(--font-mono); color: var(--paper); font-variant-numeric: tabular-nums; }
.help { font-size: var(--t-xs); line-height: 1.45; color: var(--paper-3); }
.divider { height: var(--hair); background: var(--line); }
.row { display: flex; gap: var(--s-2); }
.row .btn { flex: 1; justify-content: center; }

/* Segmented control: the highlight moves like a drop of liquid (its edges travel on separate curves). */
.seg { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: var(--seg-pad); border-radius: var(--r-full); background: var(--fill-1); box-shadow: var(--shadow-seg-track); }
.seg button { position: relative; z-index: 1; height: var(--seg-h); border: 0; background: none; border-radius: var(--r-full); color: var(--paper-2); font-size: var(--t-sm); font-weight: 600; transition: color var(--dur); padding: 0 var(--s-1); }
.seg button[aria-checked="true"] { color: var(--paper); }
.seg-thumb { position: absolute; top: var(--seg-pad); bottom: var(--seg-pad); left: 0; width: 0; border-radius: var(--r-full); background: var(--fill-4); box-shadow: var(--shadow-seg); }

/* Sliders */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: var(--range-h); margin: 0; background: transparent; --fill: 0%; }
input[type="range"]::-webkit-slider-runnable-track { height: var(--track); border-radius: var(--track); background: linear-gradient(to right, var(--accent) var(--fill), var(--fill-3) var(--fill)); }
input[type="range"]::-moz-range-track { height: var(--track); border-radius: var(--track); background: linear-gradient(to right, var(--accent) var(--fill), var(--fill-3) var(--fill)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: var(--thumb); height: var(--thumb); margin-top: var(--thumb-offset); border-radius: 50%; border: 0; background: var(--white); box-shadow: var(--shadow-thumb); transition: transform var(--dur-mid) var(--ease-out); }
input[type="range"]::-moz-range-thumb { width: var(--thumb); height: var(--thumb); border-radius: 50%; border: 0; background: var(--white); box-shadow: var(--shadow-thumb); transition: transform var(--dur-mid) var(--ease-out); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.2); }
input[type="range"]:active::-moz-range-thumb { transform: scale(1.2); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring-thumb); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: var(--ring-thumb); }

/* ── Drop ── */
.drop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--scrim-ink); -webkit-backdrop-filter: var(--drop-blur); backdrop-filter: var(--drop-blur); pointer-events: none; }
.drop-blob {
  width: var(--blob); height: var(--blob); border-radius: 50%; display: grid; place-items: center; font: 650 var(--t-lg) var(--font-display); letter-spacing: -.02em;
  background: var(--accent-soft); color: var(--paper); box-shadow: var(--shadow-drop);
}

/* ── Sheet (dialog) ── */
dialog.sheet {
  border: 0; padding: 0; width: min(var(--sheet-w), calc(100% - var(--s-7))); border-radius: var(--r-lg); background: var(--ink-2); color: var(--paper);
  box-shadow: var(--shadow-sheet);
}
dialog.sheet::backdrop { background: var(--scrim); -webkit-backdrop-filter: var(--scrim-blur); backdrop-filter: var(--scrim-blur); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-5) var(--s-2) var(--s-1) var(--s-6); }
.sheet-head h2 { font-size: var(--t-xl); }
.sheet-body { display: grid; gap: var(--s-3); padding: var(--s-2) var(--s-6) var(--s-7); font-size: var(--t-md); color: var(--paper-2); }
.sheet-body b { color: var(--paper); }

/* ── Toast: drops out of the glass bar ── */
.toast {
  position: fixed; z-index: 40; top: calc(var(--safe-top) + var(--bar-h) + var(--s-2)); left: 50%; translate: -50% 0;
  display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-5); border-radius: var(--r-full); font-size: var(--t-md); font-weight: 600; white-space: nowrap;
}
.toast .icon { color: var(--accent); width: var(--icon-sm); height: var(--icon-sm); }
.toast.err .icon { color: var(--signal); }

/* ── Phone: the panel is a sheet at the bottom; its looks row stays out, the rest opens with the handle. ── */
@media (max-width: 767px) {
  :root { --bar-h: 52px; --gap: 8px; --s-5: 16px; }
  .btn-primary span { display: none; }
  .btn-primary { width: var(--hit); padding: 0; justify-content: center; }
  .stage { right: 0; bottom: var(--peek); }
  .stage-hint { bottom: var(--s-1); font-size: var(--t-xs); }
  .panel { top: auto; left: var(--gap); right: var(--gap); bottom: var(--safe-bottom); width: auto; max-height: 74dvh; padding: 0 var(--s-3) var(--s-3); border-radius: var(--r-sheet); gap: var(--s-3); overflow: hidden; }
  .panel.open { overflow-y: auto; }
  .panel-handle { display: block; position: sticky; top: 0; z-index: 2; flex: none; width: 100%; height: var(--handle-zone); border: 0; background: none; touch-action: none; }
  .panel-handle::after { content: ""; position: absolute; left: 50%; top: var(--handle-top); width: var(--handle-w); height: var(--handle-h); border-radius: var(--handle-h); background: var(--handle-fill); translate: -50% 0; }
  .presets { display: flex; overflow-x: auto; gap: var(--s-2); margin: 0 calc(var(--s-3) * -1); padding: var(--s-1) var(--s-3); scroll-padding-inline: var(--s-3); scroll-snap-type: x mandatory; scrollbar-width: none; }
  .presets::-webkit-scrollbar { display: none; }
  .preset { scroll-snap-align: start; }
  .preset canvas { width: var(--preset-sm); height: var(--preset-sm); }
  .more { display: none; }
  .panel.open .more { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
