:root {
  --bg: #000;
  --fg: #fff;
  --fg-dim: #b3b3b3;
  --border: #222;
  --band: 120px;
  --fontSize: 42px;
  --lineH: 1.25;
  --prompt-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --prompt-weight: 600;
  /* 500–600 is ideal */
  --prompt-tracking: 0.01em;
  /* 0.01–0.03em improves legibility */
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* ===== Layout ===== */
.layout {
  height: 100vh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  overflow: hidden;
  /* optional: no page scroll */
}

.top {
  min-height: 0;
  /* CRITICAL: let the row shrink */
  display: flex;
  flex-direction: column;
}

.bottom {
  min-height: 0;
  /* prevent content from growing the row */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 16px;
  /* no top padding */
}

/* ===== Teleprompter band + viewport ===== */
.top-band {
  position: relative;
  /* was: sticky */
  top: auto;
  height: var(--band);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.25);
  pointer-events: none;
}

.viewport {
  flex: 1 1 0;
  min-height: 0;
  /* CRITICAL in Safari/Chrome */
  max-width: 1000px;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  text-align: center;
}

.probe {
  position: absolute;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  font-size: var(--fontSize);
  line-height: var(--lineH);
  pointer-events: none;
}

.scroller {
  will-change: transform;
  font-size: var(--fontSize);
  line-height: var(--lineH);
  text-align: center;
  font-family: var(--prompt-font);
  font-weight: var(--prompt-weight);
  letter-spacing: var(--prompt-tracking);
}

.line {
  color: #d0d0d0;
  padding: 0 2px;
  user-select: none;
}

.line.current {
  color: #fff;
}

.line.past {
  color: #6e6e6e;
}

/* Mirror only the prompter content */
.mirror #viewport {
  transform: scaleX(-1);
}

/* ===== Panels (bottom half) ===== */
.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #0e0e0e;
  padding: 16px;
}

.controls-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.btn {
  background: #1a1a1a;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.btn:hover {
  background: #222;
}

.sliders {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.ctl {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  color: var(--fg-dim);
  font-size: 12px;
}

.ctl input[type="range"] {
  width: 100%;
}

.meta {
  display: flex;
  gap: 18px;
  color: var(--fg-dim);
  font-size: 12px;
  margin: 6px 0 4px;
}

.hint {
  color: var(--fg-dim);
  font-size: 12px;
  margin: 0;
}

h2 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--fg);
}

.script {
  width: 100%;
  height: 93%;
  min-height: 220px;
  background: #101010;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 15px;
  line-height: 1.4;
}

/* Responsive: stack controls over editor on narrow screens */
@media (max-width: 900px) {
  .bottom {
    grid-template-columns: 1fr;
  }
}