/* ============================================================
   chus2fa — Liquid Glass over a warm, clay-toned backdrop
   ============================================================ */

:root {
  color-scheme: light dark;

  /* Warm paper palette */
  --bg: #e6f3ee;
  --surface: #f7fcfa;              /* opaque fallback for glass */
  --label: #1b2421;
  --label-2: #52615b;
  --label-3: #84938d;
  --separator: rgba(40, 80, 68, 0.15);
  --well: rgba(255, 255, 255, 0.46);
  --well-strong: rgba(255, 255, 255, 0.72);
  --fill-2: rgba(40, 80, 68, 0.12);

  /* Clay accent */
  --accent: #c96442;
  --accent-hi: #df8461;
  --accent-text: #a64d2d;
  --accent-tint: rgba(201, 100, 66, 0.13);
  /* Filled buttons carry white text: a deeper clay, 4.2:1 at the top of the gradient, 5.4:1 at the foot */
  --accent-fill-hi: #c45f3b;
  --accent-fill: #ad4d2a;
  --green: #2e7d3c;
  --red: #c0392b;
  --ring-ok: #3fae5a;
  --ring-warn: #e8912d;
  --ring-hot: #e0483a;

  /* Glass material */
  --glass-a: rgba(255, 255, 255, 0.58);
  --glass-b: rgba(255, 255, 255, 0.32);
  --glass-rim: rgba(255, 255, 255, 0.95);
  --glass-rim-soft: rgba(255, 255, 255, 0.18);
  --glass-sheen: rgba(255, 255, 255, 0.55);
  --glass-caustic: rgba(255, 255, 255, 0.55); /* light gathered along the lower inner edge */
  --glass-shadow: 0 18px 50px rgba(40, 90, 75, 0.13), 0 3px 10px rgba(40, 90, 75, 0.06);
  --glass-blur: blur(30px) saturate(1.8);

  --radius: 28px;
  --radius-sm: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  /* Apple-style springs (response / damping), with cubic-bezier fallbacks */
  --spring-soft: cubic-bezier(0.25, 0.9, 0.3, 1);
  --spring-bouncy: cubic-bezier(0.32, 1.25, 0.5, 1);
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring-soft: linear(0, 0.021, 0.075, 0.149, 0.234, 0.323, 0.411, 0.495, 0.573, 0.643, 0.705, 0.76, 0.807, 0.847, 0.881, 0.908, 0.931, 0.949, 0.964, 0.975, 0.984, 0.991, 0.996, 0.999, 1.002, 1.003, 1.004, 1.005, 1.005, 1.005, 1.005, 1.004, 1.004, 1.003, 1.003, 1.003, 1.002, 1.002, 1.002, 1.001, 1);
    --spring-bouncy: linear(0, 0.029, 0.101, 0.199, 0.31, 0.425, 0.535, 0.636, 0.726, 0.803, 0.868, 0.919, 0.959, 0.989, 1.011, 1.025, 1.033, 1.038, 1.038, 1.037, 1.034, 1.03, 1.026, 1.021, 1.017, 1.013, 1.01, 1.007, 1.005, 1.003, 1.001, 1, 1, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 1);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111816;
    --surface: #1e2825;
    --label: #edf5f1;
    --label-2: #a7b8b1;
    --label-3: #7a8a84;
    --separator: rgba(215, 245, 232, 0.12);
    --well: rgba(0, 0, 0, 0.22);
    --well-strong: rgba(0, 0, 0, 0.32);
    --fill-2: rgba(215, 245, 232, 0.14);
    --accent: #d2694a;
    --accent-hi: #e8906c;
    --accent-text: #ee9d7a;
    --accent-tint: rgba(217, 119, 87, 0.2);
    --green: #5fd07a;
    --red: #ff7b6b;
    --ring-ok: #5fd07a;
    --ring-warn: #ffad4a;
    --ring-hot: #ff6a5a;
    --glass-a: rgba(46, 60, 55, 0.5);
    --glass-b: rgba(24, 33, 30, 0.36);
    --glass-rim: rgba(225, 250, 240, 0.32);
    --glass-rim-soft: rgba(225, 250, 240, 0.05);
    --glass-sheen: rgba(215, 245, 232, 0.12);
    --glass-caustic: rgba(215, 245, 232, 0.1);
    --glass-shadow: 0 18px 50px rgba(0, 0, 0, 0.35), 0 3px 10px rgba(0, 0, 0, 0.2);
  }
}

@media (prefers-contrast: more) {
  :root {
    --label-2: #34423d;
    --separator: rgba(40, 80, 68, 0.45);
    --accent-text: #8a3a1d;
    --glass-a: rgba(255, 255, 255, 0.92);
    --glass-b: rgba(255, 255, 255, 0.86);
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --label-2: #d3e2dc;
      --separator: rgba(215, 245, 232, 0.45);
      --accent-text: #ffb894;
      --glass-a: rgba(22, 30, 27, 0.94);
      --glass-b: rgba(22, 30, 27, 0.9);
    }
  }
  .glass { outline: 1px solid var(--separator); }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden]:not(.toast) { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: clip; }

