/* Watermarks Remover — one stylesheet, both themes, no external fonts. */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2330;
  --ink: #e6edf3;
  --ink-dim: #9aa7b4;
  --line: #2a3441;
  --accent: #4c9aff;
  --accent-ink: #08131f;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --ins-bg: #12341c;
  --ins-ink: #7ee787;
  --del-bg: #3a1618;
  --del-ink: #ff9c95;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
}

:root[data-theme="light"] {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --panel2: #f0f3f6;
  --ink: #1f2328;
  --ink-dim: #5b6570;
  --line: #d8dee4;
  --accent: #0969da;
  --accent-ink: #ffffff;
  --ok: #1a7f37;
  --warn: #9a6700;
  --bad: #cf222e;
  --ins-bg: #d8f5de;
  --ins-ink: #0b5c22;
  --del-bg: #ffe1e0;
  --del-ink: #91232b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

code, pre, .mono { font-family: var(--mono); }
.mono { font-size: 0.92em; }
.small { font-size: 0.85em; }
.muted { color: var(--ink-dim); }
.hidden { display: none !important; }
.num { text-align: right; }

a { color: var(--accent); }
a:hover { text-decoration: underline; }

h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 18px 0 6px; }
h4 { font-size: 0.95rem; margin: 14px 0 6px; }
h5 { font-size: 0.85rem; margin: 0 0 6px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .04em; }

/* --- top bar ------------------------------------------------------------- */

.topbar {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brand .sep { color: var(--ink-dim); }
.backlink { text-decoration: none; }
.topactions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.credits { font-family: var(--mono); font-size: 0.85em; color: var(--ink-dim); }
.topup { font-size: 0.85em; }

button {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--ink);
  padding: 6px 12px;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; }
button.big {
  padding: 10px 18px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
}
button.mini { padding: 4px 10px; font-size: 0.85em; }
button.linkbtn {
  background: none; border: none; padding: 0; color: var(--accent);
  text-decoration: underline; font-size: inherit;
}

/* --- layout -------------------------------------------------------------- */

main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.hero { margin-bottom: 24px; }
.lede { font-size: 1.05rem; color: var(--ink-dim); max-width: 62ch; }
.herobtns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 16px 0 8px; }

/* The file input is driven by its label so it can sit beside the example button
 * as a matching control. Hidden visually but still in the tab order and still
 * focusable, so the keyboard path is unchanged — hence clip rather than
 * display:none. */
.srfile {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Upload is the primary action, so the label carries the accent fill; the
 * example button is the secondary one beside it. */
label.filebtn {
  display: inline-flex; align-items: center; margin: 0; cursor: pointer;
  font-weight: 600; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); border: 1px solid transparent;
  padding: 10px 18px;
}
label.filebtn:hover { filter: brightness(1.08); }
button.big.secondary {
  background: var(--panel2); color: var(--ink); border-color: var(--line);
}
button.big.secondary:hover:not(:disabled) { border-color: var(--accent); }
.srfile:focus-visible + label.filebtn { outline: 2px solid var(--accent); outline-offset: 2px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}
.labelrow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row .field { flex: 1 1 240px; }
.field { margin-bottom: 12px; }
label { display: block; font-weight: 600; font-size: 0.92em; margin-bottom: 4px; }
.twocol { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 28px; }

textarea, select, input[type="file"] {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px;
}
textarea { font-family: var(--mono); font-size: 0.88em; resize: vertical; }
select { padding: 8px 10px; }

.dropzone { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; }
.dropzone.dragging { border-color: var(--accent); background: var(--panel2); }
.droprow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.droprow input[type="file"] { flex: 0 1 auto; width: auto; border: none; padding: 0; background: none; }

.sourcebadge { margin-top: 8px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 0.82em; font-family: var(--mono); }
.badge.ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }

.warnline {
  border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--warn) 9%, transparent);
  padding: 8px 12px; border-radius: 0 8px 8px 0; margin: 10px 0;
}
.delta {
  border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent);
  padding: 8px 12px; border-radius: 0 8px 8px 0; margin: 10px 0; font-size: 0.92em;
}
.empty { color: var(--ink-dim); font-style: italic; }

/* --- tiles --------------------------------------------------------------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
}
.tilenum { font-size: 1.6rem; font-weight: 700; font-family: var(--mono); }
.tilelabel { font-size: 0.82em; color: var(--ink-dim); }
.tile.alert { border-color: var(--warn); }
.tile.alert .tilenum { color: var(--warn); }
.tile.lvl-high { border-color: var(--bad); } .tile.lvl-high .tilenum { color: var(--bad); }
.tile.lvl-medium { border-color: var(--warn); } .tile.lvl-medium .tilenum { color: var(--warn); }
.tile.lvl-low .tilenum { color: var(--ink-dim); }
.tile.lvl-clean .tilenum { color: var(--ok); }

/* --- segmented control --------------------------------------------------- */

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg { border: none; border-radius: 0; background: transparent; padding: 6px 12px; font-size: 0.88em; }
.seg + .seg { border-left: 1px solid var(--line); }
.seg.active { background: var(--accent); color: var(--accent-ink); }

/* --- reveal view --------------------------------------------------------- */

