/* Layout concept: a calm reading page with one "instrument" panel per tool —
   inputs on the left, an amber LCD-style readout on the right. */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --ink: #151b31;
  --muted: #59617d;
  --line: #e1e4ee;
  --soft: #eef0f7;
  --accent: #d9821f;        /* amber: actions, focus */
  --accent-ink: #ffffff;
  --link: #2350b8;
  --lcd-bg: #121a30;
  --lcd-fg: #f6b95a;
  --lcd-dim: #a9b1cb;
  --good: #1e8a5a;
  --bad: #c2412d;
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 14px;
  --wrap: 1120px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1222; --surface: #161c30; --ink: #e7eaf4; --muted: #9ba3bf; --line: #283050; --soft: #1d2440;
    --accent: #f0a443; --accent-ink: #1a1204; --link: #93b2ff; --lcd-bg: #070b17; --lcd-fg: #ffc46b; --lcd-dim: #8f98b6;
    --good: #4cc38a; --bad: #ff8a73; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1222; --surface: #161c30; --ink: #e7eaf4; --muted: #9ba3bf; --line: #283050; --soft: #1d2440;
  --accent: #f0a443; --accent-ink: #1a1204; --link: #93b2ff; --lcd-bg: #070b17; --lcd-fg: #ffc46b; --lcd-dim: #8f98b6;
  --good: #4cc38a; --bad: #ff8a73; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 var(--font-body);
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem); margin: 0 0 .4em; }
h2 { font-size: 1.45rem; margin: 2em 0 .6em; }
h3 { font-size: 1.1rem; margin: 1.4em 0 .4em; }
p { margin: 0 0 1em; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding-inline: 20px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.logo svg { width: 30px; height: 30px; flex: none; }
.header-nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.header-nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .95rem; }
.header-nav a:hover { color: var(--ink); background: var(--soft); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--soft); }
.icon-btn svg { width: 18px; height: 18px; }
.cat-strip { border-top: 1px solid var(--line); }
.cat-strip .wrap { display: flex; gap: 6px; overflow-x: auto; padding-block: 8px; scrollbar-width: none; }
.cat-strip .wrap::-webkit-scrollbar { display: none; }
.cat-strip a { flex: none; font-size: .88rem; color: var(--muted); text-decoration: none; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); white-space: nowrap; }
.cat-strip a:hover, .cat-strip a[aria-current="page"] { color: var(--ink); border-color: var(--ink); }
@media (max-width: 640px) { .header-nav a.hide-sm { display: none; } }

main { padding-block: 28px 56px; }
.crumbs { font-size: .88rem; color: var(--muted); margin-bottom: 14px; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--line); }
.crumbs a { color: var(--muted); }
.lede { color: var(--muted); font-size: 1.08rem; max-width: 66ch; }

