:root {
  --paper: #0b0b0b;
  --ink: #ffffff;
  --muted: #c8c8c8;
  --panel: #151515;
  --panel-strong: #0b0b0b;
  --line: #2c2c2c;
  --accent: #fd5a1e;
  --accent-strong: #d84d17;
  --warm: #fd5a1e;
  --danger: #ff6f61;
  --danger-bg: rgba(255, 111, 97, 0.13);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  width: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

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

.sprite {
  display: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: var(--panel-strong);
  color: #ffffff;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  min-height: 68px;
  padding: 0.85rem clamp(1rem, 3vw, 2.25rem);
}

.brand {
  align-items: center;
  color: inherit;
  display: inline-flex;
  font-size: 1.45rem;
  font-weight: 950;
  gap: 0.65rem;
  text-decoration: none;
}

.brand span {
  color: var(--accent);
}

.brand img {
  height: 34px;
  width: 34px;
}

.topbar-status {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #ffffff;
  font-size: 0.86rem;
  max-width: min(48vw, 36rem);
  overflow: hidden;
  padding: 0.45rem 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 410px);
  min-width: 0;
  min-height: calc(100vh - 68px);
}

.editor-pane {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  min-width: 0;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.editor-intro {
  max-width: 820px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 0.45rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 4.8rem;
  line-height: 0.96;
  margin-bottom: 0;
  max-width: 980px;
  overflow-wrap: break-word;
}

h2 {
  font-size: 1rem;
  margin-bottom: 0;
}

#scriptInput {
  background: #171717;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
  flex: 1;
  font-size: 16px;
  line-height: 1.45;
  min-height: 42vh;
  outline: none;
  overflow-x: hidden;
  overflow-wrap: break-word;
  padding: 1.25rem;
  resize: vertical;
  white-space: pre-wrap;
  width: 100%;
}

#scriptInput::placeholder {
  color: #9e9e9e;
}

#scriptInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(253, 90, 30, 0.18), var(--shadow);
}

.editor-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.button,
.tool-button,
.segment {
  align-items: center;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 750;
  gap: 0.5rem;
  justify-content: center;
  min-height: 42px;
  padding: 0.7rem 0.95rem;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.button:hover,
.tool-button:hover,
.segment:hover {
  transform: translateY(-1px);
}

.button svg,
.tool-button svg {
  fill: currentColor;
  flex: 0 0 auto;
  height: 18px;
  width: 18px;
}

.button.primary {
  background: var(--accent);
  color: #0b0b0b;
}

.button.primary:hover {
  background: #ff7a3d;
}

.button.ghost {
  background: #1f1f1f;
  color: #ffffff;
}

.button.ghost:hover {
  background: #2b2b2b;
}

.button.text {
  background: transparent;
  color: var(--muted);
  min-height: 32px;
  padding: 0.35rem 0.45rem;
}

.button.danger,
.tool-button.danger,
.danger {
  color: var(--danger);
}

.button.ghost.danger {
  background: var(--danger-bg);
}

.button.chip {
  background: #1f1f1f;
  color: #ffffff;
  min-height: 38px;
  padding: 0.55rem 0.8rem;
}

.button.chip.active {
  background: var(--panel-strong);
  color: #ffffff;
}

.section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 36px;
}

