/* Custom properties on body so ../css/main.css :root (marketing) can load first without clobbering app tokens */
body.page--online {
  color-scheme: dark;
  --bg: #05070a;
  --panel: #11151b;
  --panel-2: #171c23;
  --line: rgba(255, 255, 255, 0.14);
  --text: #f7f8fb;
  --muted: #a5adba;
  --accent: #49a7ff;
  --danger: #f43f5e;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  --top-control-height: 44px;
  --settings-range-width: 92px;
  --settings-value-width: 50px;
  background: var(--bg);
  background-image: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page--online .app-shell {
  flex: 1 1 auto;
  min-height: 0;
}

.stage {
  position: relative;
  flex: 1;
  min-height: calc(100vh - 132px - var(--header-h, 72px));
  overflow: hidden;
  background: var(--bg);
  --video-left: 0px;
  --video-top: 0px;
  --video-width: 100%;
  --video-height: 100%;
}

.stage.recording {
  min-height: calc(100vh - 132px - var(--header-h, 72px));
}

.camera-preview,
.record-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.camera-preview {
  display: none;
}

.stage.recording .camera-preview {
  display: block;
  inset: auto;
  left: var(--video-left);
  top: var(--video-top);
  width: var(--video-width);
  height: var(--video-height);
  transform: none;
}

.record-canvas {
  display: none;
}

.prompter-layer {
  position: absolute;
  inset: 28px 52px;
  overflow: hidden;
  transform-origin: center;
  color: #fff;
}

.prompter-content {
  width: 86%;
  min-height: 100%;
  margin: 0 auto;
  padding: 32px 12px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 42px;
  line-height: 1.2;
  text-align: left;
  will-change: transform;
}

.stage.recording .prompter-layer {
  inset: auto;
  width: 520px;
  height: 280px;
  left: calc(50% - 260px);
  top: 44px;
  border: 0;
  background: rgba(0, 0, 0, 0.18);
  box-shadow: var(--shadow);
  cursor: move;
  user-select: none;
}

.stage.recording .prompter-layer.is-move-selected {
  outline: 2px solid rgba(73, 167, 255, 0.9);
  outline-offset: 0;
}

.stage.recording .prompter-layer.is-resize-selected {
  outline: 2px solid rgba(34, 197, 94, 0.95);
  outline-offset: 0;
}

.stage.recording .prompter-layer.is-resizing {
  cursor: nwse-resize;
}

.stage.recording .prompter-layer::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 16px;
  height: 16px;
  border-right: 2px solid rgba(255, 255, 255, 0.72);
  border-bottom: 2px solid rgba(255, 255, 255, 0.72);
  cursor: nwse-resize;
}

.stage.recording .prompter-content {
  width: 100%;
}

.topbar {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.mode-tabs,
.camera-toggle,
.voice-control,
.top-actions,
.side-controls,
.record-controls {
  pointer-events: auto;
}

.mode-tabs {
  display: inline-flex;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(13, 17, 23, 0.74);
  backdrop-filter: blur(16px);
}

.tab,
.icon-button,
.ghost-button,
.seg,
.preset-row button {
  min-height: 36px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
}

.tab {
  min-height: 0;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
}

.icon-button {
  height: 36px;
  border-radius: 10px;
  font-size: 12px;
}

.tab.is-active,
.seg.is-active {
  background: rgba(73, 167, 255, 0.18);
  color: var(--text);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
}

.camera-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
}

.camera-toggle[hidden] {
  display: none;
}

.camera-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.camera-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.camera-toggle span {
  position: relative;
  width: 40px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.12);
}

.camera-toggle span::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--muted);
  transition: transform 0.16s ease, background 0.16s ease;
}

.camera-toggle input:checked + span {
  background: rgba(73, 167, 255, 0.26);
}

.camera-toggle input:checked + span::after {
  background: var(--accent);
  transform: translateX(18px);
}

.voice-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--top-control-height);
  padding: 0;
  border: 0;
  background: transparent;
}