body {
  margin: 0; overflow-x: clip;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.47;
  letter-spacing: -0.01em;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============ Backdrop: warm clay light, drifting slowly ============ */
.backdrop {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% 0%, #f5fbf8 0%, transparent 60%),
    var(--bg);
}
.blob {
  position: absolute; border-radius: 50%;
  width: 70vmax; height: 70vmax;
  will-change: transform;
  /* The drift is a few pixels a second. Stepping it (same eased path) means the glass above
     re-blurs a few times a second instead of on every frame of a 120Hz screen. All five share one
     clock (45s / 60 steps = 0.75s, delays in whole steps), so they move in the same frame:
     ~1.3 redraws a second in total instead of ~8 from five unsynchronised clocks. */
  animation: drift 45s steps(60) infinite alternate;
}
@supports (animation-timing-function: linear(0, 1)) {
  .blob { animation-timing-function: linear(0, 0.0037 0% 1.667%, 0.0131 1.667% 3.333%, 0.0256 3.333% 5%, 0.0412 5% 6.667%, 0.0601 6.667% 8.333%, 0.0824 8.333% 10%, 0.108 10% 11.667%, 0.1369 11.667% 13.333%, 0.1686 13.333% 15%, 0.2028 15% 16.667%, 0.2389 16.667% 18.333%, 0.2763 18.333% 20%, 0.3143 20% 21.667%, 0.3524 21.667% 23.333%, 0.39 23.333% 25%, 0.4268 25% 26.667%, 0.4624 26.667% 28.333%, 0.4967 28.333% 30%, 0.5295 30% 31.667%, 0.5608 31.667% 33.333%, 0.5905 33.333% 35%, 0.6187 35% 36.667%, 0.6453 36.667% 38.333%, 0.6705 38.333% 40%, 0.6942 40% 41.667%, 0.7166 41.667% 43.333%, 0.7378 43.333% 45%, 0.7576 45% 46.667%, 0.7764 46.667% 48.333%, 0.794 48.333% 50%, 0.8106 50% 51.667%, 0.8261 51.667% 53.333%, 0.8408 53.333% 55%, 0.8545 55% 56.667%, 0.8674 56.667% 58.333%, 0.8795 58.333% 60%, 0.8908 60% 61.667%, 0.9014 61.667% 63.333%, 0.9112 63.333% 65%, 0.9205 65% 66.667%, 0.929 66.667% 68.333%, 0.937 68.333% 70%, 0.9444 70% 71.667%, 0.9512 71.667% 73.333%, 0.9575 73.333% 75%, 0.9633 75% 76.667%, 0.9686 76.667% 78.333%, 0.9734 78.333% 80%, 0.9777 80% 81.667%, 0.9817 81.667% 83.333%, 0.9852 83.333% 85%, 0.9883 85% 86.667%, 0.991 86.667% 88.333%, 0.9933 88.333% 90%, 0.9953 90% 91.667%, 0.9969 91.667% 93.333%, 0.9981 93.333% 95%, 0.999 95% 96.667%, 0.9997 96.667% 98.333%, 1 98.333% 100%, 1); }
}
.b1 { left: -22vmax; top: -26vmax; background: radial-gradient(circle, rgba(166, 214, 196, 0.62) 0%, rgba(166, 214, 196, 0) 62%); }
.b2 { right: -24vmax; top: -18vmax; background: radial-gradient(circle, rgba(196, 232, 219, 0.7) 0%, rgba(196, 232, 219, 0) 62%); animation-delay: -12s; animation-direction: alternate-reverse; }
.b3 { left: 20vmax; top: 30vh; background: radial-gradient(circle, rgba(183, 212, 202, 0.6) 0%, rgba(183, 212, 202, 0) 60%); animation-delay: -19.5s; }
.b4 { left: -30vmax; bottom: -40vmax; background: radial-gradient(circle, rgba(135, 160, 152, 0.36) 0%, rgba(135, 160, 152, 0) 60%); animation-delay: -6s; animation-direction: alternate-reverse; }
.b5 { right: -28vmax; bottom: -34vmax; background: radial-gradient(circle, rgba(240, 176, 190, 0.32) 0%, rgba(240, 176, 190, 0) 62%); animation-delay: -30s; }
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(6vmax, 4vmax, 0) scale(1.08); }
  100% { transform: translate3d(-4vmax, 7vmax, 0) scale(0.96); }
}
/* Paper grain */
.backdrop::after {
  /* Plain alpha, no blend mode: on this light ground it matches multiply, and it saves the GPU
     an extra render pass on every frame */
  content: ""; position: absolute; inset: 0; opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .2 0 0 0 0 .38 0 0 0 0 .32 0 0 0 .3 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  .backdrop { background: radial-gradient(120% 80% at 50% 0%, #1b2522 0%, transparent 60%), var(--bg); }
  .b1 { background: radial-gradient(circle, rgba(80, 150, 125, 0.34) 0%, rgba(80, 150, 125, 0) 62%); }
  .b2 { background: radial-gradient(circle, rgba(110, 170, 150, 0.22) 0%, rgba(110, 170, 150, 0) 62%); }
  .b3 { background: radial-gradient(circle, rgba(90, 130, 118, 0.24) 0%, rgba(90, 130, 118, 0) 60%); }
  .b4 { background: radial-gradient(circle, rgba(60, 100, 110, 0.3) 0%, rgba(60, 100, 110, 0) 60%); }
  .b5 { background: radial-gradient(circle, rgba(200, 110, 130, 0.18) 0%, rgba(200, 110, 130, 0) 62%); }
  /* Black noise at the strength 'overlay' gave, again without a blend mode */
  .backdrop::after {
    opacity: 0.14;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .3 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }
}

/* ============ Liquid Glass material ============ */
.glass {
  position: relative;
  isolation: isolate;
  background: linear-gradient(150deg, var(--glass-a), var(--glass-b));
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow:
    inset 0 1px 0 var(--glass-rim),
    inset 0 -1px 0 var(--glass-rim-soft),
    inset 0 -14px 24px -20px var(--glass-caustic),
    var(--glass-shadow);
}
/* Content cards sit over the fixed, already very soft backdrop, where a live blur is invisible
   (measured: ~3 levels in one channel) yet triples GPU time on every scrolled frame. They keep
   the glass tint, rims and sheen; floating chrome (toolbar, tab bar, toast, sheets) keeps the
   real blur because content moves beneath it. */
.card.glass { -webkit-backdrop-filter: none; backdrop-filter: none; }
/* Specular rim: bright on the lit edges, fading on the sides */
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.25px;
  background: linear-gradient(145deg,
    var(--glass-rim) 0%, rgba(255, 255, 255, 0.12) 28%, rgba(255, 255, 255, 0) 50%,
    rgba(255, 255, 255, 0.1) 72%, var(--glass-rim) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none; z-index: 1;
}
/* Sheen: a soft light that follows the pointer on desktop */
.glass::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1; pointer-events: none;
  background: radial-gradient(70% 55% at var(--mx, 18%) var(--my, 0%), var(--glass-sheen), transparent 70%);
}

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
/* Headings focused by script (to move screen readers to a new view) are not controls: no ring */
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  padding: 10px 16px; border-radius: 12px; background: var(--surface); color: var(--accent-text);
  text-decoration: none; font-weight: 600;
}
.skip:focus { top: 12px; }
.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: 0; }

/* ============ Floating glass toolbar ============ */
/* Scroll edge: content fades as it slides under the bar */
.bar::before {
  content: ""; position: absolute; inset: 0 0 -18px 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 70%, transparent) 55%, transparent 100%);
}
.bar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(10px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
}
.bar-inner {
  max-width: 1080px; margin: 0 auto;
  min-height: 54px; padding: 0 10px 0 12px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; flex: none;
  min-height: 44px; padding-right: 6px; color: var(--label); text-decoration: none;
  font-family: var(--font-display); font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.03em;
}
/* Brand mark: your illustration as an app-icon style rounded square */
.brand-mark {
  flex: none; width: 36px; height: 36px; border-radius: 10px; object-fit: cover;
  box-shadow: 0 0 0 0.5px rgba(30, 70, 58, 0.2), 0 3px 10px rgba(40, 90, 75, 0.22);
}
@media (prefers-color-scheme: dark) { .brand-mark { box-shadow: 0 0 0 0.5px rgba(225, 250, 240, 0.25), 0 3px 10px rgba(0, 0, 0, 0.35); } }

