/* TeleP online teleprompter. Inherits site tokens when present (--accent, --surface, --text, --muted, --border). */
.tp {
  --tp-accent: var(--accent, #FFC53D);           /* yellow FILL (sliders, active chips, focus) */
  --tp-accent-text: var(--accent-text, var(--tp-accent)); /* yellow-family TEXT (AA in both themes) */
  --tp-link: var(--accent-2, #6FA3FF);
  --tp-accent-fg: var(--accent-ink, #fff);
  --tp-surface: var(--surface, #ffffff);
  --tp-surface-2: var(--surface-2, #f4f5f9);
  --tp-text: var(--text, #10131f);
  --tp-muted: var(--muted, #5a6075);
  --tp-line: var(--border, #dde0ea);
  --tp-radius: var(--radius, 16px);
  --tp-rec: var(--rec, #F04438);
  --tp-shadow: var(--shadow, 0 1px 2px rgba(16, 19, 31, .06), 0 8px 30px rgba(16, 19, 31, .08));
  color: var(--tp-text);
  font: inherit;
  position: relative;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tp {
    --tp-surface: var(--surface, #151826);
    --tp-surface-2: var(--surface-2, #1d2133);
    --tp-text: var(--text, #eef0f7);
    --tp-muted: var(--muted, #a3a9bd);
    --tp-line: var(--border, #2b3047);
    --tp-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 30px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] .tp {
  --tp-surface: var(--surface, #151826);
  --tp-surface-2: var(--surface-2, #1d2133);
  --tp-text: var(--text, #eef0f7);
  --tp-muted: var(--muted, #a3a9bd);
  --tp-line: var(--border, #2b3047);
}
.tp *, .tp-stage * { box-sizing: border-box; }
.tp-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* CLS: the template renders a skeleton of the hydrated editor (same classes/texts). Only the parts that have no
   skeleton need a reserved size: the library/settings placeholders on /teleprompter/. */
.tp-lib[data-tp-ph] { min-height: 170px; }
.tp-side[data-tp-ph] { min-height: 1160px; }
@media (min-width: 600px) { .tp-lib[data-tp-ph] { min-height: 147px; } .tp-side[data-tp-ph] { min-height: 755px; } }
@media (min-width: 900px) { .tp-lib[data-tp-ph] { min-height: 0; } }
@media (min-width: 1180px) { .tp-lib[data-tp-ph] { min-height: 209px; } .tp-side[data-tp-ph] { min-height: 0; height: min(calc(100vh - 100px), 1164px); } }

/* ---------- buttons ---------- */
.tp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 16px; line-height: 1; cursor: pointer; text-decoration: none;
  color: var(--tp-text); background: transparent; white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.tp-btn svg { width: 18px; height: 18px; flex: none; }
.tp-btn:active { transform: translateY(1px); }
.tp-btn:focus-visible, .tp-icon-btn:focus-visible, .tp-play:focus-visible, .tp-lib-load:focus-visible { outline: 3px solid var(--tp-accent); outline-offset: 2px; }
.tp-btn-primary { background: var(--btn-bg, var(--tp-accent)); color: var(--btn-ink, var(--tp-accent-fg)); border-color: var(--btn-border, transparent); }
.tp-btn-primary:hover:not(:disabled) { background: var(--btn-bg-hover, var(--btn-bg, var(--tp-accent))); }
.tp-btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.tp-btn-ghost { border-color: var(--tp-line); background: var(--tp-surface); }
.tp-btn-ghost:hover { border-color: var(--tp-muted); }
.tp-btn-sm { min-height: 40px; padding: 0 12px; font-size: 14px; font-weight: 500; }
.tp-file { position: relative; overflow: hidden; }
.tp-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.tp-file:focus-within { outline: 3px solid var(--tp-accent); outline-offset: 2px; }

/* ---------- editor ---------- */
.tp-editor { display: grid; gap: 20px; }
.tp-ed-main {
  background: var(--tp-surface); border: 1px solid var(--tp-line); border-radius: var(--tp-radius);
  box-shadow: var(--tp-shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.tp-ed-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tp-title {
  flex: 1 1 200px; min-width: 0; min-height: 44px; border: 0; border-radius: 10px; padding: 10px; margin-left: -6px;
  font: inherit; font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--tp-text); background: transparent;
  resize: none; overflow: hidden; height: 44px; white-space: normal; display: block;
}
.tp-title:hover { background: var(--tp-surface-2); }
.tp-title:focus { outline: 2px solid var(--tp-accent); background: var(--tp-surface); }
.tp-ed-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.tp-text {
  width: 100%; min-height: 220px; resize: vertical; border: 1px solid var(--tp-line); border-radius: 12px;
  padding: 14px 16px; font: inherit; font-size: 16px; line-height: 1.6; color: var(--tp-text); background: var(--tp-surface-2);
}
.tp-text:focus { outline: 2px solid var(--tp-accent); outline-offset: -1px; background: var(--tp-surface); }
.tp-editor-full .tp-text { min-height: clamp(360px, calc(100vh - 420px), 520px); }
.tp-editor-full { max-width: var(--wrap, 1120px); margin-inline: auto; }
@media (max-width: 899px) {
  /* mobile/tablet full mode: short editor + sticky Start bar */
  .tp-editor-full .tp-text { min-height: 0; height: min(42vh, 360px); }
  .tp-editor-full .tp-start-rec { flex: 1 1 0; }
  body:has(.tp[data-mode="full"]) .sticky-cta { display: none !important; }
}
.tp-ed-foot { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
/* Start stays reachable on short screens (Chromebooks 1366x768, phones): sticky footer inside the editor card */
.tp-ed-foot {
  position: sticky; bottom: 0; z-index: 5; margin: 0 -16px -16px;
  background: color-mix(in srgb, var(--tp-surface) 92%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-top: 1px solid var(--tp-line); border-radius: 0 0 var(--tp-radius) var(--tp-radius);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.tp-blanks { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, #f5a524 16%, var(--tp-surface)); border: 1px solid color-mix(in srgb, #f5a524 45%, transparent); font-size: 14px; }
.tp-blanks[hidden] { display: none; }
.tp-blanks p { margin: 0; flex: 1 1 220px; }
.tp-blanks-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tp-blanks-actions .tp-btn { min-height: 44px; }
.tp-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 100%; order: -1; }
.tp-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--tp-line);
  background: var(--tp-surface); color: var(--tp-text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.tp-chip svg { width: 16px; height: 16px; }
.tp-chip[aria-pressed="true"] { background: var(--tp-accent); border-color: var(--tp-accent); color: var(--tp-accent-fg); }
.tp-chip:focus-visible { outline: 3px solid var(--tp-accent); outline-offset: 2px; }
@media (min-width: 1180px) { .tp-chips { display: none; } } /* settings column is visible next to the editor */
.tp-stats { margin: 0; color: var(--tp-muted); font-size: 14px; flex: 1 1 200px; }
.tp-stats strong { color: var(--tp-text); font-variant-numeric: tabular-nums; }
.tp-start { min-height: 52px; padding: 0 26px; font-size: 17px; flex: 0 0 auto; }
.tp-start-rec { flex: 0 0 auto; min-height: 52px; padding: 0 22px; font-size: 17px; }
.tp-start-rec .tp-recdot { width: 14px; height: 14px; background: var(--tp-rec, #f04438); box-shadow: 0 0 0 2px rgba(255,255,255,.85); }
.tp-start svg { width: 20px; height: 20px; }
.tp-quick { display: flex; align-items: center; gap: 10px; flex: 1 1 220px; font-size: 14px; color: var(--tp-muted); }
.tp-quick input { flex: 1; min-width: 80px; }
.tp-quick output { min-width: 64px; font-variant-numeric: tabular-nums; color: var(--tp-text); font-weight: 600; }
@media (max-width: 599px) {
  .tp-start { min-height: 52px; }
  .tp-start-rec { flex: 1 1 0; min-width: 0; min-height: 52px; padding: 0 10px; font-size: 16px; gap: 8px; }
  .tp-start-rec span { overflow: hidden; text-overflow: ellipsis; }
  .tp-start { flex: none !important; width: 52px; padding: 0 !important; }
  .tp-start span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tp-ed-tools { flex-wrap: nowrap; gap: 6px; }
  .tp-ed-tools .tp-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tp-ed-tools .tp-btn { width: 40px; min-height: 40px; padding: 0; }
  .tp-ed-head { flex-wrap: nowrap; }
  .tp-title { flex: 1 1 0; }
  .tp-editor-home .tp-text { min-height: 0; height: 200px; }
  .tp-ed-main { padding: 14px; }
  .tp-ed-foot { margin: 0 -14px -14px; padding-left: 14px; padding-right: 14px; }
  .tp-title { font-size: 17px; }
}
.tp-sharebox { border: 1px solid var(--tp-line); border-radius: 12px; padding: 12px; background: var(--tp-surface-2); font-size: 14px; display: grid; gap: 8px; }
.tp-sharebox[hidden] { display: none; }
.tp-sharebox p { margin: 0; }
.tp-sharebox-row { display: flex; gap: 8px; align-items: center; }
.tp-sharebox-row input { flex: 1; min-width: 0; min-height: 44px; border: 1px solid var(--tp-line); border-radius: 10px; padding: 0 10px; font: inherit; font-size: 16px; color: var(--tp-text); background: var(--tp-surface); }
.tp-sharebox .tp-btn svg { width: 16px; height: 16px; }
.tp-popout { min-height: 52px; }
/* Pop out: desktop only (phones/tablets can't keep a document window on top) */
@media (max-width: 899px), (pointer: coarse) { .tp-popout { display: none; } }
.tp-stats-m { display: none; margin: 0; color: var(--tp-muted); font-size: 14px; }
.tp-stats-m strong { color: var(--tp-text); font-variant-numeric: tabular-nums; }
@media (max-width: 599px) {
  /* compact sticky footer (<= ~120px in every language): stats move above it, chips stay on one scrollable row */
  .tp-stats-m { display: block; margin-top: -4px; }
  .tp-ed-foot .tp-stats { display: none; }
  .tp-ed-foot { gap: 8px; padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .tp-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
  .tp-chips::-webkit-scrollbar { display: none; }
  .tp-chip { flex: none; white-space: nowrap; }
  .tp-quick { flex: 1 1 100%; }
}
.tp-note { margin: 0; font-size: 13px; color: var(--tp-muted); line-height: 1.5; }
.tp-note a { color: var(--tp-link); }

/* full app layout */
.tp-editor-full { grid-template-columns: minmax(0, 1fr); }
.tp-lib, .tp-side {
  background: var(--tp-surface); border: 1px solid var(--tp-line); border-radius: var(--tp-radius); padding: 16px; min-width: 0;
}
.tp-lib h2, .tp-side h2 { font-size: 16px; margin: 0; }
.tp-side h2 { margin-bottom: 8px; }
.tp-lib-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.tp-lib-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; max-height: 360px; overflow: auto; }
.tp-lib-item { display: flex; align-items: stretch; border-radius: 10px; transition: background-color .15s; }
/* current script: Apple-style filled selection + small inset pill + heavier title; no side bar bending round the corner */
.tp-lib-item { position: relative; }
.tp-lib-item.is-current { background: var(--tp-surface-2); }
:root[data-theme="light"] .tp-lib-item.is-current { background: var(--accent-soft, rgba(245, 181, 36, .16)); }
.tp-lib-item.is-current::before { content: ""; position: absolute; left: 6px; top: 50%; width: 3px; height: 20px; margin-top: -10px; border-radius: 3px; background: var(--tp-accent); pointer-events: none; }
.tp-lib-item.is-current .tp-lib-title { font-weight: 700; }
.tp-lib-item.is-current .tp-lib-load:hover { background: transparent; }
.tp-lib-load {
  flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; color: inherit; font: inherit; padding: 8px 10px;
  border-radius: 10px; cursor: pointer; min-height: 44px; display: flex; flex-direction: column; justify-content: center;
}
.tp-lib-load:hover { background: var(--tp-surface-2); }
.tp-lib-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-lib-meta { font-size: 12px; color: var(--tp-muted); }
.tp-lib-empty { font-size: 13px; color: var(--tp-muted); padding: 6px 2px; }
.tp-lib-del { color: var(--tp-muted) !important; background: transparent !important; }
.tp-lib-del:hover { color: var(--tp-rec) !important; }
@media (min-width: 900px) {
  .tp-editor-full { grid-template-columns: 220px minmax(0, 1fr); }
  .tp-editor-full .tp-side { grid-column: 1 / -1; }
}
@media (min-width: 700px) and (max-width: 1179px) {
  .tp-editor-full .tp-side .tp-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 28px; }
  .tp-editor-full .tp-side .tp-form-sub { grid-column: 1 / -1; }
}
.tp-form > * { min-width: 0; }
@media (min-width: 1180px) {
  .tp-editor-full { grid-template-columns: 220px minmax(0, 1fr) 300px; align-items: start; }
  .tp-editor-full .tp-side { grid-column: auto; position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; scrollbar-width: thin; scrollbar-color: var(--tp-muted) transparent; }
  .tp-editor-full .tp-side::-webkit-scrollbar { width: 8px; }
  .tp-editor-full .tp-side::-webkit-scrollbar-thumb { background: var(--tp-line); border-radius: 4px; }
  .tp-editor-full .tp-side.tp-more { -webkit-mask-image: linear-gradient(#000 calc(100% - 40px), transparent); mask-image: linear-gradient(#000 calc(100% - 40px), transparent); }
}
@media (max-width: 899px) {
  .tp-editor-full .tp-ed-main { order: -1; }
}

/* settings form (editor side + stage panel) */
.tp-form { display: grid; gap: 4px; }
.tp-form-sub { margin: 14px 0 0; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tp-muted); }
.tp-form-sub:first-child { margin-top: 4px; }
.tp-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--tp-line); font-size: 14px; }
.tp-row:last-child { border-bottom: 0; }
.tp-row label, .tp-row-label { font-weight: 500; }
.tp-row output { font-size: 13px; color: var(--tp-muted); font-variant-numeric: tabular-nums; }
.tp-row input[type="range"] { grid-column: 1 / -1; width: 100%; }
.tp-row select { min-height: 44px; border-radius: 10px; border: 1px solid var(--tp-line); background: var(--tp-surface); color: inherit; font: inherit; font-size: 16px; padding: 0 34px 0 10px;
  -webkit-appearance: none; appearance: none; background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238a90a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.tp-row.is-dim { opacity: .45; }
.tp-row-check { grid-template-columns: 1fr; }
.tp-row small { display: block; color: var(--tp-muted); font-size: 12px; font-weight: 400; }
.tp input[type="range"], .tp-stage input[type="range"] { accent-color: var(--tp-accent); min-height: 32px; }
.tp-switch { display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 36px; }
.tp-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tp-switch-ui { flex: none; width: 42px; height: 26px; border-radius: 13px; background: var(--tp-line); position: relative; transition: background .15s; }
.tp-switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.tp-switch input:checked + .tp-switch-ui { background: var(--tp-accent); }
.tp-switch input:checked + .tp-switch-ui::after { transform: translateX(16px); }
.tp-switch input:focus-visible + .tp-switch-ui { outline: 3px solid var(--tp-accent); outline-offset: 2px; }
.tp-seg { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; min-width: 0; max-width: 100%; background: var(--tp-surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.tp-seg label { position: relative; }
.tp-seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tp-seg span { display: inline-flex; align-items: center; min-height: 34px; padding: 0 10px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.tp-seg input:checked + span { background: var(--tp-surface); box-shadow: 0 1px 3px rgba(0,0,0,.15); font-weight: 600; }
.tp-seg input:focus-visible + span { outline: 2px solid var(--tp-accent); }
.tp-keys { margin-top: 12px; font-size: 14px; }
.tp-keys summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.tp-keylist { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 8px 0 0; font-size: 13px; }
.tp-keylist dt { white-space: nowrap; }
.tp-keylist dd { margin: 0; color: var(--tp-muted); }
kbd { font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 3px 6px; border-radius: 5px; border: 1px solid currentColor; opacity: .85; }

/* toast */
.tp-msg {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2147483001;
  display: flex; align-items: center; gap: 14px; max-width: min(560px, calc(100vw - 32px));
  background: #10131f; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.4;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.tp-msg[hidden] { display: none; }
.tp-msg-act { flex: none; border: 0; background: transparent; color: var(--accent, #FFC53D); font: inherit; font-weight: 700; cursor: pointer; min-height: 44px; padding: 0 8px; } /* toast is always dark: yellow accent fill colour reads >= 9:1 on it in both themes */
.tp-stage .tp-msg { position: absolute; bottom: calc(150px + env(safe-area-inset-bottom)); }

/* ---------- stage (prompter view) ---------- */
html.tp-lock, html.tp-lock body { overflow: hidden !important; }
.tp-stage {
  /* stage is always dark (spec §1); fills follow the site tokens */
  --tp-navy: #070B1A; --tp-yellow: var(--accent, #FFC53D); --tp-blue: #6FA3FF; --tp-rec-strong: var(--rec-strong, #D92D20);
  --tp-bg: var(--tp-navy); --tp-fg: #fff; --tp-cue: var(--tp-yellow); --tp-chrome: rgba(9, 14, 30, .92); --tp-chrome-fg: #fff;
  --tp-accent: var(--accent, #FFC53D); --tp-accent-fg: var(--accent-ink, #070B1A); --tp-rec: var(--rec, #F04438);
  position: fixed; inset: 0; z-index: 2147483000; background: var(--tp-bg); color: var(--tp-fg);
  height: 100vh; height: 100dvh; overflow: hidden; overscroll-behavior: contain;
  font-family: var(--font, system-ui), -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}
.tp-stage[hidden] { display: none; }
.tp-stage[data-theme="yellow"] { --tp-fg: #ffe14d; --tp-cue: #7fd4ff; }
.tp-stage[data-font="serif"] { --tp-ff: Georgia, "Times New Roman", serif; }
.tp-stage[data-font="mono"] { --tp-ff: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.tp-stage[data-font="round"] { --tp-ff: ui-rounded, "SF Pro Rounded", "Nunito", "Arial Rounded MT Bold", system-ui, sans-serif; }
.tp-stage[data-theme="green"] { --tp-fg: #4dff88; --tp-cue: #ffd34d; }
.tp-stage[data-theme="light"] { --tp-bg: #fff; --tp-fg: #000; --tp-cue: #b45309; }
.tp-stage[data-theme="blue"] { --tp-bg: #0a2a6b; --tp-fg: #fff; --tp-cue: #ffd34d; }
.tp-view { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; touch-action: none; cursor: grab; outline: none; }
.tp-view:active { cursor: grabbing; }
.tp-flipper { position: absolute; inset: 0; transform: scale(var(--tp-sx, 1), var(--tp-sy, 1)); }
.tp-mirror .tp-flipper { --tp-sx: -1; }
.tp-flip .tp-flipper { --tp-sy: -1; }
.tp-content {
  position: relative; will-change: transform;
  padding: var(--tp-focus, 33vh) var(--tp-mx, 8%) 100vh;
  font-size: var(--tp-fs, 56px); line-height: var(--tp-lh, 1.45); font-weight: 600; letter-spacing: .005em; font-family: var(--tp-ff, inherit);
  overflow-wrap: break-word; hyphens: manual;
}
.tp-center .tp-content { text-align: center; }
.tp-content p { margin: 0 0 .6em; }
.tp-cue {
  font-size: .5em; line-height: 1.3; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--tp-cue); margin: 1.2em 0 .7em; display: flex; align-items: center; gap: .6em;
}
.tp-cue::before { content: ""; width: 1.4em; height: .18em; background: currentColor; border-radius: 2px; }
.tp-center .tp-cue { justify-content: center; }
.tp-cue-inline {
  display: inline-block; font-size: .42em; font-weight: 800; letter-spacing: .1em; vertical-align: .35em;
  color: var(--tp-bg); background: var(--tp-cue); padding: .25em .6em; border-radius: .4em; line-height: 1.2;
}
.tp-end { height: 1px; }
.tp-focus {
  position: absolute; left: 0; right: 0; top: var(--tp-focus, 33vh); height: calc(var(--tp-fs, 56px) * var(--tp-lh, 1.45));
  background: color-mix(in srgb, var(--tp-fg) 8%, transparent); pointer-events: none;
  border-top: 1px solid color-mix(in srgb, var(--tp-fg) 18%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--tp-fg) 18%, transparent);
}
.tp-focus::before, .tp-focus::after {
  content: ""; position: absolute; top: 50%; width: 0; height: 0; border: 12px solid transparent; transform: translateY(-50%);
}
.tp-focus::before { left: 2px; border-left-color: var(--tp-accent); border-left-width: 16px; }
.tp-focus::after { right: 2px; border-right-color: var(--tp-accent); border-right-width: 16px; }
.tp-nofocus .tp-focus { display: none; }
.tp-fade { position: absolute; left: 0; right: 0; height: 14%; pointer-events: none; }
.tp-fade-top { top: 0; background: linear-gradient(var(--tp-bg), transparent); }
.tp-fade-bot { bottom: 0; background: linear-gradient(transparent, var(--tp-bg)); }

/* camera fills the whole viewport in record mode */
.tp-cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: none; background: #000; }
.tp-cam-on .tp-cam { display: block; }

/* progress lives in the panel's yellow top bar */
.tp-progress { position: absolute; inset: 0; background: color-mix(in srgb, var(--tp-yellow) 35%, transparent); }
.tp-progress-bar { height: 100%; background: var(--tp-yellow); transform-origin: 0 50%; transform: scaleX(0); }

/* countdown */
.tp-countdown { position: absolute; inset: 0; display: grid; place-items: center; z-index: 4; pointer-events: none; }
.tp-countdown[hidden] { display: none; }
.tp-countdown span {
  display: flex; align-items: center; justify-content: center; text-box: trim-both cap alphabetic; width: min(220px, 70%); aspect-ratio: 1; border-radius: 50%; background: rgba(0,0,0,.55);
  font-size: min(160px, 22vh); font-weight: 800; color: #fff; line-height: 1; font-variant-numeric: tabular-nums;
}
.tp-counting .tp-content { opacity: .35; }
.tp-content { transition: opacity .2s; }
.tp-cd-anim { animation: tp-cd 1s ease-out both; }
@keyframes tp-cd { from { transform: scale(1.25); opacity: 0; } 25% { opacity: 1; } to { transform: scale(.9); opacity: .85; } }

/* ---------- recorder layout: floating prompter panel + dock ---------- */
.tp-pbox {
  position: absolute; z-index: 2; left: 12px; right: 12px;
  top: calc(64px + env(safe-area-inset-top)); bottom: calc(12px + env(safe-area-inset-bottom));
  border-radius: 20px; overflow: hidden; background: var(--tp-bg); box-shadow: 0 18px 50px rgba(0,0,0,.45);
  display: flex; flex-direction: column; padding-top: 36px; /* head; the control bar sits under the text, not over it */
}
.tp-pbar { position: absolute; z-index: 3; left: 0; right: 0; top: 0; height: 4px; }
.tp-progress { transition: background-color .2s; }
.tp-recording .tp-progress { background: color-mix(in srgb, var(--tp-rec) 40%, transparent); }
.tp-recording .tp-progress-bar { background: var(--tp-rec); }
.tp-counting .tp-progress-bar { transform: scaleX(1) !important; transition: transform var(--tp-cd, 3s) linear; }
.tp-phead {
  position: absolute; z-index: 3; left: 0; right: 0; top: 4px; height: 32px; display: flex; align-items: center; gap: 8px; padding: 0 4px 0 12px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; color: rgba(255,255,255,.7); font-variant-numeric: tabular-nums;
}
.tp-pgrip { width: 18px; height: 10px; flex: none; background: radial-gradient(circle, rgba(255,255,255,.55) 1.2px, transparent 1.6px) 0 0 / 6px 5px; }
.tp-ptitle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-pmini-rec { color: #ff8a80; }
.tp-pmini-rec[hidden] { display: none; }
.tp-pcollapse { width: 32px; height: 32px; }
.tp-pcollapse svg { width: 18px; height: 18px; transform: rotate(180deg); transition: transform .2s; }
.tp-collapsed .tp-pcollapse svg { transform: none; }
.tp-mode-record .tp-phead { cursor: grab; touch-action: none; }
.tp-mode-record .tp-phead:active { cursor: grabbing; }
/* collapsed: only the slim head pill stays ("Script · 0:24 · ● REC") */
.tp-collapsed .tp-pbox { height: 36px !important; min-height: 0; bottom: auto; }
.tp-collapsed .tp-view, .tp-collapsed .tp-dock, .tp-collapsed .tp-resize, .tp-collapsed .tp-wresize { display: none !important; }
.tp-collapsed:not(.tp-mode-record) .tp-pbox { width: min(360px, calc(100% - 24px)); left: 50%; right: auto; transform: translateX(-50%); }
/* record mode: camera everywhere, compact panel near the lens (top centre), height adjustable */
.tp-mode-record .tp-pbox {
  top: calc(12px + env(safe-area-inset-top)); bottom: auto; left: 50%; right: auto; transform: translateX(-50%);
  width: min(760px, calc(100% - 24px)); height: var(--tp-ph, 42vh); min-height: 160px;
  background: rgba(7, 11, 26, var(--tp-pop, .72)); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.tp-mode-record .tp-pbox {
  width: var(--tp-pw, min(720px, calc(100% - 24px))); max-width: calc(100% - 24px);
  transform: translate(calc(-50% + var(--tp-px, 0px)), var(--tp-py, 0px));
}
.tp-mode-record .tp-fade { display: none; } /* no fades over a translucent panel */
.tp-wresize { display: none; }
@media (min-width: 700px) {
  .tp-mode-record .tp-wresize { display: block; position: absolute; z-index: 4; top: 36px; bottom: 16px; width: 10px; cursor: ew-resize; touch-action: none; }
  .tp-wresize-l { left: 0; } .tp-wresize-r { right: 0; }
}
@media (max-width: 699px) { .tp-mode-record .tp-pbox { transform: translateX(-50%); width: calc(100% - 12px); top: calc(62px + env(safe-area-inset-top)); } }
/* in-panel script editor (camera stays live) */
.tp-editpane { position: absolute; z-index: 6; inset: 36px 0 0; display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 12px; background: #0e1630; }
.tp-editpane[hidden] { display: none; }
.tp-edit-ta { flex: 1; min-height: 0; resize: none; border: 1px solid #24314f; border-radius: 10px; padding: 10px 12px; background: #16213f; color: #eef2ff; font: inherit; font-size: 16px; line-height: 1.5; -webkit-user-select: auto; user-select: auto; }
.tp-edit-ta:focus { outline: 2px solid var(--tp-yellow); }
.tp-edit-actions { display: flex; justify-content: flex-end; gap: 8px; }
.tp-editpane .tp-btn-ghost { color: #eef2ff; border-color: #5a6a92; background: transparent; }
.tp-editpane .tp-btn-primary, .tp-stage .tp-btn-primary { background: var(--tp-yellow); color: #070b1a; border-color: transparent; }
.tp-mode-record { --tp-bg: transparent; background: #000; }
.tp-mode-record .tp-top { padding-top: calc(10px + env(safe-area-inset-top)); background: none; }
.tp-resize { display: none; }
.tp-mode-record .tp-resize {
  display: grid; place-items: center; position: absolute; z-index: 4; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 72px; height: 16px; cursor: ns-resize; touch-action: none; outline: none;
}
.tp-mode-record .tp-resize span { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.55); }
.tp-resize:focus-visible span { background: var(--tp-yellow); box-shadow: 0 0 0 3px rgba(255,210,63,.35); }

/* chrome (auto-hiding controls) */
.tp-chrome { z-index: 5; transition: opacity .3s, transform .3s; color: var(--tp-chrome-fg); }
.tp-idle .tp-chrome { opacity: 0; pointer-events: none; }
.tp-idle, .tp-idle .tp-view { cursor: none; }
.tp-top {
  position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 8px; z-index: 6;
  padding: calc(10px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left));
}
.tp-mode-record .tp-top { pointer-events: none; }
.tp-mode-record .tp-top > * { pointer-events: auto; }
.tp-mode-record .tp-status { flex: 0 1 auto; padding: 4px 10px; border-radius: 999px; background: rgba(9,14,30,.6); }
.tp-mode-record .tp-top-right { margin-left: auto; }
.tp-status { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; font-variant-numeric: tabular-nums; }
.tp-time { opacity: .85; white-space: nowrap; }
.tp-pill { font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: var(--tp-blue); color: #fff; white-space: nowrap; }
.tp-pill[hidden] { display: none; }
.tp-pill-rec { background: var(--tp-rec-strong); color: #fff; }
.tp-pill-rec::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #fff; margin-right: 5px; vertical-align: 1px; animation: tp-blink 1s steps(2) infinite; }
@keyframes tp-blink { 50% { opacity: 0; } }
.tp-top-right { display: flex; gap: 6px; }
.tp-mode-record .tp-top .tp-icon-btn { background: rgba(9,14,30,.6); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

.tp-dock {
  position: relative; z-index: 4; flex: none; margin: 0 8px 8px; width: auto;
  display: grid; gap: 4px; padding: 8px 10px; border-radius: 18px; background: var(--tp-chrome);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.tp-mode-record .tp-dock { margin-bottom: 14px; }
@media (min-width: 1100px) { /* desktop: one control row (speed · mode | transport | tools) */
  .tp-dock { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 10px; }
}

.tp-dock-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tp-dock-speed { padding: 0 2px; }
.tp-dock-ico { flex: none; display: grid; place-items: center; width: 24px; height: 24px; opacity: .75; }
.tp-dock-ico svg { width: 20px; height: 20px; }
.tp-dock-range { flex: 1 1 auto; min-width: 60px; accent-color: var(--tp-yellow); min-height: 32px; }
.tp-speed-val {
  flex: none; min-width: 62px; padding: 5px 9px; border-radius: 999px; background: rgba(255,255,255,.12); text-align: center;
  font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.2;
}
.tp-mode { position: relative; flex: none; }
.tp-modechip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 150px; min-height: 36px; padding: 0 8px 0 12px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.22); background: transparent; color: inherit; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.tp-modechip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-modechip svg { width: 16px; height: 16px; flex: none; }
.tp-voice .tp-modechip { border-color: var(--tp-blue); background: color-mix(in srgb, var(--tp-blue) 30%, transparent); }
.tp-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px); min-width: 180px; padding: 6px; border-radius: 12px; z-index: 8;
  background: #111a33; box-shadow: 0 12px 30px rgba(0,0,0,.5); display: grid; gap: 2px;
}
.tp-menu[hidden] { display: none; }
.tp-menu button {
  text-align: left; min-height: 44px; padding: 0 12px 0 30px; border: 0; border-radius: 8px; background: transparent; color: #fff; font: inherit; font-size: 14px; cursor: pointer; position: relative;
}
.tp-menu button:hover, .tp-menu button:focus-visible { background: rgba(255,255,255,.1); outline: none; }
.tp-menu-note { margin: 4px 8px 4px 30px; font-size: 12px; line-height: 1.4; color: #9aa6c4; max-width: 220px; }
.tp-menu button:disabled { opacity: .45; cursor: not-allowed; }
.tp-dock-range:disabled { opacity: .4; }
.tp-speed-val.tp-flash { animation: tp-flash .3s ease-out; }
@keyframes tp-flash { from { background: var(--tp-yellow); color: #070b1a; } }
.tp-menu button[aria-checked="true"]::before { content: ""; position: absolute; left: 11px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--tp-yellow); }
.tp-bar { justify-content: space-between; }
.tp-dock-center { display: flex; align-items: center; gap: 6px; }
.tp-icon-btn {
  display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0;
  background: transparent; color: inherit; cursor: pointer; font: inherit; transition: background-color .15s;
}
.tp .tp-icon-btn { background: transparent; color: var(--tp-muted); }
.tp .tp-icon-btn:hover { background: var(--tp-surface-2); }
.tp-icon-btn svg { width: 22px; height: 22px; }
.tp-icon-btn:hover { background: rgba(255,255,255,.14); }
.tp-icon-btn[aria-pressed="true"], .tp-icon-btn[aria-expanded="true"] { background: var(--tp-yellow); color: #111; }
.tp-icon-btn:disabled { opacity: .5; cursor: progress; }
.tp-icon-btn[hidden] { display: none; }
.tp-txt-btn { display: inline-flex; align-items: center; justify-content: center; line-height: 1; font-weight: 700; font-size: 17px; }
.tp-txt-btn small { font-size: 13px; margin-left: 1px; }
.tp-play {
  display: grid; place-items: center; flex: none; width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--tp-yellow); color: #111; box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
.tp-play[hidden] { display: none; }
.tp-play svg { width: 26px; height: 26px; }
/* big record button: white ring, red dot that turns into a red square while recording */
.tp-recbig {
  display: grid; place-items: center; flex: none; width: 64px; height: 64px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 4px solid #fff; background: transparent; box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.tp-recbig[hidden] { display: none; }
.tp-recdot { display: block; width: 40px; height: 40px; border-radius: 50%; background: var(--tp-rec); transition: border-radius .2s, transform .2s; }
.tp-recording .tp-recbig .tp-recdot { border-radius: 6px; transform: scale(.6); }
.tp-recbig:focus-visible, .tp-play:focus-visible, .tp-modechip:focus-visible { outline: 3px solid var(--tp-yellow); outline-offset: 3px; }
.tp-textpop {
  position: absolute; right: 8px; bottom: calc(100% + 8px); width: min(320px, calc(100vw - 40px)); padding: 10px 14px; border-radius: 14px; z-index: 8;
  background: #111a33; color: #eef0f7; box-shadow: 0 12px 30px rgba(0,0,0,.5);
  --tp-surface: #111a33; --tp-surface-2: #1d2747; --tp-line: #2a3557; --tp-muted: #a3b1c4; --tp-text: #eef0f7;
}
.tp-textpop[hidden] { display: none; }
.tp-textpop-size { display: flex; gap: 6px; justify-content: flex-end; }
.tp-textpop .tp-seg { background: var(--tp-surface-2); flex-wrap: wrap; }
.tp-textpop .tp-seg input:checked + span { background: #33406b; }
.tp-textpop .tp-row:last-child { border-bottom: 0; }

/* mic level + device name (record mode, after the camera starts) */
.tp-mic {
  position: absolute; z-index: 5; right: max(12px, env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px; max-width: min(320px, 60vw); padding: 6px 12px 6px 8px; border-radius: 999px;
  background: rgba(9,14,30,.7); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: #fff; font-size: 12px;
}
.tp-mic[hidden] { display: none; }
.tp-mic-ico svg { width: 18px; height: 18px; display: block; }
.tp-mic-meter { flex: none; display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.tp-mic-meter i { display: block; width: 4px; border-radius: 1px; background: rgba(255,255,255,.25); }
.tp-mic-meter i:nth-child(1) { height: 5px; } .tp-mic-meter i:nth-child(2) { height: 7px; } .tp-mic-meter i:nth-child(3) { height: 9px; } .tp-mic-meter i:nth-child(4) { height: 11px; } .tp-mic-meter i:nth-child(5) { height: 14px; }
.tp-mic-meter i.on { background: #3ccb7f; }
.tp-mic-meter i:nth-child(4).on { background: var(--tp-yellow); } .tp-mic-meter i:nth-child(5).on { background: var(--tp-rec); }
.tp-mic-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }

.tp-appcard {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--tp-line, rgba(255,255,255,.2)); border-radius: 14px;
  padding: 6px 6px 6px 14px; font-size: 14px; line-height: 1.4; background: var(--tp-surface-2, #151826);
}
.tp-appcard a { flex: 1; color: inherit; text-decoration: none; padding: 6px 0; }
.tp-appcard a strong { color: var(--tp-accent-text); }
.tp-appcard-x { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; opacity: .7; }
.tp-appcard-x:hover { opacity: 1; }
.tp-appcard-x svg { width: 18px; height: 18px; }
.tp-stage .tp-appcard {
  position: absolute; z-index: 7; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom));
  width: min(460px, calc(100% - 32px)); background: #111a33; color: #eef0f7; border-color: #2a3557; box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.tp-stage .tp-appcard a strong { color: var(--tp-yellow); }
/* one-time hint under the top icons + tooltips */
.tp-hint {
  position: absolute; z-index: 7; top: calc(64px + env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); margin: 0;
  max-width: calc(100% - 20px); padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.4;
  background: #111a33; color: #eef0f7; box-shadow: 0 8px 24px rgba(0,0,0,.45); pointer-events: none;
}
.tp-hint[hidden] { display: none; }
.tp-top-right .tp-icon-btn { position: relative; }
@media (hover: hover) {
  .tp-top-right .tp-icon-btn[data-tip]:hover::after, .tp-top-right .tp-icon-btn[data-tip]:focus-visible::after {
    content: attr(data-tip); position: absolute; top: calc(100% + 6px); right: 0; white-space: nowrap; pointer-events: none;
    font-size: 12px; font-weight: 600; padding: 5px 8px; border-radius: 6px; background: #111a33; color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.4);
  }
}
/* editor: Record entry next to Start */
.tp-btn-rec { border-color: var(--tp-line); background: var(--tp-surface); min-height: 52px; }
.tp-btn-rec .tp-recdot { width: 14px; height: 14px; }
.tp-btn-rec:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 560px) {
  .tp-pbox { left: 6px; right: 6px; border-radius: 16px; }
  .tp-dock { margin: 0 6px 6px; padding: 6px; border-radius: 16px; }
  .tp-dock-row { gap: 2px; }
  .tp-dock-center { gap: 2px; }
  .tp-modechip { max-width: 104px; padding: 0 6px 0 10px; }
  .tp-speed-val { min-width: 52px; padding: 5px 6px; }
  .tp-dock-ico { width: 20px; }
  .tp-play, .tp-recbig { width: 52px; height: 52px; }
  .tp-recdot { width: 34px; height: 34px; }
  .tp-top-right { gap: 2px; }
  .tp-mic-name { display: none; }
}
@media (max-width: 360px) {
  .tp-dock-ico { display: none; }
  .tp-modechip { max-width: 92px; }
}

/* settings panel */
.tp-panel {
  position: absolute; z-index: 8; top: calc(64px + env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); width: min(360px, calc(100% - 24px));
  max-height: min(70vh, 620px); border-radius: 16px;
  background: #151826; color: #eef0f7; overflow: auto; overscroll-behavior: contain;
  padding: 12px 18px 18px;
  box-shadow: -10px 0 40px rgba(0,0,0,.45); -webkit-user-select: auto; user-select: auto;
  --tp-surface: #151826; --tp-surface-2: #23283c; --tp-line: #2e344c; --tp-muted: #a3a9bd; --tp-text: #eef0f7;
  touch-action: pan-y;
}
.tp-panel[hidden] { display: none; }
.tp-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.tp-panel-head h2 { font-size: 18px; margin: 0; }
.tp-panel .tp-row { border-color: var(--tp-line); }
.tp-panel .tp-seg { background: var(--tp-surface-2); }
.tp-panel .tp-seg input:checked + span { background: #3a4160; }
.tp-panel .tp-switch-ui { background: #3a4160; }
.tp-panel select { background-color: var(--tp-surface-2); color: #fff; border: 1px solid var(--tp-line); }
.tp-panel-notes { display: grid; gap: 10px; margin-top: 12px; }
.tp-panel .tp-note { color: var(--tp-muted); }
@media (max-width: 600px) {
  .tp-panel { top: auto; bottom: calc(8px + env(safe-area-inset-bottom)); left: 6px; right: 6px; width: auto; max-height: 55vh; border-radius: 16px; }
}

/* recording-ready sheet */
.tp-sheet {
  position: absolute; z-index: 7; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(440px, calc(100% - 32px));
  background: #151826; color: #eef0f7; border-radius: 18px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
  -webkit-user-select: auto; user-select: auto;
}
.tp-sheet[hidden] { display: none; }
.tp-sheet h2 { margin: 0 0 6px; font-size: 19px; }
.tp-sheet p { margin: 0 0 16px; color: #a3a9bd; font-size: 14px; line-height: 1.5; }
.tp-sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tp-sheet .tp-btn-ghost { background: transparent; color: #eef0f7; border-color: #3a4160; }

@media (prefers-reduced-motion: reduce) {
  .tp-chrome, .tp-btn, .tp-switch-ui, .tp-switch-ui::after { transition: none; }
  .tp-pill-rec::before { animation: none; }
}
@media (forced-colors: active) {
  .tp-focus { border-color: CanvasText; }
  .tp-icon-btn, .tp-play { border: 1px solid ButtonText; }
}
/* perf: chrome/status updates never invalidate the (possibly huge) script layout */
.tp-chrome, .tp-progress, .tp-countdown, .tp-panel, .tp-msg { contain: layout style; }
.tp-view { contain: strict; }

/* the collapse chevron is a plain icon button (not a pressed/expanded yellow state) */
.tp-phead .tp-pcollapse[aria-expanded] { background: transparent; color: inherit; }
.tp-phead .tp-pcollapse:hover { background: rgba(255,255,255,.14); }

/* Camera view "Small tile": text panel on navy, live self-view as a clear tile (never hidden while recording) */
.tp-camtile.tp-cam-on { background: var(--tp-navy); }
.tp-camtile.tp-cam-on .tp-cam {
  inset: auto; top: calc(64px + env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); width: 280px; height: 158px; z-index: 6;
  border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); border: 2px solid rgba(255,255,255,.3);
}
.tp-camtile.tp-mode-record .tp-pbox { /* same full panel as prompt-only */
  top: calc(64px + env(safe-area-inset-top)); bottom: calc(12px + env(safe-area-inset-bottom)); left: 12px; right: 12px; width: auto; height: auto;
  transform: none; background: var(--tp-navy); -webkit-backdrop-filter: none; backdrop-filter: none;
}
.tp-camtile .tp-resize, .tp-camtile .tp-wresize { display: none !important; }
@media (max-width: 560px) { .tp-camtile.tp-cam-on .tp-cam { width: 150px; height: 200px; } }
/* record mode: never cover the face with messages; keep the top bar uncluttered on phones */
.tp-mode-record .tp-msg { bottom: calc(64px + env(safe-area-inset-bottom)); }
.tp-camtile .tp-mic { bottom: auto; top: calc(232px + env(safe-area-inset-top)); }
@media (max-width: 560px) {
  .tp-recording .tp-time { display: none; }
  .tp-camtile .tp-mic { top: calc(274px + env(safe-area-inset-top)); }
}

/* ---- recorder pass 3: dock overlays the bottom of the script and auto-hides; REC timer always visible ---- */
.tp-dock { position: absolute; left: 8px; right: 8px; bottom: 8px; margin: 0; }
.tp-mode-record .tp-dock { bottom: 14px; margin: 0; }
@media (max-width: 560px) { .tp-dock { left: 6px; right: 6px; bottom: 6px; } }
.tp-idle .tp-top { opacity: 1; pointer-events: none; }
.tp-idle .tp-top > :not(.tp-status), .tp-idle .tp-status .tp-time { opacity: 0; transition: opacity .3s; }
.tp-idle .tp-mode-record .tp-status, .tp-mode-record.tp-idle .tp-status { background: transparent; }
.tp-idle .tp-resize, .tp-idle .tp-wresize, .tp-idle .tp-phead { opacity: 0; transition: opacity .3s; }
.tp-mode-record.tp-recording .tp-phead { opacity: 1; }
/* mode chip: icon + short label on phones */
.tp-modeico { display: none; } .tp-modeshort { display: none; }
.tp-modeico svg { width: 16px; height: 16px; display: block; }
@media (max-width: 560px) {
  .tp-modechip { max-width: none; gap: 4px; padding: 0 6px 0 8px; }
  .tp-modechip [data-tp-modelabel] { display: none; }
  .tp-modeico, .tp-modeshort { display: inline-block; }
}
.tp-btn-danger { color: #ffb4ab !important; border-color: #6b2b2b !important; }
.tp-devices[hidden] { display: none; }
.tp-devices select { max-width: 200px; }
.tp-mic { cursor: pointer; }

/* compact single-row control bar on desktop (record panel keeps more lines visible while it's up) */
@media (min-width: 1100px) {
  .tp-mode-record .tp-dock { padding: 4px 8px; }
  .tp-mode-record .tp-recbig { width: 52px; height: 52px; border-width: 3px; }
  .tp-mode-record .tp-recdot { width: 34px; height: 34px; }
  .tp-mode-record .tp-dock .tp-icon-btn { width: 40px; height: 40px; }
}

/* editing the script is not available during a take (keeps Stop reachable) */
.tp-recording [data-act="edit"], .tp-counting [data-act="edit"] { opacity: .35; pointer-events: none; }

/* Anatoli: never hide the controls completely. While scrolling they dim to 35% after 3s (still usable);
   when not scrolling they are fully visible. */
.tp-idle .tp-chrome { opacity: .35; pointer-events: auto; }
.tp-idle .tp-top { opacity: 1; pointer-events: auto; }
.tp-idle .tp-top > :not(.tp-status), .tp-idle .tp-status .tp-time { opacity: .35; }
.tp-idle .tp-resize, .tp-idle .tp-wresize, .tp-idle .tp-phead { opacity: .5; }
.tp-idle, .tp-idle .tp-view { cursor: auto; }
/* prompt-only screen: Record sits next to Play */
.tp-dock-center .tp-play + .tp-recbig:not([hidden]) { width: 52px; height: 52px; border-width: 3px; }
.tp-dock-center .tp-play + .tp-recbig:not([hidden]) .tp-recdot { width: 32px; height: 32px; }
.tp-play[hidden] + .tp-recbig { width: 64px; height: 64px; }
.tp-sheet .tp-btn svg { width: 18px; height: 18px; }
.tp-sheet .tp-recdot { width: 14px; height: 14px; }

.tp-panel-edit { margin-top: 12px; color: #eef0f7 !important; border-color: #3a4160 !important; background: transparent !important; }
.tp-panel-edit svg { width: 16px; height: 16px; }
@media (min-width: 561px) { .tp-panel-edit { display: none; } }
@media (max-width: 560px) { .tp-dock [data-act="edit"] { display: none; } } /* phones: Edit lives in Settings */
/* dimmed dock keeps its solid background (no script showing through), only its controls go to 35% */
.tp-idle .tp-dock { opacity: 1; }
.tp-idle .tp-dock > * { opacity: .35; transition: opacity .3s; }
/* ---- floating panel = a window: move by the head, resize from any corner/edge (record mode, full-window camera) ---- */
.tp-rz { display: none; position: absolute; z-index: 7; touch-action: none; }
.tp-mode-record:not(.tp-camtile):not(.tp-collapsed) .tp-rz { display: block; }
.tp-rz-n, .tp-rz-s { left: 24px; right: 24px; height: 10px; cursor: ns-resize; }
.tp-rz-n { top: -4px; } .tp-rz-s { bottom: -4px; }
.tp-rz-e, .tp-rz-w { top: 24px; bottom: 24px; width: 10px; cursor: ew-resize; }
.tp-rz-e { right: -4px; } .tp-rz-w { left: -4px; }
.tp-rz-nw, .tp-rz-ne, .tp-rz-se, .tp-rz-sw { width: 24px; height: 24px; }
.tp-rz-nw { left: -2px; top: -2px; cursor: nwse-resize; } .tp-rz-se { right: -2px; bottom: -2px; cursor: nwse-resize; }
.tp-rz-ne { right: -2px; top: -2px; cursor: nesw-resize; } .tp-rz-sw { left: -2px; bottom: -2px; cursor: nesw-resize; }
/* subtle L-shaped yellow corner marks: on hover/focus with a mouse, always on touch screens */
.tp-rz-nw::after, .tp-rz-ne::after, .tp-rz-se::after, .tp-rz-sw::after {
  content: ""; position: absolute; width: 14px; height: 14px; border: 0 solid var(--tp-yellow); opacity: 0; transition: opacity .15s;
}
.tp-rz-nw::after { left: 5px; top: 5px; border-left-width: 3px; border-top-width: 3px; border-top-left-radius: 6px; }
.tp-rz-ne::after { right: 5px; top: 5px; border-right-width: 3px; border-top-width: 3px; border-top-right-radius: 6px; }
.tp-rz-se::after { right: 5px; bottom: 5px; border-right-width: 3px; border-bottom-width: 3px; border-bottom-right-radius: 6px; }
.tp-rz-sw::after { left: 5px; bottom: 5px; border-left-width: 3px; border-bottom-width: 3px; border-bottom-left-radius: 6px; }
.tp-pbox:hover .tp-rz::after, .tp-pbox:focus-within .tp-rz::after { opacity: .9; }
@media (pointer: coarse) {
  .tp-rz-nw, .tp-rz-ne, .tp-rz-se, .tp-rz-sw { width: 44px; height: 44px; }
  .tp-rz-nw::after, .tp-rz-ne::after, .tp-rz-se::after, .tp-rz-sw::after { opacity: .9; }
  .tp-rz-n, .tp-rz-s { height: 20px; left: 44px; right: 44px; } .tp-rz-n { top: -8px; } .tp-rz-s { bottom: -8px; }
  .tp-rz-e, .tp-rz-w { width: 20px; top: 44px; bottom: 44px; } .tp-rz-e { right: -8px; } .tp-rz-w { left: -8px; }
}
.tp-wresize { display: none !important; }
.tp-mode-record .tp-pbox { overflow: visible; } /* handles reach slightly outside the rounded box */
.tp-mode-record .tp-view, .tp-mode-record .tp-pbar { border-radius: 0; }
.tp-mode-record .tp-pbox > .tp-pbar { border-radius: 20px 20px 0 0; overflow: hidden; }
.tp-mode-record .tp-view { overflow: hidden; }

/* ---- lean setup page (Anatoli): editor + "Your scripts" dropdown + icon tools + two CTAs; settings live in the screen ---- */
.tp-editor-full { display: block !important; max-width: 880px; margin-inline: auto; }
.tp-editor-full .tp-ed-main { width: 100%; }
.tp-ed-head { flex-wrap: nowrap !important; }
.tp-title { flex: 1 1 0 !important; min-width: 0; }
.tp-ed-tools { flex-wrap: nowrap !important; gap: 6px; align-items: center; }
.tp-tool { width: 40px; min-height: 40px; padding: 0 !important; }
.tp-tool > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tp-libwrap { position: relative; }
.tp-libbtn { gap: 6px; }
.tp-libbtn svg:last-of-type { width: 14px; height: 14px; }
.tp-libcount:not(:empty) { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--tp-surface-2); font-size: 12px; }
.tp-libwrap .tp-lib {
  position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; width: min(320px, calc(100vw - 32px)); max-height: min(60vh, 420px); overflow: auto;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
}
.tp-libwrap .tp-lib[hidden] { display: none; }
.tp-libwrap .tp-lib-list { max-height: none; }
.tp-popout { width: 52px; min-height: 52px; padding: 0; flex: none; }
.tp-popout svg { width: 22px; height: 22px; }
@media (max-width: 599px) {
  .tp-libbtn span:not(.tp-libcount) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tp-libbtn { width: auto; padding: 0 8px; }
}

/* Aa popover holds all text settings now: keep it within the screen */
.tp-textpop { max-height: min(70vh, 560px); overflow: auto; overscroll-behavior: contain; -webkit-user-select: auto; user-select: auto; }
.tp-textpop select { background-color: var(--tp-surface-2); color: #fff; border: 1px solid var(--tp-line); }

.tp-stage > .tp-textpop { position: absolute; right: auto; bottom: auto; z-index: 9; }

/* camera problems are explained inline, under the top bar; the screen stays open */
.tp-sheet.tp-camissue { top: calc(70px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 8; }
.tp-camissue p { color: #eef0f7; margin-bottom: 12px; }

/* P0: the collapsed panel is a slim pill that ALWAYS keeps the transport (back / play / Record-Stop / forward).
   min-height/inline geo height must not turn it into an empty box. */
.tp-stage.tp-collapsed .tp-pbox { height: auto !important; min-height: 0 !important; bottom: auto !important; max-width: min(420px, calc(100% - 12px)); }
.tp-stage.tp-collapsed .tp-dock { display: flex !important; justify-content: center; position: static; margin: 2px 6px 6px; padding: 4px; }
.tp-stage.tp-collapsed .tp-dock > .tp-dock-speed, .tp-stage.tp-collapsed .tp-dock .tp-textpop,
.tp-stage.tp-collapsed .tp-dock [data-act="edit"], .tp-stage.tp-collapsed .tp-dock [data-act="textmenu"],
.tp-stage.tp-collapsed .tp-dock [data-act="settings"] { display: none !important; }
.tp-stage.tp-collapsed .tp-dock .tp-bar { justify-content: center; }
/* the grip and Hide/Show script sit clear of the corner resize handles (24px mouse, 44px touch),
   so a tap on them never starts a resize and a drag by the grip moves the window */
.tp-mode-record:not(.tp-camtile) .tp-phead { padding: 0 22px 0 26px; }
@media (pointer: coarse) { .tp-mode-record:not(.tp-camtile) .tp-phead { padding: 0 42px 0 46px; } }

/* qa round: the script area ends at the dock's top (JS sets --tp-dockh): nothing hidden under the dock, no cut strip below it */
.tp-pbox { box-sizing: border-box; padding-bottom: var(--tp-dockh, 0px); }
.tp-stage.tp-collapsed .tp-pbox { padding-bottom: 0; }
.tp-mode-record .tp-pbox { height: var(--tp-ph, 38vh); }
@media (max-width: 699px) { .tp-mode-record .tp-pbox { height: var(--tp-ph, 34vh); } }
/* countdown: centred on the whole screen (camera), above the panel and the dock; never clipped */
.tp-stage > .tp-countdown { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; pointer-events: none; }
.tp-stage > .tp-countdown[hidden] { display: none; }
.tp-stage > .tp-countdown span { text-shadow: 0 4px 30px rgba(0,0,0,.6); }
/* during the countdown the centre Record button reads Cancel × */
.tp-counting .tp-recbig .tp-recdot { background: transparent; border-radius: 0; position: relative; }
.tp-counting .tp-recbig .tp-recdot::before, .tp-counting .tp-recbig .tp-recdot::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 70%; height: 4px; border-radius: 2px; background: #fff; transform: translate(-50%, -50%) rotate(45deg);
}
.tp-counting .tp-recbig .tp-recdot::after { transform: translate(-50%, -50%) rotate(-45deg); }
/* toasts on the stage stay compact (no 4-line wraps at 390) */
.tp-stage .tp-msg { max-width: min(340px, calc(100vw - 32px)); }
/* settings sheet: soft top edge so a cut cue line underneath doesn't look broken */
.tp-panel { -webkit-mask-image: linear-gradient(transparent 0, #000 12px); mask-image: linear-gradient(transparent 0, #000 12px); }
/* WebKit: draw the speed slider track */
.tp-dock-range { -webkit-appearance: none; appearance: none; height: 32px; background: transparent; }
.tp-dock-range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--tp-yellow, #FFC53D) var(--fill, 0%), rgba(255,255,255,.35) var(--fill, 0%)); }
.tp-dock-range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--tp-yellow, #FFC53D); }
.tp-dock-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--tp-yellow, #FFC53D); border: 0; }
.tp-dock-range::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.35); }
.tp-dock-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--tp-yellow, #FFC53D); border: 0; }
.tp-dock-range:focus-visible { outline: 2px solid var(--tp-yellow, #FFC53D); outline-offset: 2px; }
/* setup page: both start buttons keep their labels on phones and share one row */
@media (max-width: 599px) {
  .tp-ed-foot .tp-start-rec, .tp-ed-foot .tp-start { flex: 1 1 0 !important; min-width: 0; width: auto; min-height: 52px; padding: 0 10px !important; font-size: 15px; gap: 6px; }
  .tp-ed-foot .tp-start span { position: static; width: auto; height: auto; overflow: hidden; clip: auto; text-overflow: ellipsis; white-space: nowrap; }
  .tp-ed-foot .tp-start svg { flex: none; }
}
/* home hero: stats on their own row, both buttons together under them */
.tp-editor-home .tp-ed-foot { flex-wrap: wrap; gap: 8px; }
.tp-editor-home .tp-ed-foot .tp-stats { flex: 1 0 100%; }
/* touch targets >= 44px on the setup page */
.tp-tool, .tp-ed-tools .tp-btn { width: 44px !important; min-height: 44px !important; }
.tp-ed-tools .tp-libbtn { width: auto !important; min-width: 44px; flex: none; white-space: nowrap; padding-inline: 10px 8px !important; }
.tp-ed-tools { gap: 8px !important; }
.tp-file, .tp-file input { min-width: 44px; min-height: 44px; }
/* sticky start bar is opaque (no textarea text showing through) */
.tp-ed-foot { background: var(--tp-surface); }
/* /teleprompter/: the editor lines up with the H1 and body copy (= the .wrap content box) */
.tp-editor-full { margin-inline: auto; max-width: calc(var(--wrap, 1120px) - 40px); width: 100%; }

/* record mode: lines fade in/out at the head and dock edges instead of being cut in half */
.tp-mode-record .tp-view { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%); }
/* collapsed pill: the same bare 32px chevron as when expanded */
.tp-stage.tp-collapsed .tp-pcollapse { width: 32px !important; height: 32px !important; min-height: 0; background: transparent !important; box-shadow: none; }
/* compact dock (JS sets .tp-dock1 when the panel is 350–520px wide): ONE row = icon mode chip + transport + Aa + ⚙.
   The speed slider and wpm pill move into Aa. Every control fits; nothing is pushed off-screen. */
.tp-textpop .tp-row-wpm { display: none; }
.tp-dock1 .tp-textpop .tp-row-wpm, .tp-stage.tp-dock1 > .tp-textpop .tp-row-wpm { display: grid; }
.tp-dock1 .tp-dock { display: flex !important; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 2px; padding: 4px 6px; }
.tp-dock1 .tp-dock > .tp-dock-speed { flex: none; gap: 0; }
.tp-dock1 .tp-dock .tp-dock-range, .tp-dock1 .tp-dock .tp-dock-ico, .tp-dock1 .tp-dock .tp-speed-val { display: none; }
.tp-dock1 .tp-dock > .tp-bar { flex: 1 1 auto; min-width: 0; justify-content: space-between; gap: 2px; }
.tp-dock1 .tp-dock .tp-dock-center { gap: 2px; }
.tp-dock1 .tp-dock .tp-icon-btn { width: 44px; height: 44px; flex: none; }
.tp-dock1 .tp-dock .tp-play, .tp-dock1 .tp-dock .tp-recbig:not([hidden]) { width: 48px !important; height: 48px !important; flex: none; }
/* icon-only mode chip (compact dock and phone landscape) */
.tp-dock1 .tp-modechip, .tp-land .tp-modechip { width: 44px; min-width: 44px; height: 44px; padding: 0; justify-content: center; gap: 0; }
.tp-dock1 .tp-modechip [data-tp-modelabel], .tp-dock1 .tp-modechip [data-tp-modeshort], .tp-dock1 .tp-modechip > svg:last-child,
.tp-land .tp-modechip [data-tp-modelabel], .tp-land .tp-modechip [data-tp-modeshort], .tp-land .tp-modechip > svg:last-child { display: none !important; }
.tp-dock1 .tp-modechip .tp-modeico, .tp-land .tp-modechip .tp-modeico { display: inline-block !important; }
.tp-dock1 .tp-menu { left: 0; right: auto; }
/* phone landscape (short screens, JS .tp-land): one-row dock (slider kept when the panel is wide), Edit moves into Settings */
.tp-land .tp-dock { display: flex !important; flex-wrap: nowrap; align-items: center; gap: 4px; padding: 4px 6px; }
.tp-land .tp-dock > .tp-dock-speed { flex: 1 1 auto; min-width: 0; }
.tp-land .tp-dock .tp-dock-ico { display: none; }
.tp-land .tp-dock > .tp-bar { flex: none; }
.tp-land .tp-dock [data-act="edit"] { display: none; }
.tp-land .tp-panel-edit { display: inline-flex !important; }
.tp-land:not(.tp-mode-record) .tp-pbox { top: calc(52px + env(safe-area-inset-top)); bottom: calc(6px + env(safe-area-inset-bottom)); }

.tp-dock1 .tp-dock [data-act="edit"] { display: none !important; }
.tp-dock1 .tp-panel-edit { display: inline-flex !important; }
/* the card lines up with the H1 (.wrap has 20px side padding; 14px at <=380) */
.tp-editor-full { width: min(100%, calc(100vw - 40px)); }
@media (max-width: 380px) { .tp-editor-full { width: min(100%, calc(100vw - 28px)); } }
/* narrow phones: no ▾ on the library button, so the 2-line title keeps its width */
@media (max-width: 420px) { .tp-libbtn svg:last-of-type { display: none; } }

/* phones: Aa = size + speed only; the other text settings live under ⚙ (shown only with the compact dock) */
.tp-panel-text { display: none; }
.tp-dock1 .tp-panel-text { display: block; }
.tp-dock1 .tp-textpop .tp-row-xtra { display: none; }
/* compact dock: tighter side padding so 7 controls fit at a 344px panel */
.tp-dock1 .tp-dock { padding: 4px 3px; gap: 1px; }
.tp-dock1 .tp-dock > .tp-bar, .tp-dock1 .tp-dock .tp-dock-center { gap: 1px; }
/* setup card on phones: the title keeps one line for short titles */
@media (max-width: 420px) {
  .tp-ed-head .tp-ed-tools { flex: none; gap: 4px !important; }
  .tp-title { font-size: 14px !important; padding-left: 4px !important; padding-right: 4px !important; }
}
/* empty script box: the placeholder reads like normal text (same size), in the muted text colour (WCAG AA on the card) */
.tp-text::placeholder { color: var(--tp-muted); opacity: 1; font-size: inherit; font-weight: inherit; }
.tp-title::placeholder, .tp-title-ph { color: var(--tp-muted); opacity: 1; }

/* P0: record layout from the first frame; dark camera area with a spinner until the stream arrives, then the video fades in */
.tp-camwait { display: none; position: absolute; left: 50%; bottom: 28%; transform: translateX(-50%); z-index: 1; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 999px; background: rgba(255,255,255,.08); color: #eef0f7; font-size: 15px; font-weight: 600; }
.tp-cam-starting .tp-camwait { display: flex; }
.tp-spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; animation: tp-spin .8s linear infinite; }
@keyframes tp-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tp-spin { animation: none; } }
.tp-cam-on .tp-cam { animation: tp-camin .35s ease-out; }
@keyframes tp-camin { from { opacity: 0; } to { opacity: 1; } }
.tp-mode-record { background: #05070f; }

/* script box like the competitor: big, white, normal-weight text on a dark rounded card; placeholder = same look,
   so the box looks the same before and after typing (colours are theme tokens: dark text in the light theme) */
.tp-ed-main .tp-text {
  font-size: 28px; font-weight: 400; line-height: 1.5; color: var(--tp-text);
  padding: 40px 48px; border-radius: 32px; border: 1px solid var(--tp-line); background: var(--tp-surface-2);
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.tp-ed-main .tp-text::placeholder { color: var(--tp-text); opacity: .9; font-size: inherit; font-weight: 400; }
.tp-ed-main .tp-text:focus { outline: 2px solid var(--tp-accent); outline-offset: -1px; }
@media (max-width: 599px) {
  .tp-ed-main .tp-text { font-size: 20px; padding: 22px 22px; border-radius: 24px; }
}

/* designer polish 2026-11-26: library popover */
/* "New" sits inside .tp-ed-tools, so the 44px icon-button rules squeezed it into a circle with the label spilling out */
.tp-ed-tools .tp-lib .tp-btn { width: auto !important; padding: 0 14px 0 10px !important; gap: 6px; }
.tp-ed-tools .tp-lib .tp-btn span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
.tp-libwrap .tp-lib { border-radius: 14px; padding: 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, .18), 0 12px 32px rgba(0, 0, 0, .28); }
:root[data-theme="light"] .tp-libwrap .tp-lib { box-shadow: 0 1px 2px rgba(11, 20, 51, .06), 0 12px 32px rgba(11, 20, 51, .12); }
.tp-lib-head { padding-left: 4px; }
.tp-lib-load { padding-left: 16px; }   /* room for the selection pill; all rows stay aligned */
/* phones: the popover was anchored to the button's right edge and ran off the left of the screen; span the card head instead */
@media (max-width: 699px) {
  .tp-ed-head { position: relative; }
  .tp-libwrap { position: static; }
  .tp-libwrap .tp-lib { left: 0; right: 0; width: auto; }
}

/* ============ CuePrompter-style setup screen: ONE top toolbar, all settings out in the open ============ */
.tp-stage .tp-pbox > .tp-dock[hidden], .tp-stage.tp-stage .tp-pbox > .tp-dock { display: none !important; }
.tp-tbar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 7; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background: rgba(7, 11, 26, .94); border-bottom: 1px solid rgba(255,255,255,.1); color: #eef0f7; pointer-events: auto !important;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.tp-mode-record .tp-tbar { background: rgba(7, 11, 26, .78); padding-top: calc(8px + env(safe-area-inset-top)); }
.tp-tb-lead { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tp-tb-lead .tp-status { flex: none; }
.tp-tb-transport { display: flex; align-items: center; gap: 4px; }
.tp-tb-transport .tp-play { width: 48px !important; height: 48px !important; }
.tp-tb-transport .tp-play[hidden] { display: none; }
.tp-tb-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; flex: 1 1 auto; min-width: 0; }
.tp-tb-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; white-space: nowrap; color: #c9d1e6; }
.tp-tb-field input[type="range"] { width: 110px; accent-color: var(--tp-yellow); min-height: 32px; }
.tp-tb-field output { min-width: 52px; color: #fff; font-variant-numeric: tabular-nums; }
.tp-tb-field select { min-height: 36px; border-radius: 10px; border: 1px solid rgba(255,255,255,.22); background: #151d38; color: #fff; font: inherit; font-size: 13px; padding: 0 8px; }
.tp-tb-speed { gap: 6px; }
.tp-tb-speed .tp-dock-range { width: 120px; flex: none; }
.tp-tb-speed .tp-dock-ico { display: none; }
.tp-tb-seg { display: inline-flex; border-radius: 10px; overflow: hidden; border: 1px solid rgba(255,255,255,.22); }
.tp-tb-tog { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; cursor: pointer; color: #dfe5f5; border-radius: 10px; }
.tp-tb-seg .tp-tb-tog { border-radius: 0; }
.tp-tb-tog > input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.tp-tb-tog svg { width: 20px; height: 20px; pointer-events: none; }
.tp-tb-tog:has(input:checked) { background: var(--tp-yellow); color: #070b1a; }
.tp-tb-tog:has(input:focus-visible) { outline: 2px solid var(--tp-yellow); outline-offset: 1px; }
.tp-tb-tools > .tp-tb-tog:not(:has(input:checked)) { border: 1px solid rgba(255,255,255,.22); }
.tp-tb-rec { margin-left: auto; display: flex; align-items: center; }
.tp-tbar .tp-recbig.tp-tb-recbtn { width: auto !important; height: 44px !important; border-radius: 999px; border: 0; padding: 0 18px 0 12px;
  display: inline-flex; align-items: center; gap: 8px; background: #e5332a; color: #fff; font: inherit; font-weight: 700; font-size: 15px; }
.tp-tbar .tp-recbig.tp-tb-recbtn .tp-recdot { width: 14px !important; height: 14px !important; border-radius: 50%; background: #fff; }
.tp-recording .tp-tbar .tp-recbig.tp-tb-recbtn .tp-recdot { border-radius: 3px; }
.tp-counting .tp-tbar .tp-tb-recbtn .tp-recdot { background: transparent; }
.tp-tbar .tp-recbig.tp-tb-recbtn[hidden] { display: none; }
/* the script panel and popups start under the toolbar (its height comes from JS: it wraps on narrow screens) */
.tp-has-tbar:not(.tp-mode-record) .tp-pbox, .tp-has-tbar.tp-camtile .tp-pbox { top: calc(var(--tp-tbh, 64px) + 6px) !important; }
.tp-has-tbar .tp-panel, .tp-has-tbar .tp-hint, .tp-has-tbar .tp-sheet.tp-camissue { top: calc(var(--tp-tbh, 64px) + 8px); }
.tp-has-tbar .tp-mic { top: calc(var(--tp-tbh, 64px) + 8px); }
/* camera tile: bottom-right corner, never over the reading line near the top */
.tp-camtile.tp-cam-on .tp-cam { top: auto !important; bottom: max(16px, env(safe-area-inset-bottom)); right: max(16px, env(safe-area-inset-right)); width: 240px; height: 135px; z-index: 6; }
@media (max-width: 699px) { .tp-camtile.tp-cam-on .tp-cam { width: 108px; height: 144px; } }
/* idle: the toolbar dims like the dock did (still usable) */
.tp-idle .tp-tbar > :not(.tp-tb-lead) { opacity: .35; transition: opacity .3s; }
.tp-idle .tp-tbar { opacity: 1; }
/* row 1: close · time · transport … Record; row 2: every setting (wraps on tablets, scrolls sideways on phones) */
.tp-tb-tools { order: 5; flex: 1 0 100%; gap: 6px 16px; }
.tp-tb-field input[type="range"] { width: 96px; }
.tp-tb-speed .tp-dock-range { width: 110px; }
@media (max-width: 699px) {
  .tp-tbar { gap: 6px 8px; padding-left: 8px; padding-right: 8px; }
  .tp-tb-tools { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding-bottom: 2px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  .tp-tb-tools::-webkit-scrollbar { display: none; }
  .tp-tb-tools > * { flex: none; }
  .tp-tb-field input[type="range"], .tp-tb-speed .tp-dock-range { width: 96px; }
  .tp-tb-lead .tp-status .tp-time { display: none; }
  .tp-tbar .tp-recbig.tp-tb-recbtn { padding: 0 14px 0 10px; font-size: 14px; }
}
/* editor card: no title field (scripts are named automatically from their first words) */
.tp-ed-head .tp-title, .tp-ed-head .tp-title-ph { display: none !important; }
.tp-ed-head { justify-content: flex-end; }
/* home hero: a normal-size field (the big 28px box is for /teleprompter/) */
.tp-editor-home .tp-ed-main .tp-text { font-size: 17px; padding: 16px 18px; border-radius: 16px; box-shadow: none; }

.tp-tb-util { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.tp-tb-util:empty { display: none; }
.tp-tb-util + .tp-tb-rec { margin-left: 4px; }
/* stage messages sit at the bottom-left, clear of the script centre and the camera tile */
.tp-has-tbar .tp-msg { left: max(16px, env(safe-area-inset-left)); right: auto; transform: none; bottom: max(16px, env(safe-area-inset-bottom)); max-width: min(340px, calc(100vw - 160px)); }
/* text settings that are not in the toolbar (font, spacing, colour presets) live under ⚙ on every screen */
.tp-has-tbar .tp-panel-text { display: block; }

@media (max-width: 699px) { .tp-tb-field select { font-size: 16px; min-height: 40px; height: 40px; -webkit-appearance: none; appearance: none; padding: 0 26px 0 10px; background: #151d38 url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 12 8%27%3E%3Cpath d=%27M1 1l5 5 5-5%27 fill=%27none%27 stroke=%27%23fff%27 stroke-width=%271.6%27/%3E%3C/svg%3E") no-repeat right 9px center / 10px 7px; } } /* no iOS zoom on focus */
/* phone landscape: ONE toolbar row (settings scroll sideways inside it) so the script keeps the height */
@media (max-height: 500px) and (orientation: landscape) {
  .tp-tbar { flex-wrap: nowrap; padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  .tp-tb-tools { order: 0; flex: 1 1 0; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  .tp-tb-tools::-webkit-scrollbar { display: none; }
  .tp-tb-tools > * { flex: none; }
  .tp-tb-lead .tp-status .tp-time { display: none; }
  .tp-tb-transport .tp-play { width: 44px !important; height: 44px !important; }
}

.tp-tbar .tp-mic { position: static !important; inset: auto !important; transform: none !important; margin: 0; }
@media (max-width: 699px) { .tp-tbar .tp-mic .tp-mic-name { display: none; } }
@media (max-width: 699px) { .tp-tbar .tp-mic { padding: 0 4px; gap: 0; background: none; } .tp-tbar .tp-mic .tp-mic-ico { display: none; } }
/* the toolbar never changes height when the camera arrives: the mic meter's slot is reserved from the start */
.tp-tbar .tp-mic[hidden] { display: flex !important; visibility: hidden; }
@media (max-width: 699px) {
  .tp-tbar { column-gap: 6px; }
  .tp-tb-transport .tp-icon-btn { width: 40px; height: 40px; }
}
/* mic device names can be long ("MacBook Pro Microphone"): never let them squeeze the settings */
.tp-tbar .tp-mic .tp-mic-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-height: 500px) and (orientation: landscape) {
  .tp-tbar .tp-mic .tp-mic-name, .tp-tbar .tp-mic .tp-mic-ico { display: none; }
  .tp-tbar .tp-mic { padding: 0 2px; background: none; }
  .tp-camtile.tp-cam-on .tp-cam { width: 160px; height: 90px; } /* smaller tile: the script lines stay readable */
}

/* ===== recording view (Record pressed): full-window camera, script strip at the top, compact toolbar ===== */
.tp-taking .tp-tb-tools { display: none !important; }
.tp-taking .tp-tb-util [data-act="edit"], .tp-taking .tp-tb-util [data-act="camera"], .tp-taking .tp-tb-util [data-act="fs"] { display: none; }
@media (max-width: 699px), (max-height: 500px) and (orientation: landscape) {
  .tp-taking .tp-tb-transport [data-act="back"], .tp-taking .tp-tb-transport [data-act="fwd"], .tp-taking .tp-tbar .tp-mic { display: none !important; }
}
/* setup screen: the small tile is a button (check your framing full-window) */
.tp-camtile.tp-cam-on:not(.tp-taking) .tp-cam { cursor: zoom-in; }
.tp-mode-record.tp-cam-on:not(.tp-taking) .tp-cam { cursor: zoom-out; }
/* no keyboard ring after a mouse/touch close */
.tp-btn[data-nofv]:focus, .tp-btn[data-nofv]:focus-visible { outline: none; }

/* Fixed/Voice menu at stage level: positioned by JS below its chip */
.tp-stage > .tp-menu.tp-menu-float { position: absolute; right: auto; bottom: auto; z-index: 12; overflow: auto; width: max-content; max-width: min(280px, calc(100vw - 16px)); }
/* mic in the toolbar: icon + level bars only (name = tooltip and ⚙ › devices) */
.tp-tbar .tp-mic .tp-mic-name { display: none !important; }
/* top of the script panel: a quiet 2px progress bar instead of a gold line */
.tp-pbar { height: 2px; }
.tp-progress { background: rgba(255, 197, 61, .10); }
.tp-progress-bar { background: rgba(255, 197, 61, .55); }
.tp-recording .tp-progress { background: rgba(240, 68, 56, .15); }
.tp-recording .tp-progress-bar { background: rgba(240, 68, 56, .8); }
/* focus rings only for keyboard users (selects, sliders and toggles too); text boxes keep their typing outline */
html:not(.tp-kbd) .tp-stage :focus:not(textarea):not(input[type="text"]),
html:not(.tp-kbd) .tp :focus:not(textarea):not(input[type="text"]) { outline: none !important; }
html:not(.tp-kbd) .tp-tb-tog:has(input:focus-visible) { outline: none; }

/* ===== toolbar groups: speed · text (size, margin) · look (align, mirror, flip) · colours (swatches) ===== */
.tp-tb-group { display: inline-flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; min-width: 0; }
.tp-tb-tog-l { width: auto; padding: 0 10px 0 8px; gap: 6px; grid-auto-flow: column; display: inline-grid; font-size: 13px; font-weight: 600; }
.tp-tb-tl { white-space: nowrap; pointer-events: none; }
.tp-tb-swatches { display: inline-flex; gap: 4px; padding: 3px; border-radius: 999px; border: 1px solid rgba(255,255,255,.22); }
.tp-sw { position: relative; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; }
.tp-sw > input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.tp-sw > span { width: 20px; height: 20px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); pointer-events: none; }
.tp-sw:has(input:checked) { box-shadow: 0 0 0 2px var(--tp-yellow); }
.tp-sw:has(input:focus-visible) { outline: 2px solid var(--tp-yellow); outline-offset: 2px; }
.tp-tb-field input[type="range"] { width: 88px; }
.tp-tb-speed .tp-dock-range { width: 100px; }
/* record setup: Record is the hero in the middle; Play becomes a small "Rehearse" */
.tp-play-lbl { display: none; }
.tp-recsetup .tp-tbar .tp-tb-transport .tp-play { width: auto !important; height: 40px !important; padding: 0 14px 0 10px; border-radius: 999px; gap: 6px;
  display: inline-flex; align-items: center; background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff; font: inherit; font-size: 14px; font-weight: 600; }
.tp-recsetup .tp-tbar .tp-tb-transport .tp-play svg { width: 16px; height: 16px; }
.tp-recsetup .tp-play-lbl { display: inline; }
@media (min-width: 700px) and (min-height: 501px) {
  .tp-recsetup .tp-tbar .tp-tb-rec { position: absolute; left: 50%; top: calc(8px + env(safe-area-inset-top)); transform: translateX(-50%); margin: 0; }
  .tp-recsetup .tp-tbar .tp-recbig.tp-tb-recbtn { height: 48px !important; padding: 0 22px 0 16px; font-size: 16px; }
}
/* recording: one timer only (the REC pill) */
.tp-recording .tp-tbar .tp-time, .tp-recording .tp-phead .tp-ptitle { visibility: hidden; }
.tp-recording .tp-tbar .tp-time { display: none; }
/* keyboard hints never on touch / phone screens */
@media (pointer: coarse), (max-width: 699px) { .tp-hint { display: none !important; } }
/* phones (portrait): every setting visible — wrapped rows, NO sideways scrolling. Landscape keeps one scrolling row. */
@media (max-width: 699px) and (orientation: portrait) {
  .tp-tbar .tp-tb-tools { flex-wrap: wrap !important; overflow: visible !important; -webkit-mask-image: none !important; mask-image: none !important; gap: 6px 10px; padding-bottom: 0; }
  .tp-tb-tools > .tp-tb-group { flex: 1 0 100%; gap: 6px 10px; }
  .tp-tb-g-speed .tp-tb-speed { flex: 1 1 auto; min-width: 0; }
  .tp-tb-g-speed .tp-dock-range { flex: 1 1 auto !important; width: auto !important; min-width: 80px; }
  .tp-tb-g-text .tp-tb-field { flex: 1 1 0; min-width: 0; gap: 6px; }
  .tp-tb-g-text .tp-tb-field input[type="range"] { flex: 1 1 auto; width: auto !important; min-width: 50px; }
  .tp-tb-g-text .tp-tb-field output { min-width: 36px; }
  .tp-tb-swatchfield { gap: 6px; }
  .tp-tb-g-colors { justify-content: space-between; }
  .tp-tb-tog-l { padding: 0 8px 0 6px; font-size: 12px; }
}
/* the home hero card: buttons stack below 430 (no "Read without…" truncation) */
@media (max-width: 429px) {
  .tp-editor-home .tp-ed-foot .tp-start-rec, .tp-editor-home .tp-ed-foot .tp-start { flex: 1 0 100% !important; }
  .tp-editor-full .tp-ed-foot .tp-start-rec, .tp-editor-full .tp-ed-foot .tp-start { flex: 1 0 100% !important; }
  .tp-ed-foot .tp-start span { white-space: normal; text-overflow: clip; }
}
/* desktop: groups never split (tidy rows: speed + text + look, then colours) */
@media (min-width: 700px) { .tp-tb-group { flex-wrap: nowrap; } }
/* ⚙ quick row (phones): edit / camera / fullscreen */
.tp-panel-quick { display: flex; gap: 8px; margin: 4px 0 8px; }
.tp-panel-quick:empty { display: none; }
@media (max-width: 699px) {
  .tp-tbar .tp-mic { display: none !important; }
  .tp-recsetup .tp-tbar .tp-tb-transport [data-act="back"], .tp-recsetup .tp-tbar .tp-tb-transport [data-act="fwd"] { display: none; }
  .tp-tb-util { margin-left: 0; }
  .tp-tb-rec { margin-left: auto; }
}
.tp-panel:has(.tp-panel-quick [data-act="edit"]) .tp-panel-edit { display: none !important; }

@media (max-width: 699px) and (orientation: portrait) {
  /* colours: both swatch groups on ONE row */
  .tp-tb-g-colors { flex-wrap: nowrap !important; gap: 8px; justify-content: space-between; }
  .tp-tb-g-colors .tp-tb-swatchfield { gap: 4px; font-size: 11px; min-width: 0; }
  .tp-tb-g-colors .tp-sw { width: 26px; height: 26px; }
  .tp-tb-g-colors .tp-sw > span { width: 18px; height: 18px; }
  .tp-tb-swatches { gap: 2px; padding: 2px; }
  .tp-tbar { row-gap: 6px; }
}
@media (max-width: 359px) and (orientation: portrait) {
  .tp-recsetup .tp-play-lbl { display: none; }
  .tp-recsetup .tp-tbar .tp-tb-transport .tp-play { width: 44px !important; padding: 0; justify-content: center; }
  .tp-tb-g-colors .tp-tb-swatchfield > span:first-child { font-size: 10px; }
  .tp-tb-tog-l { padding: 0 6px; gap: 4px; }
}
@media (max-width: 699px) and (orientation: portrait) {
  .tp-tbar .tp-modechip { width: 44px; min-width: 44px; padding: 0; justify-content: center; gap: 0; }
  .tp-tbar .tp-modechip [data-tp-modelabel], .tp-tbar .tp-modechip [data-tp-modeshort], .tp-tbar .tp-modechip > svg:last-child { display: none !important; }
  .tp-tbar .tp-modechip .tp-modeico { display: inline-block !important; }
}
@media (max-width: 359px) and (orientation: portrait) {
  .tp-tb-seg .tp-tb-tl { display: none; }
  .tp-tb-seg .tp-tb-tog-l { width: 40px; padding: 0; justify-content: center; }
  .tp-tb-g-colors .tp-sw { width: 22px; height: 22px; }
  .tp-tb-g-colors .tp-sw > span { width: 16px; height: 16px; }
}

@media (max-width: 359px) { .tp-tbar .tp-tb-transport [data-act="back"], .tp-tbar .tp-tb-transport [data-act="fwd"] { display: none; } } /* clicker keys still jump */
@media (max-width: 699px) { .tp-tbar .tp-mic, .tp-tbar .tp-mic[hidden] { display: none !important; } } /* phones: no mic slot (the toolbar height never changes) */

/* toast never overlaps the camera tile on phones */
@media (max-width: 699px) { .tp-has-tbar .tp-msg { max-width: calc(100vw - 150px); } }
/* selected colour swatch: a visible check */
.tp-sw > span { position: relative; }
.tp-sw:has(input:checked) > span::after { content: ""; position: absolute; left: 50%; top: 45%; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg); filter: drop-shadow(0 0 1px rgba(0,0,0,.9)); }
.tp-sw:has(input:checked) > span[style*="#fff"]::after, .tp-sw:has(input:checked) > span[style*="#ffe14d"]::after, .tp-sw:has(input:checked) > span[style*="#4dff88"]::after { border-color: #000; filter: none; }
/* desktop / tablet: settings fit on row 2 at 1440 (tighter sliders and gaps) */
@media (min-width: 700px) and (min-height: 501px) {
  .tp-tb-tools { column-gap: 12px; }
  .tp-tb-group { gap: 8px 10px; }
  .tp-tb-field { gap: 6px; }
  .tp-tb-field input[type="range"] { width: 72px; }
  .tp-tb-speed .tp-dock-range { width: 84px; }
}
@media (min-width: 700px) and (min-height: 501px) {
  .tp-stage .tp-tbar .tp-tb-field input[type="range"] { width: 72px !important; }
  .tp-stage .tp-tbar .tp-tb-speed .tp-dock-range { width: 84px !important; }
  .tp-stage .tp-tbar .tp-tb-tools { column-gap: 10px; }
  .tp-stage .tp-tbar .tp-tb-group { column-gap: 8px; }
}
@media (max-width: 699px), (max-height: 500px) { .tp-stage .tp-tbar { padding-top: calc(6px + env(safe-area-inset-top)) !important; padding-bottom: 6px !important; } }
@media (max-width: 699px), (max-height: 500px) {
  /* X, the time (or the REC pill while recording) and Record are always visible on phones */
  .tp-tbar .tp-tb-lead .tp-status { display: flex !important; }
  .tp-tbar .tp-tb-lead .tp-status .tp-time { display: inline !important; }
  .tp-recording .tp-tbar .tp-tb-lead .tp-status .tp-time { display: none !important; }
  /* in the sheet the mode chip has room: icon + short label */
  .tp-stage.tp-adjust-open .tp-tbar .tp-modechip { width: auto !important; min-width: 0; padding: 0 10px !important; gap: 6px; }
  .tp-stage.tp-adjust-open .tp-tbar .tp-modechip [data-tp-modeshort] { display: inline !important; }
}

/* phones: settings are visible wrapped rows again (no Adjust sheet) */
.tp-tb-adjust, .tp-sheet-grab { display: none; }
@media (max-width: 419px) { .tp-recsetup .tp-play-lbl { display: none; } .tp-recsetup .tp-tbar .tp-tb-transport .tp-play { width: 44px !important; padding: 0; justify-content: center; } }
@media (max-width: 359px) {
  .tp-tbar .tp-time { font-size: 12px; letter-spacing: -.01em; }
  .tp-stage .tp-tbar { column-gap: 4px; }
  .tp-stage .tp-tbar .tp-recbig.tp-tb-recbtn { padding: 0 12px 0 10px !important; gap: 6px; }
}
@media (max-width: 359px) { .tp-stage .tp-tbar .tp-time { font-size: 11.5px !important; } .tp-stage .tp-tbar .tp-tb-lead { gap: 2px; } }
@media (max-width: 359px) { .tp-stage .tp-tbar { padding-left: 6px !important; padding-right: 6px !important; } }

/* ======== phone LANDSCAPE (height < 500): one-row bar + "Adjust" 2-column sheet (the wrapped bar can't fit) ======== */
@media (max-height: 500px) {
  .tp-stage .tp-tbar { flex-wrap: nowrap !important; contain: none !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; transform: none !important; filter: none !important; }
  .tp-tbar .tp-tb-rec { margin-left: auto; }
  .tp-stage .tp-tbar .tp-tb-adjust { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px 0 10px; border-radius: 999px; flex: none;
    border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.06); color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
  .tp-tb-adjust svg { width: 18px; height: 18px; }
  .tp-adjust-open .tp-tb-adjust { background: var(--tp-yellow) !important; color: #070b1a !important; border-color: var(--tp-yellow) !important; }
  .tp-tbar .tp-tb-tools { display: none !important; }
  .tp-stage.tp-adjust-open .tp-tbar .tp-tb-tools {
    display: flex !important; position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 11; order: 0;
    flex-wrap: wrap !important; align-content: flex-start; gap: 10px 16px; max-height: 60vh; overflow-x: hidden !important; overflow-y: auto; overscroll-behavior: contain;
    padding: 6px 16px calc(12px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; background: rgba(10, 15, 32, .97) !important;
    box-shadow: 0 -12px 40px rgba(0,0,0,.5); -webkit-mask-image: none !important; mask-image: none !important; touch-action: pan-y; opacity: 1 !important;
  }
  .tp-adjust-open .tp-sheet-grab { display: flex; flex: 1 0 100%; justify-content: center; padding: 2px 0; }
  .tp-sheet-grab span { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.35); }
  .tp-adjust-open .tp-tb-tools > .tp-tb-group { flex: 1 1 45% !important; flex-wrap: wrap; gap: 8px 10px; min-width: 0; }
  .tp-adjust-open .tp-tb-g-speed .tp-tb-speed { flex: 1 1 auto; min-width: 0; }
  .tp-adjust-open .tp-tb-g-speed .tp-dock-range, .tp-adjust-open .tp-tb-g-text .tp-tb-field input[type="range"] { flex: 1 1 auto !important; width: auto !important; min-width: 60px; }
  .tp-adjust-open .tp-tb-g-text .tp-tb-field { flex: 1 1 140px; min-width: 0; }
  .tp-adjust-open .tp-tbar .tp-modechip { width: auto !important; padding: 0 10px !important; }
  .tp-adjust-open .tp-tbar .tp-modechip [data-tp-modeshort] { display: inline !important; }
  .tp-taking.tp-adjust-open .tp-tbar .tp-tb-tools { display: flex !important; }
  .tp-adjust-open .tp-msg { display: none; }
  .tp-adjust-open .tp-tbar, .tp-adjust-open .tp-tbar > * { opacity: 1 !important; }
}
.tp-tb-g-util:empty { display: none !important; }
@media (max-height: 360px) {
  .tp-stage.tp-adjust-open .tp-tbar .tp-tb-tools { max-height: calc(100vh - 62px); gap: 6px 12px; padding-top: 4px; }
  .tp-adjust-open .tp-tb-tools > .tp-tb-group { gap: 4px 8px; }
  .tp-adjust-open .tp-sheet-grab { display: none; }
}
@media (max-height: 500px) { html body .tp-stage.tp-stage.tp-adjust-open .tp-tbar .tp-tb-tools { background: #0a0f20 !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; } }

/* each setting lives in ONE place: rows already in the toolbar / Adjust sheet are hidden in the ⚙ panel */
.tp-has-tbar .tp-panel .tp-row-intb { display: none !important; }
