:root {
  --bg: #fbfbfa; --fg: #1b1b19; --muted: #66655f; --line: #dcdbd5; --panel: #ffffff; --accent: #2f5fd0; --accent-fg: #fff;
  --warn-bg: #fff4e5; --warn-fg: #7a3d00; --err-bg: #fdeceb; --err-fg: #8a1f17;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161615; --fg: #ecebe7; --muted: #a3a29a; --line: #3a3936; --panel: #1f1f1d; --accent: #7aa2ff; --accent-fg: #0d1a3a;
    --warn-bg: #3a2a12; --warn-fg: #ffd6a0; --err-bg: #3d1a17; --err-fg: #ffb4ab;
  }
}
:root[data-theme="dark"] {
  --bg: #161615; --fg: #ecebe7; --muted: #a3a29a; --line: #3a3936; --panel: #1f1f1d; --accent: #7aa2ff; --accent-fg: #0d1a3a;
  --warn-bg: #3a2a12; --warn-fg: #ffd6a0; --err-bg: #3d1a17; --err-fg: #ffb4ab;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 1.05rem; margin: 0 0 6px; }
a { color: var(--accent); }
.lede { margin: 0 0 16px; color: var(--muted); max-width: 75ch; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
button { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); margin-bottom: 16px; font-size: .925rem; }
.status progress { flex: 1 1 160px; height: 8px; accent-color: var(--accent); }
.status.error { background: var(--err-bg); color: var(--err-fg); border-color: transparent; }
.status.ready { color: var(--muted); }

.drop { display: block; border: 2px dashed var(--line); border-radius: 10px; padding: 22px 16px; text-align: center; cursor: pointer; background: var(--panel); }
.drop.over { border-color: var(--accent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: 10px 0 18px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: .925rem; }
.pdf-nav { display: inline-flex; gap: 8px; align-items: center; }

.result { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 820px) { .result { grid-template-columns: minmax(0, 1fr); } }
.pane { min-width: 0; }
.pane-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.actions { display: inline-flex; gap: 6px; }
.canvas-wrap { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
canvas { display: block; width: 100%; height: auto; }
.md { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); white-space: pre-wrap;
  word-break: break-word; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 80vh; overflow: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
footer { margin-top: 28px; }
footer p { max-width: 90ch; }