.history-zone,
.downloads-zone {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

.history-list,
.download-list {
  display: grid;
  gap: 0.65rem;
}

.empty-state {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.history-item,
.download-item {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 0.85rem;
  justify-content: space-between;
  padding: 0.8rem 0.9rem;
}

.history-item button {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  min-width: 0;
  padding: 0;
  text-align: left;
  width: 100%;
}

.history-title {
  display: block;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta,
.download-meta {
  color: var(--muted);
  display: block;
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.download-item a {
  color: var(--accent-strong);
  display: inline-flex;
  flex: 0 0 auto;
  font-weight: 800;
  gap: 0.35rem;
  text-decoration: none;
}

.download-item svg {
  fill: currentColor;
  width: 18px;
}

.settings-pane {
  background: var(--panel-strong);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  padding: clamp(1rem, 2vw, 1.6rem);
}

.settings-pane h2 {
  font-size: 1.3rem;
}

.control-block,
.toggle-grid,
.slider-grid,
.theme-row,
.color-grid {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.9rem;
}

.control-block {
  display: grid;
  gap: 0.55rem;
}

.control-block label,
.range-row,
.color-grid label {
  font-size: 0.88rem;
  font-weight: 750;
}

select,
input[type="color"] {
  background: #ffffff;
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  color: #0b0b0b;
  min-height: 40px;
  padding: 0.55rem 0.65rem;
  width: 100%;
}

.hint {
  color: #b7b6ac;
  font-size: 0.8rem;
  line-height: 1.4;
  margin: 0;
}

.segmented {
  background: rgba(0, 0, 0, 0.22);
  border-radius: 8px;
  display: grid;
  gap: 0.35rem;
  grid-template-columns: repeat(3, 1fr);
  padding: 0.35rem;
}

.segment {
  background: transparent;
  color: #dbdad0;
  min-height: 36px;
  padding: 0.5rem 0.45rem;
}

.segment.active {
  background: #f5f5ef;
  color: #161614;
}

.toggle-grid,
.slider-grid,
.color-grid {
  display: grid;
  gap: 0.8rem;
}

.switch-row {
  align-items: center;
  color: #f0efe7;
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1fr auto;
  min-height: 34px;
}

.switch-row input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.switch {
  background: #5f5e55;
  border-radius: 999px;
  display: inline-flex;
  height: 24px;
  position: relative;
  width: 44px;
}

.switch::after {
  background: #ffffff;
  border-radius: 50%;
  content: "";
  height: 18px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform 160ms ease;
  width: 18px;
}

.switch-row input:checked + .switch {
  background: var(--accent);
}

.switch-row input:checked + .switch::after {
  transform: translateX(20px);
}

.range-row {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: 1fr auto;
}

.range-row input {
  accent-color: var(--accent);
  grid-column: 1 / -1;
  width: 100%;
}

.range-row output {
  color: #ff9b6c;
}

.theme-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.color-grid {
  grid-template-columns: 1fr 1fr;
}

.color-grid input {
  margin-top: 0.45rem;
  padding: 0.2rem;
}

.teleprompter {
  background: #000000;
  color: #ffffff;
  height: 100vh;
  overflow: hidden;
  position: relative;
  width: 100vw;
}

.teleprompter.rotated {
  height: 100vw;
  left: 50%;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
  width: 100vh;
}

.prompter-toolbar {
  align-items: center;
  background: rgba(12, 12, 10, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  display: flex;
  gap: 0.65rem;
  justify-content: space-between;
  left: 0;
  min-height: 62px;
  padding: max(0.7rem, env(safe-area-inset-top)) clamp(0.7rem, 2vw, 1rem) 0.7rem;
  position: absolute;
  right: 0;
  top: 0;
  z-index: 40;
}

.toolbar-left,
.toolbar-right {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tool-button {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  min-height: 38px;
  padding: 0.55rem 0.65rem;
}

.tool-button.icon-only {
  aspect-ratio: 1;
  min-width: 38px;
  padding: 0.55rem;
}

.tool-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.tool-button.active,
.tool-button[aria-pressed="true"] {
  background: var(--accent);
  color: #0b0b0b;
}

.tool-button.record {
  background: #ffffff;
  color: #0b0b0b;
}

.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.overlay-toggle {
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #ffffff;
  display: inline-flex;
  font-weight: 750;
  gap: 0.4rem;
  min-height: 38px;
  padding: 0.55rem 0.65rem;
}

.overlay-toggle input {
  accent-color: var(--accent);
}

.record-badge {
  align-items: center;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  font-size: 0.8rem;
  font-weight: 900;
  gap: 0.4rem;
  padding: 0.45rem 0.65rem;
  position: absolute;
  right: 1rem;
  top: 78px;
  z-index: 18;
}

.record-badge span {
  animation: pulse 900ms ease-in-out infinite;
  background: #ff3b30;
  border-radius: 50%;
  height: 9px;
  width: 9px;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.camera-preview {
  background: #050505;
  bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  height: min(34vh, 280px);
  object-fit: cover;
  position: absolute;
  right: 1rem;
  width: min(42vw, 430px);
  z-index: 12;
}

.camera-preview.overlay {
  height: 100%;
  inset: 0;
  opacity: 0.5;
  width: 100%;
  z-index: 1;
}

.active-guide {
  border-top: 2px solid rgba(253, 90, 30, 0.78);
  left: 0;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 35%;
  z-index: 4;
}

.prompter-stage {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24vh 0 45vh;
  position: relative;
  scroll-behavior: smooth;
  z-index: 5;
}

.prompter-stage.no-smooth {
  scroll-behavior: auto;
}

.script-display {
  margin: 0 auto;
  max-width: 1500px;
  min-height: 100%;
  overflow-wrap: anywhere;
  padding: 0 0;
  text-align: left;
  transform-origin: center center;
}

.script-display.mirror {
  transform: rotate(180deg) scaleX(-1);
}

.script-display p {
  margin: 0 0 var(--paragraph-spacing, 0.5em);
}

.word {
  border-radius: 0.12em;
  cursor: pointer;
  display: inline;
  opacity: 0.95;
  padding: 0 0.02em;
}

.word.spoken {
  opacity: 0.52;
}

.word.active {
  color: var(--active-color, #fd5a1e);
}

.script-display.highlight-active .word.active {
  text-decoration: underline;
  text-decoration-color: var(--active-color, #fd5a1e);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

.stop-sign {
  background: var(--active-color, #fd5a1e);
  border-radius: 999px;
  display: inline-block;
  height: 0.24em;
  margin: 0 0.22em 0.14em;
  vertical-align: middle;
  width: 0.24em;
}

.settings-drawer {
  background: rgba(11, 11, 11, 0.96);
  bottom: 0;
  color: #ffffff;
  max-width: min(92vw, 390px);
  overflow: auto;
  padding: 1rem;
  position: absolute;
  right: 0;
  top: var(--toolbar-height, 62px);
  width: 390px;
  z-index: 30;
}

.drawer-header {
  align-items: center;
  background: rgba(11, 11, 11, 0.98);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  justify-content: space-between;
  margin: -1rem -1rem 1rem;
  min-height: 54px;
  padding: 0.6rem 0.75rem 0.6rem 1rem;
  position: sticky;
  top: -1rem;
  z-index: 2;
}

.settings-drawer .settings-pane {
  background: transparent;
  min-height: 0;
  padding: 0;
}

.settings-drawer .settings-pane h2 {
  display: none;
}

.modal {
  align-items: center;
  background: rgba(10, 10, 9, 0.62);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: fixed;
  z-index: 60;
}

.modal-panel {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 460px;
  padding: 1.4rem;
  width: 100%;
}

.modal-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.toast {
  background: #0b0b0b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  bottom: 1rem;
  color: #ffffff;
  left: 50%;
  max-width: min(92vw, 560px);
  padding: 0.8rem 0.95rem;
  position: fixed;
  transform: translateX(-50%);
  z-index: 80;
}

@media (max-width: 980px) {
  h1 {
    font-size: 3.6rem;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .settings-pane {
    min-height: auto;
  }

  .prompter-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-left,
  .toolbar-right {
    overflow-x: auto;
    padding-bottom: 0.1rem;
  }

  .tool-button span {
    display: none;
  }

  .tool-button,
  .overlay-toggle {
    flex: 0 0 auto;
  }

  .prompter-stage {
    padding-top: 28vh;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-status {
    max-width: 100%;
    width: 100%;
  }

  h1 {
    font-size: 2.1rem;
  }

  .editor-actions .button {
    width: 100%;
  }

  .history-item,
  .download-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .color-grid {
    grid-template-columns: 1fr;
  }

  .camera-preview {
    bottom: 0.75rem;
    height: 24vh;
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
  }

  .settings-drawer {
    left: 0;
    max-width: none;
    right: 0;
    width: auto;
  }

  .script-display {
    max-width: 100%;
  }
}
