/* TimeLive: cores, letras e ondas da capa do app na Ascom Suite.
   Ameixa (#42125a) é o "LIVE" da capa; violeta (#a21ccf) o começo do "TI";
   rosa (#d98ce6) as ondas; o fundo é o céu lilás com o brilho menta no topo. */
:root {
  --ameixa: #42125a;
  --violeta: #a21ccf;
  --lavanda: #7a3fa8;
  --rosa: #d98ce6;
  --menta: #e3f6d6;
  --ceu-1: #ddd3f5;
  --ceu-2: #c9b9f5;
  --bg: #ece6fa;
  --glass: rgba(255, 255, 255, .72);
  --card: #ffffff;
  --text: #2a0f3a;
  --muted: #6d5a80;
  --line: #ddd2ef;
  --chip: #f1e6fb;
  --accent: var(--violeta);
  --accent-soft: #f1e6fb;
  --on-accent: #ffffff;
  --mark: #8e1f9e;
  --mark-soft: #fbe9fd;
  --danger: #c2335a;
  --ok: #2f9e6a;
  --display: "Space Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --body: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* Escuro: segue o sistema quando o tema é "auto", ou força com data-theme="dark". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ameixa: #e7d3f7;
    --violeta: #d57cf2;
    --lavanda: #b69ad0;
    --rosa: #e59bef;
    --menta: #1f3a2c;
    --ceu-1: #1a0d27;
    --ceu-2: #2a1340;
    --bg: #150b1f;
    --glass: rgba(38, 20, 54, .72);
    --card: #221232;
    --text: #f1e8f8;
    --muted: #a891bb;
    --line: #3a2450;
    --chip: #33194a;
    --accent-soft: #33194a;
    --on-accent: #1b0a26;
    --mark: #f0a8f8;
    --mark-soft: #3b1746;
    --danger: #ff7a98;
    --ok: #5fd39a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ameixa: #e7d3f7;
  --violeta: #d57cf2;
  --lavanda: #b69ad0;
  --rosa: #e59bef;
  --menta: #1f3a2c;
  --ceu-1: #1a0d27;
  --ceu-2: #2a1340;
  --bg: #150b1f;
  --glass: rgba(38, 20, 54, .72);
  --card: #221232;
  --text: #f1e8f8;
  --muted: #a891bb;
  --line: #3a2450;
  --chip: #33194a;
  --accent-soft: #33194a;
  --on-accent: #1b0a26;
  --mark: #f0a8f8;
  --mark-soft: #3b1746;
  --danger: #ff7a98;
  --ok: #5fd39a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--ceu-1); }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 15px/1.55 var(--body);
  background:
    radial-gradient(55% 40% at 45% -5%, var(--menta), transparent 70%),
    radial-gradient(60% 60% at 100% 25%, var(--ceu-2), transparent 70%),
    radial-gradient(60% 60% at 0% 100%, var(--ceu-2), transparent 70%),
    var(--ceu-1);
  background-attachment: fixed;
  background-color: var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }

