/* Layout: input · controls · output panels over a style filmstrip; two columns on tablets, one on phones.
   A single dark look by choice: the output is light-on-black text, so the frame around it stays dark. */
:root {
  --bg: #0a0f12;
  --panel: #0e1519;
  --panel-raised: #121b20;
  --line: #1c272d;
  --line-strong: #29363d;
  --text: #e7ebe4;
  --muted: #84929a;
  --accent: #dcf36b;
  --accent-soft: rgba(220, 243, 107, 0.14);
  --accent-ink: #151b05;
  --danger: #ff5f5f;
  --font-ui: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", "SF Mono", Menlo, Consolas, monospace;
  --radius: 14px;
  --gutter: clamp(16px, 3vw, 44px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font-ui);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--font-mono); }
[hidden] { display: none !important; }

.glow {
  position: fixed;
  left: -12vw;
  bottom: -35vh;
  width: 75vw;
  height: 70vh;
  background: radial-gradient(closest-side, rgba(220, 243, 107, 0.09), transparent 75%);
  pointer-events: none;
  z-index: 0;
}

/* Top bar */
.topbar {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 28px var(--gutter) 22px;
  max-width: 1640px;
  margin: 0 auto;
}
.logo {
  font: 300 30px/1 var(--font-mono);
  letter-spacing: 0.22em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.cursor { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.tabs { display: flex; gap: clamp(18px, 3.6vw, 54px); }
.tabs a {
  position: relative;
  padding: 8px 2px 16px;
  font: 400 14px var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); }
.tabs a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 8px;
  background:
    radial-gradient(circle at center, var(--accent) 3px, transparent 3.6px),
    linear-gradient(var(--accent), var(--accent)) center / 100% 2px no-repeat;
}
.topbar-note a { color: var(--accent); text-decoration: none; }
.topbar-note a:hover { text-decoration: underline; text-underline-offset: 3px; }
.topbar-note {
  justify-self: end;
  font: 12px var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.04em;
}

main {
  position: relative;
  z-index: 1;
  max-width: 1640px;
  margin: 0 auto;
  padding: 8px var(--gutter) 48px;
}