.stage.recording .voice-control {
  display: none;
}

.voice-button,
.voice-help-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.voice-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.voice-button .mic-on-icon {
  display: none;
}

.voice-control.is-listening .voice-button {
  color: #22c55e;
}

.voice-control.is-listening .mic-off-icon {
  display: none;
}

.voice-control.is-listening .mic-on-icon {
  display: block;
}

.voice-help-button {
  border: 0;
  color: var(--text);
  font-weight: 700;
}

.icon-button,
.ghost-button {
  border: 1px solid var(--line);
  background: rgba(13, 17, 23, 0.72);
}

.panel-close-button {
  display: grid;
  place-items: center;
  width: 30px;
  min-height: 30px;
  height: 30px;
  padding: 0;
}

.panel-close-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.side-controls {
  position: absolute;
  left: 50%;
  top: 16px;
  display: flex;
  flex-direction: row;
  gap: 10px;
  transform: translateX(-50%);
}

.round-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(13, 17, 23, 0.72);
  color: var(--text);
  padding: 0;
  font-size: 22px;
  backdrop-filter: blur(16px);
}

.round-button.icon-only {
  line-height: 1;
}

.round-button svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.round-button svg.play-icon {
  fill: currentColor;
  stroke: none;
}

.round-button.reset-button {
  font-size: 12px;
}

#textButton,
#speedButton {
  display: none;
}

.round-button.primary {
  background: rgba(73, 167, 255, 0.22);
}

.record-controls {
  position: absolute;
  left: 50%;
  bottom: 26px;
  display: none;
  align-items: center;
  gap: 16px;
  transform: translateX(-50%);
}

.stage.recording .record-controls {
  display: flex;
}

.record-button {
  width: 78px;
  height: 78px;
  border: 4px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: transparent;
}

.record-button span {
  display: block;
  width: 56px;
  height: 56px;
  margin: auto;
  border-radius: 50%;
  background: var(--danger);
}

.record-button.is-recording span {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.download-link {
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(13, 17, 23, 0.82);
  color: var(--text);
  text-decoration: none;
}

.countdown {
  position: absolute;
  left: 50%;
  top: 50%;
  color: #fff;
  font-size: 72px;
  font-weight: 800;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.72);
  transform: translate(-50%, -50%);
}

.panel {
  position: relative;
  order: -1;
  z-index: 8;
  display: grid;
  grid-template-columns: 172px repeat(4, calc(22px + var(--settings-range-width) + var(--settings-value-width))) 116px;
  grid-template-rows: repeat(2, 30px);
  align-items: center;
  justify-content: space-between;
  column-gap: 5px;
  row-gap: 6px;
  width: 100%;
  min-height: 0;
  max-height: 132px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  overflow-x: auto;
  overflow-y: hidden;
}

.panel-header,
.panel-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-header {
  display: contents;
}

.panel-subhead,
.preset-card h3 {
  display: none;
}

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

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 16px;
  line-height: 1.1;
}

.panel-title {
  display: grid;
  justify-items: start;
  grid-column: 1;
  grid-row: 1;
  min-width: 172px;
  padding-right: 8px;
}

.panel-title h1 {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-title::after {
  content: "";
  position: absolute;
  left: 181px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--line);
}

h2 {
  font-size: 15px;
}

h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field,
.control,
.recording-tools {
  display: grid;
  gap: 4px;
}

.field label,
.control span,
.swatches label,
.toggles label {
  color: var(--muted);
  font-size: 12px;
}

textarea {
  width: 100%;
  min-height: 220px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  resize: vertical;
}

.script-modal textarea {
  min-height: 360px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, 1fr));
  gap: 6px;
  flex: 1 1 520px;
  min-width: 460px;
}

.settings-columns {
  display: contents;
}

.control-group {
  display: grid;
  grid-template-rows: repeat(2, 30px);
  gap: 6px;
}