/* ============ Layout ============ */
main {
  max-width: 1080px; margin: 0 auto;
  --gutter-l: max(20px, env(safe-area-inset-left)); --gutter-r: max(20px, env(safe-area-inset-right));
  padding: 0 var(--gutter-r) 24px var(--gutter-l);
}
.columns, .batch { max-width: 640px; margin: 0 auto; }
.columns { display: grid; gap: 20px; }
/* Wide screens: the code generator and the key generator side by side */
@media (min-width: 1000px) {
  body[data-tab="code"] .columns { max-width: 1080px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  body[data-tab="code"] .foot { max-width: 1080px; }
}

/* ============ Views: one function at a time ============ */
/* A view that is not shown keeps its style, layout and shaped text (content-visibility: hidden)
   instead of being torn down by display: none, so switching back is close to free. It is taken out
   of the flow at the width it has in the flow, so nothing inside needs laying out again. */
main, .columns { position: relative; }
body:not([data-tab="code"]) [data-view="code"],
body:not([data-tab="saved"]) [data-view="saved"],
body:not([data-tab="batch"]) [data-view="batch"] {
  position: absolute; top: 0; left: 0; right: 0;
  content-visibility: hidden; opacity: 0;
  block-size: 0; padding-block: 0; border-block-width: 0; overflow: clip; animation: none;
}
/* main's direct children sit inside its gutters */
body:not([data-tab="code"]) main > [data-view="code"],
body:not([data-tab="batch"]) main > [data-view="batch"] { left: var(--gutter-l); right: var(--gutter-r); }
body:not([data-tab="code"]) main { padding-top: 26px; }
[data-view] { animation: view-in 0.35s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ Bottom tab bar (floating glass capsule) ============ */
.tabbar {
  position: fixed; z-index: 30;
  left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: min(420px, calc(100% - 32px));
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 6px; border-radius: 999px;
  --glass-a: rgba(255, 255, 255, 0.74);
  --glass-b: rgba(247, 253, 250, 0.6);
}
@media (prefers-color-scheme: dark) {
  .tabbar { --glass-a: rgba(44, 58, 53, 0.8); --glass-b: rgba(26, 35, 32, 0.7); }
}
/* Scroll edge: content fades out as it reaches the tab bar */
body::after {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; pointer-events: none;
  height: calc(110px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent 0%, color-mix(in srgb, var(--bg) 75%, transparent) 55%, var(--bg) 100%);
}
.tab {
  position: relative; z-index: 2;
  display: grid; justify-items: center; align-content: center; gap: 1px;
  min-height: 54px; border-radius: 999px;
  color: var(--label-2); text-decoration: none;
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0;
  transition: transform 0.25s var(--spring);
  -webkit-tap-highlight-color: transparent;
}
.tab svg { width: 26px; height: 26px; }
.tab .f { fill: currentColor; }
.tab .s { fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; }
.tab .d { fill: var(--surface); }
.tab:hover { color: var(--label); }
.tab:active { transform: scale(0.95); }
.tab[aria-current="page"] { color: var(--label); }
@media (prefers-color-scheme: dark) { .tab .d { fill: #1e2825; } }
/* Selection: one glass droplet that glides between tabs on a spring (outer layer, CSS transition)
   and stretches as it goes (inner layer, a one-shot Web Animation). Transform only, so it runs
   on the compositor. */
.tab-pill {
  position: absolute; z-index: 1; top: 6px; bottom: 6px; left: 6px;
  width: calc((100% - 20px) / 3);
  transform: translate3d(calc(var(--i, 0) * (100% + 4px)), 0, 0);
  transition: transform 0.55s var(--spring-soft);
  pointer-events: none;
}
.tabbar:not([data-ready]) .tab-pill { transition: none; }
.tab-pill i {
  position: absolute; inset: 0; border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.58));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    inset 0 -1px 1px rgba(255, 255, 255, 0.5),
    inset 0 0 0 0.5px rgba(30, 70, 58, 0.08),
    0 2px 8px rgba(30, 70, 58, 0.1);
}
@media (prefers-color-scheme: dark) {
  .tab-pill i {
    background: linear-gradient(180deg, rgba(225, 250, 240, 0.17), rgba(225, 250, 240, 0.09));
    box-shadow: inset 0 1px 0 rgba(225, 250, 240, 0.22), inset 0 0 0 0.5px rgba(225, 250, 240, 0.08), 0 2px 8px rgba(0, 0, 0, 0.25);
  }
}
.tab-badge {
  position: absolute; top: 5px; left: calc(50% + 9px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 0.6875rem; font-weight: 700; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
}

.card { border-radius: var(--radius); padding: 26px; }
@media (max-width: 480px) { .card { padding: 20px 18px; border-radius: 24px; } }

/* ============ The sign ============ */
.hero { display: grid; justify-items: center; text-align: center; padding: 60px 4px 46px; }
.sign { display: grid; justify-items: center; gap: 18px; }
.sign-icon {
  width: clamp(80px, 14vw, 100px); height: auto; aspect-ratio: 1; border-radius: 22.5%; object-fit: cover;
  box-shadow: 0 0 0 0.5px rgba(30, 70, 58, 0.18), 0 18px 40px rgba(40, 90, 75, 0.28), 0 4px 12px rgba(40, 90, 75, 0.18);
}
@media (prefers-color-scheme: dark) {
  .sign-icon { box-shadow: 0 0 0 0.5px rgba(225, 250, 240, 0.22), 0 18px 40px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3); }
}
.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 13vw, 6.5rem);
  font-weight: 800; line-height: 0.95; letter-spacing: -0.055em;
}
.wm-name { color: var(--label); }
.wm-mark {
  margin-left: 0.02em; padding-right: 0.04em;
  color: var(--accent);
  background: linear-gradient(120deg, #eb9a6f 0%, #d97757 45%, #b4502f 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
@media (prefers-contrast: more) {
  .wm-mark { background: none; -webkit-text-fill-color: currentColor; color: var(--accent-text); }
}
.tagline { margin: 22px 0 0; font-size: clamp(1.5rem, 4.2vw, 2.25rem); font-weight: 700; line-height: 1.15; letter-spacing: -0.03em; }
.lede { margin: 12px auto 0; font-size: clamp(1.0625rem, 2.2vw, 1.25rem); line-height: 1.45; color: var(--label-2); max-width: 30em; }
.traits { list-style: none; margin: 24px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.traits li {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: 999px;
  background: var(--well); color: var(--label-2);
  box-shadow: inset 0 1px 0 var(--glass-rim), 0 2px 8px rgba(40, 90, 75, 0.06);
  font-size: 0.8125rem; font-weight: 500;
}
.traits li::before { /* a small check: each pill is a promise the page keeps */
  content: ""; flex: none; width: 4px; height: 8px; margin: -2px 1px 0 0;
  border: solid var(--accent-text); border-width: 0 1.75px 1.75px 0; transform: rotate(45deg);
}
.br-narrow { display: none; }
@media (max-width: 420px) { .br-narrow { display: inline; } }

/* ============ Section text ============ */
.section-title { margin: 0 0 16px; font-family: var(--font-display); font-size: 1.375rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; }
.section-sub { margin: -8px 0 16px; color: var(--label-2); font-size: 0.9375rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head .section-title { margin: 0; }

/* Wells: recessed surfaces inside glass (no second blur) */
.field, .search, .batch textarea, .stage, .select select {
  background-color: var(--well);
  box-shadow: inset 0 1px 2px rgba(30, 70, 58, 0.08), inset 0 0 0 0.5px rgba(30, 70, 58, 0.1);
}
@media (prefers-color-scheme: dark) {
  .field, .search, .batch textarea, .stage, .select select {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3), inset 0 0 0 0.5px rgba(215, 245, 232, 0.08);
  }
}

/* Text field */
.field-label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--label-2); margin: 0 0 8px 4px; }
.field {
  display: flex; align-items: center; gap: 4px;
  border-radius: var(--radius-sm); padding: 0 6px 0 14px;
  transition: box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
.field:focus-within { background-color: var(--well-strong); box-shadow: 0 0 0 3px var(--accent-tint), 0 0 0 1px var(--accent); }
.field[data-invalid] { box-shadow: 0 0 0 1px var(--red); }
.field input {
  flex: 1; min-width: 0; min-height: 50px; border: 0; background: transparent; outline: none;
  font-family: var(--font-mono); font-size: 1rem; letter-spacing: 0.02em;
}
.field input::placeholder { color: var(--label-3); font-family: var(--font); letter-spacing: -0.01em; }
.field-btn {
  position: relative; flex: none; display: grid; place-items: center;
  min-width: 36px; min-height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--label-3);
}
.field-btn::after { content: ""; position: absolute; inset: -4px -2px; } /* 44px touch target around the 36px button */
.field-btn svg { width: 18px; height: 18px; }
.field-btn svg circle { fill: currentColor; }
.field-btn svg path { stroke: var(--surface); stroke-width: 1.8; stroke-linecap: round; fill: none; }
.field-btn-text { padding: 0 12px; color: var(--accent-text); font-weight: 600; font-size: 0.9375rem; border-radius: 999px; }
.field-btn-text:hover { background: var(--accent-tint); }
.field-msg { min-height: 1.35em; margin: 8px 4px 0; font-size: 0.8125rem; color: var(--label-2); }
.field-msg[data-tone="error"] { color: var(--red); }
.field-msg[data-tone="ok"] { color: var(--green); }

/* ============ The code ============ */
.stage {
  display: grid; justify-items: center; gap: 6px;
  margin: 12px 0 20px; padding: 28px 12px 22px; border-radius: 22px;
}
.ring { position: relative; width: 48px; height: 48px; margin-bottom: 4px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.5; }
.ring-track { stroke: var(--fill-2); }
/* Countdown arc, drawn without repainting: two half-rings rotate inside clipping halves and two
   dots make the round ends. Every moving part is a transform, so the sweep is continuous and runs
   on the compositor; the main thread only touches it once per period to keep it in sync. */
.arc { position: absolute; inset: 0; --sw: 4px; --in: 1px; /* ¼px wider than the track each side, so its edge never peeks */ color: var(--ring-ok); }
/* (no colour transition: the arcs change colour at the period roll on every row at once, and a fade
   would repaint each of their layers every frame; the sweep restarting already marks the moment) */
.arc .half { position: absolute; top: 0; bottom: 0; width: 50%; overflow: hidden; }
.arc .r { left: 50%; }
.arc .l { left: 0; }
.arc i { position: absolute; top: 0; width: 200%; height: 100%; will-change: transform; }
.arc .r i { left: -100%; }
.arc .l i { left: 0; }
.arc i::before {
  content: ""; position: absolute; inset: var(--in); border-radius: 50%;
  border: var(--sw) solid transparent; transform: rotate(45deg);
}
.arc .r i::before { border-top-color: currentColor; border-right-color: currentColor; }
.arc .l i::before { border-bottom-color: currentColor; border-left-color: currentColor; }
.arc b { position: absolute; inset: 0; }
.arc b.end { will-change: transform; }
.arc b::before {
  content: ""; position: absolute; left: calc(50% - var(--sw) / 2); top: var(--in);
  width: var(--sw); height: var(--sw); border-radius: 50%; background: currentColor;
}
.ring-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--label-2);
}
.stage[data-urgency="warn"] .arc { color: var(--ring-warn); }
.stage[data-urgency="hot"] .arc { color: var(--ring-hot); }
.stage[data-urgency="hot"] .ring-num { color: var(--red); }

