:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --ink: #18181b;
  --muted: #6b6b73;
  --line: #e3e3de;
  --accent: #2446c7;
  --accent-soft: #edf1fd;
  --ok: #1d7a4b;
  --err: #b3261e;
  --code-bg: #f1f1ee;
  --radius: 12px;
  --r-paragraph: #5b8def; --r-heading: #d64545; --r-header: #9a9a9a; --r-footer: #9a9a9a;
  --r-footnote: #b07d2b; --r-caption: #2b9a6b; --r-list: #7a4fc9; --r-index: #9a9a9a;
  --r-table: #e08a00; --r-image: #1ea5bd;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214; --panel: #1b1b1e; --ink: #ececef; --muted: #a0a0a8; --line: #2e2e33;
    --accent: #8aa2ff; --accent-soft: #1f2744; --ok: #5cc28c; --err: #f0857d; --code-bg: #25252a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* header */
.site-header { background: var(--panel); border-bottom: 1px solid var(--line); }
.site-header .inner { max-width: 1240px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.site-nav { display: flex; gap: 2px; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.site-nav a:hover { color: var(--ink); background: var(--code-bg); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.spacer { flex: 1; }
#lang { font-size: 13px; padding: 5px 12px; }

/* layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 40px 16px 64px; }
.page-title { margin: 0 0 8px; font-size: 28px; letter-spacing: -0.02em; line-height: 1.25; }
.lede { margin: 0 0 16px; color: var(--muted); max-width: 64ch; font-size: 16px; }
.privacy { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ok); margin: 0 0 24px; }
.privacy::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.section-title { font-size: 18px; margin: 40px 0 14px; letter-spacing: -0.01em; }
.note { font-size: 13px; color: var(--muted); margin: -6px 0 12px; }

/* home */
.hero { padding: 32px 0 8px; }
.hero .page-title { font-size: 36px; max-width: 20ch; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 8px; }
.card { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; transition: border-color .15s, box-shadow .15s; }
.card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(0,0,0,.05); }
.card .fmt { font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: .04em; }
.card h3 { margin: 0; font-size: 22px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.card .go { margin-top: 10px; font-size: 14px; font-weight: 600; color: var(--accent); }

/* controls */
button, .btn {
  font: inherit; font-size: 14px; padding: 6px 14px; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); border-radius: 8px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
button.link { border: none; background: none; padding: 4px 0; width: 100%; text-align: left; display: flex; gap: 12px; justify-content: space-between; color: var(--ink); border-radius: 0; }
button.link:hover span { color: var(--accent); }
button.link small { color: var(--muted); white-space: nowrap; font-size: 12px; }

.drop { display: block; border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 36px 16px; text-align: center; background: var(--panel); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { display: none; }
.drop strong { font-size: 16px; font-weight: 600; }
.drop .muted { font-size: 13px; }
.status { margin: 12px 0 0; color: var(--muted); font-size: 14px; min-height: 1.6em; }
.status.err { color: var(--err); }
.progress { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.panel h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ov-grid { display: grid; grid-template-columns: 1.1fr 1.4fr .8fr; gap: 16px; }
.ov-grid.two { grid-template-columns: 1fr 1fr; margin-top: 16px; }
@media (max-width: 960px) { .ov-grid, .ov-grid.two { grid-template-columns: 1fr; } }
.filename { margin: 0 0 12px; font-weight: 600; word-break: break-all; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.stat { background: var(--bg); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; }
.stat b { font-size: 20px; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.zero b { color: var(--muted); font-weight: 500; }
.export { display: flex; flex-direction: column; gap: 8px; }
.export button { text-align: left; }
.toc { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; font-size: 14px; }
.toc li { border-bottom: 1px solid var(--line); }
.toc li:last-child { border-bottom: none; }
.toc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* viewer */
.pager { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; }
.pageno { min-width: 90px; text-align: center; font-variant-numeric: tabular-nums; }
.toggle { margin-left: auto; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.view-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); gap: 16px; align-items: start; }
@media (max-width: 900px) { .view-grid { grid-template-columns: 1fr; } }
.stage { position: relative; }
.stage canvas { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.box { position: absolute; border: 1.5px solid; border-radius: 2px; opacity: .75; transition: background .1s; }
.box.hl { opacity: 1; background: rgba(36,70,199,.14); border-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border: 1.5px solid; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.side { position: sticky; top: 12px; max-height: calc(100vh - 24px); display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 12px; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 12px 10px 10px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.side-body { overflow: auto; padding: 14px 16px; }
.side .note { margin: 12px 16px 0; }
.block { margin: 0 0 10px; font-size: 13px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.block:hover { background: var(--accent-soft); border-radius: 4px; }
.role { display: inline-block; padding: 0 6px; border-radius: 4px; color: #fff; font-size: 11px; margin-right: 6px; vertical-align: 1px; }
.table-scroll { overflow: auto; margin-bottom: 16px; }
table.cells { border-collapse: collapse; font-size: 12px; }
table.cells td { border: 1px solid var(--line); padding: 3px 7px; vertical-align: top; }
pre.out { margin: 0; white-space: pre-wrap; word-break: break-word; max-height: 70vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; font: 14px/1.7 inherit; }

.site-footer { border-top: 1px solid var(--line); padding: 24px 16px; font-size: 13px; color: var(--muted); text-align: center; }

@media (max-width: 640px) {
  .wrap { padding-top: 24px; }
  .hero .page-title { font-size: 28px; }
  .page-title { font-size: 24px; }
  .site-header .inner { gap: 12px; }
}

:lang(ko) body, html:lang(ko) { word-break: keep-all; overflow-wrap: anywhere; }
