/* =========================================================
   Teleprompter Trinu · estilos
   Tokens: grafite quente da marca, creme do logo, dourado.
   ========================================================= */

:root,
[data-theme="dark"] {
  --bg: #16130f;
  --surface: #1f1a14;
  --surface-2: #29231b;
  --surface-3: #332c22;
  --line: #3a3226;
  --text: #f4e3cf;
  --text-2: #b6a487;
  --text-3: #a08f74;
  --gold: #e0a64e;
  --gold-hi: #f5c875;
  --on-gold: #1c150a;
  --danger: #e5534b;
  --ok: #6cbf84;
  --wordmark: #f4e3cf;
  --prompt-bg: #000000;
  --prompt-text: #f8f0e4;
  --cue: #e9a23b;
  --kw: #f5c875;
  --shadow: 0 18px 50px rgba(0,0,0,.45);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #e9e7e3;
  --surface: #ffffff;
  --surface-2: #f3f1ed;
  --surface-3: #e6e2db;
  --line: #d6d0c6;
  --text: #1f1a13;
  --text-2: #6a604f;
  --text-3: #6f6556;
  --gold: #9a6516;
  --gold-hi: #7d500f;
  --on-gold: #ffffff;
  --wordmark: #2a2116;
  --prompt-bg: #fbfaf7;
  --prompt-text: #15120d;
  --cue: #b26b00;
  --kw: #8a5612;
  --shadow: 0 18px 50px rgba(40,30,10,.18);
  color-scheme: light;
}
[data-theme="amber"] {
  --bg: #120d05;
  --surface: #1b140a;
  --surface-2: #241b0e;
  --surface-3: #2f2312;
  --line: #3b2c15;
  --text: #ffd89a;
  --text-2: #c09a5e;
  --text-3: #8e7146;
  --gold: #ffb020;
  --gold-hi: #ffc659;
  --on-gold: #1a1102;
  --wordmark: #ffd89a;
  --prompt-bg: #0b0802;
  --prompt-text: #ffcf7a;
  --cue: #ff8a3d;
  --kw: #ffe2a8;
  color-scheme: dark;
}
[data-theme="contrast"] {
  --bg: #000;
  --surface: #0d0d0d;
  --surface-2: #161616;
  --surface-3: #222;
  --line: #3d3d3d;
  --text: #fff;
  --text-2: #d6d6d6;
  --text-3: #a8a8a8;
  --gold: #ffd400;
  --gold-hi: #ffe45c;
  --on-gold: #000;
  --wordmark: #fff;
  --prompt-bg: #000;
  --prompt-text: #fff;
  --cue: #ffb000;
  --kw: #ffe45c;
  color-scheme: dark;
}

:root {
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 22px;
  --pill: 999px;
  --tap: 48px;
  --ease: cubic-bezier(.2,.8,.2,1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --app-h: 100dvh;
  --go-grad: linear-gradient(135deg, #ffe3a0 0%, #f5c16a 32%, #d99d46 68%, #b77a2c 100%);
  --gold-rgb: 224,166,78;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}
body { position: fixed; inset: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.muted { color: var(--text-2); }

.ic {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- abertura ---------- */
#launch {
  position: fixed; inset: 0; z-index: 900; display: grid; place-items: center;
  background: var(--bg); transition: opacity .35s ease, visibility .35s;
}
#launch .launch-logo { width: min(68vw, 440px); aspect-ratio: 1346 / 402; height: auto; animation: launchIn .7s var(--ease) both; }
#launch.done { opacity: 0; visibility: hidden; }
@keyframes launchIn { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: none; } }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--r-md);
  font-weight: 600; font-size: 16px; white-space: nowrap;
  transition: transform .08s, background-color .15s, opacity .15s;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; }
.btn-primary { background: var(--gold); color: var(--on-gold); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-ghost-dark { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.18); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-go {
  background: var(--go-grad); color: #1c150a; border-radius: var(--pill);
  padding: 0 26px; min-height: 54px; font-size: 17px; font-weight: 700;
  box-shadow: 0 6px 22px rgba(var(--gold-rgb),.28), inset 0 1px 0 rgba(255,255,255,.5);
}
.btn-go .ic { width: 20px; height: 20px; }
.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: var(--r-md);
  display: inline-grid; place-items: center; color: var(--text); flex: none;
}
.icon-btn:active { background: var(--surface-2); }