.reveal {
  white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px; max-height: 460px; overflow: auto; font-size: 0.88em; line-height: 2.1;
}
.chip {
  display: inline-block; padding: 0 6px; margin: 0 1px; border-radius: 5px;
  font-family: var(--mono); font-size: 0.78em; font-weight: 600;
  vertical-align: baseline; cursor: help; white-space: nowrap;
}
.chip.removed { background: color-mix(in srgb, var(--bad) 26%, transparent); color: var(--del-ink); }
.chip.kept { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.chip.sample { cursor: default; }
.chip.k-space.removed { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.chip.k-bidi.removed { background: color-mix(in srgb, var(--bad) 40%, transparent); }

.kindtag { font-size: 0.8em; padding: 1px 7px; border-radius: 999px; background: var(--panel2); white-space: nowrap; }
.kindtag.k-bidi, .kindtag.k-tag_chars, .kindtag.k-private_use { color: var(--bad); }
.kindtag.k-space { color: var(--ink-dim); }

/* --- tables -------------------------------------------------------------- */

table.grid { width: 100%; border-collapse: collapse; font-size: 0.9em; }
table.grid th, table.grid td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { color: var(--ink-dim); font-weight: 600; font-size: 0.86em; }
table.grid th.num, table.grid td.num { text-align: right; }
.tablewrap { overflow-x: auto; }

/* --- clean options ------------------------------------------------------- */

.opts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.opt { font-weight: 400; display: flex; gap: 8px; align-items: baseline; }
.opt input { margin: 0; }
.cleansummary { font-family: var(--mono); font-size: 0.86em; color: var(--ink-dim); margin: 4px 0 10px; }
.exportrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* --- metrics and findings ------------------------------------------------ */

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px 20px; margin: 10px 0; }
.metric { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.mlabel { color: var(--ink-dim); font-size: 0.88em; }
.mval { font-size: 0.88em; }
ul.findings { margin: 8px 0; padding-left: 20px; }
ul.findings li { margin-bottom: 5px; }

/* --- paragraph list ------------------------------------------------------ */

ol.paras { list-style: none; padding: 0; margin: 8px 0 0; }
li.para { display: grid; grid-template-columns: 60px 44px 1fr auto; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); }
.pbar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; }
.pfill { display: block; height: 100%; background: var(--ink-dim); }
li.para.lvl-high .pfill { background: var(--bad); }
li.para.lvl-medium .pfill { background: var(--warn); }
li.para.lvl-clean .pfill { background: var(--ok); }
.pscore { font-size: 0.82em; color: var(--ink-dim); }
.ptext { font-size: 0.86em; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptag { font-size: 0.76em; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); white-space: nowrap; }
li.para.code .pscore { color: var(--ink-dim); font-style: italic; }

/* --- model lane ---------------------------------------------------------- */

.lanenote { color: var(--ink-dim); font-size: 0.93em; max-width: 74ch; }
.runrow { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 14px 0 4px; }

.progress { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 12px 0; background: var(--panel2); }
.progresshead { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
ol.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.step { display: flex; align-items: center; gap: 9px; font-size: 0.9em; color: var(--ink-dim); }
.step .dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--line); flex: none; }
.step.active { color: var(--ink); }
.step.active .dot { background: var(--accent); border-color: var(--accent); }
.step.done .dot { background: var(--ok); border-color: var(--ok); }

.verdict p { max-width: 76ch; }
.notesbox { border-left: 3px solid var(--line); padding: 2px 14px; margin: 14px 0; }
details.stray { margin-top: 14px; }
details.stray pre { white-space: pre-wrap; font-size: 0.85em; background: var(--bg); padding: 10px; border-radius: 8px; }

/* --- diff ---------------------------------------------------------------- */

.diffblock { margin-bottom: 18px; }
.diff {
  white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; font-size: 0.92em;
}
/* Each token carries its own trailing space, so a deletion that ends mid-sentence
 * and an insertion that starts immediately have nothing between them and read as
 * one word. A little padding and a hair of margin separates the runs. */
.diff .ins, .diff .del { border-radius: 3px; padding: 1px 2px; margin: 0 1px; }
.diff .ins { background: var(--ins-bg); color: var(--ins-ink); }
.diff .del { background: var(--del-bg); color: var(--del-ink); text-decoration: line-through; }
.sidebyside { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }

/* --- history ------------------------------------------------------------- */

.histrow { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.histmain { min-width: 240px; flex: 1 1 auto; }
.histbtns { display: flex; gap: 6px; flex-wrap: wrap; }

/* --- credits and footer -------------------------------------------------- */

.credit { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 18px; font-size: 0.9em; color: var(--ink-dim); }
footer { border-top: 1px solid var(--line); padding: 20px; text-align: center; color: var(--ink-dim); }
footer p { margin: 6px 0; }

/* --- api.html ------------------------------------------------------------ */

.codegroup { margin: 12px 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tab { padding: 4px 10px; font-size: 0.82em; border-radius: 6px 6px 0 0; }
.tab.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
pre.code {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; overflow-x: auto; font-size: 0.85em; margin: 0;
}

@media (max-width: 640px) {
  li.para { grid-template-columns: 44px 1fr; }
  li.para .pbar, li.para .ptag { display: none; }
  .tilenum { font-size: 1.3rem; }
}

/* --- batch progress ------------------------------------------------------ */

.batchbar { margin: 4px 0 10px; }
.batchhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
ol.batchlist { list-style: none; display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; }
.batch {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 0.76em; padding: 2px 8px;
  border: 1px solid var(--line); border-radius: 999px; color: var(--ink-dim);
}
.batch .bdot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; }
.batch.running { color: var(--ink); border-color: var(--accent); }
.batch.running .bdot { background: var(--accent); }
.batch.retrying { color: var(--warn); border-color: var(--warn); }
.batch.retrying .bdot { background: var(--warn); }
.batch.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.batch.done .bdot { background: var(--ok); }
.batch.failed { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.batch.failed .bdot { background: var(--bad); }

/* --- how-to steps --------------------------------------------------------- */

ol.steps-howto { margin: 10px 0; padding-left: 22px; }
ol.steps-howto li { margin-bottom: 10px; max-width: 78ch; }
