/*
 * CHROMAFLUX — Swiss Editorial Print Studio / Hardware Instrument Aesthetic
 * Matte charcoal ground, archival bone ink, crisp 1px hairlines, vermilion focal point.
 */

:root {
  --bg: #0c0c0b;
  --rail: #131311;
  --surface: #1a1a17;
  --line: #272622;
  --line-strong: #3d3b35;
  --ink: #f2efe9;
  --muted: #8b877e;
  --dim: #5c5952;
  --accent: #ff3b1f;
  --accent-hover: #ff543b;
  --ok: #3ddc84;
  --font-sans: 'Inter', 'Helvetica Neue', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  selection-background-color: var(--accent);
}

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==================== TOP EDITORIAL HEADER ==================== */
.header {
  height: 56px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mark-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.mark-name {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--ink);
}

.mark-edition {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--dim);
  letter-spacing: 0.08em;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

/* Center Mode Switch */
.mode-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  overflow: hidden;
  background: var(--rail);
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 7px 22px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-btn:hover {
  color: var(--ink);
}

.mode-btn.active {
  background: var(--ink);
  color: var(--bg);
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.btn-ghost.recording {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* ==================== MAIN 2-COLUMN WORKSPACE ==================== */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 352px;
  min-height: calc(100vh - 56px);
}

/* ==================== HERO STAGE ==================== */
.stage-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 36px;
  gap: 20px;
  background:
    radial-gradient(circle at 50% 45%, rgba(242, 239, 233, 0.025), transparent 65%),
    var(--bg);
}

.canvas-mount {
  position: relative;
  padding: 14px;
  width: min(100%, 660px);
}

/* Print registration ticks */
.tick {
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--line-strong);
  border-style: solid;
  pointer-events: none;
}
.tick.tl { top: 0; left: 0; border-width: 1px 0 0 1px; }
.tick.tr { top: 0; right: 0; border-width: 1px 1px 0 0; }
.tick.bl { bottom: 0; left: 0; border-width: 0 0 1px 1px; }
.tick.br { bottom: 0; right: 0; border-width: 0 1px 1px 0; }

.stage-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #0e0e0d;
  border: 1px solid var(--line-strong);
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

.stage-frame.draw-cursor {
  cursor: none;
}

#glCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.blank-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
  text-align: center;
  padding: 24px;
}

.blank-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.blank-sub {
  font-size: 0.85rem;
  color: var(--dim);
}

