:root {
  color-scheme: dark;
  --line: rgba(243,241,234,.1); --line-strong: rgba(243,241,234,.22);
  --text-primary: #f3f1ea; --text-secondary: #bdb9ad; --text-muted: #8f8b80;
  --amber: #f49d03; --amber-hi: #ffb13a; --magenta: #ff64db; --cyan: #4cf3ff; --on-brand: #050505;
  --radius: 16px; --radius-sm: 11px;
  --glass: rgba(12,11,14,.55); --float: rgba(18,17,20,.88); --field: rgba(10,10,12,.7);
  --glass-blur: blur(26px) saturate(170%);
  --glass-edge: inset 0 1px 0 rgba(255,255,255,.1), inset 0 0 0 1px rgba(255,255,255,.035);
  --shadow-card: 0 1px 2px rgba(0,0,0,.45), 0 14px 34px -16px rgba(0,0,0,.8);
  --shadow-pop: 0 2px 8px rgba(0,0,0,.45), 0 30px 64px -20px rgba(0,0,0,.9);
  --btn-gloss: linear-gradient(to bottom, rgba(255,255,255,.16) 0, rgba(255,255,255,.04) 16px, rgba(255,255,255,0) 17px, rgba(0,0,0,.18) 100%);
  --btn-sheen: inset 0 1px 0 rgba(255,255,255,.18), inset 0 -1px 0 rgba(0,0,0,.35);
  --btn-lift: 0 1px 1px rgba(0,0,0,.45), 0 4px 14px -2px rgba(244,157,3,.28);
  --ground: radial-gradient(ellipse 70% 55% at 88% -5%, rgba(244,157,3,.34), transparent 62%), radial-gradient(ellipse 60% 50% at 0% 105%, rgba(255,100,219,.26), transparent 62%), radial-gradient(ellipse 45% 35% at 45% 55%, rgba(76,243,255,.07), transparent 70%), #070608;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { background: var(--ground); color: var(--text-primary); font: 15px/1.45 "Geist", system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
body.candle { --ground: radial-gradient(ellipse 50% 40% at 50% 55%, rgba(244,157,3,.16), transparent 70%), #030203; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
body[data-mode="move"] #stage { cursor: grab; }

.glass { background: var(--glass); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); box-shadow: var(--glass-edge), var(--shadow-card); border: 1px solid var(--line); }
h2 { font: 700 20px/1.2 "Unbounded", system-ui, sans-serif; margin: 0 0 14px; letter-spacing: -.01em; }
h3, .tabs button, .small-note, .slider span, .field span { font-family: "JetBrains Mono", ui-monospace, monospace; letter-spacing: .04em; }
h3 { text-transform: uppercase; font-size: 11px; color: var(--text-muted); margin: 14px 0 6px; font-weight: 500; }
.small-note { font-size: 11px; color: var(--text-muted); margin: 8px 0 0; }

button, .btn { font: 600 13px/1 "Geist", system-ui, sans-serif; color: var(--text-primary); background: var(--btn-gloss), rgba(243,241,234,.08); border: 1px solid var(--line); border-radius: 99px; padding: 11px 16px; cursor: pointer; box-shadow: var(--btn-sheen); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; min-height: 40px; }
button:hover { border-color: var(--line-strong); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button.primary, .btn.primary { background: var(--btn-gloss), var(--amber); color: var(--on-brand); border-color: transparent; box-shadow: var(--btn-sheen), var(--btn-lift); }
button.primary:hover { background: var(--btn-gloss), var(--amber-hi); }
button.ghost { background: none; box-shadow: none; color: var(--text-secondary); }
button.icon { width: 40px; padding: 0; }
button.icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button[aria-pressed="true"], button.on { border-color: var(--amber); color: var(--amber-hi); }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
input, select { font: 500 15px "Geist", system-ui, sans-serif; color: var(--text-primary); background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; width: 100%; user-select: text; -webkit-user-select: text; }
input[type="checkbox"] { width: auto; accent-color: var(--amber); }

.top { position: fixed; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 16px; border-radius: 99px; z-index: 5; }
.brand { font: 700 15px/1 "Unbounded", system-ui, sans-serif; letter-spacing: -.01em; display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.brand span { color: var(--magenta); }
.brand small { font: 500 10px "JetBrains Mono", monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--amber); margin-left: 6px; }
.top-actions { display: flex; gap: 6px; align-items: center; }

.float-left { position: fixed; left: 10px; bottom: calc(var(--dock-h, 190px) + 20px + var(--safe-b)); display: flex; gap: 8px; align-items: center; z-index: 4; }
.seg { display: inline-flex; padding: 3px; border-radius: 99px; gap: 2px; }
.seg button { border: 0; background: none; box-shadow: none; min-height: 34px; padding: 8px 14px; color: var(--text-secondary); }
.seg button.on { background: var(--btn-gloss), var(--amber); color: var(--on-brand); box-shadow: var(--btn-sheen); }
.seg.small { background: var(--field); border: 1px solid var(--line); }
.seg.small button { min-height: 30px; padding: 6px 12px; font-size: 12px; }
.seg.wrap { flex-wrap: wrap; border-radius: var(--radius); }
.chip { min-height: 34px; padding: 8px 12px; font-size: 12px; }

.toast { position: fixed; left: 50%; top: calc(72px + var(--safe-t)); transform: translateX(-50%); padding: 9px 16px; border-radius: 99px; font-size: 13px; z-index: 30; max-width: calc(100vw - 32px); text-align: center; }
.toast[hidden] { display: none; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; font: 500 12px "JetBrains Mono", monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--amber); pointer-events: none; transition: opacity .3s; z-index: 3; }
.loading.done { opacity: 0; }

.dock { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b)); width: min(760px, calc(100vw - 20px)); border-radius: 24px; padding: 8px 10px 10px; z-index: 5; }
.tabs { display: flex; gap: 2px; margin-bottom: 6px; }
.tabs button { flex: 1; border: 0; background: none; box-shadow: none; text-transform: uppercase; font-size: 11px; font-weight: 500; color: var(--text-muted); min-height: 32px; padding: 6px; border-radius: 99px; }
.tabs button.on { color: var(--on-brand); background: var(--btn-gloss), var(--amber); }
.pane { display: none; }
.pane.on { display: block; }
.row { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.row.scroll { overflow-x: auto; scrollbar-width: none; margin: 0 -10px; padding: 4px 10px; }
.row.scroll::-webkit-scrollbar { display: none; }
.row.controls { justify-content: space-between; gap: 12px; }
.slider { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.slider span { font-size: 10px; text-transform: uppercase; color: var(--text-muted); }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 28px; background: none; border: 0; padding: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--line-strong); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%; background: var(--amber); border: 2px solid #050505; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line-strong); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--amber); border: 2px solid #050505; }

.tool { flex: 0 0 auto; flex-direction: column; gap: 5px; min-width: 68px; min-height: 60px; padding: 8px 10px; border-radius: var(--radius); font-size: 12px; }
.tool svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool.stamp svg { fill: currentColor; stroke: none; }
.tool.on { background: var(--btn-gloss), rgba(244,157,3,.16); }
.shape { flex: 0 0 auto; flex-direction: column; gap: 4px; width: 88px; padding: 6px 4px 8px; border-radius: var(--radius); font-size: 11px; white-space: normal; text-align: center; line-height: 1.15; }
.shape img { width: 62px; height: 62px; object-fit: contain; }
.shape.on { background: var(--btn-gloss), rgba(244,157,3,.16); }
.swatch { width: 36px; min-height: 36px; height: 36px; padding: 0; border-radius: 50%; border: 2px solid var(--line-strong); box-shadow: var(--btn-sheen); }
.swatch.on { border-color: var(--text-primary); outline: 2px solid var(--amber); outline-offset: 2px; }

dialog.sheet { color: var(--text-primary); border-radius: 24px; padding: 22px; width: min(860px, calc(100vw - 20px)); max-height: calc(100dvh - 20px); overflow: auto; background: var(--float); box-shadow: var(--glass-edge), var(--shadow-pop); user-select: text; -webkit-user-select: text; }
dialog.sheet.narrow { width: min(440px, calc(100vw - 20px)); }
dialog::backdrop { background: rgba(0,0,0,.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.close { position: absolute; top: 14px; right: 14px; }
.finish-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.preview { position: relative; border-radius: var(--radius); overflow: hidden; background: #050505; border: 1px solid var(--line); display: grid; place-items: center; min-height: 200px; }
.preview img { display: block; width: 100%; max-height: 62dvh; object-fit: contain; }
.progress { position: absolute; left: 12px; right: 12px; bottom: 12px; height: 6px; border-radius: 6px; background: rgba(0,0,0,.6); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--magenta), var(--amber)); }
.field { display: block; }
.field span { display: block; font-size: 10px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 5px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.news, .entry { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--line); }
.entry summary { cursor: pointer; font-weight: 600; padding: 12px 0 4px; }
.btn.google { margin-top: 10px; }
.btn[hidden], button[hidden] { display: none; }

body.immersive .top .brand small, body.immersive .tabs, body.immersive .pane[data-pane] .row.controls, body.immersive #recenter, body.immersive #clear { display: none; }
body.immersive .dock { padding: 4px 10px; }

@media (max-width: 720px) {
  .brand small { display: none; }
  .brand { font-size: 13px; flex-direction: column; gap: 2px; align-items: flex-start; }
  .top { padding-left: 14px; }
  .top-actions { gap: 4px; }
  button.icon { width: 36px; min-height: 36px; }
  #sound { display: none; }
  .finish-grid { grid-template-columns: 1fr; gap: 12px; }
  .preview img { max-height: 38dvh; }
  dialog.sheet { padding: 18px 16px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .dock { left: auto; right: calc(10px + env(safe-area-inset-right, 0px)); transform: none; width: min(340px, 46vw); top: calc(68px + var(--safe-t)); bottom: calc(8px + var(--safe-b)); overflow-y: auto; scrollbar-width: none; }
  .float-left { bottom: calc(10px + var(--safe-b)); }
  .toast { left: 30%; }
}
#printRisk { margin: 12px 0; }
