:root {
  color-scheme: dark;
  --background: #050505;
  --surface: #171717;
  --surface-strong: #242424;
  --line: #343434;
  --text: #f5f5f0;
  --muted: #aaa69f;
  --accent: #ffb800;
  --accent-strong: #ff8a00;
  --danger: #ff6b6b;
  --prompter-font-size: 42px;
  --prompter-line-height: 1.25;
  --prompter-paragraph-spacing: 0.8em;
  --prompter-side-margin: 24px;
  --prompter-align: left;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

button,
textarea,
select,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, rgba(255, 184, 0, 0.08), transparent 30%),
    var(--background);
}

.view {
  display: none;
}

.view.is-active {
  display: flex;
}

.editor {
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  gap: 16px;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top)) 16px calc(22px + env(safe-area-inset-bottom));
}

.editor__header {
  padding-top: 6px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  color: var(--accent);
  font-size: clamp(34px, 12vw, 56px);
  line-height: 1.05;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  text-transform: uppercase;
}

.script-label {
  color: var(--muted);
  font-size: 13px;
}

.script-input {
  flex: 1;
  min-height: 320px;
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  line-height: 1.5;
  outline: none;
  caret-color: var(--accent);
}

.script-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 184, 0, 0.14);
}

.script-input::placeholder {
  color: #77736d;
}

.editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button--primary {
  grid-column: 1 / -1;
  background: var(--accent);
  color: #111;
  box-shadow: 0 14px 36px rgba(255, 184, 0, 0.24);
}

.button--secondary {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
}

.prompter {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.prompter-stage {
  position: absolute;
  inset: 0;
  transform-origin: center;
  transition: transform 180ms ease;
}

.prompter-stage.is-mirrored {
  transform: scaleX(-1);
}

.prompter-stage.is-rotated {
  inset: 50% auto auto 50%;
  width: 100dvh;
  height: 100dvw;
  transform: translate(-50%, -50%) rotate(90deg);
}

.prompter-stage.is-rotated.is-mirrored {
  transform: translate(-50%, -50%) rotate(90deg) scaleX(-1);
}

.script-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

.script-track {
  width: 100%;
  min-height: 100%;
  padding:
    calc(28vh + env(safe-area-inset-top))
    max(var(--prompter-side-margin), env(safe-area-inset-right))
    calc(62vh + env(safe-area-inset-bottom))
    max(var(--prompter-side-margin), env(safe-area-inset-left));
  color: var(--text);
  font-size: var(--prompter-font-size);
  line-height: var(--prompter-line-height);
  text-align: var(--prompter-align);
  overflow-wrap: anywhere;
  will-change: transform;
}

.script-track p {
  margin: 0 0 var(--prompter-paragraph-spacing);
  white-space: pre-wrap;
}

.script-track p:last-child {
  margin-bottom: 0;
}

.script-emphasis {
  color: var(--accent);
  font-weight: 800;
}

.control-dock {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 52px);
  gap: 10px;
  transform: translateX(-50%);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  background: rgba(34, 34, 34, 0.92);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(16px);
}

.icon-button--primary {
  width: 62px;
  height: 62px;
  margin: -5px;
  border-color: rgba(255, 184, 0, 0.5);
  background: rgba(255, 184, 0, 0.96);
  color: #111;
}

.icon-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button .icon-pause {
  display: none;
}

.is-running .icon-play {
  display: none;
}

.is-running .icon-pause {
  display: block;
}

.countdown {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.36);
  color: var(--accent);
  font-size: clamp(96px, 36vw, 180px);
  font-weight: 800;
  line-height: 1;
}

.countdown.is-visible {
  display: grid;
}

.settings-panel {
  position: fixed;
  z-index: 40;
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  max-height: min(720px, calc(100dvh - 24px - env(safe-area-inset-top)));
  overflow: auto;
  transform: translateY(calc(100% + 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(23, 23, 23, 0.97);
  box-shadow: 0 -22px 80px rgba(0, 0, 0, 0.58);
  transition: transform 180ms ease;
  -webkit-overflow-scrolling: touch;
}

.settings-panel.is-open {
  transform: translateY(0);
}

.settings-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.settings-grid {
  display: grid;
  gap: 16px;
}

.control-group {
  margin: 0;
  border: 0;
  padding: 0;
}

.control-group legend,
.range-control span,
.select-control span,
.switch-control span {
  color: var(--muted);
  font-size: 13px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: var(--surface-strong);
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: block;
  min-height: 38px;
  border-radius: 6px;
  padding: 10px 6px;
  color: var(--text);
  text-align: center;
}

.segmented input:checked + span {
  background: #777;
}

.range-control,
.select-control,
.switch-control {
  display: grid;
  gap: 8px;
}

.range-control span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

output {
  color: var(--accent);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface-strong);
  color: var(--text);
}

.switch-control {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.switch-control small {
  display: block;
  margin-top: 4px;
  color: #77736d;
  font-size: 12px;
}

.switch-control input {
  width: 48px;
  height: 28px;
  accent-color: var(--accent);
}

@media (min-width: 720px) {
  .editor {
    padding-inline: 28px;
  }

  .settings-panel {
    left: auto;
    right: 18px;
    bottom: 18px;
    width: 380px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
