/* Pikkola Grid: ink on graph paper, one blueprint accent, and a preview that
   never lets a layout spill out of its frame. Weights stay at 400 to 700. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(/tools/grid/fonts/inter.woff2) format("woff2-variations");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/tools/grid/fonts/jetbrains-mono.woff2) format("woff2");
}

:root {
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --wrap: 1180px;
  --r: 14px;
  --r-sm: 8px;
}
html[lang="ko"] {
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  word-break: keep-all;
}
html[lang="ja"] {
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  word-break: normal;
}
html[lang="ja"] h1,
html[lang="ja"] h2,
html[lang="ja"] h3,
html[lang="ja"] p,
html[lang="ja"] li,
html[lang="ja"] summary { line-break: strict; overflow-wrap: break-word; word-break: auto-phrase; }
html[lang="ja"] .hero h1 { max-width: 15ch; font-size: clamp(1.95rem, 3.9vw, 3.1rem); }

html[data-theme="light"] {
  --bg: #f2f0e8;
  --bg-2: #e9e6dc;
  --surface: #fdfcf7;
  --surface-2: #f6f4ec;
  --ink: #15181a;
  --ink-2: #444a4d;
  --ink-3: #767c7e;
  --line: #dedacd;
  --line-2: #c6c1b2;
  --accent: #1f3a5f;
  --accent-ink: #f8fafc;
  --accent-soft: #e2e9f1;
  --hot: #b6432e;
  --hot-soft: #f4ded6;
  --ok: #2f6b4f;
  --ok-soft: #e2efe7;
  --bit-on: #1f3a5f;
  --bit-off: #d3cec0;
  --bit-net: #e1e8f0;
  --bit-host: #efece2;
  --paper: #ffffff;
  --shadow: 0 24px 60px -32px rgba(22, 30, 26, 0.38);
  --shadow-sm: 0 10px 24px -18px rgba(22, 30, 26, 0.42);
  --header: rgba(242, 240, 232, 0.86);
}
html[data-theme="dark"] {
  --bg: #101314;
  --bg-2: #171b1c;
  --surface: #1a1f20;
  --surface-2: #202627;
  --ink: #eef1ec;
  --ink-2: #c0c8c4;
  --ink-3: #8e9793;
  --line: #2b3233;
  --line-2: #3d4647;
  --accent: #9dc0e0;
  --accent-ink: #0d1620;
  --accent-soft: #1b2836;
  --hot: #e08169;
  --hot-soft: #3a241f;
  --ok: #8fd0aa;
  --ok-soft: #1d2f26;
  --bit-on: #9dc0e0;
  --bit-off: #2c3435;
  --bit-net: #1c2937;
  --bit-host: #232a2b;
  --paper: #fbfaf6;
  --shadow: 0 28px 70px -30px rgba(0, 0, 0, 0.8);
  --shadow-sm: 0 12px 28px -18px rgba(0, 0, 0, 0.8);
  --header: rgba(16, 19, 20, 0.86);
}
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
/* A tool that fits its own width: no font boosting on a phone. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.66;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(720px 460px at 88% -8%, rgba(31, 58, 95, 0.10), transparent 70%),
    radial-gradient(560px 380px at 2% 6%, rgba(31, 58, 95, 0.05), transparent 72%);
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
svg { display: block; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 28px; position: relative; z-index: 1; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 40;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: var(--r-sm); text-decoration: none; font-size: 14px;
}
.skip-link:focus { top: 14px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---------- header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--header);
  backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 26px; height: 66px; }
.brand { display: inline-flex; align-items: baseline; gap: 7px; text-decoration: none; font-weight: 600; letter-spacing: -0.02em; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); align-self: center; }
.brand-name { font-size: 17px; }
.brand-tool {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3); border-left: 1px solid var(--line-2); padding-left: 8px;
}
.site-nav { display: flex; gap: 20px; margin-left: auto; font-size: 14px; }
.site-nav a { text-decoration: none; color: var(--ink-2); padding: 4px 0; border-bottom: 1px solid transparent; }
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--ink-3); }
.header-tools { display: flex; align-items: center; gap: 10px; }
.lang-field { position: relative; display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); }
.lang-globe { width: 16px; height: 16px; margin-left: 6px; pointer-events: none; position: absolute; left: 0; }
.lang-field select {
  appearance: none; background: transparent; border: 1px solid var(--line-2); border-radius: 999px;
  color: var(--ink-2); font-size: 12.5px; padding: 6px 10px 6px 26px; cursor: pointer;
}
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.icon-btn svg { width: 17px; height: 17px; }
html[data-theme="light"] .ico-sun { display: none; }
html[data-theme="dark"] .ico-moon { display: none; }

/* ---------- hero ---------- */