.stage-frame.paper-cream .blank-title { color: #524f49; }
.stage-frame.paper-cream .blank-sub { color: #7a766e; }

.brush-cursor {
  position: absolute;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
  z-index: 8;
}

.corner-status {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  background: rgba(12, 12, 11, 0.78);
  border: 1px solid rgba(242, 239, 233, 0.14);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  color: var(--ink);
  pointer-events: none;
  z-index: 6;
}

.status-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.corner-status.busy .status-led {
  background: var(--accent);
  animation: blink 0.8s infinite ease-in-out;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* ==================== TRANSPORT / ACTION DECK ==================== */
.deck {
  width: min(100%, 632px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--rail);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.btn-vermilion {
  background: var(--accent);
  color: #ffffff;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 11px 20px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.btn-vermilion:hover {
  background: var(--accent-hover);
}

.btn-vermilion:active {
  transform: translateY(1px);
}

.btn-vermilion.secondary {
  background: var(--ink);
  color: var(--bg);
}

.scrubber-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scrubber-head {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.mono {
  font-family: var(--font-mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.btn-toggle {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 9px 12px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-toggle:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.btn-toggle[data-active="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.select-compact {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 8px 8px;
  border-radius: 3px;
  cursor: pointer;
  outline: none;
}

.draw-deck-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.draw-mode-note {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ==================== RIGHT INSPECTOR RAIL ==================== */
.inspector {
  background: var(--rail);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.inspector-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.sec-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.sec-index {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 700;
}

.sec-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink);
  flex: 1;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.15s;
}

.link-btn:hover {
  color: var(--accent);
}

.accent-link {
  color: var(--accent);
}

.accent-link:hover {
  color: var(--ink);
}

/* Source & Target Film Slots */
.film-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.film-slot {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 8px;
  border-radius: 3px;
  transition: border-color 0.15s;
}

.film-slot.drag-over {
  border-color: var(--accent);
}

.film-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.film-mini-btns {
  display: flex;
  gap: 6px;
}

.film-thumb-wrap {
  width: 100%;
  aspect-ratio: 1;
  background: #0b0b0a;
  overflow: hidden;
}

.film-thumb-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Preset Strip */
.preset-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.micro-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--dim);
}

.slot-tabs {
  display: inline-flex;
  gap: 4px;
}

.slot-tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  padding: 3px 7px;
  border-radius: 2px;
  cursor: pointer;
}

.slot-tab.active {
  border-color: var(--ink);
  color: var(--ink);
}

.preset-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.preset-chip {
  position: relative;
  border: 1px solid var(--line);
  background: #0a0a09;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  border-radius: 3px;
  aspect-ratio: 4 / 3;
  transition: border-color 0.15s, transform 0.12s;
}

.preset-chip:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.preset-chip canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preset-chip span {
  position: absolute;
  inset: auto 0 0 0;
  padding: 16px 8px 6px;
  background: linear-gradient(transparent, rgba(10, 10, 9, 0.92));
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Form Fields & Swiss Hairline Controls */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-label {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.mono-val {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.mono-muted {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--muted);
}

.pill-group {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  overflow: hidden;
}

.pill {
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 8px 4px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.pill:last-child {
  border-right: none;
}

.pill:hover {
  color: var(--ink);
}

.pill.active {
  background: var(--ink);
  color: var(--bg);
}

.select-full {
  width: 100%;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  outline: none;
  cursor: pointer;
}

.select-full:focus {
  border-color: var(--accent);
}

/* Custom Hairline Range Sliders */
.hairline-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--line-strong);
  outline: none;
  cursor: pointer;
  margin: 6px 0;
}

.hairline-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--ink);
  border: 1px solid var(--bg);
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
}

.hairline-range::-webkit-slider-thumb:hover {
  background: var(--accent);
  transform: scale(1.15);
}

.hairline-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--ink);
  border: none;
  cursor: pointer;
}

.toggle-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
}

.toggle-line input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Polish Progress */
.polish-bar {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
}

.polish-track {
  height: 2px;
  background: var(--line);
  overflow: hidden;
}

.polish-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease-out;
}

/* Spec Readout Footer */
.spec-footer {
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  background: #0f0f0d;
}

.spec-cell {
  padding: 12px 10px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.spec-cell:last-child {
  border-right: none;
}

.spec-k {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  color: var(--dim);
}

.spec-v {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ==================== DRAW MODE INSPECTOR ==================== */
.draw-target-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.draw-target-row canvas {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line-strong);
  flex-shrink: 0;
  display: block;
}

.draw-target-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.draw-target-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
}

.draw-target-copy p,
.sec-note {
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--muted);
}

.sec-note {
  margin-top: 10px;
}

.ink-bar {
  display: flex;
  gap: 8px;
}

.ink-chameleon {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 8px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}

.ink-chameleon.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.color-well {
  width: 38px;
  height: 34px;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  cursor: pointer;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.swatch {
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 2px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}

.swatch:hover {
  transform: scale(1.1);
}

.swatch.active {
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--accent);
  transform: scale(1.12);
}

.hidden {
  display: none !important;
}

/* ==================== LIVE WEBCAM MODAL ==================== */
.cam-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 8, 7, 0.86);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cam-box {
  width: min(100%, 460px);
  background: var(--rail);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cam-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.cam-viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #060605;
  overflow: hidden;
}

#camVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

.cam-reticle {
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(242, 239, 233, 0.22);
  pointer-events: none;
}

.cam-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .inspector {
    border-left: none;
    border-top: 1px solid var(--line);
  }
}
