/* Inter, com os acentos do português. Fica guardada para abrir sem internet. */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/@fontsource-variable/inter@5.1.0/files/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/@fontsource-variable/inter@5.1.0/files/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Tema "Preto" (padrão). Os outros temas trocam só estas cores. */
:root {
  --bg: #0b0b0c;
  --surface: #151517;
  --surface-2: #1f1f22;
  --hover: #2a2a2e;
  --line: #2e2e33;
  --ink: #f5f5f7;
  --ink-2: #a1a1aa;
  --ink-3: #71717a;
  --accent: #f5f5f7;
  --accent-hover: #ffffff;
  --accent-ink: #0b0b0c;
  --live: #ff453a;
  --ok: #30d158;
  --prompt-bg: #000;
  --theme-ink: #ffffff;
  --theme-read: #5c5c60;
  --prompt-ink: var(--theme-ink);
  --prompt-read: var(--theme-read);
  --prompt-cue: #ffd60a;
  --prompt-slate-bg: #161618;
  --hud-line: #232326;
  --hud-ink: #c7c7cc;
  --heard-ink: #8e8e93;
  --bar-bg: #111113;
  --track: #232326;
  color-scheme: dark;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 40px;
  --space-7: 64px;
  --radius: 10px;
  --control: 40px;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: clamp(26px, 4.2vw, 38px);

  /* ajustados pelo painel de Ajustes */
  --font-size: 56px;
  --width: 84%;
  --leading: 1.4;
  --read-line: 35%;
}

:root[data-theme="grafite"] {
  --bg: #18181b; --surface: #202024; --surface-2: #2a2a2f; --hover: #34343a; --line: #3a3a40;
  --accent: #60a5fa; --accent-hover: #93c5fd; --accent-ink: #0b1220;
  --prompt-bg: #18181b; --theme-ink: #f4f4f5; --theme-read: #63636b; --prompt-slate-bg: #222228;
  --hud-line: #2c2c31; --bar-bg: #1c1c20; --track: #2c2c31;
}
:root[data-theme="azul"] {
  --bg: #08111f; --surface: #0e1a2d; --surface-2: #15243b; --hover: #1d2f4a; --line: #22344f;
  --ink: #eaf2ff; --ink-2: #9fb2cc; --ink-3: #6f84a0;
  --accent: #38bdf8; --accent-hover: #7dd3fc; --accent-ink: #04121c;
  --prompt-bg: #08111f; --theme-ink: #eaf2ff; --theme-read: #435675; --prompt-slate-bg: #0f1d33;
  --hud-line: #16263d; --hud-ink: #b8c7dc; --heard-ink: #7f93ad; --bar-bg: #0b1626; --track: #16263d;
}
:root[data-theme="contraste"] {
  --accent: #ffd60a; --accent-hover: #ffe55c; --accent-ink: #000;
  --prompt-bg: #000; --theme-ink: #ffd60a; --theme-read: #6b6b6b; --prompt-cue: #ffffff; --prompt-slate-bg: #141414;
}
:root[data-theme="claro"] {
  --bg: #f5f5f7; --surface: #ffffff; --surface-2: #ececf0; --hover: #e2e2e7; --line: #d6d6dc;
  --ink: #111113; --ink-2: #55555c; --ink-3: #85858c;
  --accent: #111113; --accent-hover: #2c2c30; --accent-ink: #ffffff;
  --live: #e5372b; --ok: #1f9d47;
  --prompt-bg: #ffffff; --theme-ink: #111113; --theme-read: #b9b9bf; --prompt-cue: #b45309; --prompt-slate-bg: #f2f2f5;
  --hud-line: #e2e2e7; --hud-ink: #3a3a40; --heard-ink: #6e6e75; --bar-bg: #f5f5f7; --track: #e2e2e7;
  color-scheme: light;
}
:root[data-theme="sepia"] {
  --bg: #f3ecdd; --surface: #faf5ea; --surface-2: #ebe2cf; --hover: #e2d7c0; --line: #d6c9ad;
  --ink: #2b2116; --ink-2: #6b5a43; --ink-3: #8d7b62;
  --accent: #8a4b0f; --accent-hover: #a65d16; --accent-ink: #fff8ee;
  --live: #c2410c; --ok: #3f7d32;
  --prompt-bg: #f3ecdd; --theme-ink: #2b2116; --theme-read: #bfae8e; --prompt-cue: #8a4b0f; --prompt-slate-bg: #ebe2cf;
  --hud-line: #e2d7c0; --hud-ink: #4a3c2b; --heard-ink: #7c6a52; --bar-bg: #efe6d4; --track: #e2d7c0;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: var(--text-md)/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: var(--text-sm); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---------- botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--control); padding: 0 var(--space-4);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); color: var(--ink);
  font: inherit; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--hover); border-color: var(--line); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .4; cursor: default; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon { width: var(--control); padding: 0; font-size: var(--text-lg); }
