/*
 * Teleprompter. The page sits on the shared media-tools layout, and is the one
 * qpkit tool with a dark theme: html[data-theme="dark"] is set before paint by
 * the head script, and everything below that has a hard-coded paper colour in
 * media-tools.css or tool-theme.css is redefined for it at the end of the file.
 */

:root {
  --tp-stage: #e7e2d9;
  --tp-stage-ink: #191918;
  --tp-surface: #fffdf8;
  --tp-sunken: #ece7de;
  --tp-text-2: #56534d;
  --tp-muted: #878278;
  --tp-red: #d63a2f;
  --tp-amber: #b7791f;
  /* The floating prompter, as rgb triplets so the backdrop slider can set
     only the alpha. */
  --tp-pr-bg: 255, 253, 248;
  --tp-pr-edge: 25, 25, 24;
  --tp-pr-text: #191918;
  --tp-pr-shadow: 0 1px 1px rgba(255, 253, 248, .55);
  --tp-pr-cue: #1a6fa3;
  --tp-pr-band: rgba(26, 111, 163, .1);
}

html[data-theme="dark"] {
  --tp-stage: #0e0e0d;
  --tp-stage-ink: #f1ede4;
  --tp-surface: #1c1b19;
  --tp-sunken: #121211;
  --tp-text-2: #bdb8ad;
  --tp-muted: #8e897f;
  --tp-pr-bg: 10, 10, 9;
  --tp-pr-edge: 255, 253, 248;
  --tp-pr-text: #fffdf8;
  --tp-pr-shadow: 0 2px 4px rgba(0, 0, 0, .8);
  --tp-pr-cue: #7cc0ea;
  --tp-pr-band: rgba(124, 192, 234, .12);
}

/* ---------- Header ---------- */

.tp-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
}

.tp-hero-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tp-theme {
  grid-template-columns: auto auto auto;
}

.tp-theme button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
}

.tp-theme svg { width: 15px; height: 15px; }

.tp-icon-btn {
  width: 42px;
  padding: 0;
}

.tp-icon-btn svg { width: 18px; height: 18px; }

.tp-ico-shrink,
.is-full .tp-ico-expand { display: none; }
.is-full .tp-ico-shrink { display: block; }

/* ---------- Camera stage ---------- */

.tp-stage {
  position: relative;
  width: min(100%, calc(68vh * var(--ar, 1.7778)));
  aspect-ratio: var(--ar, 16 / 9);
  margin-inline: auto;
  overflow: hidden;
  border-radius: 17px;
  color: var(--tp-stage-ink);
  background: var(--tp-stage);
  isolation: isolate;
}

.tp-stage[data-camera="on"] {
  color: #fffdf8;
  background: #0b0b0a;
}

.tp-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity .5s ease;
}

.tp-stage[data-camera="on"] video { opacity: 1; }
.tp-stage[data-mirror="true"] video { transform: scaleX(-1); }

.tp-stage-off,
.tp-stage-starting {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  text-align: center;
}

.tp-stage-off h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.03em; }
.tp-stage-off p { max-width: 400px; margin: 9px 0 20px; color: var(--media-muted); font-size: .82rem; line-height: 1.55; }
.tp-stage-off .drop-icon { margin-bottom: 18px; }
.tp-stage-starting { gap: 4px; color: var(--media-muted); font-size: .8rem; }
.tp-stage[data-camera="on"] .tp-stage-off,
.tp-stage[data-camera="starting"] .tp-stage-off { display: none; }

