:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --text: #1b1f2a;
  --muted: #5d6576;
  --border: #e2e5ec;
  --primary: #2f5fe0;
  --primary-ink: #ffffff;
  --primary-soft: #e8eefd;
  --ok: #137a3f;
  --ok-bg: #e6f6ec;
  --err: #b42318;
  --err-bg: #fdecea;
  --add-bg: #e6f6ec;
  --del-bg: #fdecea;
  --mark: #ffe58a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 25, 40, 0.05), 0 4px 16px rgba(20, 25, 40, 0.05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #161a22;
    --surface-2: #1d222c;
    --text: #e6e9ef;
    --muted: #9aa3b5;
    --border: #2a303c;
    --primary: #6d93ff;
    --primary-ink: #0b0e14;
    --primary-soft: #1e2840;
    --ok: #5fd08b;
    --ok-bg: #12291c;
    --err: #ff8a80;
    --err-bg: #331816;
    --add-bg: #13301f;
    --del-bg: #3a1a18;
    --mark: #6b5a12;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.65 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 0 0 0.5rem; }
h2 { font-size: 1.45rem; margin: 2rem 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
code, pre, kbd { font-family: var(--mono); font-size: 0.92em; }
:not(pre) > code { background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; overflow-wrap: anywhere; }
pre { background: var(--surface-2); border: 1px solid var(--border); padding: 1rem; border-radius: 10px; overflow-x: auto; line-height: 1.5; }
.muted { color: var(--muted); }
.wrap { width: min(1120px, 100% - 2rem); margin-inline: auto; }
.narrow { width: min(760px, 100% - 2rem); margin-inline: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: 0.5rem 1rem; z-index: 10; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--primary); text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand span { color: var(--text); }
.site-nav { display: flex; gap: 0.25rem; }
.site-nav a { color: var(--text); text-decoration: none; padding: 0.45rem 0.8rem; border-radius: 8px; font-weight: 500; }
.site-nav a:hover, .site-nav a[aria-current] { background: var(--primary-soft); color: var(--primary); }
.nav-toggle { display: none; background: none; border: 0; padding: 10px; cursor: pointer; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--text); margin: 4px 0; border-radius: 2px; }
@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .site-nav { display: none; position: absolute; top: 62px; left: 0; right: 0; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0.5rem 1rem 1rem; }
  .site-nav.open { display: flex; }
}

/* Hero */
.hero { padding: clamp(2.5rem, 7vw, 4.5rem) 0 2rem; text-align: center; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 640px; margin: 0 auto 1.5rem; }
.eyebrow { display: inline-block; font-size: 0.85rem; font-weight: 600; color: var(--primary); background: var(--primary-soft); padding: 0.25rem 0.75rem; border-radius: 99px; margin-bottom: 1rem; }
.search { max-width: 520px; margin: 0 auto; }
.search input { width: 100%; padding: 0.9rem 1.1rem; font-size: 1rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.search input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Cards */
.section { padding: 1.5rem 0 1rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.section-head h2 { margin-bottom: 0.25rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-top: 1rem; }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; color: inherit; text-decoration: none; box-shadow: var(--shadow); transition: border-color 0.15s, transform 0.15s; }
a.card:hover { border-color: var(--primary); transform: translateY(-2px); }
.card h3 { margin: 0.6rem 0 0.3rem; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.94rem; }
.card-icon { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 6px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font: 700 0.85rem var(--mono); }
.post-card .meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }
.features { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.features .card h3 { margin-top: 0; }
.no-results { display: none; text-align: center; color: var(--muted); padding: 2rem 0; }

/* Page / article */
.page-head { padding: 2rem 0 0.5rem; }
.breadcrumb { font-size: 0.88rem; color: var(--muted); margin-bottom: 0.75rem; }
.breadcrumb a { color: var(--muted); }
.lead { font-size: 1.1rem; color: var(--muted); margin-top: 0; }
.prose { font-size: 1.04rem; }
.prose p, .prose li { max-width: 72ch; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: 0.3rem 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.5rem 0.7rem; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); }
.prose blockquote { margin: 1rem 0; padding: 0.6rem 1rem; border-left: 4px solid var(--primary); background: var(--primary-soft); border-radius: 0 8px 8px 0; }
.post-meta { color: var(--muted); font-size: 0.92rem; margin-bottom: 1.5rem; }
.layout-2 { display: grid; gap: 2.5rem; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; padding-bottom: 3rem; }
.sidebar { position: sticky; top: 80px; }
.sidebar .card { margin-bottom: 1rem; }
.sidebar ul { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.sidebar li { margin: 0.35rem 0; }
@media (max-width: 900px) { .layout-2 { grid-template-columns: minmax(0, 1fr); } .sidebar { position: static; } }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem 1rem; margin: 0.6rem 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 0.6rem 0 0; }
.cta { background: var(--primary-soft); border-radius: var(--radius); padding: 1.2rem 1.4rem; margin: 2rem 0; }
.cta p { margin: 0.25rem 0 0.75rem; }