/* ---------- layout geral ---------- */
.app {
  position: fixed; inset: 0; height: var(--app-h);
  display: grid; overflow: hidden;
}
.pane { min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.safe-top { padding-top: max(var(--sat), 0px); }
.safe-bottom { padding-bottom: max(var(--sab), 0px); }
.scrim {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45);
  opacity: 0; transition: opacity .25s;
}
.scrim.show { opacity: 1; }

/* ---------- biblioteca ---------- */
.library { border-right: 1px solid var(--line); background: var(--bg); }
.lib-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-left: calc(18px + var(--sal)); padding-right: 8px;
  min-height: calc(56px + var(--sat));
}
.lib-head .logo { height: 40px; width: 134px; margin-left: -4px; }
.head-actions { display: flex; align-items: center; }
.lib-title-row { padding: 4px 18px 10px calc(18px + var(--sal)); }
.lib-title { margin: 0; font-size: 30px; line-height: 1.1; font-weight: 750; letter-spacing: -.01em; }
.search {
  margin: 0 14px 10px calc(14px + var(--sal)); display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border-radius: var(--r-md); padding: 0 12px; height: 44px;
  color: var(--text-3);
}
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font-size: 16px; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.lib-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 10px 12px calc(10px + var(--sal)); }
.lib-foot { padding: 10px 14px calc(12px + var(--sab)) calc(14px + var(--sal)); border-top: 1px solid var(--line); }

.doc-card {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
  padding: 13px 8px 13px 14px; border-radius: var(--r-md); margin-bottom: 2px;
  cursor: pointer; position: relative;
}
.doc-card:active { background: var(--surface-2); }
.doc-card.active { background: var(--surface); box-shadow: inset 3px 0 0 var(--gold); }
.doc-card .t { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card .s {
  grid-column: 1; color: var(--text-2); font-size: 14px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.doc-card .m { grid-column: 1; color: var(--text-3); font-size: 12.5px; margin-top: 4px; display: flex; gap: 12px; }
.doc-card .more { grid-row: 1 / span 3; grid-column: 2; align-self: center; color: var(--text-3); }
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty .ic { width: 40px; height: 40px; color: var(--text-3); margin-bottom: 10px; }
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

.install-card {
  margin: 0 14px 10px calc(14px + var(--sal)); padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); font-size: 14px; color: var(--text-2);
  display: flex; gap: 10px; align-items: flex-start;
}
.install-card .ic { color: var(--gold); margin-top: 1px; }
.install-card strong { color: var(--text); display: block; }
.install-card button { margin-left: auto; color: var(--text-3); }

/* ---------- editor ---------- */
.editor { background: var(--surface); }
.ed-head {
  display: flex; align-items: center; gap: 4px; padding-left: calc(6px + var(--sal)); padding-right: calc(6px + var(--sar));
  min-height: calc(56px + var(--sat)); border-bottom: 1px solid var(--line);
}
.doc-title {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 8px 10px;
  font-size: 18px; font-weight: 700; color: var(--text); border-radius: var(--r-sm);
}
.doc-title:focus { background: var(--surface-2); }
.save-state { font-size: 12px; color: var(--text-3); white-space: nowrap; padding: 0 4px; }
.ed-body { flex: 1; min-height: 0; display: flex; justify-content: center; }
.ed-wrap { position: relative; flex: 1; min-height: 0; max-width: 860px; }
.ed-text {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: 0; border: 0; box-sizing: border-box;
  padding: 20px calc(22px + var(--sar)) 40px calc(22px + var(--sal));
  font-family: inherit; font-size: 19px; font-weight: 400; line-height: 1.7; letter-spacing: 0;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; tab-size: 4;
}
#hl { overflow: hidden; pointer-events: none; color: var(--text); }
#hl .h-mk { color: var(--gold-hi); background: rgba(var(--gold-rgb),.12); border-radius: 4px; }
#hl .h-cue { color: var(--cue); }
#hl .h-kw { color: var(--kw); background: rgba(var(--gold-rgb),.10); }
#hl .h-pz { color: var(--gold); background: rgba(var(--gold-rgb),.18); border-radius: 3px; }
#script {
  width: 100%; height: 100%; resize: none; outline: 0; background: transparent; overflow-y: auto;
  color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--gold-hi);
  -webkit-user-select: text; user-select: text;
}
#script::placeholder { color: var(--text-3); -webkit-text-fill-color: var(--text-3); }
#script::selection { background: rgba(var(--gold-rgb),.35); }
.fmt-bar {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 8px calc(12px + var(--sar)) 8px calc(12px + var(--sal)); border-top: 1px solid var(--line);
  background: var(--surface);
}
.fmt-bar::-webkit-scrollbar { display: none; }
.fmt {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 38px; padding: 0 12px; border-radius: var(--pill);
  background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 550;
}
.fmt .ic { width: 18px; height: 18px; color: var(--gold); }
.fmt:active { background: var(--surface-3); }
.ed-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 10px calc(14px + var(--sar)) calc(10px + var(--sab)) calc(16px + var(--sal));
  border-top: 1px solid var(--line); background: var(--bg);
}
.ed-stats { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; line-height: 1.3; }
.ed-stats span:first-child { font-weight: 600; }

