:root {
  --bg:        #0a0e1a;
  --bg-elev:   #121828;
  --surface:   #1a2138;
  --line:      #232c47;
  --text:      #ecf0f8;
  --text-dim:  #8995b3;
  --text-low:  #5b6789;
  --accent:    #7dffc4;
  --accent-d:  #4adba0;
  --warn:      #ffc97a;
  --error:     #ff7a7a;
  --shadow:    0 24px 60px -20px rgba(0,0,0,.6);

  --font-display: 'Instrument Serif', 'Times New Roman', serif;
  --font-ui:      'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  --banner-h:    52px;
  --drawer-w:    380px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(125, 255, 196, .06), transparent 50%),
    radial-gradient(ellipse at 70% 100%, rgba(74, 137, 255, .05), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.4'/></svg>");
  opacity: .035;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
 * TUNING BANNER
 * ============================================================ */
.tuning-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--banner-h);
  z-index: 100;
  background: rgba(125, 255, 196, .04);
  border-bottom: 1px solid rgba(125, 255, 196, .15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.banner-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: live 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes live {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}
.banner-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}
.banner-sub {
  font-size: 12px;
  color: var(--text-low);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 600px) {
  .banner-sub { display: none; }
}

.banner-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.banner-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.02);
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s ease;
}
.banner-btn:hover {
  border-color: var(--text-dim);
  color: var(--text);
  background: rgba(255,255,255,.04);
}
.banner-btn.primary-action {
  border-color: rgba(125, 255, 196, .4);
  color: var(--accent);
}
.banner-btn.primary-action:hover {
  background: rgba(125, 255, 196, .1);
  color: var(--accent);
}
.banner-btn svg { width: 13px; height: 13px; }
.banner-btn.icon-only { padding: 7px 9px; }
.banner-btn.icon-only svg { width: 16px; height: 16px; }

/* User indicator + divider in the banner */
.banner-user {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 4px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.banner-user::before {
  content: '@ ';
  color: var(--text-low);
}
.banner-divider {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 4px;
}
@media (max-width: 600px) {
  .banner-user { display: none; }
}

/* ============================================================
 * LOGIN PAGE
 * ============================================================ */
body.login-body {
  overflow: auto;
}
.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.login-brand {
  align-self: center;
  margin-bottom: 28px;
}
.login-title {
  font-size: clamp(38px, 7vw, 56px);
  margin-bottom: 10px;
}
.login-subtitle {
  margin-bottom: 32px;
  font-size: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.login-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-low);
}
.login-input {
  appearance: none;
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 13px 14px;
  border-radius: 10px;
  font-family: var(--font-ui);
  font-size: 15px;
  outline: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.login-input:hover { border-color: var(--text-low); }
.login-input:focus {
  border-color: var(--accent);
  background: rgba(125, 255, 196, .03);
  box-shadow: 0 0 0 4px rgba(125, 255, 196, .08);
}
.login-input::placeholder { color: var(--text-low); }
.login-input::-webkit-credentials-auto-fill-button { filter: invert(.5); }

.login-password-wrap {
  position: relative;
}
.show-pw-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-low);
  border-radius: 6px;
  transition: color .15s ease, background .15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.show-pw-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,.04);
}
.show-pw-btn svg { width: 16px; height: 16px; }

.login-error {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--error);
  min-height: 1em;
  margin-bottom: 16px;
  opacity: 0;
  transition: opacity .15s ease;
}
.login-error.visible { opacity: 1; }

.login-submit {
  width: 100%;
  justify-content: center;
  padding: 15px 24px;
  margin-top: 4px;
}
.login-submit:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none !important;
}