.tp-stage-top,
.tp-stage-bottom {
  position: absolute;
  right: 14px;
  left: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.tp-stage-top { top: 14px; }
.tp-stage-bottom { bottom: 14px; justify-content: space-between; }
.tp-stage-top .tp-timer { margin-right: auto; }

.tp-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(255, 253, 248, .14);
  border-radius: 99px;
  color: #fffdf8;
  background: rgba(15, 15, 14, .6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.tp-pill svg { width: 13px; height: 13px; }
.tp-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tp-timer { font-size: .86rem; }
.tp-rec { border-color: rgba(255, 255, 255, .25); background: var(--tp-red); font-weight: 500; }
.tp-rec i { animation: tp-blink 1.1s steps(1) infinite; }
.tp-paused { border-color: rgba(255, 255, 255, .25); background: var(--tp-amber); font-weight: 500; }
.tp-paused i { border-radius: 2px; }

.tp-meter-track {
  position: relative;
  width: 58px;
  height: 5px;
  overflow: hidden;
  border-radius: 9px;
  background: rgba(255, 253, 248, .2);
}

.tp-meter-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #4cc38a;
  transform: scaleX(0);
  transform-origin: left;
}

.tp-meter.is-hot .tp-meter-fill { background: #ef6a4c; }
.tp-meter.is-silent { opacity: .55; }

.tp-countdown {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: #fffdf8;
  background: rgba(10, 10, 9, .5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.tp-countdown span {
  font-family: "Manrope", "Inter", sans-serif;
  font-size: clamp(4.5rem, 16vw, 9rem);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 6px 30px rgba(0, 0, 0, .45);
}

.tp-countdown span.is-tick { animation: tp-pop .9s ease-out both; }
.tp-countdown small { font-family: "DM Mono", monospace; font-size: .68rem; letter-spacing: .06em; opacity: .75; }

/* ---------- Transport ---------- */

.tp-transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.tp-transport-gap { flex: 1; }

.tp-record {
  min-width: 128px;
  border-color: var(--tp-red) !important;
  color: #fff !important;
  background: var(--tp-red) !important;
  box-shadow: 0 8px 18px rgba(214, 58, 47, .2);
}

.tp-record i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.tp-record.is-cancel { border-color: var(--media-line) !important; color: inherit !important; background: var(--tp-surface) !important; box-shadow: none; }
.tp-record.is-cancel i { display: none; }

@media (hover: hover) {
  .tp-record:hover:not(:disabled):not(.is-cancel) { background: #bf2f25 !important; }
}

#pauseButton .tp-ico-play,
#pauseButton.is-paused .tp-ico-pause { display: none; }
#pauseButton.is-paused .tp-ico-play { display: block; }

#stopButton svg { width: 13px; height: 13px; }

#mirrorCameraButton[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--media-accent) 45%, var(--media-line));
  color: var(--media-accent-dark);
  background: color-mix(in srgb, var(--media-soft) 70%, var(--tp-surface));
}

/* ---------- Takes ---------- */

.tp-takes { margin-top: 20px; }

.tp-takes-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 10px;
}

.tp-takes-head h2 { margin: 0; font-size: .95rem; letter-spacing: -.02em; }
.tp-takes-head span { color: var(--media-muted); font-size: .7rem; }

.tp-take-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.tp-take {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--media-line);
  border-radius: 14px;
  background: var(--tp-surface);
  animation: tp-rise .35s ease-out both;
}

.tp-take video {
  display: block;
  width: 100%;
  aspect-ratio: var(--ar, 16 / 9);
  max-height: 340px;
  background: #0b0b0a;
}

.tp-take-body { padding: 11px 12px 12px; }

.tp-take-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  font-size: .8rem;
  font-weight: 750;
}

.tp-take-title time { color: var(--media-muted); font-size: .66rem; font-weight: 500; }

.tp-take-meta {
  margin: 4px 0 10px;
  color: var(--media-muted);
  font-family: "DM Mono", monospace;
  font-size: .62rem;
  letter-spacing: .02em;
}

.tp-take-actions { display: flex; gap: 6px; }
.tp-take-actions .btn { min-height: 36px; padding: 0 12px; font-size: .72rem; text-decoration: none; }
.tp-take-actions .btn-primary { flex: 1; }
.tp-take-actions .tp-icon-btn { width: 36px; }
.tp-take-actions .tp-icon-btn svg { width: 16px; height: 16px; }
.tp-saved-mark { color: #2d9b63; font-size: .66rem; font-weight: 600; }

/* ---------- Sidebar ---------- */

.tp-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.tp-inline-actions { display: flex; gap: 12px; }

.tp-text-btn {
  padding: 2px 0;
  border: 0;
  color: var(--media-accent-dark);
  background: none;
  cursor: pointer;
  font-size: .72rem;
  font-weight: 700;
}

.tp-text-btn:disabled { color: var(--tp-muted); cursor: default; opacity: .6; }

@media (hover: hover) {
  .tp-text-btn:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
}

.tp-script {
  display: block;
  width: 100%;
  min-height: 220px;
  padding: 12px 13px;
  border: 1px solid var(--media-line);
  border-radius: 12px;
  outline: 0;
  resize: vertical;
  font: 500 .88rem/1.6 "Inter", system-ui, sans-serif;
}

.tp-script.is-dragging {
  border-color: var(--media-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--media-accent) 14%, transparent);
}

.tp-script-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--tp-muted);
  font-size: .68rem;
  line-height: 1.45;
}

