:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1b1f24;
  --muted: #5d6673;
  --line: #dfe3e8;
  --accent: #0b6e69;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ef;
  --warn: #9a5b00;
  --warn-soft: #fff3df;
  --err: #b42318;
  --err-soft: #fdecea;
  --ok: #1a7f37;
  --code: #eef1f4;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418;
    --card: #191d22;
    --ink: #e7eaee;
    --muted: #9aa4b1;
    --line: #2b3139;
    --accent: #3fb5ad;
    --accent-ink: #06201e;
    --accent-soft: #15302e;
    --warn: #e7a945;
    --warn-soft: #2d2412;
    --err: #ff7b72;
    --err-soft: #321816;
    --ok: #56d364;
    --code: #22272e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --card: #191d22; --ink: #e7eaee; --muted: #9aa4b1; --line: #2b3139;
  --accent: #3fb5ad; --accent-ink: #06201e; --accent-soft: #15302e; --warn: #e7a945; --warn-soft: #2d2412;
  --err: #ff7b72; --err-soft: #321816; --ok: #56d364; --code: #22272e; color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "PingFang SC", sans-serif;
}
code { font-family: var(--mono); font-size: 0.92em; background: var(--code); padding: 0 4px; border-radius: 4px; }

.top {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--line); background: var(--card);
}
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-size: 18px; font-weight: 700; letter-spacing: 1px;
}
h1 { margin: 0; font-size: 19px; }
.tagline { margin: 2px 0 0; color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: currentColor; }
.pill.bad { color: var(--err); border-color: currentColor; }

.banner { margin: 16px 24px 0; padding: 12px 14px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); border: 1px solid currentColor; }
.banner.err { background: var(--err-soft); color: var(--err); }

.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px;
  padding: 16px 24px 24px; max-width: 1500px; margin: 0 auto;
}
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.wide { grid-column: 1 / -1; }
@media (max-width: 980px) { .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; } .top { padding: 14px 16px; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
h2 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.step {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700;
}
.hint { color: var(--muted); margin: 6px 0 10px; font-size: 13px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); min-width: 0; }
input[type="number"], input[type="text"], select {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; min-width: 0; width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, .filebtn:focus-within, .drop:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.row3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; margin: 4px 0; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 13.5px; margin: 6px 0; }
.check input { margin: 0; }

button, .filebtn {
  font: inherit; font-size: 13.5px; cursor: pointer; border-radius: 7px; padding: 6px 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); display: inline-flex; align-items: center;
}
button:hover:not(:disabled), .filebtn:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.small { font-size: 12px; padding: 2px 8px; margin-left: auto; font-weight: 400; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.status { color: var(--muted); font-size: 13px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.sources { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sources input[type="text"] { width: 180px; flex: 1 1 140px; }
.or { color: var(--muted); font-size: 13px; }
.picked { font-size: 12.5px; color: var(--muted); margin: 8px 0; font-family: var(--mono); overflow-wrap: anywhere; }
.plan { font-size: 13px; margin: 6px 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 10px 0 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.progress { position: relative; height: 22px; border-radius: 6px; background: var(--code); overflow: hidden; margin-top: 10px; }
.progress-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-soft); border-right: 2px solid var(--accent); transition: width 0.2s; }
.progress-fill.indeterminate { width: 30%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { left: -30%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress-fill.indeterminate { animation: none; width: 100%; opacity: 0.6; } }
.progress span { position: relative; padding: 0 8px; font-size: 12px; line-height: 22px; color: var(--ink); white-space: nowrap; }

.meter { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.meter-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--code); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--accent); }
.meter-fill.high { background: var(--warn); }
.meter-text { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.presets span { color: var(--muted); font-size: 12.5px; margin-right: 4px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 10px; padding: 8px 12px 10px; min-width: 0; }
legend { font-size: 12.5px; font-weight: 600; color: var(--ink); padding: 0 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { flex-direction: row; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: 5px 16px; cursor: pointer; color: var(--ink); font-size: 13.5px; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.outs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 12px; }
.cli summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.cli code { display: block; margin-top: 8px; padding: 10px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }

.drop {
  display: block; border: 1.5px dashed var(--line); border-radius: 8px; padding: 18px; text-align: center;
  color: var(--muted); cursor: pointer; font-size: 13.5px;
}
.drop strong { color: var(--ink); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.queue { margin-top: 10px; }
.queue td:first-child { overflow-wrap: anywhere; }
.badge { font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--code); white-space: nowrap; }
.badge.run { background: var(--accent-soft); color: var(--accent); }
.badge.done { color: var(--ok); }
.badge.err { background: var(--err-soft); color: var(--err); }
.table-wrap { overflow-x: auto; }
.results td.run { overflow-wrap: anywhere; min-width: 160px; }
.results .sub { color: var(--muted); font-size: 12px; }
.dl { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.dl a { color: var(--accent); text-decoration: none; font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.dl a:hover { text-decoration: underline; }
.icon-btn { border: none; background: none; color: var(--muted); padding: 0 4px; font-size: 16px; }

#log {
  margin: 0; max-height: 360px; overflow: auto; font: 12px/1.45 var(--mono); background: var(--code);
  border-radius: 8px; padding: 10px; white-space: pre-wrap; overflow-wrap: anywhere;
}
#log .warn { color: var(--warn); }
#log .err { color: var(--err); }
#log .meta { color: var(--muted); }

footer { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 16px 24px; }
