:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #5d6677;
  --line: #e1e5ec;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --tr: #0f766e;
  --tr-bg: #ecfdf8;
  --hl: #fff4c2;
  --word: #fde68a;
  --code-bg: #eef1f6;
  --error: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --card: #1a1f26;
    --text: #e6e9ef;
    --muted: #9aa3b2;
    --line: #2b323c;
    --accent: #5b8cff;
    --accent-text: #0b1020;
    --tr: #5eead4;
    --tr-bg: #13262a;
    --hl: #3a3417;
    --word: #6b5a12;
    --code-bg: #242b35;
    --error: #ff8a80;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main, .top, .foot { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-top: 20px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 1.5rem; }
.sub { margin: 4px 0 0; color: var(--muted); }
.account { font-size: .9rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 16px 0; }
.lbl { font-weight: 600; display: block; margin-bottom: 6px; }
textarea {
  width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  background: var(--bg); color: var(--text); font: 15px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }
.count, .quota, .note { color: var(--muted); font-size: .9rem; }
.quota { margin: 8px 0 0; }
.note:empty, .quota:empty { display: none; }

button, select {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 8px; padding: 7px 12px; cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button:disabled { opacity: .6; cursor: default; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
label { display: inline-flex; gap: 6px; align-items: center; font-size: .92rem; }
.chk input { width: 18px; height: 18px; }

.result { margin: 16px 0; }
.blank { height: 14px; }
.pair { padding: 8px 10px; border-radius: 8px; margin: 2px 0; }
.pair.playing { background: var(--hl); }
.src { display: flex; gap: 8px; align-items: baseline; }
.src .txt { flex: 1; }
.tr { color: var(--tr); font-style: italic; padding-left: 22px; border-left: 3px solid var(--tr); margin-left: 4px; background: var(--tr-bg); border-radius: 0 6px 6px 0; }
.tr .txt { display: inline; }
.tr.speakable { display: flex; gap: 8px; align-items: baseline; font-style: normal; }
.tr.speakable .txt { flex: 1; }
.prefix { color: var(--muted); white-space: pre; font-family: ui-monospace, Menlo, monospace; }
.play { padding: 0 8px; line-height: 1.6; font-size: .85rem; flex: none; }
.w { cursor: pointer; border-radius: 3px; }
.w:hover { text-decoration: underline dotted; }
.w.on { background: var(--word); }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: .92em; font-style: normal; }
a { color: var(--accent); }

body.practica .tr { filter: blur(6px); cursor: pointer; user-select: none; }
body.practica .tr.revealed { filter: none; user-select: auto; }

.bubble {
  position: absolute; z-index: 10; max-width: 260px; background: var(--text); color: var(--bg);
  padding: 6px 10px; border-radius: 8px; font-size: .9rem; box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.history ul { padding-left: 18px; }
.history li { margin: 4px 0; }
.history li button { border: 0; background: none; color: var(--accent); padding: 0; text-align: left; }
.history summary { cursor: pointer; font-weight: 600; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); max-width: 360px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin-top: 0; }
dialog label { display: flex; flex-direction: column; align-items: stretch; margin: 10px 0; }
dialog input { font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.error { color: var(--error); font-size: .9rem; min-height: 1.2em; margin: 4px 0; }

.foot { color: var(--muted); font-size: .85rem; padding-bottom: 32px; }

@media (max-width: 560px) {
  .tr { padding-left: 12px; }
  .row:not(.wrap) { flex-wrap: wrap; }
}
select { max-width: 100%; }
#voz { max-width: min(320px, 100%); }
.tools label { max-width: 100%; min-width: 0; }
.tools label select { min-width: 0; flex: 1 1 auto; }