/* Login page reuses .brand and .title from elsewhere; override centering */
.login-card .brand { align-self: center; }
.login-card .title { text-align: center; }
.login-card .subtitle { text-align: center; align-self: center; }
.login-card > * {
  animation: rise .5s cubic-bezier(.2, .9, .3, 1) backwards;
}
.login-card > *:nth-child(1) { animation-delay: .04s; }
.login-card > *:nth-child(2) { animation-delay: .10s; }
.login-card > *:nth-child(3) { animation-delay: .16s; }
.login-card > *:nth-child(4) { animation-delay: .22s; }
.login-card > *:nth-child(5) { animation-delay: .28s; }
.login-card > *:nth-child(6) { animation-delay: .34s; }
.login-card > *:nth-child(7) { animation-delay: .40s; }

/* ============================================================
 * LAYOUT
 * ============================================================ */
.layout {
  position: fixed;
  inset: var(--banner-h) 0 0 0;
  display: flex;
  z-index: 1;
}

#app {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  min-width: 0;
}

.screen {
  width: 100%;
  max-width: 560px;
  display: none;
  flex-direction: column;
  align-items: center;
}
.screen.active { display: flex; }

/* ============================================================
 * IDLE
 * ============================================================ */
.brand {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--text-low);
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

h1.title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(40px, 7vw, 60px);
  line-height: 1;
  letter-spacing: -.02em;
  text-align: center;
  margin-bottom: 12px;
}
h1.title em { font-style: italic; color: var(--accent); }

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
  max-width: 420px;
  margin-bottom: 32px;
}

.steps-preview {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
  flex-wrap: wrap;
  justify-content: center;
}
.step-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: rgba(255,255,255,.02);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--text-dim);
}
.step-chip-num {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 500;
}

button.primary {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 16px 32px;
  background: var(--accent);
  color: #061611;
  border-radius: 100px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 0 0 0 rgba(125, 255, 196, .4), var(--shadow);
  transition: transform .2s ease, box-shadow .3s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 8px rgba(125, 255, 196, .12), var(--shadow);
}
button.primary svg { width: 16px; height: 16px; }

button.ghost {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  cursor: pointer;
  padding: 11px 22px;
  border-radius: 100px;
  font-family: var(--font-ui);
  font-size: 13px;
  transition: all .2s ease;
}
button.ghost:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

.hint {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .15em;
  color: var(--text-low);
  margin-top: 24px;
  text-transform: uppercase;
}

/* ============================================================
 * CAPTURE
 * ============================================================ */
.step-indicator {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--text-low);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.step-indicator .dots { display: flex; gap: 5px; }
.step-indicator .dot {
  width: 18px; height: 2px;
  background: var(--line);
  border-radius: 2px;
  transition: background .3s ease;
}
.step-indicator .dot.done   { background: var(--accent); }
.step-indicator .dot.active { background: var(--text); }

.instruction {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(22px, 4.5vw, 28px);
  line-height: 1.15;
  text-align: center;
  margin-bottom: 4px;
  min-height: 1.2em;
}
.instruction em { font-style: italic; color: var(--accent); }

.reason {
  font-size: 12px;
  color: var(--warn);
  text-align: center;
  margin-bottom: 16px;
  min-height: 16px;
  font-family: var(--font-mono);
  letter-spacing: .03em;
}
.reason.error { color: var(--error); }

.stage {
  position: relative;
  width: min(280px, 70vw);
  aspect-ratio: 1 / 1;
  margin-bottom: 18px;
}
.stage-mask {
  position: absolute; inset: 0;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04), 0 30px 60px -20px rgba(0,0,0,.7);
}
video {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

.ring {
  position: absolute;
  inset: -10px;
  pointer-events: none;
}
.ring svg { width: 100%; height: 100%; overflow: visible; }
.ring circle {
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
  transition: stroke .3s ease;
}
.ring .progress {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 8 14;
  transform-origin: center;
  animation: rotate 8s linear infinite;
  opacity: .6;
}
.ring.scanning .progress { opacity: 1; }
.ring.success .progress {
  stroke: var(--accent);
  stroke-dasharray: none;
  animation: none;
  opacity: 1;
}
.ring.success circle:first-child { stroke: var(--accent-d); }
@keyframes rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.stage-mask::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(125, 255, 196, 0);
  pointer-events: none;
  transition: box-shadow .3s ease;
}
.stage.scanning .stage-mask::after { animation: pulse 2.4s ease-in-out infinite; }
.stage.success .stage-mask::after {
  box-shadow: 0 0 0 4px rgba(125, 255, 196, .25), 0 0 60px rgba(125, 255, 196, .35);
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(125, 255, 196, 0); }
  50%      { box-shadow: 0 0 0 6px rgba(125, 255, 196, .15); }
}