.code {
  border: 0; background: transparent; padding: 4px 18px; border-radius: 16px;
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 13vw, 4.25rem);
  font-weight: 600; line-height: 1.1; letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums; color: var(--label);
  transition: background 0.2s var(--ease), transform 0.2s var(--spring);
}
.code:not(:disabled):hover { background: var(--well-strong); }
.code:not(:disabled):active { transform: scale(0.97); }
.code:disabled { color: var(--label-3); }
.code span { display: inline-block; }
.next { margin: 0; font-size: 0.875rem; color: var(--label-2); }
.next .mono { font-variant-numeric: tabular-nums; }
.next-label { margin-right: 4px; }
.stage[data-state="empty"] .next { visibility: hidden; }
/* Landing cue after a scan: an accent rim that breathes once (opacity only) and the code settling in */
.stage { position: relative; }
.stage::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 28px var(--accent-tint);
  opacity: 0;
}
.stage.arrive::after { animation: arrive-rim 1.1s var(--ease); }
.stage.arrive .code { animation: arrive-code 0.7s cubic-bezier(0.32, 1.25, 0.5, 1); } /* (a Bézier: runs on the compositor in Safari too) */
@keyframes arrive-rim { 0% { opacity: 0; } 22% { opacity: 1; } 100% { opacity: 0; } }
@keyframes arrive-code { from { transform: scale(0.92); } to { transform: none; } }

/* ============ Glass buttons ============ */
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  position: relative; overflow: hidden;
  flex: 1 1 140px; min-height: 50px; padding: 0 22px;
  border: 0; border-radius: 999px;
  font-size: 1.0625rem; font-weight: 600;
  transition: filter 0.15s var(--ease), transform 0.25s var(--spring), opacity 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.btn::after { /* liquid highlight across the top half */
  content: ""; position: absolute; left: 8%; right: 8%; top: 1px; height: 48%;
  border-radius: 999px; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0));
  opacity: 0.7;
}
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn:not(:disabled):active { transform: scale(0.97); }
.btn:disabled { opacity: 0.42; }
.btn-prominent {
  color: #fff;
  background: linear-gradient(180deg, var(--accent-fill-hi), var(--accent-fill));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 8px 20px rgba(180, 80, 47, 0.3);
}
.btn-prominent:not(:disabled):hover { filter: brightness(1.05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 12px 26px rgba(180, 80, 47, 0.36); }
.btn-tinted {
  color: var(--accent-text);
  background: var(--well-strong);
  box-shadow: inset 0 1px 0 var(--glass-rim), inset 0 0 0 0.5px rgba(30, 70, 58, 0.1), 0 4px 14px rgba(40, 90, 75, 0.08);
}
@media (prefers-color-scheme: dark) {
  .btn-tinted { background: rgba(215, 245, 232, 0.1); box-shadow: inset 0 1px 0 rgba(225, 250, 240, 0.2), 0 4px 14px rgba(0, 0, 0, 0.2); }
  .btn-tinted:not(:disabled):active { box-shadow: inset 0 1px 0 rgba(225, 250, 240, 0.24), inset 0 0 18px rgba(225, 250, 240, 0.12), 0 2px 8px rgba(0, 0, 0, 0.2); }
  .btn::after { opacity: 0.32; }
  .btn-tinted::after { opacity: 0.12; }
}
.btn-tinted:not(:disabled):hover { filter: brightness(1.03); }
.btn-tinted:not(:disabled):active { box-shadow: inset 0 1px 0 var(--glass-rim), inset 0 0 18px rgba(255, 255, 255, 0.6), 0 2px 8px rgba(40, 90, 75, 0.08); }
.btn[data-done] { background: linear-gradient(180deg, #4fbf68, #2e9a48); color: #fff; }

.text-btn {
  min-height: 44px; padding: 0 12px; border: 0; background: transparent;
  color: var(--accent-text); font-size: 1.0625rem; border-radius: 999px;
}
.text-btn:hover { background: var(--accent-tint); }
.text-btn-strong { font-weight: 600; }

/* Advanced disclosure */
.advanced { margin-top: 18px; border-top: 0.5px solid var(--separator); padding-top: 6px; }
.advanced summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between;
  min-height: 44px; cursor: pointer; color: var(--label); font-size: 0.9375rem; font-weight: 500; border-radius: 10px;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary svg { width: 12px; height: 12px; fill: none; stroke: var(--label-3); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.25s var(--spring); }
.advanced[open] summary svg { transform: rotate(90deg); }
.adv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 6px; }
.select { display: grid; gap: 6px; font-size: 0.8125rem; color: var(--label-2); font-weight: 600; }
.select select {
  min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px;
  color: var(--label); font-size: 0.9375rem; font-weight: 400;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5 9 4.5' fill='none' stroke='%238d887f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
}
.footnote { margin: 12px 4px 0; font-size: 0.8125rem; color: var(--label-2); line-height: 1.45; }

/* Search */
.search { display: flex; align-items: center; gap: 6px; border-radius: 12px; padding: 0 12px; margin-bottom: 8px; }
.search svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--label-3); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; min-height: 42px; border: 0; background: transparent; outline: none; font-size: 1rem; }
.search input::placeholder { color: var(--label-3); }