/* ---------- ajustes ---------- */
.settings { background: var(--bg); border-left: 1px solid var(--line); }
.set-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px 0 20px; min-height: 56px;
}
.set-head h2 { margin: 0; font-size: 20px; font-weight: 750; }
.tabs {
  display: flex; gap: 2px; padding: 6px 12px 10px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1 0 auto; height: 36px; padding: 0 9px; border-radius: var(--pill);
  color: var(--text-2); font-size: 14px; font-weight: 600;
}
.tabs button[aria-selected="true"] { background: var(--surface-3); color: var(--text); }
.set-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 18px calc(24px + var(--sab)); }
.tab-panel { display: flex; flex-direction: column; gap: 18px; padding-bottom: 8px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field label, .label { font-size: 15px; font-weight: 600; color: var(--text); }
.field output, .q-field output { font-variant-numeric: tabular-nums; color: var(--gold-hi); font-weight: 650; font-size: 15px; }
.hint { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text-2); }
select {
  width: 100%; height: 48px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23998870' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center;
  padding: 0 38px 0 14px; color: var(--text); font-size: 16px; -webkit-appearance: none; appearance: none;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: transparent; margin: 0;
  --p: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 6px;
  background: linear-gradient(to right, var(--gold) var(--p), var(--surface-3) var(--p));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 6px; background: var(--surface-3); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--gold); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -11px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.35), 0 0 0 1px rgba(0,0,0,.06);
}
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.35); }

.seg {
  display: flex; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); gap: 2px;
}
.seg button {
  flex: 1 1 0; min-height: 40px; padding: 0 10px; border-radius: 11px;
  color: var(--text-2); font-weight: 600; font-size: 14.5px;
  transition: background-color .15s, color .15s;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.seg-wrap { flex-wrap: wrap; }
.seg-wrap button { flex: 1 0 auto; }
.seg button:disabled { opacity: .4; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  min-height: 52px; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.switch-row > span { font-size: 15.5px; font-weight: 550; display: flex; flex-direction: column; }
.switch-row small { font-size: 13px; font-weight: 400; color: var(--text-2); margin-top: 2px; }
.switch-row.strong > span { font-weight: 700; font-size: 16px; }
.switch-row.disabled { opacity: .45; pointer-events: none; }
.switch {
  -webkit-appearance: none; appearance: none; flex: none; position: relative;
  width: 51px; height: 31px; border-radius: 31px; background: var(--surface-3);
  transition: background-color .2s; cursor: pointer; margin: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.3); transition: transform .2s var(--ease);
}
.switch:checked { background: var(--gold); }
.switch:checked::after { transform: translateX(20px); }

.preview-strip {
  border-radius: var(--r-md); background: var(--prompt-bg); color: var(--prompt-text);
  padding: 16px 18px; font-weight: 600; overflow: hidden; max-height: 150px;
  border: 1px solid var(--line);
}
.preview-strip b { color: var(--kw); }
.cam-test { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 38px; padding: 0 6px 0 14px;
  border-radius: var(--pill); background: var(--surface-2); border: 1px solid var(--line);
  font-size: 14.5px; font-weight: 600;
}
.chip .x { width: 28px; height: 28px; display: grid; place-items: center; color: var(--text-3); border-radius: 50%; }
.chip .x .ic { width: 16px; height: 16px; }

.list-group { border-radius: var(--r-md); background: var(--surface); overflow: hidden; border: 1px solid var(--line); }
.list-item {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 13px 16px; border-bottom: 1px solid var(--line); min-height: 56px;
}
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: var(--surface-2); }
.list-item .ic { color: var(--gold); }
.list-item span { display: flex; flex-direction: column; font-weight: 600; }
.list-item small { color: var(--text-2); font-weight: 400; font-size: 13px; }
.about { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 0 6px; }
.about-logo { width: 190px; height: 57px; }
.version { color: var(--text-3); font-size: 12.5px; text-align: center; margin: 0; }