.hero {
  display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  gap: 46px; align-items: center;
  padding-top: 72px; padding-bottom: 60px;
}
.eyebrow {
  font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent);
  margin-bottom: 14px;
}
.hero h1 { font-size: clamp(2.1rem, 4.3vw, 3.4rem); line-height: 1.03; letter-spacing: -0.035em; max-width: 16ch; }
.hero-lede { margin-top: 22px; font-size: 17px; color: var(--ink-2); max-width: 54ch; }
.facts { display: flex; gap: 34px; margin: 34px 0 0; padding: 0; flex-wrap: wrap; }
.facts div { display: flex; flex-direction: column; gap: 2px; }
.facts dt { font-family: var(--mono); font-size: 22px; font-weight: 500; color: var(--ink); }
.facts dd { margin: 0; font-size: 12px; color: var(--ink-3); letter-spacing: 0.02em; }

.hero-art { position: relative; display: grid; place-items: center; min-height: 340px; padding-bottom: 30px; }
.art-block {
  width: min(430px, 100%); padding: 22px 22px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: var(--shadow); transform: rotate(-0.8deg);
}
.art-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.art-head .art-tag { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; color: var(--ink-3); text-transform: uppercase; }
.art-cidr { font-family: var(--mono); font-size: 19px; color: var(--ink); letter-spacing: -0.02em; }
.art-rows { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 12px 0 14px; font-size: 11px; }
.art-rows dt { color: var(--ink-3); font-family: var(--mono); letter-spacing: 0.02em; }
.art-rows dd { margin: 0; font-family: var(--mono); color: var(--ink-2); text-align: right; }
.art-foot { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.art-foot span { font-size: 10px; letter-spacing: 0.06em; color: var(--ink-3); font-family: var(--mono); }
.art-caption {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3);
  white-space: nowrap;
}

/* ---------- sections ---------- */

.section { padding-top: 62px; padding-bottom: 62px; border-top: 1px solid var(--line); }
.section[id] { scroll-margin-top: 84px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 40px; margin-bottom: 30px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(1.5rem, 2.7vw, 2.05rem); }
.section-lede { max-width: 46ch; color: var(--ink-2); font-size: 15.5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card-label { display: block; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-bottom: 12px; }
.hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.55; margin-top: 10px; }

.actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 15px;
  background: transparent; border: 1px solid var(--line-2); border-radius: 999px;
  color: var(--ink-2); cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { border-color: var(--ink-3); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  min-width: 140px; height: 44px; font-weight: 600;
  box-shadow: 0 10px 24px -14px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); color: var(--accent-ink); }
.btn.small { height: 34px; font-size: 12px; padding: 0 12px; }
.btn.tiny { height: 28px; font-size: 11px; padding: 0 9px; border-radius: 7px; }

/* ---------- snippet ---------- */

.snip-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.snip-tabs button {
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-2); padding: 4px 10px; cursor: pointer;
}
.snip-tabs button.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.snip-body {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 13px; position: relative;
}
.snip-body pre {
  margin: 0; font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--ink);
  white-space: pre-wrap; word-break: break-word; max-height: 190px; overflow: auto;
}
.snip-copy { position: absolute; top: 6px; right: 6px; }
.snip-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 9px; }
.allow-row { display: inline-flex; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-3); }
.allow-row select {
  appearance: none; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px;
  color: var(--ink); font-family: var(--mono); font-size: 11.5px; padding: 5px 7px; cursor: pointer;
}

/* ---------- rules ---------- */

.rule-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.rule-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; }
.rule-card .rule-num { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: 0.1em; }
.rule-card h3 { margin-top: 8px; font-size: 16px; }
.rule-card p { margin-top: 10px; font-size: 13.5px; color: var(--ink-2); }

