:root {
  --bg: #090b10;
  --surface: #11141c;
  --surface-2: #181c27;
  --surface-3: #202534;
  --line: #262c3d;
  --text: #eceff7;
  --muted: #8f97ad;
  --accent: #7c9cff;
  --accent-2: #c08cff;
  --accent-ink: #0a0c14;
  --danger: #ff7a8a;
  --glow: rgba(124, 156, 255, .16);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  --radius: 18px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5fa; --surface: #ffffff; --surface-2: #f0f2f8; --surface-3: #e6e9f2; --line: #dde1ee;
    --text: #181b27; --muted: #626a80; --accent: #4f6bff; --accent-2: #9a5cff; --accent-ink: #ffffff;
    --danger: #d6334a; --glow: rgba(79, 107, 255, .12); --shadow: 0 10px 30px -14px rgba(30, 40, 90, .25);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f5fa; --surface: #ffffff; --surface-2: #f0f2f8; --surface-3: #e6e9f2; --line: #dde1ee;
  --text: #181b27; --muted: #626a80; --accent: #4f6bff; --accent-2: #9a5cff; --accent-ink: #ffffff;
  --danger: #d6334a; --glow: rgba(79, 107, 255, .12); --shadow: 0 10px 30px -14px rgba(30, 40, 90, .25);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 50% -120px, var(--glow), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.sprite { position: absolute; }
svg { width: 1.25em; height: 1.25em; flex: none; }
code, pre, kbd { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- topo ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px max(16px, calc((100vw - 1080px) / 2));
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.logo { width: 30px; height: 30px; }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 12px; cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--line); }

/* ---------- layout ---------- */
.layout {
  max-width: 1080px; margin: 0 auto; padding: 8px 16px 48px;
  display: grid; gap: 18px;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
  .hero, .actionbar, .player, .history { grid-column: 1 / -1; }
}
.hero { padding: 28px 0 6px; text-align: center; }
.hero h1 { margin: 0; font-size: clamp(30px, 6vw, 48px); letter-spacing: -.035em; line-height: 1.08; }
.grad { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 12px auto 0; max-width: 520px; color: var(--muted); font-size: 16px; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
h2 { margin: 0 0 12px; font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.panel-head h2 { margin: 0; }

/* ---------- composer ---------- */
textarea {
  display: block; width: 100%; min-height: 210px; resize: vertical; padding: 14px 16px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
  font: inherit; font-size: 16px; line-height: 1.65; transition: border-color .15s, box-shadow .15s;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
textarea::placeholder { color: var(--muted); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.count.warn { color: #f5b35c; }
.count.over { color: var(--danger); font-weight: 600; }
.tools { display: flex; gap: 6px; }

.chip {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-checked="true"] { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--accent-ink); font-weight: 600; }

details > summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; list-style: none; user-select: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; margin-right: 8px; transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details > summary:hover { color: var(--text); }
.help { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.help-body { color: var(--muted); font-size: 14px; }
.help-body p { margin: 8px 0; }
.help pre { margin: 6px 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; overflow: auto; color: var(--text); font-size: 13px; }
.help code { font-size: 13px; color: var(--text); }

/* ---------- vozes ---------- */
.voice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.voice {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; cursor: pointer; font: inherit; transition: border-color .15s, transform .15s, background .15s;
}
.voice:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); transform: translateY(-1px); }
.voice[aria-checked="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); box-shadow: 0 0 0 1px var(--accent) inset; }
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h, 230) 80% 62%), hsl(calc(var(--h, 230) + 50) 75% 55%));
}
.voice b { display: block; line-height: 1.2; }
.voice small { color: var(--muted); font-size: 12px; }

.speed { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; margin: 16px 0 6px; color: var(--muted); font-size: 13px; }
.speed output, .mix-label { font-variant-numeric: tabular-nums; color: var(--text); min-width: 52px; text-align: right; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.more { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.hint { margin: 4px 0 10px; color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 4px; }
.mix { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; align-items: center; }
.mix input[type=range] { grid-column: 1 / -1; }
.mix-label { grid-column: 1; text-align: left; }
select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 8px; font: inherit; font-size: 14px; min-width: 0;
}

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: filter .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 14px 26px; font-size: 16px; border-radius: 16px; box-shadow: 0 12px 28px -12px var(--accent); }
.btn kbd { font-size: 11px; font-weight: 500; opacity: .75; padding: 2px 6px; border: 1px solid currentColor; border-radius: 6px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.busy svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.25) rotate(12deg); opacity: .7; } }

.actionbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; }
.err { margin: 0; color: var(--danger); font-size: 14px; min-height: 1.2em; }

/* ---------- player ---------- */
.wave { display: block; width: 100%; height: 96px; border-radius: 14px; background: var(--surface-2); cursor: pointer; }
.transport { display: flex; align-items: center; gap: 14px; margin: 14px 0; }
.grow { flex: 1; }
.play {
  display: grid; place-items: center; width: 52px; height: 52px; border: 0; border-radius: 50%; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
  box-shadow: 0 10px 24px -10px var(--accent); transition: transform .12s;
}
.play:hover { transform: scale(1.05); }
.play svg { width: 24px; height: 24px; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.transcript { position: relative; display: grid; gap: 4px; max-height: 280px; overflow: auto; padding-right: 4px; }
.seg { padding: 8px 12px; border-radius: 12px; color: var(--muted); border-left: 3px solid transparent; cursor: pointer; transition: background .15s, color .15s; }
.seg:hover { background: var(--surface-2); }
.seg.on { color: var(--text); background: var(--surface-2); border-left-color: var(--accent); }
.seg em { font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-right: 8px; }
.seg.queued { opacity: .45; }

/* ---------- histórico ---------- */
.hist { display: grid; gap: 8px; }
.empty { margin: 0; color: var(--muted); font-size: 14px; }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 12px; background: var(--surface-2); border: 1px solid transparent; border-radius: 14px;
}
.item.active { border-color: var(--accent); }
.item-main { min-width: 0; }
.item-title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.item-meta { color: var(--muted); font-size: 12px; }
.item-actions { display: flex; gap: 2px; }
.item-actions .icon-btn { width: 34px; height: 34px; }
.item-actions .icon-btn:hover.danger { color: var(--danger); }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 12px 16px 36px; }

/* ---------- diálogo ---------- */
dialog {
  width: min(380px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(5, 7, 12, .6); backdrop-filter: blur(4px); }
dialog h3 { margin: 0 0 4px; font-size: 18px; }
dialog p { margin: 0 0 14px; color: var(--muted); }
dialog input {
  width: 100%; padding: 11px 12px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; font: inherit;
}
dialog input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

@media (max-width: 520px) {
  .panel { padding: 14px; border-radius: 16px; }
  .btn.big { width: 100%; }
  .btn.big kbd { display: none; }
  .item { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