.arrow-hint {
  position: absolute;
  top: 50%;
  width: 36px; height: 36px;
  transform: translateY(-50%);
  color: var(--accent);
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
}
.arrow-hint svg { width: 100%; height: 100%; }
.arrow-hint.visible { opacity: .7; animation: nudge 1.2s ease-in-out infinite; }
.arrow-hint.left  { left: -6px; }
.arrow-hint.right { right: -6px; transform: translateY(-50%) scaleX(-1); }
@keyframes nudge {
  0%, 100% { translate: 0 0; }
  50%      { translate: -8px 0; }
}
.arrow-hint.right.visible { animation: nudge-right 1.2s ease-in-out infinite; }
@keyframes nudge-right {
  0%, 100% { translate: 0 0; }
  50%      { translate: 8px 0; }
}

.check-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease;
}
.check-overlay.visible { opacity: 1; }
.check-overlay .badge {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 60px rgba(125,255,196,.5);
  transform: scale(.7);
  transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
}
.check-overlay.visible .badge { transform: scale(1); }
.check-overlay svg {
  width: 40px; height: 40px;
  stroke: #061611;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.check-overlay svg path {
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  transition: stroke-dashoffset .4s ease .15s;
}
.check-overlay.visible svg path { stroke-dashoffset: 0; }

/* ============================================================
 * LIVE READOUT (capture screen)
 * ============================================================ */
.readout {
  width: 100%;
  max-width: 480px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}
.readout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.015);
}
.readout-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.readout-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-low);
}
.readout-meta.ok    { color: var(--accent); }
.readout-meta.fail  { color: var(--warn); }

.readout-body { padding: 8px; max-height: 200px; overflow-y: auto; }
.readout-empty {
  font-size: 12px;
  color: var(--text-low);
  text-align: center;
  padding: 16px 8px;
  font-family: var(--font-mono);
}

.check-row {
  display: grid;
  grid-template-columns: 16px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 6px;
}
.check-row + .check-row { margin-top: 1px; }
.check-row.fail { background: rgba(255, 122, 122, .07); }
.check-row.skipped { opacity: .35; }
.check-row .icon {
  width: 14px; height: 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.check-row.pass    .icon { background: rgba(125, 255, 196, .15); color: var(--accent); }
.check-row.fail    .icon { background: rgba(255, 122, 122, .15); color: var(--error); }
.check-row.skipped .icon { background: var(--line); color: var(--text-low); }
.check-row .icon svg { width: 9px; height: 9px; stroke-width: 3; }
.check-row .label {
  color: var(--text-dim);
  font-family: var(--font-ui);
}
.check-row.pass .label { color: var(--text); }
.check-row .value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
}
.check-row .threshold {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-low);
  white-space: nowrap;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ============================================================
 * PREVIEW
 * ============================================================ */