.format-table { margin-top: 22px; overflow-x: auto; }
.format-table table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.format-table caption { text-align: left; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); padding-bottom: 10px; }
.format-table th, .format-table td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); }
.format-table thead th { border-top: 0; border-bottom: 1px solid var(--line-2); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.format-table td { font-family: var(--mono); color: var(--ink-2); white-space: nowrap; }
.format-table td:first-child { color: var(--ink); }
.format-table tbody tr:hover { background: var(--surface-2); }

/* ---------- faq ---------- */

.faq-section { padding-top: 54px; }
.faq { border-top: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  cursor: pointer; padding: 18px 30px 18px 0; font-size: 15.5px; font-weight: 500;
  list-style: none; position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 16px; color: var(--ink-3);
}
.faq details[open] summary::after { content: "−"; color: var(--accent); }
.faq details p { padding: 0 0 20px; color: var(--ink-2); font-size: 14.5px; max-width: 78ch; }

/* ---------- related ---------- */

.related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.rel-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px; text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.rel-card:hover { transform: translateY(-2px); border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.rel-kicker { font-size: 10px; letter-spacing: 0.1em; color: var(--accent); }
.rel-card h3 { font-size: 16px; }
.rel-card p { font-size: 13px; color: var(--ink-3); }
.rel-open { margin-top: auto; font-size: 12px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 5px; }
.rel-open::after { content: "→"; font-family: var(--mono); }

/* ---------- footer ---------- */

.site-footer { border-top: 1px solid var(--line); background: var(--bg-2); margin-top: 40px; padding: 40px 0 46px; position: relative; z-index: 1; }
.footer-inner { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 30px; align-items: start; }
.footer-brand .brand-name { font-weight: 600; font-size: 16px; }
.footer-brand .brand-tool { margin-left: 8px; }
.footer-tagline { margin-top: 10px; font-size: 13px; color: var(--ink-3); max-width: 46ch; }
.footer-note { margin-top: 10px; font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.04em; }
.footer-links { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.footer-links a { color: var(--ink-2); text-decoration: none; }
.footer-links a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.footer-legal { font-size: 12px; color: var(--ink-3); }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 999px; font-size: 13.5px;
  box-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.6);
  opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease; z-index: 120;
  max-width: calc(100vw - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- plain pages ---------- */

.doc { max-width: 780px; padding: 56px 0 70px; }
.doc h1 { font-size: clamp(1.9rem, 3.4vw, 2.5rem); }
.doc .updated { margin-top: 10px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--ink-3); text-transform: uppercase; }
.doc-lede { margin-top: 20px; font-size: 17px; color: var(--ink-2); }
.doc h2 { margin-top: 36px; font-size: 1.22rem; }
.doc h3 { margin-top: 24px; font-size: 1.02rem; }
.doc p, .doc li { font-size: 15px; color: var(--ink-2); }
.doc p { margin-top: 12px; }
.doc ul { margin: 12px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; }
.doc a { color: var(--accent); text-underline-offset: 3px; }
.doc code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.doc .doc-foot { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }

.notfound { padding: 96px 0 110px; max-width: 620px; }
.notfound h1 { font-size: clamp(2rem, 4vw, 2.9rem); }
.notfound p { margin-top: 16px; color: var(--ink-2); }
.notfound .btn { margin-top: 26px; text-decoration: none; }

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; gap: 30px; padding-top: 52px; padding-bottom: 48px; }
  .hero-art { min-height: 280px; order: -1; }
  .deck { grid-template-columns: 1fr; }
  .side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side .card:last-child { grid-column: 1 / -1; }
  .split-grid { grid-template-columns: 1fr; }
  .rule-cards { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; gap: 22px; }
  .footer-links { flex-direction: row; flex-wrap: wrap; gap: 16px; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 18px; }
  .site-nav { display: none; }
  .header-inner { height: 60px; }
  .header-tools { margin-left: auto; }
  .section { padding-top: 44px; padding-bottom: 44px; }
  .section-head { gap: 12px; margin-bottom: 22px; }
  .section-lede { font-size: 14.5px; }
  .hero h1 { max-width: none; }
  .facts { gap: 24px; }
  .panel { padding: 18px 15px 20px; }
  .value-input { font-size: 19px; }
  .mask-row { grid-template-columns: 1fr; gap: 0; }
  .readout { grid-template-columns: 1fr 1fr; }
  .readout div.wide { grid-column: span 2; }
  .side { grid-template-columns: 1fr; }
  .presets { grid-template-columns: 1fr; }
  .bit-row { gap: 8px; }
  .compare-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .doc { padding: 36px 0 54px; }
  .art-block { transform: none; }
}
@media (max-width: 460px) {
  .seg button { padding: 6px 10px; font-size: 11.5px; }
  .actions .btn.primary { flex: 1 1 100%; }
  .format-table th, .format-table td { padding: 8px 8px; font-size: 12px; }
  .bit-cells i { font-size: 9px; height: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- spacing helpers used by the markup ---------- */

.card-snip { margin-top: 18px; }
.label-flush { margin-bottom: 0; }
.field-first { margin-top: 0; }
.range-close { margin-top: 6px; }
.label-gap { margin-top: 16px; }

/* ---------- the four tabs (Unit) ---------- */

.tool-shell { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 20px 22px 24px; box-shadow: var(--shadow); position: relative; }
.tool-shell > * { position: relative; z-index: 1; }
.tabbar { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: thin; }
.tabbar button {
  flex: 1 1 0; min-width: max-content; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent; border: 0; border-radius: 10px; padding: 10px 14px;
  font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.tabbar button:hover { color: var(--ink); }
.tabbar button.is-on { background: var(--accent-soft); color: var(--ink); box-shadow: var(--shadow-sm); }
.tabbar .t-num { font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: 0.08em; }
.tabbar button.is-on .t-num { color: var(--accent); }
html[data-theme="dark"] .tabbar button.is-on { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent); }

.tabpanel { display: grid; gap: 18px; }
.tabpanel[hidden] { display: none !important; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.panel-head h2 { font-size: clamp(1.25rem, 2vw, 1.55rem); }
.panel-head p { font-size: 13.5px; color: var(--ink-3); max-width: 60ch; margin-top: 6px; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.two-col > * { min-width: 0; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.subpanel { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.subpanel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.subpanel-head b { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.subpanel-head span { font-size: 11.5px; color: var(--ink-3); }

.inp-grid { display: grid; grid-template-columns: minmax(0, 1fr) 132px; gap: 10px; align-items: end; }
.inp-grid.wide-unit { grid-template-columns: minmax(0, 1fr) 160px; }
.inp-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(0, 1fr); }
.mini-label { display: block; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }

.num-input, .unit-select {
  width: 100%; height: 42px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
  color: var(--ink); font-family: var(--mono); font-size: 16px;
}
.num-input { font-variant-numeric: tabular-nums; }
.num-input:focus, .unit-select:focus { outline: none; border-color: var(--accent); }
.num-input.is-bad { border-color: var(--hot); color: var(--hot); }
.unit-select { appearance: none; cursor: pointer; font-size: 13px; padding-right: 30px; background-image: none; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 6px; height: 6px; pointer-events: none;
  border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3);
  transform: translateY(-70%) rotate(45deg);
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chips button {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px;
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); padding: 5px 11px; cursor: pointer;
}
.chips button:hover { border-color: var(--accent); color: var(--ink); }
.chips button.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.note { margin-top: 10px; font-size: 12px; color: var(--ink-3); line-height: 1.55; }
.note.is-bad { color: var(--hot); }
.note code { font-family: var(--mono); font-size: 0.94em; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }

.res-table { display: grid; gap: 1px; margin-top: 14px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.res-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; align-items: center; gap: 10px; background: var(--surface); padding: 10px 13px; }
.res-row .tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; color: var(--ink-3); text-transform: uppercase; }
.res-row .val { font-family: var(--mono); font-size: 15px; color: var(--ink); overflow-wrap: anywhere; }
.res-row.is-primary { background: var(--accent-soft); }
.res-row.is-primary .val { color: var(--ink); font-weight: 600; }
.res-row .sub { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.copy-mini {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px;
  background: transparent; border: 1px solid var(--line-2); color: var(--ink-3); cursor: pointer;
}
.copy-mini:hover { color: var(--ink); border-color: var(--ink-3); }
.copy-mini svg { width: 13px; height: 13px; }





@media (max-width: 1080px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
  .inp-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .tool-shell { padding: 16px 13px 18px; border-radius: 16px; }
  .tabbar { flex-wrap: wrap; overflow: visible; }
  .tabbar button { flex: 1 1 42%; padding: 9px 10px; font-size: 12px; }
  .tabbar .t-num { display: none; }
  .inp-grid, .inp-grid.wide-unit { grid-template-columns: minmax(0, 1fr) 112px; }
  .inp-grid.three { grid-template-columns: 1fr; }
  .res-row { grid-template-columns: 62px minmax(0, 1fr) auto; gap: 6px; padding: 9px 10px; }
  .res-row .val { font-size: 13px; }
}

/* ---------- spacing utilities (inline style attributes are barred by the CSP) ---------- */

.mt-0 { margin-top: 0; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.field-flush { margin-top: 0; }
.field-block { display: block; margin-top: 10px; }
.panel-actions { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }

.res-table.wide-tags .res-row { grid-template-columns: 104px minmax(0, 1fr) auto; }
@media (max-width: 760px) {
  .res-table.wide-tags .res-row { grid-template-columns: 88px minmax(0, 1fr) auto; }
}

/* ---------- the epoch card in the hero ---------- */

.art-epoch { transform: rotate(0.6deg); }
.art-epoch .art-foot { gap: 6px 12px; }
.art-epoch .art-foot span { font-size: 9px; letter-spacing: 0.03em; }
.art-frac { margin: 0 0 4px; font-size: 11.5px; letter-spacing: 0.02em; color: var(--ink-3); }
.art-frac b { font-weight: 500; color: var(--accent); }
.art-frac span { margin-left: 4px; font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; }
.art-rows dd { text-align: right; }
.art-scale { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin: 2px 0 12px; }
.art-scale i { height: 18px; border-radius: 2px; background: var(--bit-off); }
.art-scale i.on { background: var(--accent); }
html[data-theme="dark"] .art-scale i { background: #2c3435; }
html[data-theme="dark"] .art-scale i.on { background: var(--accent); }

/* ---------- the clock ---------- */

.state-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft); border-radius: 999px; padding: 5px 11px;
}
.state-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.state-pill.is-paused { color: var(--ink-3); background: var(--surface-2); border-color: var(--line-2); }
.state-pill.is-bad {
  color: var(--hot); background: var(--hot-soft);
  border-color: color-mix(in srgb, var(--hot) 42%, transparent);
}

.clock-face {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 22px 18px; margin-bottom: 16px;
}
.clock-label {
  display: block; margin-bottom: 6px;
  font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3);
}
.clock-line { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.clock-digits {
  font-size: clamp(2rem, 6.2vw, 4rem); font-weight: 500; letter-spacing: -0.035em; line-height: 1;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.clock-frac { font-size: clamp(1.1rem, 2.6vw, 1.45rem); color: var(--ink-3); padding-bottom: 6px; }
.clock-frac span { margin-left: 3px; }
.clock-frac #clockMs { color: var(--accent); }
.clock-face .btn { height: 38px; font-size: 12.5px; padding: 0 13px; }
.clock-face .actions { margin-top: 20px; }

/* ---------- the converter ---------- */

.inp-grid .btn { justify-self: start; }

/* ---------- the batch ---------- */

.batch-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
.batch-grid > * { min-width: 0; }
.batch-input {
  width: 100%; min-height: 196px; resize: vertical; display: block;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px;
  color: var(--ink); font-family: var(--mono); font-size: 12.5px; line-height: 1.75;
  padding: 11px 13px;
}
.batch-input:focus { outline: none; border-color: var(--accent); }
.batch-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.batch-scroll {
  max-height: 400px; max-width: 100%; overflow: auto;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
table.batch-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.batch-table th, .batch-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.batch-table thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600;
}
.batch-table td { font-family: var(--mono); color: var(--ink-2); }
.batch-table td.batch-in { color: var(--ink); max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.batch-table td.batch-num { color: var(--ink-3); width: 26px; }
.batch-table tbody tr:hover { background: var(--surface-2); }
.batch-table tr.is-bad td { color: var(--hot); }
.batch-table td.batch-fail { font-family: var(--sans); }
.batch-table td.batch-empty { font-family: var(--sans); color: var(--ink-3); text-align: center; padding: 26px 10px; }
.batch-exports { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- the code ---------- */

.snip-body pre { max-height: 320px; }

/* ---------- a clipboard fallback that never touches inline styles ---------- */

.copy-probe { position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 1080px) {
  .batch-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .clock-face { padding: 16px 15px 14px; }
  .clock-label { width: 100%; margin-bottom: 2px; }
  .clock-line { gap: 4px; }
  .clock-underline { padding-left: 0; }
  .batch-table th, .batch-table td { padding: 6px 7px; font-size: 11px; }
  .batch-table td.batch-in { max-width: 130px; }
  .snip-body pre { font-size: 11px; }
}

@media (max-width: 760px) {
  .clock-face .btn { height: 36px; font-size: 12px; }
}

/* ---------- the schema card in the hero ---------- */

.art-schema { transform: rotate(0.7deg); }
.art-schema .art-json,
.art-schema .art-out {
  margin: 0; font-family: var(--mono); font-size: 10.5px; line-height: 1.62;
  color: var(--ink-2); white-space: pre; overflow: hidden;
}
.art-schema .art-json { color: var(--ink); }
.art-schema .art-out { color: var(--ink-2); }
.art-schema .art-out b { font-weight: 500; color: var(--accent); }
.art-arrow {
  display: flex; align-items: center; gap: 9px; margin: 10px 0 9px;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
}
.art-arrow::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--line-2); }
.art-schema .art-foot span { font-size: 9px; letter-spacing: 0.04em; }

/* ---------- the two panes (input and output) ---------- */

.io-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.io-grid > * { min-width: 0; }

.code-area {
  width: 100%; min-height: 300px; resize: vertical; display: block;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px;
  color: var(--ink); font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  padding: 12px 13px; tab-size: 2;
}
.code-area.short { min-height: 264px; }
.code-area:focus { outline: none; border-color: var(--accent); }
.code-area.is-bad { border-color: var(--hot); }

.pane-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.kind-tabs { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; margin-bottom: 9px; }
.kind-tabs button {
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-2); padding: 5px 10px; cursor: pointer;
}
.kind-tabs button:hover { border-color: var(--accent); color: var(--ink); }
.kind-tabs button.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.kind-tabs .kind-tools { display: flex; gap: 5px; margin-left: auto; }

.code-wrap { position: relative; min-width: 0; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.code-out {
  margin: 0; padding: 13px 14px 16px; min-height: 300px; max-height: 460px; overflow: auto;
  font-family: var(--mono); font-size: 12px; line-height: 1.66; color: var(--ink);
  white-space: pre; tab-size: 2;
}
.code-out.is-empty { color: var(--ink-3); }

.found-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.found-chips .chip-static {
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 4px 10px; background: var(--surface);
}
.found-chips .chip-static b { color: var(--accent); font-weight: 500; }
.found-empty { font-size: 12.5px; color: var(--ink-3); }

/* ---------- the validator result ---------- */

.val-summary { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; margin-bottom: 12px; }
.val-summary .val-count { font-family: var(--mono); font-size: 22px; font-weight: 500; color: var(--ink); }
.val-summary .val-count.is-bad { color: var(--hot); }
.val-summary .val-count.is-ok { color: var(--ok); }
.val-summary .val-word { font-size: 12.5px; color: var(--ink-3); }
.val-list {
  display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden auto; max-height: 460px;
}
.val-row { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 2px 10px; background: var(--surface); padding: 9px 12px; }
.val-row.is-bad { background: var(--hot-soft); }
.val-row.is-ok { background: var(--surface); }
.val-badge {
  grid-row: 1 / span 2; align-self: center; text-align: center;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  border-radius: 999px; padding: 3px 0;
}
.val-badge.ok { color: var(--ok); background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 34%, transparent); }
.val-badge.bad { color: var(--hot); background: var(--surface); border: 1px solid color-mix(in srgb, var(--hot) 44%, transparent); }
.val-path { font-family: var(--mono); font-size: 11.5px; color: var(--ink); overflow-wrap: anywhere; }
.val-row.is-bad .val-path { color: var(--hot); }
.val-msg { font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.val-empty { padding: 22px 14px; text-align: center; font-size: 12.5px; color: var(--ink-3); background: var(--surface); }
.val-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }

/* ---------- the presets ---------- */

.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.preset-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; text-align: left;
}
.preset-card h3 { font-size: 16px; }
.preset-card p { font-size: 13px; color: var(--ink-2); }
.preset-meta { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.06em; }
.preset-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }

/* ---------- the options ---------- */

.opt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.opt-field { display: block; margin-bottom: 10px; }
.opt-field:last-child { margin-bottom: 0; }
.switch-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.switch-row:first-of-type { border-top: 0; padding-top: 0; }
.switch-row input[type="checkbox"] {
  appearance: none; width: 34px; height: 20px; border-radius: 999px; margin: 2px 0 0;
  background: var(--line-2); border: 1px solid var(--line-2); position: relative; cursor: pointer; flex: 0 0 auto;
  transition: background 0.15s, border-color 0.15s;
}
.switch-row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--surface); transition: transform 0.15s;
}
.switch-row input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(14px); }
.switch-row label { font-size: 13.5px; color: var(--ink); cursor: pointer; }
.switch-row .switch-hint { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }

