:root {
  --bg: #111111;
  --panel: rgba(20, 20, 20, 0.92);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #f6f1e8;
  --muted: rgba(246, 241, 232, 0.62);
  --accent: #d6b36a;
  --stage-bg: #050505;
  --stage-text: #f6f1e8;
  --focus-text: #ffffff;
  --dim-opacity: .26;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, #2c2416, #080808 42%, #000 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  color: #12100b;
  background: var(--accent);
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); opacity: .82; }
button.secondary, button.ghost, #reset, #fullscreen {
  color: var(--text);
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.1);
}
button.ghost { padding: 8px 10px; color: var(--muted); }
button.primary { font-weight: 700; }

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 18px;
  padding: 18px;
}
.app.panelCollapsed { grid-template-columns: 0 1fr; }
.app.panelCollapsed .panel { transform: translateX(-430px); pointer-events: none; }
.app.panelCollapsed .stageWrap { grid-column: 2; }

.panel {
  min-width: 0;
  overflow-y: auto;
  background: var(--panel);
  backdrop-filter: blur(24px);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 22px 80px rgba(0,0,0,.38);
  transition: transform .2s ease;
}
.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
h1 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.card {
  display: grid;
  gap: 10px;
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  background: rgba(255,255,255,.045);
}
.card label { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; }
.wrap { flex-wrap: wrap; }
input[type="text"], input[type="file"], select, textarea {
  width: 100%;
  color: var(--text);
  background: rgba(0,0,0,.32);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding: 10px 11px;
  outline: none;
}
input[type="file"] { min-width: 0; font-size: 12px; }
textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.5;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
}
.hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.voiceMeter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
}
.voiceMeter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6ac78f, var(--accent));
  transition: width .12s linear;
}
.grid2 { grid-template-columns: 1fr; }
.compact { grid-template-columns: 1fr 1fr; align-items: center; }
.check { display: flex; align-items: center; gap: 8px; }
.wide { grid-column: 1 / -1; }
.check.wide { grid-column: 1 / -1; }
.controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.stageWrap {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: rgba(246,241,232,.55);
  font-size: 13px;
  padding: 0 4px;
}
.stage {
  position: relative;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
  border-radius: 28px;
  background: var(--stage-bg);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02), 0 28px 100px rgba(0,0,0,.52);
}
.stage.dragging { cursor: grabbing; }
.stage::before, .stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 22%;
  z-index: 2;
  pointer-events: none;
}
.stage::before { top: 0; background: linear-gradient(to bottom, var(--stage-bg), transparent); }
.stage::after { bottom: 0; background: linear-gradient(to top, var(--stage-bg), transparent); }
.stage.focusGuide::before,
.stage.focusGuide::after { display: none; }
.script {
  position: absolute;
  width: 100%;
  padding: 42vh 7vw 60vh;
  color: var(--stage-text);
  font-size: 56px;
  line-height: 1.55;
  white-space: normal;
  will-change: transform;
  transform: translateY(0);
  letter-spacing: .01em;
}
.scriptLine {
  opacity: 1;
  transition: opacity .12s linear;
}
.stage.focusGuide .scriptLine { opacity: var(--dim-opacity); }
.stage.focusGuide .scriptLine.inFocus { opacity: 1; color: var(--focus-text); }
.transparent .stage {
  background: transparent !important;
  border-color: transparent;
  box-shadow: none;
}
.transparent .stage::before,
.transparent .stage::after { display: none; }
.mirror .script { transform: scaleX(-1) translateY(0); }

@media (max-width: 900px) {
  body { overflow: auto; }
  .app { min-height: 100%; height: auto; grid-template-columns: 1fr; overflow: visible; }
  .stageWrap { min-height: 72vh; }
  .stage { min-height: 72vh; }
  .controls { grid-template-columns: 1fr; }
}