/* ===== responsivo ===== */
.only-mobile, .only-tablet { display: none !important; }

/* DESKTOP / iPad horizontal grande: três colunas */
@media (min-width: 1100px) {
  .app { grid-template-columns: minmax(260px, 300px) 1fr minmax(340px, 380px); }
  .settings { border-left: 1px solid var(--line); }
  .set-head .icon-btn { display: none; }
  #scrim { display: none !important; }
}

/* TABLET: editor ocupa tudo, lista e ajustes viram gavetas */
@media (min-width: 768px) and (max-width: 1099.98px) {
  .app { grid-template-columns: 1fr; }
  .only-tablet { display: inline-grid !important; }
  .library, .settings {
    position: fixed; top: 0; bottom: 0; z-index: 50; height: var(--app-h);
    box-shadow: var(--shadow); transition: transform .3s var(--ease); will-change: transform;
  }
  .library { left: 0; width: min(360px, 86vw); transform: translateX(-104%); }
  .settings { right: 0; width: min(400px, 90vw); transform: translateX(104%); padding-top: var(--sat); }
  .app.show-lib .library { transform: none; }
  .app.show-set .settings { transform: none; }
  .editor { grid-column: 1; }
}
@media (min-width: 1100px) { .only-tablet { display: none !important; } }

/* CELULAR: lista é a tela inicial; editor desliza por cima; ajustes = folha de baixo */
@media (max-width: 767.98px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-flex !important; }
  .icon-btn.only-mobile { display: inline-grid !important; }
  .library, .editor { grid-area: 1 / 1; }
  .editor {
    transform: translateX(100%); transition: transform .32s var(--ease); z-index: 10;
    box-shadow: -10px 0 30px rgba(0,0,0,.25);
  }
  .app[data-view="editor"] .editor { transform: none; }
  .app[data-view="editor"] .library { visibility: hidden; transition: visibility 0s .32s; }
  .settings {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: min(86dvh, 720px); border-radius: var(--r-lg) var(--r-lg) 0 0; border: 0;
    transform: translateY(104%); transition: transform .32s var(--ease); box-shadow: var(--shadow);
    background: var(--bg);
  }
  .app.show-set .settings { transform: none; }
  .sheet-grabber { display: block !important; width: 40px; height: 5px; border-radius: 5px; background: var(--surface-3); margin: 8px auto 0; flex: none; }
  .set-head { min-height: 48px; padding-top: 0; }
  .ed-foot .btn-go { padding: 0 22px; }
  .ed-foot .btn-ghost { padding: 0 12px; }
  .fmt span { display: none; }
  .fmt { width: 44px; padding: 0; justify-content: center; }
  .fmt[data-fmt="sentences"] span { display: inline; }
  .fmt[data-fmt="sentences"] { width: auto; padding: 0 12px; }
  .lib-title { font-size: 32px; }
}
@media (max-width: 380px) {
  .ed-foot .btn-ghost span { display: none; }
  .ed-stats span:last-child { font-size: 12.5px; }
}

/* ---------- diálogos ---------- */
.dlg {
  position: fixed; inset: 0; z-index: 800; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.5); opacity: 0; transition: opacity .2s;
}
.dlg.show { opacity: 1; }
.dlg-card {
  width: 100%; max-width: 560px; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 8px 0 calc(14px + var(--sab)); box-shadow: var(--shadow);
  transform: translateY(30px); transition: transform .28s var(--ease);
}
.dlg.show .dlg-card { transform: none; }
.dlg-card h3 { margin: 10px 20px 4px; font-size: 19px; font-weight: 750; }
.dlg-card .dlg-msg { margin: 4px 20px 0; color: var(--text-2); font-size: 15px; }
.dlg-body { padding: 10px 20px 4px; overflow-y: auto; }
.dlg-body input[type="text"] {
  width: 100%; height: 50px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); padding: 0 14px; font-size: 17px; outline: 0;
}
.dlg-body input[type="text"]:focus { border-color: var(--gold); }
.dlg-actions { display: flex; gap: 10px; padding: 14px 20px 0; flex-wrap: wrap; }
.dlg-actions .btn { flex: 1 1 auto; }
.dlg-list { display: flex; flex-direction: column; padding: 6px 12px 0; }
.dlg-list button {
  display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 0 12px; border-radius: var(--r-md);
  font-size: 16.5px; font-weight: 550; text-align: left;
}
.dlg-list button:active { background: var(--surface-2); }
.dlg-list button .ic { color: var(--gold); }
.dlg-list button.danger, .dlg-list button.danger .ic { color: var(--danger); }
.dlg-list button small { display: block; color: var(--text-2); font-size: 13px; font-weight: 400; }
@media (min-width: 768px) {
  .dlg { align-items: center; padding: 20px; }
  .dlg-card { border-radius: var(--r-lg); padding-bottom: 16px; }
}