@media (max-width: 1080px) {
  .io-grid { grid-template-columns: 1fr; }
  .preset-grid { grid-template-columns: 1fr; }
  .opt-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .code-area { min-height: 200px; font-size: 11.5px; }
  .code-area.short { min-height: 180px; }
  .code-out { min-height: 200px; font-size: 11px; }
  .art-schema .art-json, .art-schema .art-out { font-size: 9.5px; }
  .val-row { grid-template-columns: 58px minmax(0, 1fr); padding: 8px 10px; }
  .kind-tabs .kind-tools { margin-left: 0; width: 100%; }
}

/* Korean and Japanese set their own word spacing: the wide tracking that suits
   a Latin upper-case label tears a Korean phrase into pieces. */
html[lang="ko"] .eyebrow,
html[lang="ko"] .subpanel-head b,
html[lang="ko"] .mini-label,
html[lang="ko"] .art-tag,
html[lang="ko"] .state-pill,
html[lang="ko"] .val-badge,
html[lang="ko"] .card-label { letter-spacing: 0.03em; }
html[lang="ja"] .eyebrow,
html[lang="ja"] .subpanel-head b,
html[lang="ja"] .mini-label,
html[lang="ja"] .art-tag,
html[lang="ja"] .state-pill,
html[lang="ja"] .val-badge,
html[lang="ja"] .card-label { letter-spacing: 0.06em; }

