/* Layout: tool rail on the left, one working bench on top, reading matter underneath. System fonts only, no external requests. */
:root {
  --bg: #F3F5F8; --surface: #FFFFFF; --ink: #17202B; --muted: #5B6777; --line: #D9DFE7;
  --accent: #1F4FD8; --accent-ink: #FFFFFF; --accent-soft: #E6ECFC;
  --ok: #18794E; --ok-soft: #E3F3EA; --warn: #8A5200; --warn-soft: #FBF0DC; --err: #B42318; --err-soft: #FBE9E7;
  --code-bg: #EEF1F5; --mark: #FFE08A; --mark-ink: #17202B;
  --f-body: system-ui, -apple-system, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --f-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1319; --surface: #171C24; --ink: #E6EAF0; --muted: #98A3B3; --line: #2A3340;
    --accent: #8AA8FF; --accent-ink: #0F1319; --accent-soft: #1C2740;
    --ok: #5FD39A; --ok-soft: #143024; --warn: #F0B55A; --warn-soft: #33270F; --err: #FF8A7A; --err-soft: #3A1A16;
    --code-bg: #1D242E; --mark: #6B5200; --mark-ink: #FFF3C4; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.6; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 5; }
.skip:focus { left: 8px; top: 8px; }

.wrap { max-width: 1180px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 16px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 19px; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; display: flex; align-items: baseline; gap: 8px; }
.brand small { font-family: var(--f-mono); font-weight: 400; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; letter-spacing: 0; }
.top-note { color: var(--muted); font-size: 13px; margin-right: auto; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-left: auto; }
.lang a { padding: 5px 11px; font-size: 13px; color: var(--muted); text-decoration: none; }
.lang a[aria-current="true"] { background: var(--ink); color: var(--bg); }

.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: 28px; padding-top: 24px; padding-bottom: 40px; }
.rail { min-width: 0; }
.rail h2 { font-family: var(--f-mono); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 18px 0 6px; }
.rail h2:first-child { margin-top: 0; }
.rail ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.rail a { display: block; padding: 6px 10px; border-radius: 6px; font-size: 14px; text-decoration: none; color: var(--ink); }
.rail a:hover { background: var(--code-bg); }
.rail a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.crumb { font-size: 13px; color: var(--muted); }
h1 { font-weight: 700; font-size: clamp(24px, 3.2vw, 32px); line-height: 1.2; letter-spacing: -0.02em; margin: 2px 0 6px; text-wrap: balance; }
.lede { color: var(--muted); max-width: 62ch; margin: 0; }
.privacy { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ok); background: var(--ok-soft); border-radius: 999px; padding: 3px 11px; margin-top: 10px; }
.privacy::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* bench */
.bench { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { background: transparent; border: 0; border-right: 1px solid var(--line); padding: 6px 13px; font-size: 13.5px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.opts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.opts label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.chip { margin-left: auto; font-family: var(--f-mono); font-size: 12px; border-radius: 5px; padding: 3px 9px; background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.err { background: var(--err-soft); color: var(--err); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip:empty { display: none; }

.panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.pane { min-width: 0; display: flex; flex-direction: column; }
.pane + .pane { border-left: 1px solid var(--line); }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px; font-size: 12px; font-family: var(--f-mono); text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); min-height: 44px; }
.acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; font-size: 12.5px; font-family: var(--f-body); text-transform: none; letter-spacing: 0; cursor: pointer; color: var(--ink); transition: border-color .12s, color .12s; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; padding: 6px 14px; font-size: 13.5px; }
.btn.primary:hover { color: var(--accent-ink); filter: brightness(1.08); }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
textarea { display: block; width: 100%; min-height: 210px; resize: vertical; border: 0; border-top: 1px solid var(--line); background: var(--surface); padding: 12px 14px; font-family: var(--f-mono); font-size: 13.5px; line-height: 1.55; outline-offset: -2px; word-break: break-all; border-radius: 0; }
textarea.short { min-height: 120px; }
textarea.prose { font-family: var(--f-body); font-size: 15px; word-break: normal; }
textarea[readonly], .outbox { background: var(--code-bg); }
input[type="text"], input[type="number"], input[type="datetime-local"], input[type="password"], select { border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; background: var(--surface); min-width: 0; }
input.mono, select.mono { font-family: var(--f-mono); font-size: 13.5px; }
.block { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.block:first-child { border-top: 0; }
.block h3, .preview h3 { margin: 0; font-family: var(--f-mono); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.fields { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; }
.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.f.grow { flex: 1 1 240px; }
.f.grow input { width: 100%; }
.filebar { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 13px; background: var(--accent-soft); color: var(--accent); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 9px 14px; border-top: 1px solid var(--line); font-family: var(--f-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats b { color: var(--ink); font-weight: 500; }
.stats:empty { display: none; }
.msg { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13.5px; background: var(--err-soft); color: var(--err); white-space: pre-wrap; }
.msg.info { background: var(--warn-soft); color: var(--warn); }
.note { font-size: 13px; color: var(--muted); margin: 0; }
.preview { border-top: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
pre, .pre { margin: 0; background: var(--code-bg); border-radius: 7px; padding: 12px 14px; overflow-x: auto; font-family: var(--f-mono); font-size: 13px; line-height: 1.55; white-space: pre; }
pre.wrap-pre { white-space: pre-wrap; word-break: break-word; }
.preview img { max-width: 100%; max-height: 260px; border: 1px solid var(--line); border-radius: 6px; background: repeating-conic-gradient(var(--code-bg) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; image-rendering: pixelated; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.two > div { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.badge { font-family: var(--f-mono); font-size: 11.5px; border-radius: 4px; padding: 1px 7px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.info { background: var(--code-bg); color: var(--muted); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
/* decoded links: directly under the input, large enough to tap */
.linkbox { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.linkbox h3 { margin: 0; font-family: var(--f-mono); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.links a { display: block; padding: 12px 14px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 16px; line-height: 1.45; text-decoration: none; word-break: break-all; }
.links a:hover, .links a:focus { text-decoration: underline; }
/* input | output side by side with the links row underneath; stacked on phones as input, links, output */
.panes.with-links .p-in { grid-column: 1; grid-row: 1; }
.panes.with-links .p-out { grid-column: 2; grid-row: 1; border-left: 1px solid var(--line); }
.panes.with-links .linkbox { grid-column: 1 / -1; grid-row: 2; }
/* options folded away until wanted */
details.more { border: 0; padding: 0; font-size: 13px; color: var(--muted); }
details.more:last-of-type { border-bottom: 0; }
details.more > summary { font-weight: 400; display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; list-style: none; color: var(--ink); }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] { flex-basis: 100%; order: 5; }
details.more[open] > summary { margin-bottom: 8px; background: var(--code-bg); }
.samples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

/* image compressor and QR */
a.btn { display: inline-block; text-decoration: none; }
.drop { padding: 30px 14px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: 14px; background: var(--code-bg); }
.bench.dragover { border-color: var(--accent); }
.bench.dragover .drop { background: var(--accent-soft); color: var(--accent); }
.imgrow { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.imgrow .th { width: 72px; height: 72px; border-radius: 6px; border: 1px solid var(--line); background: var(--code-bg); overflow: hidden; }
.imgrow .th img { display: block; width: 100%; height: 100%; object-fit: cover; }
.imgrow .nm { font-size: 13.5px; word-break: break-all; }
.imgrow .meta { font-family: var(--f-mono); font-size: 12px; color: var(--muted); line-height: 1.7; }
.imgrow .meta b { color: var(--ink); font-weight: 500; }
.imgrow .badge { white-space: normal; }
.f input[type="range"] { vertical-align: middle; width: 150px; max-width: 100%; }
.f b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
canvas.qr { display: block; width: 100%; max-width: 280px; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; image-rendering: pixelated; }

/* key/value and result rows */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.kv { width: 100%; }
th, td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
th { background: var(--code-bg); font-weight: 500; color: var(--muted); white-space: nowrap; }
td.mono, table.mono td { font-family: var(--f-mono); font-size: 13px; word-break: break-all; }
td.hl { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
table.bits { font-family: var(--f-mono); font-size: 13px; }
table.bits td { text-align: center; white-space: nowrap; }
.rows { display: flex; flex-direction: column; }
.rowx { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 14px; border-top: 1px solid var(--line); }
.rowx .lab { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.rowx .val { font-family: var(--f-mono); font-size: 13px; word-break: break-all; }
.rowx.match { background: var(--ok-soft); }

/* diff */
.diff { font-family: var(--f-mono); font-size: 13px; line-height: 1.5; overflow-x: auto; border-top: 1px solid var(--line); }
.dl { display: grid; grid-template-columns: 44px 44px 18px minmax(0, 1fr); min-width: max-content; }
.dl span { padding: 0 6px; white-space: pre; }
.dl .n { color: var(--muted); text-align: right; user-select: none; background: var(--code-bg); }
.dl.add { background: var(--ok-soft); }
.dl.del { background: var(--err-soft); }
.dl.add .s { color: var(--ok); } .dl.del .s { color: var(--err); }
.dl.gap { color: var(--muted); background: var(--code-bg); font-style: italic; }
mark { background: var(--mark); color: var(--mark-ink); border-radius: 2px; padding: 0 1px; }
mark.alt { filter: saturate(.6) brightness(1.08); }

/* stat tiles (count tool) */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.tile { background: var(--surface); padding: 12px 14px; }
.tile b { display: block; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile span { font-size: 12.5px; color: var(--muted); }
.meter { height: 8px; border-radius: 4px; background: var(--code-bg); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); }
.meter.over i { background: var(--err); }
.cand { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.cand-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 12px; background: var(--code-bg); font-size: 13px; }
.cand-body { padding: 10px 12px; white-space: pre-wrap; word-break: break-word; }
.big { font-family: var(--f-mono); font-size: clamp(20px, 4vw, 30px); font-weight: 600; font-variant-numeric: tabular-nums; }

/* reading matter */
.read { display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; max-width: 760px; }
.read.wide { max-width: none; }
.read h2 { font-weight: 700; font-size: 21px; letter-spacing: -0.01em; margin: 0 0 8px; text-wrap: balance; }
.read h3 { font-size: 16px; margin: 14px 0 4px; }
.read p { margin: 0 0 10px; max-width: 66ch; }
.read ul, .read ol { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; max-width: 66ch; }
.read code { font-family: var(--f-mono); font-size: 13px; background: var(--code-bg); border-radius: 4px; padding: 1px 5px; word-break: break-all; }
.read pre code { background: none; padding: 0; }
.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.related a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 13px; text-decoration: none; color: var(--ink); font-size: 14px; font-weight: 600; }
.related a:hover { border-color: var(--accent); }
.related a small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
details { border-top: 1px solid var(--line); padding: 10px 0; }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 600; }
details p { margin: 8px 0 0; color: var(--muted); }

.foot { border-top: 1px solid var(--line); background: var(--surface); }
.foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; padding-top: 18px; padding-bottom: 18px; font-size: 13px; color: var(--muted); }
.foot nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { text-decoration: underline; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 14px; padding-top: 14px; padding-bottom: 32px; }
  .rail { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
  .rail h2 { display: none; }
  .rail ul { flex-direction: row; gap: 6px; }
  .rail a { white-space: nowrap; border: 1px solid var(--line); background: var(--surface); padding: 5px 11px; }
  .panes { grid-template-columns: minmax(0, 1fr); }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
  textarea { min-height: 150px; }
  .chip { margin-left: 0; }
  .panes.with-links .p-in, .panes.with-links .p-out, .panes.with-links .linkbox { grid-column: 1; grid-row: auto; }
  .panes.with-links .p-out { border-left: 0; border-top: 1px solid var(--line); }
  .panes.with-links .linkbox { border-top: 1px solid var(--line); }
  .top-note { display: none; }
  .rowx { grid-template-columns: 64px minmax(0, 1fr) auto; }
  .imgrow { grid-template-columns: 56px minmax(0, 1fr); }
  .imgrow .th { width: 56px; height: 56px; }
  .imgrow > div:last-child { grid-column: 1 / -1; }
  /* the tool row scrolls sideways: fade its right edge as a hint, and start it with a link to the full list */
  .rail { padding-right: 36px; scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
  .rail::-webkit-scrollbar { display: none; }
  .rail .rail-all { display: flex; }
  .rail .rail-all a { border-color: var(--ink); font-weight: 600; }
  /* keep the result label on a second row that is always there, so the panes below do not jump when it appears */
  .bar.chiprow::after { content: ""; order: 9; flex-basis: 100%; height: 0; margin-top: -10px; }
  .bar.chiprow .chip { order: 10; min-height: 26px; }
  .bar.chiprow .chip:empty { display: inline-block; visibility: hidden; }
}
.rail-all { display: none; }
/* Tool pages: the tool fills in its example when its script runs. Until then the tool and what follows keep their space but are not
   painted, so the page does not visibly jump. Shown anyway after 3s if the script never arrives, and at once without JavaScript (base.html). */
html:not(.ready) .bench, html:not(.ready) .bench ~ * { visibility: hidden; animation: reveal 0s linear 3s forwards; }
@keyframes reveal { to { visibility: visible; } }
/* touch screens: form text at 16px (iOS zooms the page when a focused field is smaller) and targets of about 44px */
@media (max-width: 860px), (pointer: coarse) {
  input[type="text"], input[type="number"], input[type="datetime-local"], input[type="password"], select, textarea,
  textarea.prose, input.mono, select.mono { font-size: 16px; }
  input[type="text"], input[type="number"], input[type="datetime-local"], input[type="password"], select { min-height: 44px; }
  .btn, .btn.primary { min-height: 44px; padding: 8px 14px; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
  .seg button { min-height: 44px; padding: 8px 14px; font-size: 14px; }
  .opts { gap: 0 16px; font-size: 14px; }
  .opts label { min-height: 44px; gap: 8px; }
  input[type="checkbox"] { width: 20px; height: 20px; flex: none; }
  input[type="range"] { min-height: 44px; }
  details.more > summary { min-height: 44px; display: inline-flex; align-items: center; padding: 8px 14px; font-size: 14px; }
  .read details { padding: 0; }
  .read summary { padding: 12px 0; }
  .read details p { margin: 0 0 12px; }
  .rail a { padding: 10px 14px; }
  .lang a { padding: 10px 13px; font-size: 14px; }
  .brand { min-height: 44px; align-items: center; }
  .brand small { font-size: 12px; }
  .badge { font-size: 12px; }
  .foot nav { gap: 0 18px; }
  .foot a { display: inline-block; padding: 11px 0; }
  .foot .wrap { align-items: center; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