.help h4 { margin: 16px 0 6px; font-size: 15px; }
.help p, .help li { font-size: 14.5px; color: var(--text-2); }
.help ul { padding-left: 18px; margin: 6px 0; }
.help code { background: var(--surface-2); color: var(--gold-hi); padding: 1px 6px; border-radius: 6px; font-size: 13.5px; }
.kbd-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14.5px; color: var(--text-2); }
.kbd-grid kbd { font: 600 13px/1 -apple-system, sans-serif; background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 5px 7px; color: var(--text); white-space: nowrap; }

.qr-box { display: grid; place-items: center; padding: 10px 0; }
.qr-box svg, .qr-box img { width: 220px; height: 220px; background: #fff; border-radius: 14px; padding: 8px; }
.link-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.link-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; background: var(--surface-2); padding: 10px 12px; border-radius: var(--r-sm); color: var(--text-2); }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--text-2); margin-top: 10px; }
.status-line i { width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); flex: none; }
.status-line.on i { background: var(--ok); box-shadow: 0 0 0 4px rgba(108,191,132,.2); }

.take-video { width: 100%; max-height: 52dvh; border-radius: var(--r-md); background: #000; display: block; }
.take-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; color: var(--text-2); margin-top: 10px; }
.take-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.take-row:last-child { border-bottom: 0; }
.take-row .info { flex: 1; min-width: 0; }
.take-row .info strong { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.take-row .info small { color: var(--text-2); }
.badge-saved { color: var(--ok); font-size: 12.5px; font-weight: 600; }

/* ---------- aviso rápido ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--sab)); z-index: 950;
  transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  background: #2b251d; color: #f4e3cf; padding: 12px 18px; border-radius: var(--r-md);
  font-size: 15px; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: min(92vw, 520px);
  display: flex; align-items: center; gap: 14px; transition: opacity .2s, transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: #f5c875; font-weight: 700; white-space: nowrap; }

/* medição fora da tela */
#measure {
  position: fixed; left: -99999px; top: 0; visibility: hidden; pointer-events: none;
  white-space: pre-wrap; overflow-wrap: break-word; font-weight: 600;
}

/* =========================================================
   PROMPTER
   ========================================================= */
.player {
  position: fixed; inset: 0; z-index: 600; background: var(--prompt-bg); overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; color: #fff;
  --guide-y: 40%;
}
.player.cam-on { background: #000; }
#camVideo {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0;
  opacity: 0; transition: opacity .3s; background: #000;
}
.player.cam-on #camVideo { opacity: 1; }
#camVideo.mirror { transform: scaleX(-1); }
.layer { position: absolute; inset: 0; pointer-events: none; }
#camShade { z-index: 1; background: #000; opacity: 0; }
#cropFrame { z-index: 2; inset: auto; border: 2px solid rgba(245,200,117,.85); border-radius: 4px; box-shadow: 0 0 0 200vmax rgba(0,0,0,.42); }
#camGrid { z-index: 2; }
#camGrid i { position: absolute; background: rgba(255,255,255,.28); }
#camGrid i:nth-child(1) { left: 33.333%; top: 0; bottom: 0; width: 1px; }
#camGrid i:nth-child(2) { left: 66.666%; top: 0; bottom: 0; width: 1px; }
#camGrid i:nth-child(3) { top: 33.333%; left: 0; right: 0; height: 1px; }
#camGrid i:nth-child(4) { top: 66.666%; left: 0; right: 0; height: 1px; }
#camLevel { position: absolute; z-index: 3; left: 50%; top: 50%; width: 140px; height: 2px; margin-left: -70px; background: rgba(255,255,255,.25); pointer-events: none; }
#camLevel i { position: absolute; inset: 0; background: var(--gold-hi); transform-origin: 50% 50%; }
#camLevel.level i { background: var(--ok); }