/* Workspace */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px minmax(0, 1.06fr);
  align-items: stretch;
  gap: 20px;
}
.panel {
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 24px 48px -28px rgba(0, 0, 0, 0.7);
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  margin-bottom: 14px;
}
.panel-head h2 {
  flex: 1;
  margin: 0;
  font: 400 15px var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.head-icon { width: 22px; height: 22px; color: var(--accent); flex: none; }
.chip {
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 12px var(--font-mono);
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 7px 10px;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 4;
  max-width: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.stage canvas { display: block; }
#inCanvas { width: 100%; height: 100%; }
.stage:fullscreen { aspect-ratio: auto; width: 100vw; height: 100vh; border: 0; border-radius: 0; }
.stage-tag {
  position: absolute;
  left: 10px;
  top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 11px var(--font-mono);
  letter-spacing: 0.05em;
  color: var(--text);
  background: rgba(10, 15, 18, 0.72);
  border: 1px solid var(--line-strong);
  padding: 4px 9px;
  border-radius: 99px;
  backdrop-filter: blur(6px);
}
.stage-tag.live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.dropzone {
  position: absolute;
  inset: 14px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  border: 1px dashed rgba(231, 235, 228, 0.35);
  border-radius: 8px;
  background: rgba(10, 15, 18, 0.55);
  color: var(--text);
  text-align: center;
  padding: 16px;
  transition: background 0.15s, border-color 0.15s;
}
.dropzone svg { width: 28px; height: 28px; color: var(--accent); margin-bottom: 4px; }
.dropzone strong { font-weight: 500; font-size: 15px; }
.dropzone span { color: var(--muted); font-size: 13px; }
.dropzone:hover, .studio.dragging .dropzone { background: rgba(10, 15, 18, 0.35); border-color: var(--accent); }
.studio.dragging .stage { outline: 2px solid var(--accent); outline-offset: 2px; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash 0.35s ease-out; }
@keyframes flash { from { opacity: 0.55; } to { opacity: 0; } }

.input-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  margin-top: 24px;
}
.round {
  width: 58px;
  height: 58px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  display: grid;
  place-items: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.round:hover { border-color: var(--muted); }
.round svg { width: 20px; height: 20px; }
.round.sm { width: 46px; height: 46px; }
.round.is-rec { border-color: var(--danger); color: var(--danger); background: rgba(255, 95, 95, 0.08); }
.pill {
  height: 58px;
  min-width: 180px;
  padding: 0 28px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.pill:hover { border-color: var(--muted); }
.pill:active { transform: scale(0.98); }
.pill.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill.primary:hover { background: #e6f88c; }
.pill.ghost { height: 46px; min-width: 0; padding: 0 22px; }
.pill svg { width: 18px; height: 18px; }
.pill-icon { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.pill-icon.stop { border-radius: 2px; }
.pill-icon.upload {
  width: 16px;
  height: 16px;
  border-radius: 0;
  background: none;
  border: 1.5px solid currentColor;
  border-top: 0;
  position: relative;
}
.pill-icon.upload::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  width: 7px;
  height: 7px;
  border-left: 1.5px solid currentColor;
  border-top: 1.5px solid currentColor;
  transform: translateX(-50%) rotate(45deg);
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  padding: 14px 0 0;
  contain: size; /* take the row height set by the input and output panels, scroll inside */
  min-height: 420px;
}
.effect-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin: 0 14px 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.effect-tab {
  height: 32px;
  padding: 0 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: 500 12px var(--font-ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.effect-tab:hover { color: var(--text); }
.effect-tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.control-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 22px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.control-section {
  margin: 18px 0 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font: 400 11.5px var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.control-list > .control-section:first-child { border-top: 0; padding-top: 4px; margin-top: 6px; }
.chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.chip-btn {
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-btn:hover { color: var(--text); border-color: var(--muted); }
.chip-btn[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.swatches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.swatch-btn {
  display: grid;
  gap: 5px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11.5px;
  text-align: left;
}
.swatch-btn .bar { display: flex; height: 12px; border-radius: 3px; overflow: hidden; }
.swatch-btn .bar span { flex: 1; }
.swatch-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--text); }
.text-input { width: 100%; }
.controls-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px 14px;
  border-top: 1px solid var(--line);
}
.controls-foot .control { margin: 0; display: flex; gap: 10px; }
.controls-title {
  margin: 6px 0 24px;
  font: 400 13px var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.control { display: grid; gap: 10px; margin-bottom: 22px; }
.control > label { font-size: 13px; }
.range-row { display: grid; grid-template-columns: minmax(0, 1fr) 46px; align-items: center; gap: 12px; }
output {
  font: 12px var(--font-mono);
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  --p: 50%;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--text) var(--p), var(--line-strong) var(--p));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line-strong); border-radius: 2px; }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--text); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.select-wrap select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 38px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23e7ebe4' stroke-width='2' d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  font-size: 13px;
  cursor: pointer;
  text-overflow: ellipsis;
}
.select-wrap select:disabled { opacity: 0.5; cursor: not-allowed; }
.select-wrap.compact select { height: 34px; width: auto; min-width: 140px; max-width: 220px; border-radius: 8px; }
.toggle-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 32px;
  height: 18px;
  margin: 0;
  border-radius: 99px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); background: var(--accent-ink); }
input[type="text"] {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
}
input[type="color"] {
  width: 40px;
  height: 26px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.advanced summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}
.advanced summary:hover { color: var(--text); }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary svg { width: 14px; height: 14px; transition: transform 0.2s; }
.advanced[open] summary svg { transform: rotate(90deg); }
.advanced-body { margin-top: 18px; }

/* Output */
#out { max-width: 100%; max-height: 100%; }
#outText {
  position: absolute;
  margin: 0;
  overflow: hidden;
  font-family: var(--font-mono);
  white-space: pre;
  letter-spacing: 0;
  user-select: text;
}
.output-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}
.meta {
  margin: 0;
  font: 12px var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.foot-actions { display: flex; align-items: center; gap: 10px; }
.rec-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 11px var(--font-mono);
  letter-spacing: 0.05em;
  color: #fff;
  background: rgba(200, 40, 40, 0.9);
  padding: 4px 9px;
  border-radius: 99px;
}
.rec-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1s steps(1) infinite; }