/* =========================================================================
   48호기 Pikkola Grid: the layout lab
   ---------------------------------------------------------------------- */

/* graph paper: the page sits on a measured sheet, faint enough to stay quiet */
body::before {
  background:
    radial-gradient(760px 480px at 88% -8%, rgba(31, 58, 95, 0.10), transparent 70%),
    repeating-linear-gradient(0deg, rgba(31, 58, 95, 0.055) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(31, 58, 95, 0.055) 0 1px, transparent 1px 28px);
}
html[data-theme="dark"] body::before {
  background:
    radial-gradient(760px 480px at 88% -8%, rgba(157, 192, 224, 0.10), transparent 70%),
    repeating-linear-gradient(0deg, rgba(157, 192, 224, 0.055) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(157, 192, 224, 0.055) 0 1px, transparent 1px 28px);
}

.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 44px; align-items: center; }
@media (max-width: 960px) { .hero-grid { grid-template-columns: 1fr; gap: 30px; } }

/* ---------- the hero wireframe ---------- */

.art-layout {
  width: min(420px, 100%);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 14px 12px; box-shadow: var(--shadow); transform: rotate(0.5deg);
}
@media (max-width: 1080px) { .hero-art { order: 0; } }
.art-layout .art-head { margin-bottom: 10px; }
.art-ruler { display: flex; gap: 4px; margin-bottom: 6px; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.06em; color: var(--ink-3); }
.art-ruler span { flex: 1 1 0; text-align: center; border-top: 1px solid var(--line-2); padding-top: 3px; }
.art-ruler span.wide { flex: 3 1 0; }
.wire { display: grid; gap: 5px; height: 236px; }
.wire i {
  position: relative; display: flex; align-items: flex-start;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px dashed color-mix(in srgb, var(--accent) 46%, transparent);
  border-radius: 4px; padding: 4px 5px;
  font-family: var(--mono); font-style: normal; font-size: 9px; letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--accent) 88%, var(--ink)); overflow: hidden;
}
.wire i.is-solid { background: color-mix(in srgb, var(--accent) 17%, var(--surface)); border-style: solid; }
.wire-dashboard { grid-template-columns: 62px 1fr; grid-template-rows: 26px 1fr; }
.wire-dashboard i:nth-child(1) { grid-row: 1 / span 2; }
.wire-bento { grid-template-columns: 1.5fr 1fr 1fr; grid-template-rows: 1fr 1fr; }
.wire-bento i:nth-child(1) { grid-row: 1 / span 2; }
.wire-bento i:nth-child(4) { grid-column: 2 / span 2; }
.wire-grail { grid-template-columns: 44px 1fr 54px; grid-template-rows: 22px 1fr 20px; }
.wire-grail i:nth-child(1), .wire-grail i:nth-child(5) { grid-column: 1 / span 3; }
.wire-twelve { grid-template-columns: repeat(4, 1fr); grid-template-rows: 1.5fr 1fr 0.55fr; }
.wire-twelve i:nth-child(1) { grid-column: 1 / span 2; grid-row: 1 / span 2; }
.wire-twelve i:nth-child(6) { grid-column: 1 / span 4; }
.wire-centre { grid-template-columns: 1fr; grid-template-rows: 1fr 22px 22px 1fr; }
.wire-centre i:nth-child(1), .wire-centre i:nth-child(4) { border-style: none; background: transparent; }
.wire-centre i:nth-child(2) { width: 68%; margin: 0 auto; }
.wire-centre i:nth-child(3) { width: 46%; margin: 0 auto; }
.art-layout .art-foot { margin-top: 10px; }