#stage {
  position: absolute; inset: 0; z-index: 4; overflow: hidden;
  -webkit-mask-image: var(--mask, none); mask-image: var(--mask, none);
}
#mirrorWrap { position: absolute; inset: 0; }
#mirrorWrap.mx { transform: scaleX(-1); }
#mirrorWrap.my { transform: scaleY(-1); }
#mirrorWrap.mx.my { transform: scale(-1, -1); }
#track { position: absolute; left: 0; right: 0; top: 0; will-change: transform; transform: translate3d(0,0,0); backface-visibility: hidden; }
.ptext { white-space: pre-wrap; overflow-wrap: break-word; font-weight: 600; }
#prompt {
  position: relative; margin: 0 auto; color: var(--prompt-text);
  padding-left: 5vw; padding-right: 5vw;
  text-rendering: optimizeLegibility;
}
.player.cam-on #prompt { color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,.65), 0 0 2px rgba(0,0,0,.6); }
.ptext .ln { min-height: 1em; }
.ptext .mk { color: var(--gold-hi); font-weight: 800; font-size: .72em; letter-spacing: .01em; padding: .5em 0 .25em; display: flex; align-items: center; gap: .4em; }
.ptext .mk::before { content: ""; width: .55em; height: .55em; transform: rotate(45deg); background: currentColor; flex: none; border-radius: 2px; }
.ptext .kw { color: var(--kw); font-weight: 800; }
.ptext .cue { color: var(--cue); font-style: italic; font-weight: 500; font-size: .6em; display: inline-block; line-height: 1.3; vertical-align: .12em; max-width: 100%; }
.ptext.hide-cues .cue { display: none; }
.ptext .pz { display: inline-block; font-size: .5em; vertical-align: middle; color: var(--gold-hi); border: 1.5px dashed currentColor; border-radius: .4em; padding: .05em .5em; margin: 0 .3em; font-weight: 700; }

#guide {
  position: absolute; left: 0; right: 0; top: var(--guide-y); z-index: 5; height: 0; pointer-events: none;
  display: flex; align-items: center;
}
#guide .rule { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(var(--gold-rgb),0), rgba(var(--gold-rgb),.14) 15%, rgba(var(--gold-rgb),.14) 85%, rgba(var(--gold-rgb),0)); }
#guide .notch { width: 0; height: 0; border-top: 11px solid transparent; border-bottom: 11px solid transparent; flex: none; }
#guide .notch.l { border-left: 15px solid var(--gold); margin-left: max(4px, var(--sal)); }
#guide .notch.r { border-right: 15px solid var(--gold); margin-right: max(4px, var(--sar)); }
.player.no-guide-rule #guide .rule { opacity: 0; }

