:root {
  /* Critical Tech house palette — shared across MassStrobo / MassLink / MassBlocker */
  --primary: #1D80ED;  /* final blade on dark · single CTA per screen · record state */
  --light:   #6DB3FB;  /* leading blades · hover · secondary fills */
  --core:    #1463C0;  /* final blade on light · pressed · links */
  --ink:     #0E1116;  /* dark surfaces · primary text */
  --paper:   #F7F9FC;  /* light surfaces · reversed text */

  --bg: var(--ink);
  --panel: #161B22;
  --panel-2: #1E252F;
  --line: #2A323D;
  --text: var(--paper);
  --muted: #9AA6B6;
  --accent: var(--primary);   /* alias: general accent = Primary */
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  /* Flat Ink with a faint lift — no Primary as background, no purple. */
  background: radial-gradient(1200px 600px at 70% -10%, #141A22 0%, var(--ink) 55%);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */
.topbar {
  padding: 22px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.lockup { height: 26px; width: auto; display: block; }
.house {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); border-left: 1px solid var(--line); padding-left: 12px;
}
.tagline { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

main { padding: clamp(16px, 4vw, 48px); max-width: 1200px; margin: 0 auto; }

.hidden { display: none !important; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: clamp(36px, 9vw, 90px) 24px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  cursor: pointer;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--light); background: var(--panel-2); }
.dropzone.dragover { border-color: var(--light); background: #182238; transform: scale(1.005); }
.drop-icon {
  width: 64px; height: 64px; margin: 0 auto 18px;
  display: grid; place-items: center;
  font-size: 24px; color: var(--paper);
  background: var(--primary);
  border-radius: 50%;
}
.dropzone h2 { margin: 0 0 6px; font-size: 22px; }
.dropzone p { margin: 4px 0; color: var(--muted); }
.hint { font-size: 13px; opacity: 0.85; }
.link-btn {
  background: none; border: none; color: var(--core);
  cursor: pointer; font: inherit; padding: 0; text-decoration: underline;
}
.sep { color: var(--line); margin: 0 6px; }

/* ---------- Camera recorder ---------- */
.recorder {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 720px;
  margin: 0 auto;
}
.rec-stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
  display: grid; place-items: center;
}
.cam-preview { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.rec-badge {
  position: absolute; top: 12px; left: 12px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.55); color: #fff;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ff4d4d; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.rec-controls { margin-top: 18px; }
.rec-actions { flex-direction: row; }
.rec-actions .btn { flex: 1; }

/* ---------- Workbench ---------- */
.workbench {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 820px) {
  .workbench { grid-template-columns: 1fr; }
}

.stage { min-width: 0; }
.canvas-wrap {
  position: relative;
  background:
    linear-gradient(45deg, #0f1420 25%, transparent 25%) -8px 0,
    linear-gradient(-45deg, #0f1420 25%, transparent 25%) -8px 0,
    linear-gradient(45deg, transparent 75%, #0f1420 75%),
    linear-gradient(-45deg, transparent 75%, #0f1420 75%);
  background-size: 16px 16px;
  background-color: #0a0d13;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 240px;
  display: grid;
  place-items: center;
}
#output { max-width: 100%; height: auto; display: block; }

/* ---------- Manual frame selection filmstrip ---------- */
.filmstrip-wrap {
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.filmstrip-label { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.filmstrip {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: thin;
}
.frame-thumb {
  position: relative; flex: 0 0 auto; padding: 0; cursor: pointer;
  border: 2px solid transparent; border-radius: 8px; overflow: hidden;
  background: #000; line-height: 0; opacity: 0.4; filter: grayscale(0.5);
  transition: opacity 0.12s, border-color 0.12s, filter 0.12s;
}
.frame-thumb canvas { display: block; height: 54px; width: auto; }
.frame-thumb:hover { opacity: 0.75; }
.frame-thumb.selected { opacity: 1; filter: none; border-color: var(--primary); }
.thumb-num {
  position: absolute; top: 2px; left: 2px;
  font-size: 10px; font-weight: 600; line-height: 1;
  color: var(--paper); background: rgba(14,17,22,0.6);
  padding: 2px 4px; border-radius: 4px;
}
.frame-thumb.selected .thumb-num { background: var(--primary); }

.stage-overlay {
  position: absolute; inset: 0;
  background: rgba(9, 12, 18, 0.72);
  backdrop-filter: blur(2px);
  display: grid; place-content: center; justify-items: center; gap: 14px;
  padding: 24px;
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--light);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress { width: min(260px, 60vw); height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--light); transition: width 0.15s; }
#progressText { margin: 0; color: var(--text); font-size: 14px; }

/* ---------- Controls ---------- */
.controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: sticky; top: 20px;
}
.control-group { margin-bottom: 22px; }
.control-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 10px; letter-spacing: 0.01em;
}
.control-label .val { color: var(--light); font-variant-numeric: tabular-nums; }
.control-hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

.segmented { display: flex; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 10px; }
.seg {
  flex: 1; border: none; background: none; color: var(--muted);
  padding: 8px 6px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 13px;
  transition: background 0.12s, color 0.12s;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--core); color: var(--paper); }

input[type="range"] {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 999px; background: var(--panel-2); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; cursor: pointer; border: 3px solid var(--light);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; cursor: pointer; border: 3px solid var(--light);
}

.checkbox { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 12px 16px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600;
  transition: transform 0.05s, background 0.12s, opacity 0.12s;
}
.btn:hover:not(:disabled) { background: #232c3d; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* The single Primary action per screen. */
.btn.primary { background: var(--primary); border-color: transparent; color: var(--paper); }
.btn.primary:hover:not(:disabled) { background: var(--core); }
.btn.ghost { background: none; }
.upgrade { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
/* Secondary CTA — outlined Primary, so it reads as an offer without competing
   with the one Primary action or introducing an off-palette accent. */
.btn.unlock {
  background: transparent; border: 1px solid var(--primary); color: var(--light);
}
.btn.unlock:hover:not(:disabled) { background: rgba(29, 128, 237, 0.12); }
.link-btn.small { font-size: 12px; color: var(--muted); align-self: center; }
.link-btn.small:hover { color: var(--light); }
.pro-badge {
  display: inline-block; text-align: center; font-size: 12px; font-weight: 600;
  color: var(--light); background: rgba(29, 128, 237, 0.1);
  border: 1px solid rgba(29, 128, 237, 0.35); border-radius: 8px; padding: 8px 10px;
}

.meta { margin: 14px 0 0; font-size: 12px; color: var(--muted); min-height: 16px; }

.footer { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 12px; }