input:focus-visible + .btn, label.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.field-label { display: block; margin: var(--space-4) 0 var(--space-1); color: var(--ink-2); font-size: var(--text-sm); }
.field { width: 100%; padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--ink); font: inherit; line-height: 1.55; }
textarea.field { resize: vertical; }
.error { padding: var(--space-3) var(--space-4); border-left: 3px solid var(--live); background: var(--surface); }

/* ---------- biblioteca ---------- */
.home { width: min(760px, 100%); margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-7); }
.home-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.wordmark { font: 650 var(--text-lg)/1 var(--sans); letter-spacing: -.01em; }
.wordmark::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: var(--space-2); border-radius: 50%; background: var(--live); vertical-align: 1px; }

.ask { margin-bottom: var(--space-6); }
.ask-label { display: block; margin-bottom: var(--space-3); font: 650 var(--text-xl)/1.15 var(--sans); letter-spacing: -.02em; }
.ask-input { width: 100%; height: 56px; padding: 0 var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit; font-size: var(--text-lg); }
.ask-input::placeholder { color: var(--ink-3); }
.ask-hint { min-height: 22px; margin-top: var(--space-2); color: var(--ink-2); font-size: var(--text-sm); }

.importer { margin-bottom: var(--space-6); }
.dropzone { padding: var(--space-7) var(--space-5); border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; transition: border-color .15s, background .15s; }
.dropzone.is-over, body.is-dragging .dropzone { border-color: var(--accent); background: var(--surface); }
.importer-title { margin-bottom: var(--space-2); font: 650 var(--text-xl)/1.15 var(--sans); letter-spacing: -.02em; }
.dropzone-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-5); }
.paste { margin-top: var(--space-4); }
.paste summary { color: var(--ink-2); cursor: pointer; }
.paste .btn { margin-top: var(--space-4); }
#import-error, #import-busy { margin-top: var(--space-4); }

