:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d8dce3;
  --text: #1a1d23;
  --muted: #5b6472;
  --accent: #1f4e78;
  --accent-soft: #e8eef5;
  --good: #1a7f4b;
  --good-soft: #e6f4ec;
  --warn: #8a6100;
  --warn-soft: #fdf3dc;
  --bad: #b3261e;
  --bad-soft: #fbeae9;
  --highlight: #fcf485;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #242932;
    --border: #333a45;
    --text: #e7eaef;
    --muted: #98a2b3;
    --accent: #7bb0e8;
    --accent-soft: #1e2a38;
    --good: #4ade80;
    --good-soft: #16281f;
    --warn: #fbbf24;
    --warn-soft: #2a2413;
    --bad: #f87171;
    --bad-soft: #2c1a1a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 1.15rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin-top: 1.4em; }
p { margin: 0 0 .8em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em;
       background: var(--surface-2); padding: .12em .4em; border-radius: 4px; }
a { color: var(--accent); }

/* ─────────────────────────────────────────────────────────── header ── */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.25rem; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .75rem; }
.mark { font-size: 1.7rem; line-height: 1; }
.sub { margin: 0; color: var(--muted); font-size: .82rem; }
.bar-right { display: flex; align-items: center; gap: .5rem; }

.pill {
  font-size: .78rem; padding: .25rem .6rem; border-radius: 999px;
  border: 1px solid var(--border); white-space: nowrap;
}
.pill-off { color: var(--muted); background: var(--surface-2); }
.pill-on { color: var(--good); background: var(--good-soft); border-color: transparent; }

/* ───────────────────────────────────────────────────────────── tabs ── */
.tabs {
  display: flex; gap: .25rem; padding: 0 1.25rem; background: var(--surface);
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font: inherit; font-size: .88rem; padding: .7rem .8rem;
  cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 920px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.panel { display: none; }
.panel.is-active { display: block; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ───────────────────────────────────────────────────────────── drop ── */
.drop {
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface); text-align: center; padding: 2.5rem 1rem;
  transition: border-color .15s, background .15s;
}
.drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { font-size: 2.2rem; }
.drop-title { font-weight: 600; margin: .5rem 0 .15rem; }
.drop-sub { color: var(--muted); font-size: .87rem; margin-bottom: 1rem; }

.filelist { list-style: none; margin: 1rem 0 0; padding: 0; }
.filelist li {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: .4rem; font-size: .9rem;
}
.filelist .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist .meta { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.filelist button {
  appearance: none; border: 0; background: none; color: var(--muted);
  cursor: pointer; font-size: 1.05rem; line-height: 1; padding: 0 .2rem;
}
.filelist button:hover { color: var(--bad); }

/* ─────────────────────────────────────────────────────────── button ── */
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }
.btn {
  appearance: none; font: inherit; font-size: .9rem; cursor: pointer;
  padding: .5rem .95rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 600;
}
@media (prefers-color-scheme: dark) { .btn-primary { color: #10151c; } }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

/* ──────────────────────────────────────────────────────────── log ──── */
.log {
  margin-top: 1rem; padding: .8rem 1rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem; white-space: pre-wrap; max-height: 200px; overflow-y: auto;
}
.log .err { color: var(--bad); }

/* ────────────────────────────────────────────────────────── result ── */
.result { margin-top: 1rem; }
.banner {
  display: flex; align-items: flex-start; gap: .6rem; padding: .8rem 1rem;
  border-radius: 8px; margin-bottom: 1rem; font-size: .9rem;
}
.banner-good { background: var(--good-soft); color: var(--good); }
.banner-warn { background: var(--warn-soft); color: var(--warn); }
.banner-bad { background: var(--bad-soft); color: var(--bad); }
.banner strong { font-weight: 700; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--muted); font-size: .82rem;
     text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0 0; }
.chip {
  font-size: .82rem; padding: .3rem .65rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.chip a { text-decoration: none; }

.rulestats { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.rulestats div { font-size: .85rem; color: var(--muted); }
.rulestats strong { display: block; font-size: 1.3rem; color: var(--text); font-weight: 700; }

textarea {
  width: 100%; min-height: 340px; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem; line-height: 1.5; padding: .8rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
}

.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .9rem; }
.tree {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: .8rem 1rem; font-size: .82rem; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.check { display: flex; gap: .5rem; align-items: flex-start; font-size: .87rem;
         color: var(--muted); margin-top: .9rem; }
.check input { margin-top: .25rem; }

dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem;
  background: var(--surface); color: var(--text); max-width: 460px; width: calc(100% - 2rem);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }
.field input, .field select {
  width: 100%; font: inherit; font-size: .9rem; padding: .5rem .6rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
}
.field small { display: block; color: var(--muted); font-size: .8rem; margin-top: .3rem; }