/* ---------- the lab shell ---------- */

.lab { display: grid; gap: 12px; }
.lab > * { min-width: 0; }
.lab-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 13px;
}
.lab-bar .spacer { flex: 1 1 40px; }
.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.seg button {
  border: 0; background: transparent; border-radius: 7px; padding: 6px 11px;
  font-size: 12px; line-height: 1; color: var(--ink-2); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.is-on { background: var(--ink); color: var(--bg); }
.seg button svg { width: 13px; height: 13px; }
.seg-label {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-3); margin-right: 2px;
}
.lab-body { display: grid; grid-template-columns: 336px minmax(0, 1fr); gap: 12px; align-items: start; }
.lab-body > * { min-width: 0; }
.controls { display: grid; gap: 10px; }

.control-group {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 13px; padding: 13px 13px 14px;
}
.control-group > h3 {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600; margin: 0;
}
.control-group > h3 .cg-hint { font-family: var(--mono); font-size: 9px; letter-spacing: 0.04em; text-transform: none; }
.cg-body { display: grid; gap: 9px; margin-top: 11px; }
.count-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.count-row .mini-label { margin: 0; }
.stepper { display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.stepper button {
  width: 28px; height: 28px; border: 0; background: transparent; cursor: pointer;
  font-family: var(--mono); font-size: 13px; color: var(--ink-2); line-height: 1;
}
.stepper button:hover { background: var(--surface-2); color: var(--ink); }
.stepper button:disabled { color: var(--line-2); cursor: default; }
.stepper .n { min-width: 28px; text-align: center; font-family: var(--mono); font-size: 11.5px; color: var(--ink); border-left: 1px solid var(--line); border-right: 1px solid var(--line); line-height: 28px; }

.track-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; max-height: 152px; overflow: auto; padding-right: 2px; }
.track-field {
  display: flex; align-items: center; gap: 4px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 2px 5px 2px 6px;
}
.track-field span { flex: 0 0 auto; font-family: var(--mono); font-size: 9px; color: var(--ink-3); }
.track-field input {
  width: 100%; min-width: 0; border: 0; background: transparent; color: var(--ink);
  font-family: var(--mono); font-size: 11px; padding: 4px 0;
}
.track-field input:focus { outline: none; }
.track-field:focus-within { border-color: var(--accent); }
.track-field.is-bad { border-color: var(--hot); }

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.field-row .mini-label { margin-bottom: 4px; }
.field-row .unit-select, .field-row .num-input { height: 32px; font-size: 12px; }
.gap-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.link-toggle {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 9px;
  font-size: 11.5px; color: var(--ink-3); cursor: pointer;
}
.link-toggle input { accent-color: var(--accent); width: 14px; height: 14px; }