/* Tool UI */
.tool { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: clamp(1rem, 3vw, 1.5rem); box-shadow: var(--shadow); margin: 1.25rem 0 2rem; }
.field { margin-bottom: 1rem; }
.field > label, .label-row label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.35rem; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.cols-2 { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .cols-2 { grid-template-columns: minmax(0, 1fr); } }
textarea, input[type='text'], input[type='number'], input[type='datetime-local'], select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 0.6rem 0.75rem;
}
textarea { resize: vertical; min-height: 120px; }
textarea.code, input.code, .code-out { font-family: var(--mono); font-size: 0.9rem; line-height: 1.5; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
select { width: auto; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.inline { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.92rem; }
.inline input[type='number'] { width: 90px; }
.btn { font: inherit; font-weight: 600; font-size: 0.93rem; border: 1px solid var(--primary); background: var(--primary); color: var(--primary-ink); padding: 0.5rem 1rem; border-radius: 9px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn.sm { padding: 0.2rem 0.6rem; font-size: 0.82rem; }
.status { min-height: 1.5em; margin: 0 0 1rem; font-size: 0.93rem; padding: 0; }
.status.ok, .status.err { padding: 0.5rem 0.8rem; border-radius: 8px; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.err { background: var(--err-bg); color: var(--err); }
.out-box { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 0.75rem; min-height: 3rem; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 0.9rem; }
.out-box mark { background: var(--mark); color: inherit; border-radius: 3px; }
table.kv { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.kv th, table.kv td { border-bottom: 1px solid var(--border); padding: 0.5rem 0.4rem; text-align: left; vertical-align: top; word-break: break-all; }
table.kv th { width: 34%; color: var(--muted); font-weight: 600; word-break: normal; }
table.kv td.mono, .mono { font-family: var(--mono); font-size: 0.88rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.9rem; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.2; }
.stat span { font-size: 0.85rem; color: var(--muted); }
.swatch { height: 110px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 1rem; }
.diff { font-family: var(--mono); font-size: 0.86rem; border: 1px solid var(--border); border-radius: 9px; overflow-x: auto; }
.diff div { display: grid; grid-template-columns: 3.2em 3.2em 1.5em 1fr; white-space: pre-wrap; word-break: break-word; }
.diff .n { color: var(--muted); text-align: right; padding-right: 0.5em; user-select: none; }
.diff .add { background: var(--add-bg); }
.diff .del { background: var(--del-bg); }
.match-list { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
.match-list li { border-bottom: 1px solid var(--border); padding: 0.4rem 0; }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 3rem; padding-top: 2.5rem; }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: 2fr 1fr 1fr; }
.site-footer h2 { font-size: 0.95rem; margin: 0 0 0.6rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 0.35rem 0; }
.site-footer li a { color: var(--muted); text-decoration: none; }
.site-footer li a:hover { color: var(--primary); }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 2rem; padding: 1.2rem 0; font-size: 0.88rem; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > div:first-child { grid-column: 1 / -1; } }