/* barras */
.p-top, .p-bottom {
  position: absolute; left: 0; right: 0; z-index: 10;
  transition: opacity .3s, transform .3s var(--ease);
}
.p-top {
  top: 0; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--sat)) calc(10px + var(--sar)) 10px calc(10px + var(--sal));
  background: linear-gradient(rgba(0,0,0,.72), rgba(0,0,0,.35) 70%, rgba(0,0,0,0));
}
.p-bottom {
  bottom: 0; padding: 18px calc(12px + var(--sar)) calc(12px + var(--sab)) calc(12px + var(--sal));
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.62) 28%, rgba(0,0,0,.9));
}
.player.idle .p-top { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.player.idle .p-bottom { opacity: 0; transform: translateY(10px); pointer-events: none; }
.player.idle { cursor: none; }

.p-icon {
  width: 46px; height: 46px; border-radius: 14px; display: inline-grid; place-items: center; color: #fff;
  background: rgba(255,255,255,.1); flex: none; transition: background-color .15s, transform .08s;
}
.p-icon:active { transform: scale(.94); background: rgba(255,255,255,.2); }
.p-icon.on { background: var(--gold); color: #1c150a; }
.p-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; padding: 0 4px; }
.p-title strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.p-title span { font-size: 13px; color: rgba(255,255,255,.7); font-variant-numeric: tabular-nums; }
.p-chips { display: flex; align-items: center; gap: 8px; }
.chip-rec { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px; background: rgba(229,83,75,.92); color: #fff; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.chip-rec i { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: blink 1.1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.chip-info { height: 28px; padding: 0 10px; border-radius: 999px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.18); color: #fff; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; }
.meter { width: 56px; height: 8px; border-radius: 8px; background: rgba(255,255,255,.18); overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, #6cbf84 0 65%, #f5c875 65% 85%, #e5534b 85%); }

.progress { position: relative; height: 26px; margin: 0 4px 6px; cursor: pointer; touch-action: none; }
.progress-track { position: absolute; left: 0; right: 0; top: 11px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.22); overflow: hidden; }
.progress-fill { height: 100%; width: 100%; background: var(--gold-hi); transform-origin: left; transform: scaleX(0); }
.progress-ticks i { position: absolute; top: 8px; width: 3px; height: 10px; margin-left: -1.5px; border-radius: 2px; background: rgba(255,255,255,.8); }
.progress:active .progress-track { top: 9px; height: 8px; }

.p-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.p-group { display: flex; gap: 8px; align-items: center; }
.p-group.end { justify-content: flex-end; }
.p-center { display: flex; align-items: center; gap: 14px; }
.p-play {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: var(--go-grad); color: #1c150a; box-shadow: 0 8px 28px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.5);
  transition: transform .08s;
}
.p-play:active { transform: scale(.94); }
.p-play .ic { width: 30px; height: 30px; }
.speed-read { min-width: 44px; text-align: center; font-weight: 750; font-size: 16px; color: #fff; font-variant-numeric: tabular-nums; }
.speed-read::after { content: "vel"; display: block; font-size: 11px; font-weight: 500; color: rgba(255,255,255,.6); margin-top: -2px; }
.p-rec {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  border: 3px solid #fff; background: transparent; flex: none;
}
.p-rec i { width: 40px; height: 40px; border-radius: 50%; background: #e5534b; transition: all .2s var(--ease); }
.p-rec.on i { width: 22px; height: 22px; border-radius: 5px; }

.p-banner {
  position: absolute; z-index: 11; left: 50%; top: calc(76px + var(--sat)); transform: translateX(-50%);
  background: var(--gold); color: #1c150a; font-weight: 700; padding: 10px 18px; border-radius: 999px; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}

#countdown {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(0,0,0,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#countdown svg { position: absolute; width: min(46vmin, 300px); height: min(46vmin, 300px); transform: rotate(-90deg); }
#countdown circle { fill: none; stroke: var(--gold-hi); stroke-width: 3; stroke-dasharray: 276.5; stroke-dashoffset: 0; }
#countdown circle.run { transition: stroke-dashoffset 1s linear; stroke-dashoffset: 276.5; }
#countdown span { font-size: min(26vmin, 180px); font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
#countdown small { position: absolute; bottom: calc(40px + var(--sab)); color: rgba(255,255,255,.7); font-size: 14px; }

.p-end {
  position: absolute; z-index: 15; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(20,17,13,.92); border: 1px solid rgba(255,255,255,.12); border-radius: var(--r-lg);
  padding: 22px; text-align: center; box-shadow: var(--shadow); min-width: 280px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.p-end strong { display: block; font-size: 20px; margin-bottom: 16px; color: #fff; }
.p-end-actions { display: flex; gap: 10px; justify-content: center; }

.quick {
  position: absolute; z-index: 30; right: calc(10px + var(--sar)); top: calc(64px + var(--sat));
  width: min(380px, calc(100vw - 20px)); max-height: calc(100% - 150px - var(--sat) - var(--sab));
  display: flex; flex-direction: column; color: #fff;
  background: rgba(22,19,15,.93); border: 1px solid rgba(255,255,255,.12); border-radius: var(--r-lg);
  box-shadow: 0 20px 50px rgba(0,0,0,.5); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  --text: #f4e3cf; --text-2: #b6a487; --surface-3: rgba(255,255,255,.18); --gold-hi: #f5c875; --gold: #e0a64e;
}
.quick-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 4px 18px; }
.quick-head strong { font-size: 16px; }
.quick-body { overflow-y: auto; padding: 6px 16px 16px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }
.q-field { display: flex; flex-direction: column; gap: 2px; font-size: 14.5px; font-weight: 600; }
.q-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.q-tog {
  display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 12px; border-radius: 13px;
  background: rgba(255,255,255,.1); color: #fff; font-size: 14px; font-weight: 600; text-align: left;
}
.q-tog .ic { width: 19px; height: 19px; }
.q-tog.on { background: var(--gold); color: #1c150a; }
.q-cam { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,.12); }
.marker-item { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 12px; border-radius: 12px; background: rgba(255,255,255,.08); text-align: left; font-weight: 600; color: #fff; }
.marker-item small { margin-left: auto; color: rgba(255,255,255,.55); font-weight: 500; font-variant-numeric: tabular-nums; }
.marker-item.current { box-shadow: inset 3px 0 0 var(--gold); background: rgba(255,255,255,.14); }

@media (max-width: 560px) {
  .p-play { width: 64px; height: 64px; }
  .p-center { gap: 8px; }
  .p-group { gap: 6px; }
  .p-icon { width: 42px; height: 42px; }
  #paraPrevBtn, #paraNextBtn { display: none; }
  .p-rec { width: 52px; height: 52px; }
  .p-rec i { width: 36px; height: 36px; }
  .speed-read { min-width: 36px; }
  .quick { left: 10px; right: 10px; width: auto; top: auto; bottom: calc(10px + var(--sab)); max-height: 72dvh; }
  #markerSheet.quick { top: auto; }
}
@media (max-height: 500px) {
  .p-play { width: 58px; height: 58px; }
  .p-top { padding-top: calc(4px + var(--sat)); }
}

/* prompter no tema claro: barras claras (com câmera ligada continuam escuras) */
[data-theme="light"] .player:not(.cam-on) { color: #1f1a13; }
[data-theme="light"] .player:not(.cam-on) .p-top { background: linear-gradient(rgba(251,250,247,.96), rgba(251,250,247,.7) 70%, rgba(251,250,247,0)); }
[data-theme="light"] .player:not(.cam-on) .p-bottom { background: linear-gradient(rgba(251,250,247,0), rgba(251,250,247,.8) 28%, rgba(251,250,247,.97)); }
[data-theme="light"] .player:not(.cam-on) .p-icon { color: #1f1a13; background: rgba(31,26,19,.07); }
[data-theme="light"] .player:not(.cam-on) .p-title strong, [data-theme="light"] .player:not(.cam-on) .speed-read { color: #1f1a13; }
[data-theme="light"] .player:not(.cam-on) .p-title span, [data-theme="light"] .player:not(.cam-on) .speed-read::after { color: rgba(31,26,19,.6); }
[data-theme="light"] .player:not(.cam-on) .progress-track { background: rgba(31,26,19,.14); }
[data-theme="light"] .player:not(.cam-on) .progress-fill { background: var(--gold); }
[data-theme="light"] .player:not(.cam-on) .progress-ticks i { background: rgba(31,26,19,.5); }
[data-theme="light"] .player:not(.cam-on) .p-rec { border-color: #1f1a13; }

/* ---------- cliente remoto ---------- */
.remote-app { position: fixed; inset: 0; display: flex; flex-direction: column; background: #000; color: #fff; }
.remote-mirror { flex: 1; position: relative; overflow: hidden; }
.remote-mirror #rTrack { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.remote-mirror #rPrompt { position: relative; white-space: pre-wrap; overflow-wrap: break-word; font-weight: 600; padding: 0 5vw; color: #f8f0e4; }
.remote-mirror #rPrompt .mk { color: #f5c875; font-weight: 800; font-size: .72em; padding: .5em 0 .25em; }
.remote-mirror #rPrompt .kw { color: #f5c875; font-weight: 800; }
.remote-mirror #rPrompt .cue { color: #e9a23b; font-style: italic; font-size: .6em; font-weight: 500; }
.remote-mirror #rPrompt .pz { font-size: .5em; color: #f5c875; }
.remote-guide { position: absolute; left: 0; right: 0; top: 35%; height: 0; display: flex; align-items: center; pointer-events: none; }
.remote-guide::before { content: ""; border-top: 9px solid transparent; border-bottom: 9px solid transparent; border-left: 12px solid #e0a64e; margin-left: 4px; }
.remote-top { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--sat)) 12px 8px; background: #16130f; border-bottom: 1px solid #3a3226; }
.remote-top .r-logo { width: 34px; height: 34px; flex: none; }
.remote-top .st { flex: 1; font-size: 14px; color: #b6a487; display: flex; align-items: center; gap: 8px; }
.remote-top .st i { width: 9px; height: 9px; border-radius: 50%; background: #8a7b64; }
.remote-top .st.on i { background: #6cbf84; }
.remote-panel { padding: 12px 12px calc(12px + var(--sab)); background: #16130f; border-top: 1px solid #3a3226; display: flex; flex-direction: column; gap: 10px; }
.remote-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.remote-grid button, .remote-play {
  min-height: 56px; border-radius: 14px; background: #29231b; color: #f4e3cf; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.remote-grid button:active, .remote-play:active { transform: scale(.97); }
.remote-play { background: var(--go-grad); color: #1c150a; min-height: 66px; font-size: 18px; }
.remote-grid .danger { background: #4a1f1c; color: #ffb4ae; }
.remote-app.control-only .remote-mirror { display: none; }
.remote-app.control-only .remote-panel { flex: 1; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