/* tool */
.tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-top: 18px; }
.tool.tool-wide { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 820px) { .tool { grid-template-columns: minmax(0, 1fr); padding: 16px; } }
#tool-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; align-content: start; }
@media (max-width: 460px) { #tool-form { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { font-size: .86rem; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
.field textarea { font-family: var(--font-mono); font-size: .92rem; line-height: 1.5; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.affix { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: hidden; }
.affix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.affix input { border: 0; border-radius: 0; background: transparent; min-width: 0; }
.affix input:focus { box-shadow: none; }
.affix span { display: grid; place-items: center; padding: 0 10px; color: var(--muted); font-size: .9rem; background: var(--soft); white-space: nowrap; }
.field-check { justify-content: center; }
.check { display: flex; align-items: center; gap: 10px; font-size: .95rem; color: var(--ink) !important; font-weight: 500 !important; cursor: pointer; min-height: 44px; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.help { font-size: .82rem; color: var(--muted); margin: 0; }

.out { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.display { background: var(--lcd-bg); color: var(--lcd-fg); border-radius: 12px; padding: 18px 20px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), inset 0 10px 30px rgba(0,0,0,.35); }
.display-label { overflow-wrap: anywhere; font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; color: var(--lcd-dim); }
.display-value { font-family: var(--font-mono); font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.3rem); font-weight: 500; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-shadow: 0 0 18px color-mix(in srgb, var(--lcd-fg) 35%, transparent); }
.display-sub { color: var(--lcd-dim); font-size: .9rem; margin-top: 6px; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0; }
.stats div { background: var(--soft); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.stats dt { font-size: .8rem; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.out-error { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); border-radius: 10px; padding: 12px 14px; margin: 0; }
.out-text { width: 100%; font: .92rem/1.5 var(--font-mono); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; resize: vertical; }
.note { font-size: .86rem; color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.table-wrap[data-tall] { max-height: 380px; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--soft); font-weight: 600; color: var(--muted); font-size: .82rem; }
tr:last-child td { border-bottom: 0; }
.swatch { height: 64px; border-radius: 10px; border: 1px solid var(--line); }
.diff { font: .88rem/1.5 var(--font-mono); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; max-height: 420px; }
.diff div { padding: 1px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff .add { background: color-mix(in srgb, var(--good) 16%, transparent); }
.diff .del { background: color-mix(in srgb, var(--bad) 14%, transparent); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.diff .add::before { content: "+ "; color: var(--good); }
.diff .del::before { content: "− "; color: var(--bad); }
.diff .same::before { content: "  "; }

.actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.btn { font: inherit; font-size: .92rem; font-weight: 600; border-radius: 10px; padding: 9px 14px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 40px; }
.btn:hover { background: var(--soft); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }

/* article */
.content { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 40px; margin-top: 8px; }
@media (max-width: 900px) { .content { grid-template-columns: minmax(0, 1fr); } }
.prose { max-width: 70ch; min-width: 0; }
.prose ol, .prose ul { padding-left: 1.3em; }
.prose li { margin-bottom: .35em; }
.prose code, .prose .formula { font-family: var(--font-mono); font-size: .92em; }
.formula { display: block; background: var(--soft); border-radius: 10px; padding: 12px 14px; overflow-x: auto; white-space: pre; margin: 0 0 1em; line-height: 1.7; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-weight: 700; font-size: 1.2rem; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 8px 0 0; color: var(--ink); }
.disclaimer { font-size: .88rem; color: var(--muted); background: var(--soft); border-radius: 10px; padding: 12px 14px; margin-top: 2em; }
.side { min-width: 0; }
.side-box { position: sticky; top: 130px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.side-box h2 { font-size: 1rem; margin: 0 0 10px; }
.side-box ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side-box a { display: block; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: .95rem; }
.side-box a:hover { background: var(--soft); }

/* home & category */
.hero { padding-block: 18px 8px; }
.hero h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.1rem); max-width: 18ch; }
.search { position: relative; max-width: 560px; margin-top: 18px; }
.search input { width: 100%; font: inherit; font-size: 1.05rem; padding: 14px 16px 14px 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 52px; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }
.hero-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 16px; color: var(--muted); font-size: .92rem; }
.hero-stats b { color: var(--ink); font-family: var(--font-mono); font-weight: 500; }
.group { margin-top: 36px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.group-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; }
.group-head .cat-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--lcd-bg); color: var(--lcd-fg); display: grid; place-items: center; font-family: var(--font-mono); font-size: .95rem; flex: none; }
.group-head a { font-size: .92rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 14px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; min-width: 0; }
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card b { display: block; font-size: 1rem; }
.card span { display: block; color: var(--muted); font-size: .88rem; margin-top: 2px; line-height: 1.45; }
.empty { color: var(--muted); margin-top: 24px; }
.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 16px; }
.why div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.why h3 { margin: 0 0 6px; }
.why p { margin: 0; color: var(--muted); font-size: .95rem; }

/* footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding-block: 32px; font-size: .92rem; color: var(--muted); }
.foot-grid { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 24px; }
@media (max-width: 720px) { .foot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.site-footer h2 { font-size: .9rem; margin: 0 0 8px; color: var(--ink); font-family: var(--font-body); text-transform: uppercase; letter-spacing: .06em; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }
.copy { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
