/* ASCII//FORGE — dark brutalist, Blade Runner leaning */

:root {
  --bg: #060608;
  --bg-panel: #0b0b0f;
  --bg-inset: #101016;
  --line: #2a2a33;
  --line-hard: #3d3d4a;
  --text: #c8c8d0;
  --text-dim: #5e5e6c;
  --acid: #ccff00;
  --neon: #00f0ff;
  --magenta: #ff2a6d;
  --mono: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* scanline overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.18) 0px,
    rgba(0, 0, 0, 0.18) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 999;
}

/* ============ HEADER ============ */
.topbar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 2px solid var(--line-hard);
  background: var(--bg-panel);
}

.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--text);
}

.logo-slash { color: var(--magenta); }

.tagline {
  color: var(--text-dim);
  letter-spacing: 2px;
  font-size: 11px;
}

/* ============ LAYOUT ============ */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 0;
}

/* ============ CONTROL PANEL ============ */
.panel {
  background: var(--bg-panel);
  border-right: 2px solid var(--line-hard);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.block-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--acid);
  margin-bottom: 10px;
}

/* drop zone */
.dropzone {
  border: 2px dashed var(--line-hard);
  padding: 22px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--neon);
  background: var(--bg-inset);
}

.drop-label {
  color: var(--text-dim);
  letter-spacing: 1px;
  line-height: 1.6;
}

.drop-hint {
  margin-top: 8px;
  color: var(--line-hard);
  font-size: 10px;
  letter-spacing: 1px;
}

.drop-meta {
  margin-top: 8px;
  color: var(--neon);
  font-size: 11px;
  word-break: break-all;
}

/* demo gallery */
.demo-row { margin-top: 10px; }

.demo-label {
  display: block;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.demo-btns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.btn-demo { padding: 8px 4px; }

.btn-cam {
  width: 100%;
  margin-top: 10px;
}

.btn-rec {
  width: 100%;
  margin-top: 8px;
}

.btn-rec.recording {
  background: var(--magenta);
  color: #000;
  border-color: var(--magenta);
  animation: recblink 1s steps(2) infinite;
}

@keyframes recblink {
  50% { opacity: 0.55; }
}

.paste-hint {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--line-hard);
  text-align: center;
}

/* controls */
.ctl {
  display: block;
  margin-bottom: 12px;
}

.ctl-name {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.ctl-name em {
  font-style: normal;
  color: var(--text);
}

.ctl-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctl-check .ctl-name { margin-bottom: 0; }

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--line);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 18px;
  background: var(--neon);
  cursor: ew-resize;
  border: none;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 18px;
  background: var(--neon);
  cursor: ew-resize;
  border: none;
  border-radius: 0;
}

select, input[type="text"] {
  width: 100%;
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--line-hard);
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 8px;
  border-radius: 0;
  outline: none;
}

select:focus, input[type="text"]:focus { border-color: var(--neon); }

input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--line-hard);
  background: var(--bg-inset);
  cursor: pointer;
  flex-shrink: 0;
}

input[type="checkbox"]:checked {
  background: var(--magenta);
  border-color: var(--magenta);
}

/* buttons */
.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--line-hard);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 10px 6px;
  cursor: pointer;
  border-radius: 0;
  transition: all 0.1s;
}

.btn:hover:not(:disabled) {
  background: var(--neon);
  color: #000;
  border-color: var(--neon);
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.save-options { margin-top: 10px; }

.save-options-label {
  display: block;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.btn.flash {
  background: var(--acid);
  color: #000;
  border-color: var(--acid);
}

/* ============ STAGE ============ */
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 2px;
}

.stage-toggle { margin: 0; }

.stage-body {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background:
    linear-gradient(rgba(0, 240, 255, 0.02), transparent 40%),
    var(--bg);
}

#out-canvas {
  display: block;
  image-rendering: pixelated;
  border: 1px solid var(--line);
}

#out-text {
  font-family: var(--mono);
  line-height: 1;
  white-space: pre;
  color: var(--text);
}

.stage-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-dim);
  letter-spacing: 4px;
}

.empty-art {
  color: var(--line-hard);
  font-size: 11px;
  line-height: 1.2;
}

/* ============ STATUS BAR ============ */
.statusbar {
  display: flex;
  justify-content: space-between;
  padding: 8px 20px;
  border-top: 2px solid var(--line-hard);
  background: var(--bg-panel);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 1px;
}

/* ============ MOBILE ============ */
@media (max-width: 820px) {
  /* release fixed viewport height so page scrolls naturally */
  html, body { height: auto; }

  body {
    overflow: auto;
    min-height: 100vh;
  }

  .layout {
    flex: none;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  /* preview pinned on top, controls scroll underneath */
  .stage {
    order: 1;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    border-bottom: 2px solid var(--line-hard);
  }

  .stage-body {
    /* flex:1 from desktop has flex-basis 0 which beats height; kill it */
    flex: none;
    /* dvh tracks the real visible viewport on mobile (url bar etc.) */
    height: 38vh;
    height: 38dvh;
    min-height: 200px;
    padding: 10px;
  }

  /* fit inside the preview box in BOTH directions, never spill over controls */
  #out-canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    margin: 0 auto;
  }

  .panel {
    order: 2;
    border-right: none;
    overflow: visible;
  }

  .topbar {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .logo { font-size: 16px; }

  /* touch targets */
  input[type="range"] { height: 6px; }

  input[type="range"]::-webkit-slider-thumb {
    width: 22px;
    height: 26px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 26px;
  }

  input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }

  .btn { padding: 14px 6px; font-size: 12px; }

  select, input[type="text"] { padding: 11px 8px; font-size: 14px; }

  .stage-header { padding: 8px 14px; }

  .statusbar {
    flex-wrap: wrap;
    gap: 4px;
  }
}

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-hard); }
::-webkit-scrollbar-thumb:hover { background: var(--neon); }