/* ============ Lists ============ */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; border-top: 0.5px solid var(--separator); }
.row-main {
  flex: 1; min-width: 0; min-height: 64px;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 0 -12px; border: 0; background: transparent; text-align: left;
  border-radius: 16px;
  transition: background 0.15s var(--ease), transform 0.2s var(--spring);
}
.row-main:hover { background: var(--well); }
.row-main:active { background: var(--well-strong); transform: scale(0.99); }
.row-text { flex: 1; min-width: 0; display: grid; }
.row-title { font-weight: 600; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 0.8125rem; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-code { flex: none; font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; letter-spacing: 0.03em; font-variant-numeric: tabular-nums; color: var(--label); }
.row-code[data-error] { font-size: 0.875rem; font-weight: 500; color: var(--red); letter-spacing: 0; }
.row-ring { flex: none; position: relative; width: 22px; height: 22px; }
.row-ring svg { display: block; width: 100%; height: 100%; }
.row-ring circle { fill: none; stroke-width: 3.2; }
.row-ring .t { stroke: var(--fill-2); }
.row-ring .arc { --sw: 3.7px; --in: 0.15px; }
.row-ring[data-urgency="warn"] .arc { color: var(--ring-warn); }
.row-ring[data-urgency="hot"] .arc { color: var(--ring-hot); }
.row-del {
  flex: none; min-height: 40px; margin-left: 8px; padding: 0 16px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #e0574a, #c0392b); color: #fff; font-weight: 600; font-size: 0.9375rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.row-copied .row-code { color: var(--green); }

.empty { display: grid; justify-items: center; text-align: center; padding: 28px 12px 20px; }
.empty svg { width: 48px; height: 48px; fill: none; stroke: var(--label-3); stroke-width: 2.2; stroke-linecap: round; margin-bottom: 10px; }
.empty-title { margin: 0; font-weight: 600; }
.empty-sub { margin: 4px 0 0; color: var(--label-2); font-size: 0.9375rem; max-width: 22em; }

/* ============ Key generator ============ */
.generator { scroll-margin-top: 84px; }
.keygen .field + .field-label { margin-top: 14px; }
#kgAccount, #kgIssuer { font-family: var(--font); letter-spacing: -0.01em; }
.kg-actions { margin-top: 18px; }
.kg-out {
  display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 18px 20px; align-items: center;
  margin-top: 6px; padding-top: 18px; border-top: 0.5px solid var(--separator);
  animation: view-in 0.35s var(--ease);
}
.kg-qr svg {
  display: block; width: 168px; height: 168px; border-radius: 16px;
  box-shadow: 0 0 0 0.5px rgba(30, 70, 58, 0.14), 0 8px 24px rgba(40, 90, 75, 0.14);
}
.kg-info { min-width: 0; }
.kg-info .field-label { margin-left: 2px; }
.kg-secret {
  display: block; width: 100%; margin: 0 0 14px; padding: 12px 14px; border: 0; border-radius: var(--radius-sm);
  background: var(--well-strong); text-align: left; word-break: break-all;
  font-family: var(--font-mono); font-size: 1.0625rem; font-weight: 600; letter-spacing: 0.04em; line-height: 1.5;
  box-shadow: inset 0 1px 0 var(--glass-rim), inset 0 0 0 0.5px rgba(30, 70, 58, 0.1);
  transition: transform 0.2s var(--spring), background 0.15s var(--ease);
}
.kg-secret:active { transform: scale(0.98); }
.kg-info .actions { gap: 10px; }
.kg-info .btn { flex-basis: 120px; min-height: 44px; font-size: 0.9375rem; padding: 0 14px; }
.kg-note { grid-column: 1 / -1; margin: 0; }
@media (prefers-color-scheme: dark) {
  .kg-secret { background: rgba(0, 0, 0, 0.28); box-shadow: inset 0 0 0 0.5px rgba(215, 245, 232, 0.1); }
  .kg-qr svg { box-shadow: 0 0 0 0.5px rgba(225, 250, 240, 0.2), 0 8px 24px rgba(0, 0, 0, 0.35); }
}
@media (max-width: 480px) {
  .kg-out { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .kg-info { width: 100%; }
}

/* ============ Batch ============ */
.batch textarea {
  display: block; width: 100%; resize: vertical; min-height: 128px;
  padding: 12px 14px; margin-bottom: 14px; border: 0; border-radius: var(--radius-sm); outline: none;
  font-family: var(--font-mono); font-size: 0.9375rem; line-height: 1.55; letter-spacing: 0;
  transition: box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
.batch textarea::placeholder { color: var(--label-3); }
.batch textarea:focus { background-color: var(--well-strong); box-shadow: 0 0 0 3px var(--accent-tint), 0 0 0 1px var(--accent); }
.batch .actions { max-width: 440px; }
#batchOut:not(:empty) { margin-top: 4px; }
#batchOut .row-sub { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0; }

/* ============ Footer ============ */
.foot {
  max-width: 640px; margin: 28px auto 0; padding: 28px 24px calc(120px + env(safe-area-inset-bottom));
  border-top: 0.5px solid var(--separator);
  font-size: 0.8125rem; color: var(--label-2);
}
.foot p { margin: 6px 0; max-width: 60em; }
.foot strong { color: var(--label); font-weight: 600; }
.foot-welcome { font-size: 1.0625rem; color: var(--label-2); }
.foot-sign { margin: 0 0 12px !important; font-family: var(--font-display); font-size: 1.375rem; font-weight: 800; letter-spacing: -0.045em; }

/* ============ Toast (glass capsule) ============ */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 40;
  /* (left: 50% alone would leave it half the screen to lay out in, wrapping longer messages) */
  width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 10px;
  min-height: 50px; padding: 0 8px 0 18px; border-radius: 999px;
  background: rgba(24, 38, 34, 0.74); color: #fff;
  -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 14px 34px rgba(0, 0, 0, 0.22);
  font-size: 0.9375rem; font-weight: 500;
  transform: translate(-50%, 0); transition: opacity 0.25s var(--ease), transform 0.35s var(--spring);
}
.toast:not(:has(.toast-action:not([hidden]))) { padding-right: 20px; }
.toast[hidden] { display: flex; opacity: 0; transform: translate(-50%, 14px) scale(0.96); pointer-events: none; }
.toast svg { width: 18px; height: 18px; fill: none; stroke: #5fd07a; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.toast-action { min-height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 600; font-size: 0.9375rem; }

/* ============ Sheets: float in on a soft spring, sink away when closed ============ */
.sheet {
  position: fixed; /* .glass sets relative; dialogs must stay fixed */
  width: min(440px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: 28px; color: var(--label);
  transition: opacity 0.32s var(--ease), transform 0.6s var(--spring-soft);
  --glass-a: rgba(248, 253, 251, 0.84);
  --glass-b: rgba(244, 251, 248, 0.72);
}
@media (prefers-color-scheme: dark) { .sheet { --glass-a: rgba(36, 48, 44, 0.86); --glass-b: rgba(28, 38, 35, 0.8); } }
.sheet::backdrop { background: rgba(15, 35, 30, 0.28); transition: background-color 0.35s var(--ease); }
.sheet form { position: relative; z-index: 2; padding: 8px 16px 20px; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 1.0625rem; font-weight: 600; }
.sheet-head .text-btn:first-child { justify-self: start; }
.sheet-head .text-btn:last-child { justify-self: end; }
.group { background: var(--well-strong); border-radius: 16px; overflow: hidden; box-shadow: inset 0 0 0 0.5px rgba(30, 70, 58, 0.1); }
.group-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; position: relative; }
.group-row + .group-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--separator); }
.group-row span { width: 3.2em; flex: none; }
.group-row input { flex: 1; min-width: 0; min-height: 46px; border: 0; background: transparent; outline: none; font-size: 1rem; }
.group-row input::placeholder { color: var(--label-3); }
@starting-style {
  .sheet[open] { opacity: 0; transform: translateY(18px) scale(0.96); }
  .sheet[open]::backdrop { background-color: transparent; }
}
.sheet[data-closing] {
  opacity: 0; transform: translateY(14px) scale(0.975);
  transition: opacity 0.24s var(--ease), transform 0.26s var(--ease);
}
.sheet[data-closing]::backdrop { background-color: transparent; }
@media (max-width: 560px) {
  .sheet { margin: auto auto 8px; width: calc(100% - 16px); max-width: 100%; border-radius: 32px; padding-bottom: env(safe-area-inset-bottom); }
  @starting-style { .sheet[open] { transform: translateY(48px); } }
  .sheet[data-closing] { transform: translateY(40px); }
}

/* ============ Quick actions: scan / image ============ */
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip-btn {
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px;
  background: var(--well); color: var(--label);
  box-shadow: inset 0 1px 0 var(--glass-rim), inset 0 0 0 0.5px rgba(30, 70, 58, 0.1);
  font-size: 0.875rem; font-weight: 500;
  transition: transform 0.2s var(--spring);
  /* Own layer: pressing scales it on the compositor instead of repainting the page around it
     (that repaint used to land in the very frames the scanner starts to slide in). */
  will-change: transform;
}
/* Press/hover light: painted once, only its opacity changes */
.chip-btn::after { content: ""; position: absolute; inset: -2px 0; } /* 44px touch target around the 40px chip */
.chip-btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: var(--well-strong);
  box-shadow: inset 0 1px 0 var(--glass-rim), inset 0 0 14px rgba(255, 255, 255, 0.55);
  opacity: 0; transition: opacity 0.15s var(--ease); will-change: opacity;
}
.chip-btn svg { width: 17px; height: 17px; fill: none; stroke: var(--accent-text); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .chip-btn:hover::before { opacity: 0.6; } }
.chip-btn:active::before { opacity: 1; }
.chip-btn:active { transform: scale(0.96); }
@media (prefers-color-scheme: dark) {
  .chip-btn { box-shadow: inset 0 1px 0 rgba(225, 250, 240, 0.12); }
  .chip-btn::before { box-shadow: inset 0 1px 0 rgba(225, 250, 240, 0.18), inset 0 0 14px rgba(225, 250, 240, 0.12); }
}
.generator[data-drop] { outline: 2px dashed var(--accent); outline-offset: -8px; }

/* ============ Toolbar extras ============ */
.bar-end { display: flex; align-items: center; gap: 8px; min-width: 0; }
.install-btn {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  min-height: 34px; padding: 0 12px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 4px 10px rgba(180, 80, 47, 0.25);
  font-size: 0.8125rem; font-weight: 600;
}
.install-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ============ Saved list extras ============ */
.avatar {
  flex: none; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--av) 78%, #fff), var(--av));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 6px color-mix(in srgb, var(--av) 35%, transparent);
  color: #fff; font-weight: 700; font-size: 1.0625rem; letter-spacing: 0;
}
/* Service icon: the brand's glyph on a tile of its colour, lit like the rest of the glass */
.avatar[data-ink="dark"] { color: #1c1c1e; }
.avatar svg { width: 58%; height: 58%; fill: currentColor; }
.avatar[data-wide] { font-size: 0.875rem; letter-spacing: -0.02em; }
.avatar-plain { background: var(--fill-2); color: var(--label-2); box-shadow: inset 0 1px 0 var(--glass-rim), inset 0 0 0 0.5px rgba(30, 70, 58, 0.08); }
.avatar-plain svg { width: 50%; height: 50%; }
.avatar-xs {
  display: inline-grid; vertical-align: -5px; margin-right: 7px;
  width: 20px; height: 20px; border-radius: 6px; font-size: 0.6875rem;
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.35), 0 1px 3px color-mix(in srgb, var(--av) 30%, transparent);
}
@media (prefers-color-scheme: dark) {
  /* Near-black brands (GitHub, X, Apple…) still read as tiles on the dark page */
  .avatar { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 2px 6px rgba(0, 0, 0, 0.3); }
  .avatar-plain { box-shadow: inset 0 1px 0 rgba(225, 250, 240, 0.14); }
}
.saved-tools { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px -8px -6px; padding-top: 8px; border-top: 0.5px solid var(--separator); }
.saved-tools .text-btn { font-size: 0.9375rem; }
.saved-tools .text-btn:disabled { color: var(--label-3); background: transparent; }