.settings-columns .control {
  display: grid;
  grid-template-columns: 18px var(--settings-range-width) var(--settings-value-width);
  align-items: center;
  column-gap: 1px;
}

.speed-size-group {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.text-layout-group {
  grid-column: 3;
  grid-row: 1 / span 2;
}

.area-size-group {
  grid-column: 4;
  grid-row: 1 / span 2;
}

.position-group {
  grid-column: 5;
  grid-row: 1 / span 2;
}

.control b {
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.control span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.control span svg,
.settings-columns .control > svg,
.swatches svg,
.toggles svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.settings-columns input[type="range"] {
  width: var(--settings-range-width);
}

.swatches,
.toggles,
.segmented,
.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.swatches {
  align-items: center;
}

.quick-icons {
  display: grid;
  grid-template-rows: 30px 30px;
  gap: 6px;
  grid-column: 6;
  grid-row: 1 / span 2;
}

.swatches label,
.toggles label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.swatches label {
  width: 38px;
  height: 30px;
  min-height: 30px;
}

.toggles label,
.segmented label {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.swatches input[type="color"] {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  background: transparent;
}

.toggles input,
.segmented input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
  margin: 0;
}

.segmented label {
  display: grid;
  place-items: center;
  padding: 0;
}

.segmented label svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.segmented {
  flex: 0 0 auto;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  width: max-content;
  gap: 3px;
}

.seg {
  display: grid;
  place-items: center;
  min-width: 22px;
  min-height: 22px;
  padding: 0;
  color: var(--muted);
}

.seg.is-active {
  border-radius: 6px;
}

.icon-label {
  display: grid;
  place-items: center;
}

.icon-label svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.recording-tools {
  display: contents;
}

.preset-card {
  display: flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  grid-column: 1;
  grid-row: 2;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  width: 140px;
}

.preset-row button {
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.preset-icon-button {
  display: grid;
  place-items: center;
  padding: 0;
}

.preset-icon-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.has-tooltip {
  position: relative;
}

.has-tooltip::after {
  display: none;
}

.floating-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 80;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(5, 7, 10, 0.96);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  opacity: 1;
  pointer-events: none;
  transform: translateX(-50%);
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.floating-tooltip[hidden] {
  display: none;
}

body.panel-collapsed .panel {
  display: none;
}

body.panel-collapsed .app-shell {
  grid-template-columns: 1fr;
}

body.panel-collapsed .stage {
  min-height: calc(100vh - var(--header-h, 72px));
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.54);
}

.modal-backdrop[hidden] {
  display: none;
}

.script-modal {
  position: relative;
  display: grid;
  gap: 18px;
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: auto;
}

.script-modal .panel-header,
.voice-modal .panel-header {
  display: flex;
}

.script-modal .panel-header {
  padding-right: 46px;
}

.script-modal .modal-close-button {
  position: absolute;
  top: 14px;
  right: 14px;
}

.script-modal .ghost-button {
  border-radius: 10px;
}

.voice-modal {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(440px, 100%);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.command-list {
  display: grid;
  gap: 8px;
}

.command-list div {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}

.command-list b {
  font-size: 14px;
}

.command-list span {
  color: var(--muted);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button {
  min-height: 36px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--accent);
  color: #03101d;
  font-weight: 700;
}

.modal-close-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
}

.modal-close-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

@media (max-width: 980px) {
  .panel {
    grid-template-columns: 160px repeat(4, calc(22px + var(--settings-range-width) + var(--settings-value-width))) 116px;
    justify-content: flex-start;
    column-gap: 10px;
    max-height: 132px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .stage {
    min-height: calc(100vh - 132px - var(--header-h, 72px));
  }

  .panel-title {
    min-width: 160px;
  }

  .panel-title h1 {
    font-size: 15px;
  }

  .control-grid {
    flex: 0 0 460px;
  }

  .preset-card {
    flex: 0 0 auto;
  }

  .prompter-layer {
    inset: 70px 18px 28px;
  }
}