/* As ondas da capa, desenhadas por app.js atrás de tudo. */
.waves { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 1000px; margin: 0 auto; padding: 22px 16px 14px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font: 700 28px/1 var(--display); letter-spacing: -.03em; margin: 0; color: var(--ameixa); }
.logo b {
  background: linear-gradient(90deg, var(--violeta), var(--ameixa));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.top-right { display: flex; align-items: center; gap: 14px; }
.clock { display: grid; justify-items: end; gap: 3px; }
#clock { font: 700 24px/1 var(--display); color: var(--ameixa); font-variant-numeric: tabular-nums; }
.stats { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1em; text-align: right; }
.theme {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.theme:hover { color: var(--text); border-color: var(--accent); }
.theme svg { width: 15px; height: 15px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font: 700 11px/1 var(--display); letter-spacing: .08em; text-transform: uppercase;
  padding: 6px 11px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.pill.live { color: var(--danger); }
.pill.live::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
  animation: pulse 1.4s ease-in-out infinite;
}
.pill.busy { color: var(--accent); }
.pill.paused { color: var(--violeta); }
.pill.paused::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
@keyframes pulse { 50% { opacity: .3; } }

main { max-width: 1000px; margin: 0 auto; padding: 0 16px 32px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }

/* Faixa de controles */
.rack {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

.meter { display: flex; align-items: center; gap: 3px; height: 30px; padding: 0 4px; }
.rack:has(#pause:not([hidden])) .meter i:nth-child(-n+8) { display: none; }
.meter i {
  width: 4px; height: 12%; border-radius: 2px;
  background: linear-gradient(var(--rosa), var(--violeta)); transition: height .08s linear;
}

/* Resumo dos ajustes na faixa: mostra o que está escolhido e abre o modal. */
.summary {
  margin-left: auto; display: grid; justify-items: end; gap: 1px; min-width: 0;
  border: 0; background: none; cursor: pointer; padding: 4px 10px; border-radius: 12px; text-align: right;
}
.summary span:first-child { font-size: 13px; font-weight: 600; color: var(--text); }
.summary span:last-child { font-size: 12px; color: var(--muted); }
.summary span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary:hover { background: var(--chip); }

/* Engrenagem ao lado do tema */
.top-buttons { display: flex; align-items: center; gap: 8px; }
.gear {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer;
}
.gear:hover { color: var(--text); border-color: var(--accent); }
.gear svg { width: 17px; height: 17px; transition: transform .4s; }
.gear:hover svg { transform: rotate(60deg); }

/* Modal de ajustes */
.modal {
  width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--line); border-radius: 22px; background: var(--card); color: var(--text);
  box-shadow: 0 24px 80px rgba(42, 15, 58, .35);
}
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: color-mix(in srgb, var(--ameixa) 30%, transparent); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal-head h2 { margin: 0; font: 700 22px/1 var(--display); color: var(--ameixa); letter-spacing: -.02em; }
.close { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); }
.close:hover { color: var(--text); border-color: var(--accent); }
.modal-body { overflow-y: auto; padding: 4px 20px 16px; display: grid; gap: 10px; }
.modal-body h3 {
  margin: 12px 0 0; font: 700 11px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--violeta);
}
.modal-body .hint { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
.modal-foot .primary { height: 40px; min-width: 110px; }
.modal-foot .primary::before { display: none; }
@media (prefers-reduced-motion: reduce) { .gear svg { transition: none; } }

.grid { display: flex; flex-wrap: wrap; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.field.grow { flex: 1 1 100%; }
.field.wide { flex: 1 1 240px; }
.field > span { font-size: 12px; color: var(--muted); }
input, select {
  height: 36px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); min-width: 0;
}
textarea {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  resize: vertical; min-height: 60px; font-size: 14px;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.vocab-bar { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.vocab-info { font-size: 12px; color: var(--muted); }
.vocab-info.warn { color: var(--mark); }
button.small, select.small { height: 30px; padding: 0 12px; font-size: 13px; }
.field.vocab.over textarea { outline: 2px dashed var(--accent); outline-offset: 2px; }
.drop {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 75%, transparent); backdrop-filter: blur(2px);
  pointer-events: none;
}
.drop[hidden] { display: none; }
.drop > div {
  padding: 28px 36px; border: 2px dashed var(--rosa); border-radius: 18px;
  background: var(--card); font-size: 17px;
}
input[type=range] { padding: 0; height: 36px; border: 0; background: none; accent-color: var(--violeta); }
input:focus, select:focus, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; height: 32px; background: var(--card); }
.seg button { border: 0; background: none; padding: 0 14px; cursor: pointer; font-size: 13px; }
.seg button[aria-checked=true] { background: var(--ameixa); color: var(--on-accent); }

button.ghost {
  height: 36px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); font-size: 14px;
}
button.ghost:hover { border-color: var(--accent); }
button.primary {
  height: 46px; padding: 0 22px 0 18px; border-radius: 999px; cursor: pointer; border: 0;
  background: var(--ameixa); color: var(--on-accent); font-weight: 600; min-width: 128px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
button.primary::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--rosa); }
button.primary.stop::before { border-radius: 3px; background: var(--danger); }
button.pausebtn { height: 46px; min-width: 116px; font-weight: 600; color: var(--ameixa); }
button.pausebtn.paused { background: var(--chip); border-color: var(--violeta); color: var(--violeta); }
button:disabled { opacity: .5; cursor: default; }
button.danger { color: var(--danger); }

/* Avisos, gasto e download de modelo */
.info { display: grid; gap: 8px; padding: 0 6px; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.hint:empty { display: none; }
.hint.warn { color: var(--mark); }

.cost { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; cursor: help; }
.cost[hidden] { display: none; }
.cost-bar { flex: 0 1 220px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.cost-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--violeta), var(--rosa)); transition: width .3s; }
.cost b { color: var(--text); font-weight: 600; }
.cost.over .cost-bar i { background: var(--danger); }
.cost.over b { color: var(--danger); }

.progress { position: relative; height: 24px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress[hidden] { display: none; }
.progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--chip), var(--rosa)); }
.progress span { position: relative; display: block; text-align: center; font-size: 12px; line-height: 24px; }