.book { margin-bottom: var(--space-6); }
.book-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); padding-bottom: var(--space-2); }
.book-title { font: 650 var(--text-lg)/1.3 var(--sans); letter-spacing: -.01em; overflow-wrap: anywhere; }
.program-title { margin-top: var(--space-4); color: var(--accent); font-size: var(--text-md); font-weight: 600; overflow-wrap: anywhere; }
.module-title { margin-top: var(--space-5); padding-bottom: var(--space-2); border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: var(--text-sm); font-weight: 500; }
.lesson { display: flex; align-items: center; border-bottom: 1px solid var(--surface-2); }
.lesson-open {
  flex: 1; min-width: 0; display: flex; align-items: baseline; gap: var(--space-3); padding: var(--space-3) var(--space-2);
  border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: var(--radius);
}
.lesson-open:hover { background: var(--surface); }
.lesson-num { flex: none; min-width: 58px; color: var(--ink-3); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.lesson-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lesson-meta { flex: none; color: var(--ink-3); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.lesson-resume { color: var(--accent); }
.lesson-edit { flex: none; }
.no-results { margin-bottom: var(--space-6); }

.toast { position: fixed; left: 50%; bottom: var(--space-5); z-index: 30; max-width: calc(100vw - var(--space-6)); padding: var(--space-3) var(--space-4); transform: translateX(-50%); border-radius: var(--radius); background: var(--ink); color: var(--bg); font-weight: 500; }

/* ---------- editor ---------- */
.editor { width: min(720px, calc(100vw - var(--space-5))); padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.editor::backdrop { background: rgb(0 0 0 / .7); }
.editor-title { font: 650 var(--text-lg) var(--sans); }
.editor-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }
.editor .small { margin-top: var(--space-2); }

/* ---------- teleprompter ---------- */
.stage { position: fixed; inset: 0; background: var(--prompt-bg); }
.viewport { position: absolute; inset: 0; overflow: hidden; background: var(--prompt-bg); color: var(--prompt-ink); touch-action: none; user-select: none; -webkit-user-select: none; cursor: default; }
.viewport.mirror-h.flip-v { transform: scale(-1, -1); }
.viewport.mirror-h:not(.flip-v) { transform: scaleX(-1); }
.viewport.flip-v:not(.mirror-h) { transform: scaleY(-1); }
.scroller { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.script {
  position: relative; width: var(--width); margin: 0 auto; padding-bottom: 100vh;
  font: 600 var(--font-size)/var(--leading) var(--sans); letter-spacing: -.015em; overflow-wrap: anywhere;
  font-feature-settings: "cv11", "ss01";
}
.script.is-upper { text-transform: uppercase; }
.script p { margin: 0 0 .9em; }
.w { transition: color .25s; }
.script.dim-read .w.read { color: var(--prompt-read); }
.cue { color: var(--prompt-cue); font-size: .62em; font-weight: 500; }

/* identificação da aula: a primeira coisa na tela, para ler em voz alta */
.slate { margin-bottom: 1.1em; padding: .45em .65em .55em; border: 3px solid var(--accent); border-radius: var(--radius); background: var(--prompt-slate-bg); }
.script .slate p { margin: 0; line-height: 1.2; }
.script .slate p + p { margin-top: .25em; }
.slate-program, .slate-module, .slate-lesson { text-transform: uppercase; letter-spacing: .01em; }
.slate-program { color: var(--accent); font-size: .78em; font-weight: 700; }
.slate-module { color: var(--accent); font-size: .78em; font-weight: 600; }
.slate-lesson { font-size: 1.05em; font-weight: 800; }
.slate-title { font-size: 1.05em; font-weight: 700; }

/* tópicos e imagens */
.script p.topic { padding-left: 1em; text-indent: -1em; }
.script p.topic::before { content: "•"; display: inline-block; width: 1em; text-indent: 0; color: var(--accent); }
.script p.topic-numbered { padding-left: 0; text-indent: 0; }
.script p.topic-numbered::before { content: none; }
.script p.image-block { margin: 1em 0 1.3em; line-height: 1.2; }
.cue-image { display: inline-block; padding: .12em .5em; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); font-size: .8em; font-weight: 800; letter-spacing: .06em; }

.shade { position: absolute; inset: 0 0 auto; height: calc(var(--read-line) - var(--font-size)); background: linear-gradient(var(--prompt-bg) 20%, transparent); pointer-events: none; }
.marker { position: absolute; top: var(--read-line); width: 0; height: 0; margin-top: -11px; border-top: 11px solid transparent; border-bottom: 11px solid transparent; pointer-events: none; }
.marker-left { left: 6px; border-left: 16px solid var(--accent); }
.marker-right { right: 6px; border-right: 16px solid var(--accent); }

.hud { position: absolute; inset: 0 0 auto; background: var(--prompt-bg); border-bottom: 1px solid var(--hud-line); pointer-events: none; }
.progress { height: 3px; background: var(--track); }
.progress-fill { height: 100%; width: 0; background: var(--accent); }
.hud-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-4); padding: var(--space-2) var(--space-4); color: var(--hud-ink); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.status { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.status-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.status[data-state="listening"] .status-dot { background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
.status[data-state="running"] .status-dot { background: var(--ok); }
.status[data-state="lost"] .status-dot { background: var(--accent); }
.status[data-state="error"] .status-dot { background: var(--live); }
.lesson-label { padding: 0 var(--space-4) var(--space-2); color: var(--accent); font-size: clamp(15px, 1.9vw, 24px); font-weight: 700; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
.clock { text-align: right; }
.heard { padding: 0 var(--space-4) var(--space-2); color: var(--heard-ink); font-size: var(--text-sm); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heard:empty { display: none; }
@keyframes pulse { 50% { opacity: .35; } }

.bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-3) var(--space-4) max(var(--space-3), env(safe-area-inset-bottom)); border-top: 1px solid var(--hud-line); background: var(--bar-bg); transition: transform .25s, opacity .25s;
}
.bar-group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.stage.is-quiet .bar { transform: translateY(100%); opacity: 0; }
.stage.is-quiet .viewport { cursor: none; }
.btn-play { min-width: 132px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-play:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg { min-height: calc(var(--control) - 2px); padding: 0 var(--space-3); border: 0; background: var(--surface-2); color: var(--ink-2); font: inherit; font-weight: 500; cursor: pointer; }
.seg[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg:focus-visible { outline-offset: -3px; }
.stepper { display: inline-flex; align-items: center; gap: var(--space-1); }
.stepper-value { min-width: 66px; text-align: center; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }

.notice { position: absolute; left: 50%; bottom: 84px; z-index: 11; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); width: min(620px, calc(100vw - var(--space-5))); padding: var(--space-3) var(--space-4); transform: translateX(-50%); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.notice p { flex: 1 1 240px; }

.settings { position: absolute; right: var(--space-4); bottom: 84px; z-index: 12; display: grid; gap: var(--space-3); width: min(340px, calc(100vw - var(--space-5))); max-height: calc(100vh - 110px); overflow-y: auto; padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.setting { display: grid; gap: var(--space-1); color: var(--ink-2); font-size: var(--text-sm); }
.setting input { width: 100%; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: var(--space-2); }
.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.swatch { width: 30px; height: 30px; padding: 0; border: 2px solid var(--line); border-radius: 50%; background: var(--swatch); cursor: pointer; }
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.theme-chip { display: grid; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); color: var(--ink-2); font: inherit; font-size: 12px; cursor: pointer; text-align: left; }
.theme-chip:hover { border-color: var(--ink-3); }
.theme-chip[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); box-shadow: 0 0 0 1px var(--accent); }
.theme-chip .theme-sample { display: block; height: 26px; padding: 4px 6px; border-radius: 6px; font-size: 11px; font-weight: 650; line-height: 18px; }
.home-tools { display: flex; align-items: center; gap: var(--space-2); }
.select { min-height: var(--control); padding: 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); color: var(--ink); font: inherit; cursor: pointer; }
.offline-status { color: var(--ink-3); font-size: var(--text-sm); line-height: 1.5; }
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.setting .color-input { width: 38px; height: 32px; padding: 0 2px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.keys { color: var(--ink-3); font-size: var(--text-sm); line-height: 1.7; }
kbd { padding: 0 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-2); font: inherit; font-size: 12px; }

/* importar por link */
.link-import { margin-top: var(--space-4); }
.link-import .field-label { margin-top: 0; }
.link-row { display: flex; gap: var(--space-2); }
.link-row .field { flex: 1; min-width: 0; padding: 0 var(--space-3); min-height: var(--control); }
.link-row .btn { flex: none; }
.link-import .muted { margin-top: var(--space-2); }
.btn:disabled { opacity: .55; cursor: progress; }

/* câmera em tela cheia atrás do texto; o fundo do texto fica translúcido para você se ver */
.cam { position: absolute; inset: 0; overflow: hidden; background: #000; }
.cam-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam.is-front .cam-video { transform: scaleX(-1); }
.stage.with-cam { background: #000; }
.stage.with-cam .viewport { z-index: 1; bottom: auto; height: var(--cam-text, 100%); background: color-mix(in srgb, var(--prompt-bg) var(--cam-shade, 55%), transparent); }
.stage.with-cam .hud { background: color-mix(in srgb, var(--prompt-bg) 75%, transparent); }
.stage.with-cam .shade { background: linear-gradient(color-mix(in srgb, var(--prompt-bg) 60%, transparent) 20%, transparent); }
.stage.with-cam .script { text-shadow: 0 0 .08em var(--prompt-bg), 0 0 .25em var(--prompt-bg); }
.stage.with-cam .slate { background: color-mix(in srgb, var(--prompt-slate-bg) 80%, transparent); }
.stage:not(.with-cam) .cam-flip { display: none; }

@media (max-width: 1040px) {
  .notice, .settings { bottom: 112px; }
}

@media (max-width: 720px) {
  .bar { justify-content: center; }
  .btn { padding: 0 var(--space-3); }
  .btn-icon { padding: 0; }
  .btn-play { order: -1; flex-basis: 100%; }
  .notice, .settings { bottom: 150px; }
  .settings { right: var(--space-3); }
  .lesson-num { min-width: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  .w, .bar, .btn { transition: none; }
  .status[data-state="listening"] .status-dot { animation: none; }
}

/* aviso de mudança de endereço (só aparece no endereço antigo) */
.move-banner { display: grid; gap: var(--space-3); width: min(760px, calc(100% - var(--space-5))); margin: var(--space-4) auto 0; padding: var(--space-4); border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.move-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.move-status:empty { display: none; }
.move-status { color: var(--ink-2); font-size: var(--text-sm); }