/* ============ Scanner: an instant camera ============
   A clay camera body with a black lens. Opening on a phone, the body grows out of the scan button;
   the lens springs up into place and, once the camera is live, an iris opens over the picture. A
   caught code blinks the iris shut and the result is printed out of the slot under the lens (see
   app.js). Every moving part is a transform or an opacity with an easing Core Animation can run,
   so on an iPhone it all runs off the main thread at the display's full refresh rate. */
:root { --pw: 212px; } /* the print's width: room to come all the way out above the keys */
@media (min-width: 400px) and (min-height: 760px) { :root { --pw: 236px; } }
@media (max-height: 620px) { :root { --pw: 184px; } }
.scan-sheet {
  --body-a: #d97650;
  --body-b: #b4512e;
  /* Springs as cubic Béziers in here: Safari cannot run a linear() easing on the compositor */
  --spring-soft: cubic-bezier(0.25, 0.9, 0.3, 1);
  --spring-bouncy: cubic-bezier(0.32, 1.25, 0.5, 1);
  /* Phone browsers let the page show through below the dynamic viewport, under a translucent
     toolbar (iOS 26 Safari's floating bar). The body runs on under it by --under, so nothing of the
     page peeks out there. */
  --under: 140px;
  /* The lens: as wide as the screen allows (392pt on an iPhone 17 Pro Max, 440pt wide) while the
     slot and the controls keep their room below it. Clear of the status bar and the Dynamic Island
     at the top, and of the home indicator at the bottom. */
  --top: calc(env(safe-area-inset-top) + 14px);
  --Wo: clamp(220px, min(100vw - 48px, 100dvh - var(--top) - env(safe-area-inset-bottom) - 238px), 400px);
  --B: 11px; /* bezel */
  --Ro: calc(var(--Wo) * 0.13);
  --V: calc(var(--Wo) - 2 * var(--B)); /* the picture */
  --slot-y: calc(var(--top) + var(--Wo) + 16px);
  /* The body's size, for its picture, and its corner radius at rest: round only where the page
     runs up to the screen's own (round) top corners, under the status bar */
  --skin-w: 100vw;
  --skin-h: calc(100dvh + var(--under));
  --R: min(40px, calc(env(safe-area-inset-top) * 1000));
  --Rc: max(var(--R), 34px); /* the corners' drawn radius: they only ever shrink, so stay sharp */
  position: fixed; inset: 0; width: 100%;
  height: calc(100vh + var(--under)); height: calc(100dvh + var(--under));
  max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0;
  background: none;
  color: #fff; overflow: hidden;
  -webkit-font-smoothing: antialiased;
  /* Opened as a plain (non-modal) dialog (see presentScanner): its own stacking, a scrim instead of
     ::backdrop, and layout/paint containment so opening it never relayouts the page. */
  z-index: 100; transition: none; will-change: opacity, transform; contain: strict;
  touch-action: none; overscroll-behavior: contain;
}
@media (prefers-color-scheme: dark) { .scan-sheet { --body-a: #b55c3a; --body-b: #84381e; } }
/* The body itself (see index.html): four round corners, two narrow sides and a middle column over
   them, laid out inside the body as if its corners were --Rc round, each showing its own part of
   one picture of the body (clay, moulded-plastic grain), so at rest they read as one. app.js moves
   and scales them into a rounded rectangle of any size, so each part's picture is squeezed by its
   own amount on the way: the clay is shaded only between 22% and 80% of the way down (the corners
   never reach in there while it matters), and the light on its top falls only on the middle
   column. The column runs 1.5px over the sides, so no seam opens between them. (The radius
   here only tells app.js the body's own corner radius at rest.) */
.skin { position: absolute; inset: 0; pointer-events: none; border-top-left-radius: var(--R); }
.skin i {
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .048 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 180px 180px;
  --clay: linear-gradient(180deg, var(--body-a) 22%, var(--body-b) 80%) 0 0 / var(--skin-w) var(--skin-h) no-repeat;
  position: absolute;
  background: var(--grain), var(--clay);
  background-position: var(--bx) var(--by);
  will-change: transform;
}
.skin .sk-m {
  top: 0; bottom: 0; left: calc(var(--Rc) - 1.5px); right: calc(var(--Rc) - 1.5px); --bx: calc(1.5px - var(--Rc)); --by: 0px;
  background: var(--grain), radial-gradient(calc(var(--skin-w) / 2 - var(--Rc)) 58% at 50% 0%, rgba(255, 236, 214, 0.24), rgba(255, 236, 214, 0)) 0 0 / var(--skin-w) var(--skin-h) no-repeat, var(--clay);
  background-position: var(--bx) var(--by);
}
.sk-l, .sk-r { top: var(--Rc); bottom: var(--Rc); width: var(--Rc); --by: calc(-1 * var(--Rc)); }
.sk-l { left: 0; --bx: 0px; }
.sk-r { right: 0; --bx: calc(var(--Rc) - var(--skin-w)); }
.sk-c { width: calc(2 * var(--Rc)); height: calc(2 * var(--Rc)); border-radius: 50%; }
.sk-c.tl { left: 0; top: 0; --bx: 0px; --by: 0px; }
.sk-c.tr { right: 0; top: 0; --bx: calc(2 * var(--Rc) - var(--skin-w)); --by: 0px; }
.sk-c.bl { left: 0; bottom: 0; --bx: 0px; --by: calc(2 * var(--Rc) - var(--skin-h)); }
.sk-c.br { right: 0; bottom: 0; --bx: calc(2 * var(--Rc) - var(--skin-w)); --by: calc(2 * var(--Rc) - var(--skin-h)); }
/* Kept laid out and painted while closed (transparent, inert, unclickable), so opening it is
   compositor-only from the very first frame. */
.scan-sheet:not([open]) { display: block; pointer-events: none; opacity: 0; }
.scan-scrim {
  position: fixed; inset: 0 0 -140px; z-index: 99; background: rgba(0, 0, 0, 0.5);
  opacity: 0; pointer-events: none; will-change: opacity; touch-action: none;
}
.scan-scrim[data-on] { opacity: 1; pointer-events: auto; }
@media (min-width: 561px) {
  /* Wider screens: the camera is a device on the table, over the dimmed page */
  .scan-sheet {
    --under: 0px; --top: 20px;
    --Wo: clamp(220px, calc(100dvh - 48px - 20px - 252px), 336px);
    --skin-w: 400px; --skin-h: min(720px, calc(100dvh - 48px)); --R: 0px; /* (the card's own corners clip it) */
    inset: 0; margin: auto; width: 400px; height: min(720px, calc(100dvh - 48px));
    border-radius: 46px;
    box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.25), 0 40px 100px rgba(0, 0, 0, 0.45);
  }
  /* The lit top edge, over the body's pieces */
  .scan-sheet::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28); pointer-events: none; }
  .scan-scrim { background: rgba(10, 22, 18, 0.45); }
  .scan-scrim[data-on] { -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
}
/* While the scanner is up the page behind stops moving; once covered it is not drawn at all */
html.scan-open .blob { animation-play-state: paused; }
html.scan-covered body > :not(dialog, .scan-scrim, .print) { visibility: hidden; }