.tp-scroll-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

#scrollButton { flex: 1; }
#scrollButton .tp-ico-pause,
#scrollButton.is-on .tp-ico-play { display: none; }
#scrollButton.is-on .tp-ico-pause { display: block; }
#showPrompterButton { flex-basis: 100%; }

.tp-field-label {
  color: var(--tp-text-2);
  font-size: .74rem;
  font-weight: 650;
}

.tp-block { display: block; margin-bottom: 7px; }
.field .tp-field-label { display: block; margin-bottom: 7px; }

.tp-seg-2 { grid-template-columns: repeat(2, 1fr); }
.tp-seg-4 { grid-template-columns: repeat(4, 1fr); }
.segmented button:disabled { opacity: .45; cursor: not-allowed; }

.tp-checks { display: grid; gap: 9px; margin-top: 13px; }

.tp-check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--tp-text-2);
  font-size: .76rem;
  cursor: pointer;
}

.tp-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--media-accent); }

.tp-keys { display: grid; gap: 7px; margin: 0; }
.tp-keys div { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .72rem; }
.tp-keys dt { flex: 0 0 auto; margin: 0; }
.tp-keys dd { margin: 0; color: var(--media-muted); text-align: right; }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  border: 1px solid var(--media-line);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--tp-text-2);
  background: var(--tp-surface);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: .66rem;
  text-align: center;
}

/* ---------- The floating prompter ---------- */

.tp-prompter {
  --backdrop: .72;
  --fs: 36px;
  --lh: 1.45;
  --line-h: 52px;
  --guide-y: 90px;
  --mx: 1;
  --my: 1;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 9000;
  display: flex;
  width: 640px;
  height: 260px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(var(--tp-pr-edge), .12);
  border-radius: 16px;
  color: var(--tp-pr-text);
  background: rgba(var(--tp-pr-bg), var(--backdrop));
  box-shadow: 0 18px 50px rgba(0, 0, 0, calc(.08 + var(--backdrop) * .2));
  backdrop-filter: blur(calc(var(--backdrop) * 14px));
  -webkit-backdrop-filter: blur(calc(var(--backdrop) * 14px));
  container-type: inline-size;
  font-family: "Inter", system-ui, sans-serif;
}

.tp-prompter.is-away,
.tp-prompter.is-editing:not(.is-fill) { visibility: hidden; pointer-events: none; }

.tp-bar {
  position: relative;
  z-index: 2;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
  height: 38px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(var(--tp-pr-edge), .08);
  background: rgba(var(--tp-pr-edge), .045);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity .3s;
}

.tp-bar.is-dragging { cursor: grabbing; }

.tp-bar-btn {
  display: grid;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: 600 1.05rem/1 "Inter", sans-serif;
  opacity: .78;
}

.tp-bar-btn svg { width: 16px; height: 16px; }
.tp-bar-btn .tp-ico-pause,
.tp-prompter.is-scrolling #barPlay .tp-ico-play { display: none; }
.tp-prompter.is-scrolling #barPlay .tp-ico-pause { display: block; }
.tp-prompter .tp-ico-shrink { display: none; }
.tp-prompter.is-fill .tp-ico-expand { display: none; }
.tp-prompter.is-fill .tp-ico-shrink { display: block; }

