:root, [data-theme="light"] {
  --bg: #f6f6f3; --panel: #ffffff; --ink: #1b1b1f; --muted: #5d5f66; --line: #dedfe3; --soft: #eef0f3;
  --accent: #1f6fd1; --accent-ink: #ffffff; --accent-soft: #e5effb; --bad: #b3261e; --ok: #1e7b4b; --warn-bg: #fff6e0; --ok-bg: #e6f4ec; --bad-bg: #fdecea;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}
[data-theme="dark"] {
  --bg: #121316; --panel: #1b1c20; --ink: #ececef; --muted: #a3a6ad; --line: #2e3036; --soft: #24262b;
  --accent: #5c9cf0; --accent-ink: #0d1117; --accent-soft: #1d2a3d; --bad: #f28b82; --ok: #7ccf9e; --warn-bg: #2d2717; --ok-bg: #16281e; --bad-bg: #321c1b;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overflow-x: hidden; }
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .bad { color: var(--bad); } .strong { font-weight: 600; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { color: var(--accent); flex: none; }
.brand strong { white-space: nowrap; }
.sep { color: var(--muted); }
.sum-t { font-weight: 600; }
.topactions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.backlink { text-decoration: none; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.credits { font-size: .86rem; color: var(--muted); }
.topup { font-size: .86rem; }

button { font: inherit; cursor: pointer; border-radius: 10px; min-height: 40px; }
button:disabled { cursor: not-allowed; opacity: .55; }
.primary { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); padding: 8px 18px; font-weight: 600; }
.primary:hover:not(:disabled) { filter: brightness(1.07); }
.primary.big { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; font-size: 1.05rem; min-height: 48px; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); padding: 6px 12px; }
.ghost:hover:not(:disabled) { background: var(--soft); }
.ghost.sq { width: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.ghost.strong { font-weight: 600; border-color: var(--accent); color: var(--accent); }
.quiet { background: none; border: none; color: var(--accent); padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px; }
.small { min-height: 36px; }
.linkbtn { background: none; border: none; color: var(--accent); padding: 4px 0; min-height: 32px; text-align: left; font-weight: 600; }

main { max-width: 1120px; margin: 0 auto; padding: 0 16px 40px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.hero { padding: 22px 0 8px; max-width: 760px; }
h1 { font-size: clamp(1.55rem, 4.6vw, 2.25rem); line-height: 1.15; margin: 0 0 8px; letter-spacing: -.01em; }
.lede { margin: 0 0 10px; color: var(--muted); font-size: 1.04rem; }
.perks { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 12px; }
.perks li { font-size: .82rem; background: var(--accent-soft); color: var(--ink); padding: 3px 10px; border-radius: 999px; }
textarea, input[type=text], select { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 0; }
.chipbtn { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .9rem; min-height: 40px; }
.chipbtn:hover, .chipbtn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.msg { margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--soft); }
.msg.bad { background: var(--warn-bg); color: var(--ink); border-left: 3px solid var(--bad); }

.work { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; margin-top: 16px; align-items: start; scroll-margin-top: 64px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); }
select { padding: 6px 8px; min-height: 40px; }
.notes { margin: 8px 0 0; padding: 8px 12px 8px 28px; background: var(--warn-bg); border-radius: 10px; font-size: .9rem; }

.exports { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.exp-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.exp-grid .ghost { flex: 1 1 auto; }
.more summary { cursor: pointer; color: var(--muted); padding: 6px 0; }

.ai { padding: 12px 14px; }
.ai summary { cursor: pointer; font-weight: 600; list-style-position: inside; padding: 4px 0; min-height: 36px; }
.badge { font-size: .74rem; font-weight: 500; background: var(--soft); color: var(--muted); border-radius: 999px; padding: 2px 8px; margin-left: 4px; }
.hint { font-size: .88rem; color: var(--muted); margin: 8px 0; }
.hint.bad { color: var(--bad); }
.warn-soft { background: var(--warn-bg); color: var(--ink); padding: 8px 10px; border-radius: 8px; }
.ai input[type=text] { width: 100%; padding: 8px 10px; min-height: 40px; margin: 4px 0 8px; }
.ai-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.progress { margin-top: 10px; padding: 10px; background: var(--soft); border-radius: 10px; }
.progresshead { display: flex; justify-content: space-between; }
.steps { margin: 6px 0 0; padding-left: 20px; font-size: .9rem; color: var(--muted); }
.steps li.on { color: var(--ink); font-weight: 600; }
.steps li.done { color: var(--ok); }
.steps li.done::marker { content: "\2713  "; }
.report { margin-top: 10px; font-size: .9rem; }
.report p { margin: 6px 0; }
.report ul { margin: 4px 0 8px; padding-left: 20px; }

.history { margin-top: 16px; padding: 14px; }
.h3 { font-size: 1.05rem; margin: 0 0 4px; }
.historylist { list-style: none; padding: 0; margin: 8px 0 0; }
.historylist li { padding: 4px 0; border-top: 1px solid var(--line); }

.about { margin-top: 32px; max-width: 760px; }
.about h2 { font-size: 1.2rem; margin: 22px 0 8px; }
.howlist { padding-left: 20px; } .howlist li { margin: 6px 0; }
.faq dt { font-weight: 600; margin-top: 12px; } .faq dd { margin: 4px 0 0; color: var(--muted); }
.foot { border-top: 1px solid var(--line); padding: 18px 16px 30px; text-align: center; color: var(--muted); font-size: .88rem; }
.foot p { margin: 4px 0; }

/* docs pages */
.doc { max-width: 900px; padding-top: 18px; }
.doc h1 { font-size: 1.8rem; } .doc h2 { margin-top: 28px; } .doc h3 { margin-top: 20px; }
.doc table { border-collapse: collapse; width: 100%; font-size: .9rem; display: block; overflow-x: auto; }
.doc th, .doc td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.doc pre { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: .84rem; line-height: 1.45; margin: 0; }
.codegroup { margin: 10px 0 18px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tab { background: var(--panel); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 4px 10px; min-height: 34px; font-size: .84rem; }
.tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.statebox { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--panel); }
.statebox p { margin: 4px 0; }
.tokenrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.tokenbox { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; word-break: break-all; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); width: 100%; }
.mini { background: var(--panel); border: 1px solid var(--line); color: var(--ink); padding: 6px 12px; border-radius: 10px; }

@media (max-width: 860px) {
  .work { grid-template-columns: minmax(0, 1fr); }
  .results { grid-row: auto; }
}
@media (max-width: 480px) {
  .topbar { padding: 8px 12px; }
  .hero { padding-top: 14px; }
  .lede { font-size: .98rem; }
  .drop { padding: 18px 12px; }
  .hrow { grid-template-columns: 62px minmax(0, 1fr) auto; }
}


textarea { width: 100%; padding: 10px 12px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92rem; line-height: 1.45; }
.drop { padding: 22px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; border-style: dashed; border-width: 2px; }
.drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.drop p { margin: 0; }
.dropicon { color: var(--accent); }
.droptitle { font-weight: 600; font-size: 1.08rem; }
.textwrap { width: 100%; margin-top: 4px; }
.textwrap textarea { min-height: 80px; }

.results { padding: 14px; min-width: 0; grid-row: span 2; display: flex; flex-direction: column; gap: 10px; }
.verdict { border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; border-left: 5px solid var(--line); background: var(--soft); }
.verdict .vhead { font-size: 1.25rem; }
.verdict .vbody { color: var(--ink); }
.verdict.good { border-left-color: var(--ok); background: var(--ok-bg); }
.verdict.good .vhead { color: var(--ok); }
.verdict.bad { border-left-color: var(--bad); background: var(--bad-bg); }
.verdict.bad .vhead { color: var(--bad); }
.verdict.warn { border-left-color: #c98a00; background: var(--warn-bg); }
.exp-label { font-weight: 600; font-size: .95rem; }
#expected { min-height: 64px; }
.notes { margin: 0; padding: 8px 12px 8px 28px; background: var(--warn-bg); border-radius: 10px; font-size: .9rem; }
.filelist { display: flex; flex-direction: column; gap: 10px; }
.fcard { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.fcard.match { border-color: var(--ok); }
.fcard.mismatch, .fcard.not_listed, .fcard.error { border-color: var(--bad); }
.ftop { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 6px; }
.fname { font-weight: 600; word-break: break-all; }
.pill { font-size: .78rem; font-weight: 600; border-radius: 999px; padding: 2px 10px; background: var(--soft); color: var(--ink); }
.pill.match { background: var(--ok-bg); color: var(--ok); }
.pill.mismatch, .pill.not_listed, .pill.error { background: var(--bad-bg); color: var(--bad); }
.pill.working, .pill.pending { color: var(--muted); }
.bar { height: 8px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }
.barlbl { margin: 4px 0 0; }
.htable { display: flex; flex-direction: column; gap: 4px; }
.hrow { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 8px; }
.hrow.hit { background: var(--ok-bg); }
.halg { font-size: .84rem; color: var(--muted); font-weight: 600; }
.hval { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .84rem; word-break: break-all; line-height: 1.35; }
.mini { background: var(--panel); border: 1px solid var(--line); color: var(--ink); padding: 4px 10px; border-radius: 8px; min-height: 40px; font-size: .84rem; }
.mini:hover:not(:disabled) { background: var(--soft); }
.diff { background: var(--bad-bg); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; }
.dline { margin: 2px 0; display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; }
.dlab { font-size: .84rem; color: var(--muted); font-weight: 600; }
.diff mark { background: var(--bad); color: var(--panel); border-radius: 2px; }
.unchecked { border-top: 1px solid var(--line); padding-top: 8px; }
.unchecked p { margin: 4px 0; }
.unchecked ul { margin: 4px 0; padding-left: 20px; word-break: break-all; }
.listopts { display: flex; flex-wrap: wrap; gap: 8px; }
.listpreview, .cmds { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 0; font-size: .78rem; line-height: 1.4; max-height: 180px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.listpreview:empty { display: none; }
.cmdbox { display: flex; flex-direction: column; gap: 6px; }
.h4 { font-weight: 600; margin: 0; font-size: .92rem; }
.more label.inline { display: flex; justify-content: space-between; margin: 6px 0; gap: 8px; }
.more select { max-width: 60%; }
.rhead { font-weight: 600; margin: 12px 0 4px !important; }
.report ol { margin: 4px 0 8px; padding-left: 22px; }
#exportMsg:empty { display: none; }

/* ---- File Type Checker ---- */
.results { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.verdict { gap: 6px; }
.verdict .vhead { font-size: 1.3rem; font-weight: 700; margin: 2px 0 0; line-height: 1.25; }
.verdict .vbody { margin: 0; }
.verdict p { margin: 0; }
.vtop { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.fname { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem; color: var(--muted); overflow-wrap: anywhere; }
.verdict.ok { border-left-color: var(--ok); background: var(--ok-bg); }
.verdict.caution { border-left-color: #c98a00; background: var(--warn-bg); }
.verdict.danger { border-left-color: var(--bad); background: var(--bad-bg); }
.verdict.danger .vhead { color: var(--bad); }
.pill.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); }
.pill.caution { background: var(--warn-bg); color: #8a5d00; border: 1px solid #c98a00; }
[data-theme="dark"] .pill.caution { color: #f0c060; }
.pill.danger { background: var(--bad); color: #fff; }
.preview { max-width: 100%; max-height: 220px; border-radius: 8px; border: 1px solid var(--line); align-self: flex-start; background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 16px 16px; image-rendering: auto; margin-top: 6px; }
.signals { margin: 8px 0 4px; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.signals li { font-size: .95rem; }
.sig.danger b { color: var(--bad); } .sig.caution b { color: #8a5d00; } [data-theme="dark"] .sig.caution b { color: #f0c060; } .sig.info b, .sig.ok b { color: var(--muted); }
.facts { border-collapse: collapse; width: 100%; margin-top: 8px; font-size: .9rem; table-layout: fixed; }
.facts th { text-align: left; font-weight: 600; color: var(--muted); padding: 4px 10px 4px 0; width: 34%; vertical-align: top; }
.facts td { padding: 4px 0; overflow-wrap: anywhere; vertical-align: top; }
.facts tr + tr th, .facts tr + tr td { border-top: 1px solid var(--line); }
.inside { padding: 14px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.block { min-width: 0; }
.capslist, .picks, .archive { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 4px; }
.capslist li, .picks li { font-size: .9rem; overflow-wrap: anywhere; }
.picks code, .capslist code { font-size: .82rem; background: var(--soft); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; word-break: break-all; }
.picks .kind { display: inline-block; font-size: .74rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; margin-right: 6px; }
.picks .off, .hex .off { color: var(--muted); }
.archive li { overflow-wrap: anywhere; }
.archive li.flag { color: var(--bad); font-weight: 600; }
.lib summary { cursor: pointer; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; padding: 3px 0; overflow-wrap: anywhere; }
.fnlist { margin: 2px 0 8px 14px; overflow-wrap: anywhere; word-break: break-word; line-height: 1.6; }
.tablewrap { overflow-x: auto; }
.sections { border-collapse: collapse; width: 100%; font-size: .86rem; }
.sections th, .sections td { text-align: left; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ebar { display: inline-block; height: 8px; border-radius: 4px; background: var(--accent); vertical-align: middle; }
.ebar.hi { background: var(--bad); }
.entropy { width: 100%; }
.espark { width: 100%; height: 48px; display: block; background: var(--soft); border-radius: 8px; }
.espark rect.lo { fill: var(--accent); opacity: .55; } .espark rect.mid { fill: var(--accent); } .espark rect.hi { fill: var(--bad); }
.hex { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .74rem; line-height: 1.45; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; overflow-x: auto; margin: 6px 0 4px; white-space: pre; max-width: 100%; }
.hex .sig { background: #ffd54a; color: #1b1b1f; border-radius: 2px; }
.hex .asc { color: var(--muted); }
.more label.inline { margin: 4px 12px 4px 0; }
.rhead { font-weight: 700; margin-top: 10px !important; }
.report code { font-size: .82rem; background: var(--soft); padding: 1px 4px; border-radius: 4px; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .hex { font-size: .6rem; padding: 6px; }
  .facts th { width: 38%; }
  .verdict .vhead { font-size: 1.15rem; }
}
