:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b1f27;
  --muted: #667085;
  --line: #e3e6ec;
  --accent: #2f6fed;
  --accent-soft: #e8efff;
  --mark: #b45309;
  --mark-soft: #fff4e5;
  --danger: #c0362c;
  --ok: #1f9d55;
  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"]) {
    --bg: #0f1216;
    --card: #171b21;
    --text: #e6e8ec;
    --muted: #8b93a1;
    --line: #2a3039;
    --accent: #5b8cff;
    --accent-soft: #1c2740;
    --mark: #f0a54a;
    --mark-soft: #2d2213;
    --danger: #ff6b5e;
    --ok: #3ccf7d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216;
  --card: #171b21;
  --text: #e6e8ec;
  --muted: #8b93a1;
  --line: #2a3039;
  --accent: #5b8cff;
  --accent-soft: #1c2740;
  --mark: #f0a54a;
  --mark-soft: #2d2213;
  --danger: #ff6b5e;
  --ok: #3ccf7d;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 980px; margin: 0 auto; padding: 18px 16px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 28px; height: 28px; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.top-right { display: flex; align-items: center; gap: 10px; }
.theme {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  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 {
  font-size: 13px; padding: 3px 10px; border-radius: 999px;
  background: var(--line); color: var(--muted);
}
.pill.live { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.pill.live::before { content: "● "; }
.pill.busy { background: var(--accent-soft); color: var(--accent); }

main { max-width: 980px; margin: 0 auto; padding: 0 16px 32px; display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }

.grid { display: flex; flex-wrap: wrap; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.field.grow { flex: 1 1 240px; }
.field > span { font-size: 12px; color: var(--muted); }
input, select {
  height: 36px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); min-width: 0;
}
textarea {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
  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 { height: 28px; padding: 0 10px; 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(--accent); border-radius: 14px;
  background: var(--card); font-size: 17px;
}
input[type=range] { padding: 0; height: 36px; border: 0; background: none; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; height: 36px; }
.seg button { border: 0; background: var(--bg); padding: 0 14px; cursor: pointer; }
.seg button[aria-checked=true] { background: var(--accent); color: #fff; }

button.ghost, button.primary {
  height: 36px; padding: 0 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card);
}
button.ghost:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; min-width: 130px; }
button.primary.stop { background: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
button.danger { color: var(--danger); }

.hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.hint.warn { color: var(--mark); }

.adv { margin-top: 12px; }
.adv summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 10px; }

.run { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.meter { flex: 1 1 120px; max-width: 260px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s linear; }
.stats { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.cost { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; cursor: help; }
.cost[hidden] { display: none; }
.cost-bar { flex: 0 0 180px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.cost-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.cost b { color: var(--text); font-weight: 600; }
.cost.over .cost-bar i { background: var(--mark); }
.cost.over b { color: var(--mark); }

.progress { position: relative; margin-top: 12px; height: 22px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-soft); border-right: 2px solid var(--accent); }
.progress span { position: relative; display: block; text-align: center; font-size: 12px; line-height: 22px; }

.markbar { display: flex; gap: 8px; margin-bottom: 12px; }
.markbar input { flex: 1; }

.list { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow-y: auto; }
.list li {
  display: grid; grid-template-columns: 84px 1fr 24px; gap: 10px; align-items: start;
  padding: 7px 4px; border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.ts { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; color: var(--accent); padding-top: 1px; font-variant-numeric: tabular-nums; }
.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: 6px; }
.list li.mark .ts, .list li.mark .tx { color: var(--mark); font-weight: 600; }
.list li.mark .tx::before { content: "▶ "; }
.del { border: 0; background: none; color: var(--muted); cursor: pointer; opacity: 0; font-size: 16px; line-height: 1; padding: 2px; }
.list li:hover .del, .del:focus { opacity: 1; }
.empty { color: var(--muted); font-size: 14px; margin: 18px 0 6px; text-align: center; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

@media (max-width: 560px) {
  .field { min-width: calc(50% - 6px); flex: 1 1 calc(50% - 6px); }
  .list li { grid-template-columns: 70px 1fr 20px; }
}