@media (hover: hover) {
  .tp-bar-btn:hover { background: rgba(var(--tp-pr-edge), .1); opacity: 1; }
}

.tp-bar-btn:focus-visible { outline: 2px solid var(--tp-pr-cue) !important; outline-offset: 0 !important; }

.tp-grip {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(3, 3px);
  grid-auto-rows: 3px;
  align-content: center;
  justify-content: center;
  gap: 3px;
  min-width: 20px;
  opacity: .35;
}

.tp-grip i { border-radius: 50%; background: currentColor; }

.tp-bar-rec {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  color: #ef5a4b;
  font: 500 .7rem "DM Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.tp-bar-rec i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: tp-blink 1.1s steps(1) infinite; }
.tp-bar-rec.is-paused { color: #e0a33a; }
.tp-bar-rec.is-paused i { border-radius: 2px; animation: none; }

.tp-bar-left {
  flex: 0 0 auto;
  padding: 0 6px;
  font: 500 .66rem "DM Mono", monospace;
  font-variant-numeric: tabular-nums;
  opacity: .58;
  white-space: nowrap;
}

.tp-bar-speed { display: inline-flex; flex: 0 0 auto; align-items: center; }
.tp-bar-speed output { min-width: 24px; font: 500 .74rem "DM Mono", monospace; font-variant-numeric: tabular-nums; text-align: center; }

@container (max-width: 420px) {
  .tp-bar-left { display: none; }
}

.tp-view {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 86%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 86%, transparent 100%);
}

.tp-view.is-scrubbing { cursor: grabbing; }

.tp-flip {
  position: absolute;
  inset: 0;
  transform: scale(var(--mx), var(--my));
}

.tp-text {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1;
  padding: max(0px, calc(var(--guide-y) - var(--line-h) / 2)) 7% 0;
  color: var(--tp-pr-text);
  font-size: var(--fs);
  font-weight: 600;
  line-height: var(--lh);
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
  text-align: var(--align, center);
  text-shadow: var(--tp-pr-shadow);
  white-space: pre-wrap;
  will-change: transform;
}

.tp-cue { color: var(--tp-pr-cue); }

/* The band marks the line to read. It sits behind the text so it never
   strikes through a word, with an arrow at each edge. */
.tp-guide {
  position: absolute;
  top: calc(var(--guide-y) - var(--line-h) / 2);
  right: 0;
  left: 0;
  z-index: 0;
  height: var(--line-h);
  background: var(--tp-pr-band);
}

.tp-guide::before,
.tp-guide::after {
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  content: "";
  transform: translateY(-50%);
}

.tp-guide::before { left: 0; border-left: 10px solid var(--tp-pr-cue); }
.tp-guide::after { right: 0; border-right: 10px solid var(--tp-pr-cue); }

.tp-end {
  position: absolute;
  bottom: 12px;
  left: 50%;
  z-index: 2;
  padding: 5px 11px;
  border-radius: 99px;
  background: rgba(var(--tp-pr-edge), .1);
  font: 500 .66rem "DM Mono", monospace;
  letter-spacing: .03em;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.tp-progress {
  flex: 0 0 auto;
  height: 3px;
  background: rgba(var(--tp-pr-edge), .08);
}

.tp-progress i {
  display: block;
  height: 100%;
  background: var(--tp-pr-cue);
  transform: scaleX(0);
  transform-origin: left;
}

.tp-handle {
  position: absolute;
  z-index: 3;
  width: 12px;
  height: 12px;
  touch-action: none;
}

.tp-handle[data-edge="nw"] { top: 0; left: 0; cursor: nwse-resize; }
.tp-handle[data-edge="ne"] { top: 0; right: 0; cursor: nesw-resize; }
.tp-handle[data-edge="sw"] { bottom: 0; left: 0; width: 22px; height: 22px; cursor: nesw-resize; }
.tp-handle[data-edge="se"] { right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize; }

.tp-handle::after {
  position: absolute;
  width: 9px;
  height: 9px;
  border: 0 solid var(--tp-pr-cue);
  content: "";
  opacity: 0;
  transition: opacity .2s;
}

.tp-handle[data-edge="nw"]::after { top: 4px; left: 4px; border-width: 2px 0 0 2px; border-top-left-radius: 4px; }
.tp-handle[data-edge="ne"]::after { top: 4px; right: 4px; border-width: 2px 2px 0 0; border-top-right-radius: 4px; }
.tp-handle[data-edge="sw"]::after { bottom: 5px; left: 5px; border-width: 0 0 2px 2px; border-bottom-left-radius: 4px; }
.tp-handle[data-edge="se"]::after { right: 5px; bottom: 5px; border-width: 0 2px 2px 0; border-bottom-right-radius: 4px; }

@media (hover: hover) {
  .tp-prompter:hover .tp-handle::after { opacity: .75; }
}

/* A finger cannot find a 12px corner, and has no hover to reveal it. */
@media (hover: none) {
  .tp-handle[data-edge="sw"],
  .tp-handle[data-edge="se"] { width: 32px; height: 32px; }
  .tp-handle[data-edge="sw"]::after,
  .tp-handle[data-edge="se"]::after { opacity: .55; }
}

/* Fill the screen: the prompter covers everything, the qpkit mark included,
   and in the idle moments of a take the bar and the pointer get out of the
   way. */
.tp-prompter.is-fill {
  top: 0 !important;
  left: 0 !important;
  z-index: 100000;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  border: 0;
  border-radius: 0;
  /* Solid whatever the backdrop slider says: the see-through window is for
     watching the camera, and a full screen of prompter has nothing to show
     behind it. Dark is black, which is what a teleprompter glass wants. */
  background: rgb(var(--tp-pr-bg));
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.tp-prompter.is-fill .tp-handle { display: none; }
.tp-prompter.is-fill .tp-bar { cursor: default; }
.tp-prompter.is-fill.is-idle { cursor: none; }
.tp-prompter.is-fill.is-idle .tp-view { cursor: none; }
.tp-prompter.is-fill.is-idle .tp-bar { opacity: .12; }

/* ---------- Confirm modal and toast ---------- */

.tp-modal {
  position: fixed;
  inset: 0;
  z-index: 100002;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 15, 14, .42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.tp-modal-card {
  width: min(400px, 100%);
  padding: 22px;
  border: 1px solid var(--media-line);
  border-radius: 18px;
  background: var(--tp-surface);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .25);
  animation: tp-rise .2s ease-out both;
}

.tp-modal-card h2 { margin: 0; font-size: 1.05rem; letter-spacing: -.02em; }
.tp-modal-card p { margin: 8px 0 20px; color: var(--media-muted); font-size: .82rem; line-height: 1.55; }
.tp-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.tp-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 100003;
  max-width: min(460px, calc(100% - 32px));
  padding: 11px 15px;
  border-radius: 12px;
  color: #fffdf8;
  background: #191918;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .25);
  font-size: .78rem;
  line-height: 1.45;
  transform: translateX(-50%);
  animation: tp-toast-in .25s ease-out both;
}

html[data-theme="dark"] .tp-toast { color: #191918; background: #f1ede4; }

@keyframes tp-blink { 50% { opacity: 0; } }
@keyframes tp-pop { 0% { opacity: 0; transform: scale(.55); } 35% { opacity: 1; transform: scale(1.08); } 100% { opacity: .9; transform: scale(1); } }
@keyframes tp-rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes tp-toast-in { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ---------- Narrow screens ---------- */

@media (max-width: 840px) {
  .tp-stage { width: min(100%, calc(60vh * var(--ar, 1.7778))); }
}

@media (max-width: 540px) {
  .tp-theme button span { display: none; }
  .tp-theme button { padding: 0 10px; }
  .tp-record { flex: 1; }
  .tp-transport-gap { display: none; }
  .tp-stage { border-radius: 13px; }
  .tp-stage-top, .tp-stage-bottom { right: 10px; left: 10px; }
  .tp-stage-top { top: 10px; }
  .tp-stage-bottom { bottom: 10px; }
  .tp-stage-off p { margin-bottom: 14px; font-size: .76rem; }
  .tp-stage-off .drop-icon { display: none; }
  .tp-modal { place-items: end center; padding: 10px; }
  .tp-modal-card { border-radius: 18px 18px 14px 14px; }
}

/* ---------- Dark theme ---------- */

html[data-theme="dark"] {
  color-scheme: dark;
  background: #131312;
  --media-ink: #f1ede4;
  --media-muted: #9a958a;
  --media-line: #34322e;
  --media-surface: rgba(28, 27, 25, .92);
}

html[data-theme="dark"] body.__accessbox-tool {
  --bg: #131312;
  --paper: #131312;
  --surface: #1c1b19;
  --surface-strong: #232220;
  --surface-subtle: #181816;
  --card: #1c1b19;
  --ink: #f1ede4;
  --text: #f1ede4;
  --text-secondary: #bdb8ad;
  --text-dim: #bdb8ad;
  --muted: #9a958a;
  --quiet: #7c776e;
  --faint: #7c776e;
  --text-muted: #7c776e;
  --border: #34322e;
  --line: #34322e;
  --line2: #45433d;
  --border-hover: #5d5a52;
}

html[data-theme="dark"] body.__accessbox-teleprompter {
  --ab-accent: #4a9fd6;
  --media-accent: #4a9fd6;
  --media-accent-dark: #86c3ea;
  --media-soft: #173247;
}

html[data-theme="dark"] body.__accessbox-tool input,
html[data-theme="dark"] body.__accessbox-tool textarea,
html[data-theme="dark"] body.__accessbox-tool select {
  background-color: #181816;
}

html[data-theme="dark"] body.__accessbox-tool input::placeholder,
html[data-theme="dark"] body.__accessbox-tool textarea::placeholder { color: #6f6b63; }

html[data-theme="dark"] body.__accessbox-tool::-webkit-scrollbar-thumb,
html[data-theme="dark"] body.__accessbox-tool *::-webkit-scrollbar-thumb { background: #45433d; background-clip: padding-box; }

html[data-theme="dark"] .media-panel { box-shadow: 0 22px 60px rgba(0, 0, 0, .35); }
html[data-theme="dark"] .media-sidebar { background: rgba(255, 253, 248, .018); }
html[data-theme="dark"] .btn { color: var(--media-ink); background: #1f1e1c; }
html[data-theme="dark"] .btn-primary { border-color: #f1ede4; color: #191918; background: #f1ede4; box-shadow: 0 8px 18px rgba(0, 0, 0, .3); }
html[data-theme="dark"] .segmented { background: #121211; }
html[data-theme="dark"] .segmented button { color: #9a958a; }
html[data-theme="dark"] .segmented button[aria-pressed="true"] { color: #f1ede4; background: #2b2a27; box-shadow: 0 2px 9px rgba(0, 0, 0, .35); }
html[data-theme="dark"] .control-label,
html[data-theme="dark"] .control-section > label:first-child { color: #a9a499; }
html[data-theme="dark"] .control-help { color: #8b867c; }
html[data-theme="dark"] .media-select,
html[data-theme="dark"] .media-input { background: #181816; }
html[data-theme="dark"] .drop-icon { background: color-mix(in srgb, var(--media-soft) 70%, #1c1b19); box-shadow: 0 12px 28px rgba(0, 0, 0, .3); }

@media (hover: hover) {
  html[data-theme="dark"] .btn:hover:not(:disabled) { border-color: #5d5a52; }
  html[data-theme="dark"] .btn-primary:hover:not(:disabled) { border-color: var(--media-accent); color: #0f0f0e; background: var(--media-accent); }
}

@media (prefers-reduced-motion: reduce) {
  .tp-rec i, .tp-bar-rec i { animation: none; }
}