/* ---------- the selected cell ---------- */

.sel-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  padding: 12px; display: grid; gap: 9px;
}
.sel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sel-head b { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.sel-head .mono { font-size: 10px; color: var(--ink-3); }
.sel-empty { font-size: 12px; color: var(--ink-3); line-height: 1.55; }
.sel-readout {
  font-family: var(--mono); font-size: 10.5px; line-height: 1.6; color: var(--accent);
  background: var(--accent-soft); border-radius: 7px; padding: 6px 8px; overflow-wrap: anywhere;
}
.span-field { display: grid; grid-template-columns: 1fr 46px; gap: 6px; align-items: center; }
.span-field .mini-label { margin: 0; }
.name-input {
  width: 100%; height: 32px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-family: var(--mono); font-size: 12px; padding: 0 9px;
}
.name-input:focus { outline: none; border-color: var(--accent); }
.sel-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sel-panel .name-input { height: 42px; font-size: 13px; }

/* ---------- the preview ---------- */

.preview-wrap {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px;
  padding: 11px; display: grid; gap: 9px; align-content: start;
}
@media (min-width: 1081px) {
  .preview-wrap { position: sticky; top: 78px; }
}
.pv-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.pv-head .pv-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.pv-head .pv-size { font-family: var(--mono); font-size: 10px; color: var(--accent); }
.pv-frame {
  position: relative; display: grid; place-items: center; overflow: hidden;
  height: 440px; border: 1px solid var(--line-2); border-radius: 10px;
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(0deg, rgba(31, 58, 95, 0.09) 0 1px, transparent 1px 20px),
    repeating-linear-gradient(90deg, rgba(31, 58, 95, 0.09) 0 1px, transparent 1px 20px);
}
html[data-theme="dark"] .pv-frame {
  background-image:
    repeating-linear-gradient(0deg, rgba(157, 192, 224, 0.10) 0 1px, transparent 1px 20px),
    repeating-linear-gradient(90deg, rgba(157, 192, 224, 0.10) 0 1px, transparent 1px 20px);
}
.pv-stage { position: relative; flex: 0 0 auto; transform-origin: center center; }
.pv-canvas { display: flex; width: 100%; height: 100%; padding: 13px; }
.pv-layout { flex: 1 1 auto; min-width: 0; }
.pv-cell {
  position: relative; display: flex; flex-direction: column; gap: 3px; justify-content: flex-start;
  min-width: 0; min-height: 26px; overflow: hidden; text-align: left;
  padding: 6px 8px; border-radius: 8px;
  border: 1px dashed color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  color: var(--ink); font: inherit; cursor: pointer;
  transition: border-color 0.14s, background 0.14s, color 0.14s;
}
.pv-cell:hover { border-color: var(--accent); }
.pv-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pv-cell .cell-name {
  font-size: 12px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pv-cell .cell-tag { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.04em; color: var(--ink-3); }
.pv-cell.is-sel { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); }
.pv-cell.is-sel .cell-tag { color: color-mix(in srgb, var(--accent-ink) 76%, transparent); }
.pv-cell.is-named { border-style: solid; background: color-mix(in srgb, var(--accent) 11%, var(--surface)); }
.pv-cell.is-named.is-sel { background: var(--accent); }
.pv-empty { display: grid; place-items: center; min-height: 120px; font-size: 12px; color: var(--ink-3); }

.pv-readout {
  display: flex; gap: 4px 12px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 10px; color: var(--ink-3); line-height: 1.6;
}
.pv-readout b { color: var(--ink); font-weight: 500; }
.pv-note { font-size: 11px; color: var(--ink-3); }
.pv-note.is-bad { color: var(--hot); }

/* ---------- the presets ---------- */

.preset-strip { display: flex; gap: 5px; flex-wrap: wrap; }
.preset-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 11px 5px 9px; font-size: 11.5px; color: var(--ink-2); cursor: pointer;
}
.preset-chip:hover { border-color: var(--accent); color: var(--ink); }
.preset-chip.is-on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--ink); }
.preset-chip .n { font-family: var(--mono); font-size: 9px; color: var(--ink-3); }