/* Styles filmstrip */
.styles-strip {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.styles-strip h2 {
  margin: 32px 0 0;
  font: 400 14px var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.style-list {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 4px 4px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.style-tile {
  flex: none;
  display: grid;
  justify-items: center;
  gap: 10px;
  width: 94px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
}
.style-tile .thumb {
  display: grid;
  place-items: center;
  width: 94px;
  height: 94px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #000;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}
.style-tile canvas { width: 100%; height: 100%; display: block; }
.style-tile:hover .thumb { border-color: var(--muted); transform: translateY(-2px); }
.style-tile:hover { color: var(--text); }
.style-tile[aria-pressed="true"] { color: var(--accent); }
.style-tile[aria-pressed="true"] .thumb { border: 2px solid var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.style-tile .name { font-size: 12.5px; }
.style-tile .tag {
  font: 10px var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: -6px;
  opacity: 0.8;
}
.effect-badge {
  display: inline-block;
  margin-left: 8px;
  font: 10.5px var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  vertical-align: 2px;
}

/* Library and About pages */
.page { max-width: 1240px; margin: 0 auto; padding-block: 8px 40px; }
.page-head h1 {
  margin: 12px 0 10px;
  font: 300 34px/1.1 var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.page-head p { margin: 0; max-width: 62ch; color: var(--muted); font-size: 15px; }
.section-label {
  margin: 36px 0 14px;
  font: 400 13px var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-grid, .capture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 16px;
}
.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.card canvas, .card img, .card video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  background: #000;
}
.card-body { flex: 1; display: grid; align-content: start; gap: 6px; padding: 14px 16px 16px; }
.card h3 { margin: 0; font-size: 15px; font-weight: 500; }
.card p { margin: 0; color: var(--muted); font-size: 13px; }
.card-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.btn-sm {
  height: 32px;
  padding: 0 14px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-size: 12.5px;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm.danger:hover { border-color: var(--danger); color: var(--danger); }
.card.current { border-color: var(--accent); }
.empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 32px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}
.about-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 48px; margin-top: 28px; }
.prose { max-width: 66ch; }
.prose h2, .about-side h2 { margin: 28px 0 10px; font-size: 16px; font-weight: 500; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: #c4ccc6; line-height: 1.65; }
.prose ol { padding-left: 20px; display: grid; gap: 8px; }
code, kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--panel-raised);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 1px 6px;
}
.ramp { border: 1px solid var(--line); border-radius: 12px; background: #000; padding: 18px; }
.ramp pre {
  margin: 0;
  font: 400 28px/1.2 var(--font-mono);
  letter-spacing: 0.25em;
  color: var(--text);
  background: linear-gradient(90deg, #3a443e, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  overflow-x: auto;
}
.ramp-scale { display: flex; justify-content: space-between; margin-top: 10px; font: 11px var(--font-mono); color: var(--muted); }
.keys { display: grid; gap: 10px; margin: 0; }
.keys div { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.keys dt { margin: 0; }
.keys dd { margin: 0; color: var(--muted); font-size: 13px; text-align: right; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel-raised);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  font-size: 13.5px;
}
.toast button { border: 0; background: none; color: var(--accent); font-weight: 500; padding: 0; }

/* Responsive */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .controls { grid-column: 1 / -1; order: 3; contain: none; min-height: 0; }
  .control-list { overflow: visible; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; align-items: start; }
  .control-section { grid-column: 1 / -1; }
  .effect-tabs { max-width: 520px; }
  .about-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .topbar { grid-template-columns: minmax(0, 1fr); justify-items: start; padding-top: 20px; }
  .topbar-note { display: none; }
  .logo { font-size: 24px; }
  .tabs { gap: 22px; overflow-x: auto; max-width: 100%; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .control-list { grid-template-columns: minmax(0, 1fr); }
  .output-panel { order: 2; }
  .input-actions { gap: 12px; }
  .pill { min-width: 0; flex: 1; padding: 0 18px; }
  .round { width: 52px; height: 52px; }
  .styles-strip { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .styles-strip h2 { margin: 0; }
  .panel-head { flex-wrap: wrap; row-gap: 8px; }
  .select-wrap.compact select { min-width: 0; max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