#preview-screen { max-width: 640px; }
.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  margin-bottom: 28px;
}
.preview-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  position: relative;
}
.preview-card img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);
}
.preview-card .label {
  position: absolute;
  bottom: 8px; left: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  background: rgba(10, 14, 26, .8);
  backdrop-filter: blur(8px);
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--accent);
}
.preview-card .edit-btn {
  position: absolute;
  top: 8px; right: 8px;
  width: 32px; height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(10, 14, 26, .85);
  backdrop-filter: blur(8px);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.preview-card .edit-btn svg { width: 13px; height: 13px; }
.preview-card .edit-btn:hover {
  background: var(--accent);
  color: #061611;
  transform: scale(1.08);
}

/* ============================================================
 * COMPLETE / ERROR
 * ============================================================ */
.complete-icon {
  width: 76px; height: 76px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 0 80px rgba(125,255,196,.4);
}
.complete-icon svg { width: 36px; height: 36px; stroke: #061611; stroke-width: 3; fill: none; }

.error-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 2px solid var(--error);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px;
  color: var(--error);
  font-size: 26px;
  font-family: var(--font-display);
}

/* ============================================================
 * DRAWER
 * ============================================================ */
.drawer {
  width: var(--drawer-w);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  transition: width .25s ease, opacity .2s ease;
}
.drawer.collapsed {
  width: 0;
  opacity: 0;
  border-left: none;
}
.drawer-inner {
  width: var(--drawer-w);
  padding: 20px;
}
.drawer-header { margin-bottom: 18px; }
.drawer-header h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  line-height: 1;
  margin-bottom: 4px;
}
.drawer-header p {
  font-size: 12px;
  color: var(--text-low);
}

.drawer-group { margin-bottom: 22px; }
.drawer-group-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-low);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* ----- Rule (a checkbox + 0..n sliders) ----- */
.rule {
  margin-bottom: 14px;
  transition: opacity .2s ease;
}
.rule.disabled .rule-body {
  opacity: .35;
  pointer-events: none;
}
.rule.disabled .rule-label {
  color: var(--text-low);
}

.rule-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
  cursor: default;
}
.rule-toggle-only .rule-header { margin-bottom: 0; }
.rule-label {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 400;
}

.rule-body {
  padding-left: 24px;
  border-left: 1px solid var(--line);
  margin-left: 7px;
  padding-top: 2px;
  padding-bottom: 2px;
}
.rule.disabled .rule-body { border-left-color: rgba(35, 44, 71, .5); }

.rule-slider + .rule-slider { margin-top: 8px; }

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 10px;
}
.slider-label {
  font-size: 11.5px;
  color: var(--text-dim);
}
.slider-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
}

/* ----- Checkbox (consistent across all rules) ----- */
.checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--text-low);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: all .15s ease;
}
.checkbox:hover { border-color: var(--text-dim); }
.checkbox:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox svg {
  width: 12px;
  height: 12px;
  color: #061611;
  opacity: 0;
  transition: opacity .12s ease;
}
.checkbox.checked svg { opacity: 1; }

/* ----- Range slider ----- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(125, 255, 196, .15);
  transition: box-shadow .15s ease, transform .15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 7px rgba(125, 255, 196, .25);
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.1); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 0 4px rgba(125, 255, 196, .15);
}

/* ============================================================
 * MOBILE: drawer becomes bottom sheet
 * ============================================================ */
@media (max-width: 900px) {
  :root { --drawer-w: 100%; }
  .layout { flex-direction: column; }
  .drawer {
    width: 100%;
    max-height: 50vh;
    border-left: none;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
  }
  .drawer.collapsed {
    max-height: 0;
    width: 100%;
  }
  .drawer-inner { width: 100%; }
  #app { padding: 16px; }
  .stage { width: min(240px, 65vw); }
  .readout { max-width: 100%; }
}

/* ============================================================
 * TOAST
 * ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: #061611;
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 40px rgba(125,255,196,.4), 0 4px 12px rgba(0,0,0,.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 200;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
 * ANIMATIONS
 * ============================================================ */
.screen.active > * {
  animation: rise .5s cubic-bezier(.2, .9, .3, 1) backwards;
}
.screen.active > *:nth-child(1) { animation-delay: .04s; }
.screen.active > *:nth-child(2) { animation-delay: .08s; }
.screen.active > *:nth-child(3) { animation-delay: .12s; }
.screen.active > *:nth-child(4) { animation-delay: .16s; }
.screen.active > *:nth-child(5) { animation-delay: .20s; }
.screen.active > *:nth-child(6) { animation-delay: .24s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast { z-index: 200; }
canvas { display: none; }