/* The lens: a black window moulded into the body (a dark rim above, a lit lip below) */
.lens {
  position: absolute; z-index: 2; left: 50%; top: var(--top);
  width: var(--Wo); height: var(--Wo); margin-left: calc(var(--Wo) / -2);
  border-radius: var(--Ro); background: #060606;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 -1px 0 rgba(70, 20, 4, 0.3), 0 1.5px 0 rgba(255, 236, 214, 0.3), 0 14px 30px rgba(90, 25, 0, 0.22);
  pointer-events: none; will-change: transform, opacity;
}
.vf {
  position: absolute; inset: var(--B);
  border-radius: calc(var(--Ro) - var(--B)); overflow: hidden; background: #000;
}
.vf video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  /* The picture comes up a touch zoomed in and settles as the iris opens over it (no blur: a filter
     on live video costs every frame on a phone) */
  opacity: 0; transform: scale(1.08);
  transition: opacity 0.35s var(--ease), transform 0.9s var(--spring-soft);
}
.vf:is([data-state="scanning"], [data-state="found"]) video { opacity: 1; transform: none; }

/* The reticle: four corners that breathe while looking, then lock onto the code (app.js) in yellow */
.aim {
  position: absolute; left: 50%; top: 50%;
  width: calc(var(--V) * 0.6); height: calc(var(--V) * 0.6);
  margin: calc(var(--V) * -0.3) 0 0 calc(var(--V) * -0.3);
  opacity: 0; transition: opacity 0.45s var(--ease);
}
.vf:is([data-state="scanning"], [data-state="found"]) .aim { opacity: 1; }
.vf[data-state="scanning"] .aim { animation: aim-breathe 1.6s var(--ease) 0.5s infinite alternate; }
@keyframes aim-breathe { to { transform: scale(0.955); } }
.aim i {
  position: absolute; width: 26px; height: 26px;
  border: 0 solid rgba(255, 255, 255, 0.95);
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.45));
  transition: border-color 0.2s var(--ease);
}
.aim .tl { left: 0; top: 0; border-width: 3px 0 0 3px; border-top-left-radius: 11px; }
.aim .tr { right: 0; top: 0; border-width: 3px 3px 0 0; border-top-right-radius: 11px; }
.aim .bl { left: 0; bottom: 0; border-width: 0 0 3px 3px; border-bottom-left-radius: 11px; }
.aim .br { right: 0; bottom: 0; border-width: 0 3px 3px 0; border-bottom-right-radius: 11px; }
.vf[data-state="found"] .aim i { border-color: #ffd60a; }

/* The iris: six blades, each in two halves pivoting on the centre of the picture. The left halves
   lie over the right ones, so round the aperture every blade overlaps the next, as in a real lens.
   Closed (as here) the blades meet just past the centre; app.js slides each out by its own height,
   clear of the picture, while the ring turns. */
.iris { position: absolute; inset: 0; transform: rotate(-45deg); }
.iris i {
  position: absolute; left: 50%; top: 50%;
  width: calc(var(--V) * 0.76); height: calc(var(--V) * 0.8);
  transform-origin: 0 0;
  transform: rotate(var(--a)) translate3d(0, -4%, 0);
  background: linear-gradient(180deg, #34343a 0, #1a1a1d 7%, #0e0e10 45%, #070708);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.iris i:nth-child(n + 7) { margin-left: calc(var(--V) * -0.76 + 1px); transform-origin: calc(100% - 1px) 0; }
.iris i:nth-child(6n + 1) { --a: 0deg; }
.iris i:nth-child(6n + 2) { --a: 60deg; }
.iris i:nth-child(6n + 3) { --a: 120deg; }
.iris i:nth-child(6n + 4) { --a: 180deg; }
.iris i:nth-child(6n + 5) { --a: 240deg; }
.iris i:nth-child(6n + 6) { --a: 300deg; }

.vf-off {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  fill: none; stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0; transition: opacity 0.3s var(--ease);
}
.vf[data-state="error"] .vf-off { opacity: 1; }
.vf-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; will-change: opacity; }

/* The slot the print comes out of: a groove in the body under the lens */
.slot {
  position: absolute; z-index: 1; left: 50%; top: var(--slot-y);
  width: calc(var(--pw) + 22px); height: 8px; margin-left: calc((var(--pw) + 22px) / -2);
  border-radius: 4px;
  background: linear-gradient(180deg, #250b02, #57220e);
  box-shadow: inset 0 1.5px 2px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 236, 214, 0.32), 0 -1px 0 rgba(70, 20, 4, 0.22);
}

/* Controls on the body */
.scan-sheet .orb {
  width: 52px; height: 52px;
  background: rgba(70, 20, 4, 0.2);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), inset 0 0 0 0.5px rgba(255, 255, 255, 0.12);
}
.orb {
  position: relative; display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  color: #fff;
  transition: transform 0.45s var(--spring-bouncy), background-color 0.25s var(--ease), color 0.25s var(--ease), opacity 0.3s var(--ease);
}
.orb:active { transform: scale(0.9); transition-duration: 0.12s; }
.orb svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.orb:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.orb[aria-pressed="true"] { background: rgba(255, 255, 255, 0.94); color: #1c1c1e; }
/* Flashlight, where the camera has one: in the corner of the picture */
.scan-sheet #torchBtn {
  position: absolute; z-index: 3; width: 38px; height: 38px;
  left: calc(50% + var(--Wo) / 2 - var(--B) - 50px);
  top: calc(var(--top) + var(--Wo) - var(--B) - 50px);
  background: rgba(0, 0, 0, 0.42);
}
#torchBtn svg { width: 19px; height: 19px; }
#torchBtn[hidden] { display: grid !important; visibility: hidden; opacity: 0; pointer-events: none; }

/* Under the slot: the hint, then (down where the thumb is) the keys and the maker's mark */
.cam-deck {
  position: absolute; z-index: 1; left: 0; right: 0; bottom: var(--under);
  top: calc(var(--slot-y) + 22px);
  display: grid; grid-template-rows: auto minmax(12px, 1fr) auto auto; justify-items: center; align-items: center;
  padding: 0 20px calc(env(safe-area-inset-bottom) + 18px);
}
.scan-hint {
  margin: 0; max-width: 100%; padding: 8px 15px; border-radius: 999px;
  background: rgba(70, 20, 4, 0.22);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.2);
  font-size: 0.9375rem; font-weight: 500; text-align: center; line-height: 1.35;
  transition: opacity 0.2s var(--ease), transform 0.35s var(--spring-soft);
  will-change: opacity, transform;
}
.scan-hint.swap { opacity: 0; transform: scale(0.96); }
.cam-keys { grid-row: 3; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center; width: min(100%, 320px); margin-bottom: 16px; }
.shutter {
  position: relative; display: grid; place-items: center;
  width: 78px; height: 78px; padding: 0; border: 0; border-radius: 50%; background: transparent;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.94), 0 8px 22px rgba(90, 25, 0, 0.22);
}
.shutter i {
  width: 60px; height: 60px; border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #ffd88a 0%, #f8a33c 55%, #e5801c 100%);
  box-shadow: inset 0 1.5px 1px rgba(255, 255, 255, 0.65), inset 0 -4px 8px rgba(150, 60, 0, 0.35);
  transition: transform 0.2s var(--spring);
}
.shutter:active i { transform: scale(0.88); }
.shutter:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.cam-mark {
  grid-row: 4;
  margin: 0; font-family: var(--font-display); font-size: 1.625rem; font-weight: 800;
  letter-spacing: -0.05em; line-height: 1; color: rgba(255, 255, 255, 0.96);
  text-shadow: 0 1px 0 rgba(110, 35, 8, 0.25);
}
.cam-mark b { font-weight: 800; color: #ffdcae; }
/* Once a code is caught the controls are gone: nothing to tap by accident */
.scan-sheet[data-caught] :is(.cam-deck, #torchBtn) { pointer-events: none; }

/* ============ The print ============ */
.print {
  --slack: 40px; /* room either side for the print to tip */
  position: fixed; z-index: 101; left: 0; top: 0; overflow: hidden; pointer-events: none;
  contain: layout;
}
.print[hidden] { display: none; }
.print[data-free] { overflow: visible; }
/* The slot's shadow on the print as it comes out (only over the print's own column) */
.print::after {
  content: ""; position: absolute; z-index: 1; top: 0; left: var(--slack); width: var(--pw); height: 14px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0));
  opacity: 0; transition: opacity 0.25s var(--ease);
}
.print[data-out]::after { opacity: 1; }
.print-fly { position: absolute; top: 0; left: var(--slack); width: var(--pw); will-change: transform, opacity; }
.print-card {
  padding: 10px 10px 0; border-radius: 3px;
  background: linear-gradient(180deg, #fffdf8, #f6f1e7);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 14px 30px rgba(40, 10, 0, 0.3), 0 2px 6px rgba(40, 10, 0, 0.18);
  color: #1c1c1e;
  transform: translate3d(0, -101%, 0);
  will-change: transform;
}
.print-photo { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; background: #2b2724; }
.print-photo canvas { display: block; width: 100%; height: 100%; }
.print-photo::after { /* a little gloss on the film */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 42%);
}
/* Undeveloped film: fades off as the picture comes up */
.print-dev { position: absolute; inset: 0; background: linear-gradient(160deg, #4d4640, #27231f); will-change: opacity; }
.print-caption { display: flex; align-items: center; gap: 9px; height: 56px; padding: 0 3px; }
.print-icon .avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 0.8125rem; }
.print-icon .avatar-plain { background: rgba(28, 28, 30, 0.08); color: rgba(28, 28, 30, 0.62); box-shadow: none; }
.print-text { display: grid; min-width: 0; line-height: 1.22; }
.print-text b, .print-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.print-text b { font-size: 0.875rem; font-weight: 650; }
.print-text small { font-size: 0.75rem; color: rgba(28, 28, 30, 0.56); }

/* Content sits above the glass sheen layer */
.card > :not(.sr-only), .bar-inner > * { position: relative; z-index: 2; }

/* ============ Accessibility preferences ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .glass { background: var(--surface) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  .toast { background: #1e2825 !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  .blob { display: none; }
}