.preset-card .wire { height: 92px; margin-bottom: 4px; }
.preset-card .wire i { font-size: 0; }

/* ---------- the code ---------- */

.code-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.code-bar .kind-tabs { margin-bottom: 0; flex: 1 1 auto; }
.code-out.tall { min-height: 340px; max-height: 540px; }

/* ---------- the property table ---------- */

.prop-table { margin-top: 22px; overflow-x: auto; }
.prop-table table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.prop-table th:nth-child(1), .prop-table td:nth-child(1) { width: 25%; }
.prop-table th:nth-child(3), .prop-table td:nth-child(3) { width: 25%; }
.prop-table caption { text-align: left; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); padding-bottom: 10px; }
.prop-table th, .prop-table td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.prop-table thead th { border-top: 0; border-bottom: 1px solid var(--line-2); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.prop-table td:first-child { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.prop-table td:last-child { font-family: var(--mono); font-size: 11.5px; color: var(--accent); overflow-wrap: anywhere; }
.prop-table td { color: var(--ink-2); }
.prop-table tbody tr:hover { background: var(--surface-2); }

/* ---------- media ---------- */

@media (max-width: 1080px) {
  .lab-body { grid-template-columns: 1fr; }
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls .control-group:first-child, .controls .sel-panel { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .lab-bar { padding: 8px; gap: 6px; }
  .seg button { padding: 6px 9px; font-size: 11.5px; }
  .seg-label { display: none; }
  .lab-body { gap: 10px; }
  .controls { grid-template-columns: 1fr; }
  .pv-frame { height: 400px; }
  .track-list { max-height: 132px; }
  .prop-table td:last-child { display: none; }
  .prop-table thead th:last-child { display: none; }
  .wire { height: 190px; }
}