/* O vídeo ao lado da transcrição */
.work { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
@media (min-width: 900px) {
  .work.with-screen { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .work.with-screen .screen { position: sticky; top: 12px; }
}
.screen {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 10px; border-radius: 20px; min-width: 0;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.yt-bar { display: flex; gap: 8px; }
.yt-bar input { flex: 1; height: 38px; border-radius: 999px; padding: 0 16px; }
.yt-bar button { height: 38px; }
.frame {
  position: relative; aspect-ratio: 16 / 9; max-width: 100%; border-radius: 14px; overflow: hidden;
  background: color-mix(in srgb, var(--ameixa) 88%, #000); display: grid; place-items: center;
}
.yt-wrap, .yt-wrap iframe, .frame video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.frame video { object-fit: contain; background: #000; }
.frame video.crop { inset: auto; object-fit: fill; }
.crop-toggle {
  position: absolute; right: 10px; bottom: 10px; z-index: 1; height: 28px; padding: 0 12px;
  border-radius: 999px; border: 0; cursor: pointer; font-size: 12px; font-weight: 500;
  background: rgba(27, 10, 38, .72); color: #f1e8f8; backdrop-filter: blur(6px);
}
.crop-toggle:hover { background: rgba(27, 10, 38, .9); }
.modal-body a { color: var(--violeta); }
.frame-empty { margin: 0; padding: 0 24px; text-align: center; font-size: 14px; color: #e7d3f7; }
.screen-info { margin: 0 4px; font-size: 12px; color: var(--muted); }
.screen-info:empty { display: none; }
.screen-info.warn { color: var(--danger); }

/* A folha da transcrição */
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 8px 8px 12px; }
.markbar { display: flex; gap: 8px; padding: 6px 6px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.markbar input {
  flex: 1; height: 40px; border-radius: 12px; border: 1px dashed var(--rosa);
  background: var(--mark-soft); padding: 0 14px;
}
.markbar input::placeholder { color: var(--mark); opacity: .75; }

.list { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow-y: auto; }
.list li {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) 24px; gap: 14px; align-items: start;
  padding: 9px 8px;
}
.list li + li { border-top: 1px solid var(--line); }
.ts {
  font: 700 13px/1 var(--display); color: var(--violeta); background: var(--chip);
  padding: 6px 0; border-radius: 8px; text-align: center; font-variant-numeric: tabular-nums; margin-top: 1px;
}
.tx { outline: none; border-radius: 4px; overflow-wrap: anywhere; }
.tx:focus { background: var(--accent-soft); }
.list li.pending .tx { color: var(--muted); font-style: italic; }
.list li.error .tx { color: var(--danger); font-size: 13px; }
.list li.mark { background: var(--mark-soft); border-radius: 12px; }
.list li.mark, .list li.mark + li { border-top-color: transparent; }
.list li.mark .ts { background: var(--rosa); color: #2a0f3a; }
.list li.mark .tx { color: var(--mark); font-weight: 600; }
.list li.pause .ts { background: none; color: var(--muted); }
.list li.pause .tx { color: var(--muted); font-size: 13px; font-style: italic; }
.ts.seek { cursor: pointer; }
.ts.seek:hover { background: var(--violeta); color: var(--on-accent); }
.del { border: 0; background: none; color: var(--muted); cursor: pointer; opacity: 0; font-size: 16px; line-height: 1; padding: 4px 2px; }
.list li:hover .del, .del:focus { opacity: 1; }
.empty { color: var(--muted); font-size: 14px; margin: 22px 12px 10px; text-align: center; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .lbl { font: 700 11px var(--display); letter-spacing: .1em; color: var(--muted); text-transform: uppercase; margin-right: 2px; }
.spacer { flex: 1; }

@media (max-width: 640px) {
  .top-right { width: 100%; justify-content: space-between; }
  .clock { justify-items: start; }
  .stats { text-align: left; }
  .summary { margin-left: 0; justify-items: start; text-align: left; flex-basis: 100%; }
  button.primary { flex: 0 0 auto; }
  .meter { flex: 1; }
  .field { min-width: calc(50% - 6px); flex: 1 1 calc(50% - 6px); }
  .list li { grid-template-columns: 1fr 20px; gap: 6px 10px; }
  .list li .ts { justify-self: start; padding: 5px 8px; }
  .list li .tx { grid-column: 1; }
  .list li .del { grid-row: 1; grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) {
  .pill.live::before { animation: none; }
  .meter i { transition: none; }
}
