/* Pikkola Mermaid: warm paper, ink, one red pencil accent, and a studio that
   looks like a drafting table rather than a dashboard. Weights stay between 400
   and 700; the display face is a system serif in English and Pretendard in
   Korean and Japanese, where a serif fallback would look borrowed. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(/tools/mermaid/fonts/inter.woff2) format("woff2-variations");
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/tools/mermaid/fonts/newsreader.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/tools/mermaid/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;
  --display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --wrap: 1180px;
  --r: 8px;
  --r-sm: 4px;
  --header: 64px;
}

html[lang="ko"] {
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --display: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", 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;
  --display: "Newsreader", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", 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[data-theme="light"] {
  --bg: #f7f4ed;
  --bg-2: #efe9dd;
  --surface: #fdfbf6;
  --surface-2: #f4eee2;
  --surface-3: #eae2d3;
  --ink: #1b1812;
  --ink-2: #4e4639;
  --ink-3: #6d6354;
  --line: #ded5c5;
  --line-2: #c9bda6;
  --accent: #a63d2f;
  --accent-strong: #7d2a20;
  --accent-ink: #fff8f3;
  --accent-soft: #f5e3dd;
  --accent-soft-2: #ebcdc4;
  --ok: #3d6b4e;
  --ok-soft: #e4ecdd;
  --warn: #8a5a1f;
  --warn-soft: #f6e9d2;
  --dot: rgba(27, 24, 18, 0.13);
  --shadow: 0 1px 0 rgba(27, 24, 18, 0.04), 0 30px 60px -42px rgba(27, 24, 18, 0.55);
  --shade: rgba(27, 24, 18, 0.06);
  --funnel-bg: #1b1812;
  --funnel-ink: #f6f0e3;
  --funnel-line: rgba(246, 240, 227, 0.18);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #14120e;
  --bg-2: #1a1712;
  --surface: #1c1914;
  --surface-2: #231f18;
  --surface-3: #2b261d;
  --ink: #f3ecdd;
  --ink-2: #cbc1ae;
  --ink-3: #9b9080;
  --line: #352f25;
  --line-2: #4c4335;
  --accent: #e0795f;
  --accent-strong: #f0a48f;
  --accent-ink: #24100a;
  --accent-soft: #3a211b;
  --accent-soft-2: #4a2a22;
  --ok: #8fbf9a;
  --ok-soft: #22301f;
  --warn: #d7a55f;
  --warn-soft: #352a18;
  --dot: rgba(243, 236, 221, 0.1);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 30px 60px -40px rgba(0, 0, 0, 0.8);
  --shade: rgba(243, 236, 221, 0.05);
  --funnel-bg: #231f18;
  --funnel-ink: #f3ecdd;
  --funnel-line: rgba(243, 236, 221, 0.16);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--ink); }
h1 {
  font-family: var(--display);
  font-size: clamp(2.6rem, 5.75vw, 4.15rem);
  line-height: 1.0;
  letter-spacing: -0.012em;
  font-weight: 500;
  max-width: 22ch;
}
h2 {
  font-family: var(--display);
  font-size: clamp(1.7rem, 3.1vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: -0.008em;
  font-weight: 500;
  max-width: 24ch;
}
h3 { font-size: 1.02rem; line-height: 1.35; letter-spacing: -0.005em; }
p { margin: 0; }
a { color: inherit; }
img, svg { max-width: 100%; }
button { font: inherit; }
pre, code, textarea { font-family: var(--mono); }
[hidden] { display: none !important; }

::selection { background: var(--accent-soft-2); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 32px;
}

.mono { font-family: var(--mono); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 4px;
  text-decoration: none; font-size: 0.85rem;
}
.skip-link:focus { top: 10px; }

.eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  margin-bottom: 14px;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--header);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  flex: none;
}
.brand-mark { width: 27px; height: 27px; color: var(--accent); flex: none; }
.brand-name { font-weight: 600; letter-spacing: -0.01em; font-size: 1rem; }
.brand-tool {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  border-left: 1px solid var(--line-2);
  padding-left: 9px;
}
.site-nav {
  display: flex;
  gap: 22px;
  margin-left: 8px;
}
.site-nav a {
  text-decoration: none;
  font-size: 0.86rem;
  color: var(--ink-2);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }
.header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lang-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 6px 0 7px;
  height: 32px;
  background: var(--surface);
}
.lang-globe { width: 15px; height: 15px; color: var(--ink-3); }
.lang-field select {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 0.78rem;
  padding: 5px 2px;
  cursor: pointer;
}
.icon-btn {
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
.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.1fr) minmax(0, 0.9fr);
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
  padding-top: clamp(48px, 6vw, 84px);
  padding-bottom: clamp(52px, 6.5vw, 92px);
}
.hero-lede {
  margin-top: 22px;
  font-size: clamp(1rem, 1.3vw, 1.1rem);
  line-height: 1.66;
  color: var(--ink-2);
  max-width: 46ch;
}
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 30px 0 0;
  padding: 0;
}
.facts div {
  padding: 2px 20px;
  border-left: 1px solid var(--line);
}
.facts div:first-child { padding-left: 0; border-left: 0; }
.facts dt {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.facts dd {
  margin: 3px 0 0;
  font-size: 0.74rem;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}
.hero-note {
  margin-top: 26px;
  font-size: 0.7rem;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}

/* the plate card in the hero */

.plate-card {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  position: relative;
}
.plate-card::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  pointer-events: none;
  opacity: 0.55;
}
.plate-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  margin-bottom: 12px;
}
.plate-rule { flex: 1; height: 1px; background: var(--line); }
.plate-pips { display: inline-flex; gap: 4px; }
.plate-pips i { width: 5px; height: 5px; border-radius: 50%; background: var(--line-2); display: block; }
.plate-pips i:first-child { background: var(--accent); }
.plate-code {
  margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 11px 12px;
  font-size: 0.72rem;
  line-height: 1.75;
  color: var(--ink-2);
  overflow: hidden;
  white-space: pre;
}
.plate-draw { padding: 10px 4px 2px; }
.plate-draw svg { width: 100%; height: auto; display: block; }
.pnode { fill: var(--surface); stroke: var(--line-2); stroke-width: 1.3; }
.pnode-2 { fill: var(--accent-soft); stroke: var(--accent); }
.pnode-label {
  fill: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.pedge { fill: none; stroke: var(--ink-3); stroke-width: 1.4; }
.pedge-label {
  fill: var(--ink-3);
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.punderline { fill: none; stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 3 6; opacity: 0.45; }
.plate-caption {
  margin: 2px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-3);
}

/* --------------------------------------------------------------- section */

.section {
  padding: clamp(52px, 6.5vw, 88px) 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: calc(var(--header) + 12px);
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 30px;
}
.section-lede {
  max-width: 44ch;
  font-size: 0.92rem;
  color: var(--ink-3);
  line-height: 1.7;
  padding-bottom: 3px;
}
.section-head .eyebrow { margin-bottom: 10px; }

/* --------------------------------------------------------------- studio */

.preset-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
}
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  padding: 6px 11px;
  border-radius: 100px;
  font-size: 0.78rem;
  cursor: pointer;
  line-height: 1.4;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip.is-on {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft);
}
.chip-n { font-size: 0.62rem; color: var(--ink-3); letter-spacing: 0.06em; }
.chip.is-on .chip-n { color: var(--accent-strong); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 5px;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
html[data-theme="dark"] .btn.primary:hover { background: var(--accent-strong); color: #2a120c; }
.btn.small { padding: 7px 12px; font-size: 0.81rem; }
.btn.tiny { padding: 4px 9px; font-size: 0.73rem; border-radius: 4px; }
.btn.ghost { background: transparent; border-style: dashed; color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); }

.studio {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.studio-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.studio-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  padding: 3px 9px 3px 8px;
  border-radius: 100px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); display: block; }
.pill.is-ready .dot { background: var(--ink-3); }
.pill.is-ok { border-color: var(--ok); color: var(--ok); }
.pill.is-ok .dot { background: var(--ok); }
.pill.is-err { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); }
.pill.is-err .dot { background: var(--accent); }
.pill.is-rendering .dot { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.type-chip {
  font-size: 0.68rem;
  color: var(--ink-3);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--surface);
  text-transform: lowercase;
}
.meta-sep { width: 1px; height: 14px; background: var(--line); }
.meta-note { font-size: 0.66rem; color: var(--ink-3); }

.studio-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.field { display: inline-flex; align-items: center; gap: 7px; }
.mini {
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.select-wrap { position: relative; display: inline-flex; }
.select-wrap::after {
  content: "";
  position: absolute; right: 8px; top: 50%;
  width: 5px; height: 5px;
  border-right: 1.2px solid var(--ink-3);
  border-bottom: 1.2px solid var(--ink-3);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 4px;
  font-size: 0.76rem;
  padding: 4px 22px 4px 8px;
  cursor: pointer;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.45fr);
  min-height: 560px;
}
.pane { display: flex; flex-direction: column; min-width: 0; }
.pane-source { border-right: 1px solid var(--line); }
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  min-height: 42px;
}
.pane-head h3 {
  font-family: var(--mono);
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  font-weight: 500;
}
.pane-actions { display: flex; gap: 4px; }

/* the editor */

.editor {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 380px;
  background: var(--surface);
  overflow: hidden;
}
.gutter {
  position: relative;
  z-index: 2;
  width: 46px;
  padding: 14px 0;
  text-align: right;
  font-size: 0.72rem;
  line-height: 22px;
  color: var(--ink-3);
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  overflow: hidden;
  user-select: none;
  transition: transform 0.04s linear;
}
.gutter span { display: block; height: 22px; padding-right: 8px; }
.gutter span.is-marked { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.band {
  position: absolute;
  left: 0;
  right: 0;
  top: 14px;
  height: 22px;
  background: var(--accent-soft);
  border-top: 1px solid var(--accent-soft-2);
  border-bottom: 1px solid var(--accent-soft-2);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}
.band.is-on { opacity: 0.85; }

textarea.code {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-height: 380px;
  margin: 0;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  padding: 14px 16px;
  font-size: 0.8rem;
  line-height: 22px;
  tab-size: 2;
  outline: none;
  overflow: auto;
  white-space: pre;
  caret-color: var(--accent);
}
textarea.code::placeholder { color: var(--ink-3); }

.pane-foot {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 9px 12px 10px;
  max-height: 148px;
  overflow: auto;
}
.diag-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin-bottom: 5px;
}
.diag-head span:first-child { font-family: var(--mono); }
.diag-list { display: flex; flex-direction: column; gap: 2px; }
.diag { display: flex; align-items: baseline; gap: 7px; font-size: 0.79rem; color: var(--ink-2); line-height: 1.5; }
.diag.is-error { color: var(--accent-strong); }
.diag-line {
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: inherit;
  border-radius: 3px;
  font-size: 0.64rem;
  padding: 0 4px;
  cursor: pointer;
  flex: none;
}
.diag-line:hover { border-color: var(--ink-3); }
.diag-clean { font-size: 0.79rem; color: var(--ink-3); }

/* the plate */

.pane-plate { background: var(--surface); }
.zoom-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
}
.zoom-btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  width: 27px;
  height: 25px;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}
.zoom-btn:hover { background: var(--surface-2); color: var(--ink); }
.zoom-btn + .zoom-btn { border-left: 1px solid var(--line); }
.zoom-pct { width: 50px; font-size: 0.66rem; letter-spacing: -0.01em; }
.zoom-fit svg { width: 14px; height: 14px; }

.notice {
  margin: 10px 12px 0;
  border: 1px solid var(--accent);
  border-left-width: 3px;
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 9px 11px;
}
.notice.is-entering { animation: noticeIn 0.22s ease-out; }
@keyframes noticeIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.notice-title { font-size: 0.84rem; font-weight: 600; color: var(--accent-strong); }
.notice-hint { font-size: 0.8rem; color: var(--ink-2); margin-top: 2px; }
.notice-snippet {
  display: block;
  margin-top: 7px;
  padding: 5px 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 0.71rem;
  color: var(--ink-2);
  white-space: pre;
  overflow-x: auto;
}
.notice-more { margin-top: 5px; }
.notice-more summary { font-size: 0.68rem; color: var(--ink-3); cursor: pointer; }
.notice-more pre {
  margin: 6px 0 0;
  max-height: 160px;
  overflow: auto;
  font-size: 0.64rem;
  line-height: 1.6;
  color: var(--ink-3);
  white-space: pre-wrap;
}

.canvas {
  position: relative;
  flex: 1;
  min-height: 400px;
  overflow: hidden;
  background-color: var(--surface-2);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 18px 18px;
  background-position: -9px -9px;
  cursor: grab;
  touch-action: none;
}
.canvas.is-dragging { cursor: grabbing; }
.stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.host { transition: opacity 0.2s ease, filter 0.2s ease; }
.stage { transform-origin: 0 0; }
.host svg { display: block; }
.canvas.is-stale .host { opacity: 0.32; filter: saturate(0.5); }
.empty {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  text-align: center;
  padding: 28px;
  pointer-events: none;
}
.empty h3 { font-size: 0.98rem; }
.empty p { font-size: 0.82rem; color: var(--ink-3); max-width: 38ch; line-height: 1.6; }
.plate-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  font-size: 0.65rem;
  color: var(--ink-3);
  background: var(--surface);
  min-height: 32px;
}
.plate-foot #captionDims { color: var(--ink-2); }

.studio-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 11px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.action-note { margin-left: auto; color: var(--ink-3); font-size: 0.64rem; letter-spacing: 0.04em; }

/* --------------------------------------------------------------- plates */

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.preset-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 16px 16px 14px;
  transition: border-color 0.16s, transform 0.16s;
}
.preset-card:hover { border-color: var(--line-2); }
.card-num {
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.preset-card h3 { font-size: 0.96rem; }
.preset-card p { font-size: 0.81rem; color: var(--ink-3); line-height: 1.6; flex: 1; }
.preset-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.preset-meta { font-size: 0.62rem; color: var(--ink-3); text-transform: lowercase; }

/* --------------------------------------------------------------- syntax */

.syntax-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.syntax-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 2px solid var(--ink);
  border-radius: 0 0 5px 5px;
  background: var(--surface);
}
.syntax-card header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.syntax-card header h3 { font-size: 0.98rem; }
.syntax-card header .mono { font-size: 0.62rem; color: var(--ink-3); }
.syntax-card p { font-size: 0.81rem; color: var(--ink-3); line-height: 1.6; }
.mini-code {
  margin: 2px 0 4px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.71rem;
  line-height: 1.7;
  color: var(--ink-2);
  overflow-x: auto;
  white-space: pre;
  flex: 1;
}
.syntax-card .btn { align-self: flex-start; }
.syntax-more {
  margin-top: 18px;
  font-size: 0.82rem;
  color: var(--ink-3);
  max-width: 88ch;
  line-height: 1.7;
}

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

.rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px;
}
.rule-card { border-top: 2px solid var(--ink); padding-top: 14px; }
.rule-num { display: block; font-size: 0.64rem; letter-spacing: 0.14em; color: var(--accent); margin-bottom: 10px; }
.rule-card h3 { font-family: var(--display); font-size: 1.3rem; font-weight: 500; letter-spacing: -0.006em; margin-bottom: 8px; }
.rule-card p { font-size: 0.86rem; color: var(--ink-2); line-height: 1.7; }

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

.faq { max-width: 860px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq details:first-child { border-top: 1px solid var(--line); }
.faq summary {
  cursor: pointer;
  padding: 15px 30px 15px 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
  position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 13px;
  font-family: var(--mono);
  color: var(--ink-3);
  font-weight: 400;
}
.faq details[open] summary::after { content: "−"; color: var(--accent); }
.faq details p { font-size: 0.87rem; color: var(--ink-2); line-height: 1.72; padding: 0 40px 17px 0; }

/* --------------------------------------------------------------- funnel */

.funnel {
  background: var(--funnel-bg);
  color: var(--funnel-ink);
  padding: clamp(44px, 5.5vw, 64px) 0;
  border-top: 1px solid var(--line);
}
.funnel-head {
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  opacity: 0.62;
  margin-bottom: 18px;
}
.funnel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.funnel-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 20px;
  border: 1px solid var(--funnel-line);
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  transition: background 0.16s, border-color 0.16s;
}
.funnel-card:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.34); }
html[data-theme="dark"] .funnel-card:hover { background: rgba(255, 255, 255, 0.03); }
.funnel-kicker { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.14em; opacity: 0.6; }
.funnel-title { font-family: var(--display); font-size: 1.42rem; font-weight: 500; letter-spacing: -0.015em; line-height: 1.2; }
.funnel-sub { font-size: 0.84rem; opacity: 0.72; line-height: 1.6; max-width: 44ch; }
.funnel-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.funnel-price { font-family: var(--mono); font-size: 0.9rem; }
.funnel-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--funnel-line);
  padding-bottom: 2px;
}
.funnel-arrow { width: 15px; height: 15px; }
.funnel-arrow path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

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

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.rel-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.16s, transform 0.16s;
}
.rel-card:hover { border-color: var(--accent); }
.rel-kicker { font-size: 0.64rem; color: var(--ink-3); }
.rel-card h3 { font-size: 0.98rem; }
.rel-card p { font-size: 0.81rem; color: var(--ink-3); line-height: 1.6; flex: 1; }
.rel-open { font-size: 0.76rem; color: var(--accent); margin-top: 4px; }
.rel-card:hover .rel-open { text-decoration: underline; }

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

.site-footer {
  border-top: 1px solid var(--line);
  padding: 36px 0 40px;
  background: var(--surface-2);
}
.footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.footer-brand .brand-name { font-size: 0.98rem; }
.footer-brand .brand-tool { font-size: 0.68rem; }
.footer-tagline { margin-top: 10px; font-size: 0.82rem; color: var(--ink-2); max-width: 42ch; line-height: 1.65; }
.footer-note { margin-top: 6px; font-size: 0.66rem; color: var(--ink-3); }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: flex-end;
  font-size: 0.8rem;
}
.footer-links a { color: var(--ink-2); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }
.footer-legal {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--ink-3);
}

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(12px);
  z-index: 80;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 5px;
  font-size: 0.82rem;
  max-width: min(520px, calc(100vw - 32px));
  box-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-on { opacity: 1; transform: none; }
.clip-fallback { position: fixed; left: -4000px; top: 0; opacity: 0; }
.noscript { padding: 20px 0 40px; font-size: 0.85rem; color: var(--ink-3); }

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

.page-main { padding: clamp(40px, 5vw, 64px) 0 clamp(56px, 6vw, 88px); }
.page-main .eyebrow { margin-bottom: 12px; }
.page-main h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.1rem);
  line-height: 1.03;
  max-width: 22ch;
  margin-bottom: 18px;
}
.page-lede {
  font-size: 1rem;
  color: var(--ink-2);
  max-width: 62ch;
  line-height: 1.7;
  margin-bottom: 34px;
}
.prose { max-width: 700px; }
.page-meta { font-size: 0.68rem; color: var(--ink-3); letter-spacing: 0.04em; margin: -8px 0 20px; }
.page-foot { margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 0.86rem; }
.page-foot a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft-2); padding-bottom: 1px; }
.page-foot a:hover { border-bottom-color: var(--accent); }
.prose h2 {
  font-family: var(--sans);
  font-size: 1.12rem;
  letter-spacing: -0.005em;
  font-weight: 600;
  margin: 32px 0 9px;
  max-width: none;
}
.prose h3 { font-size: 0.96rem; margin: 22px 0 6px; }
.prose p, .prose li { font-size: 0.9rem; color: var(--ink-2); line-height: 1.75; }
.prose ul { padding-left: 20px; margin: 8px 0; }
.prose li { margin: 4px 0; }
.prose a { color: var(--accent); }
.prose code { font-size: 0.82em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px; }
.prose .lede-block { margin-bottom: 8px; }

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

@media (max-width: 1080px) {
  .preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .syntax-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule-grid { gap: 18px; }
}

@media (max-width: 940px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 40px; padding-top: 44px; }
  .plate-card { max-width: 560px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .section-lede { max-width: 60ch; }
  .studio-grid { grid-template-columns: minmax(0, 1fr); }
  .pane-source { border-right: 0; }
  .pane-plate { order: -1; border-bottom: 1px solid var(--line); }
  .editor { min-height: 300px; }
  textarea.code { min-height: 300px; }
  .canvas { min-height: 380px; }
  .rule-grid { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .funnel-grid { grid-template-columns: minmax(0, 1fr); }
  .related-grid { grid-template-columns: minmax(0, 1fr); }
  .footer-inner { grid-template-columns: minmax(0, 1fr); }
  .footer-links { justify-content: flex-start; }
}

@media (max-width: 720px) {
  .wrap { padding: 0 20px; }
  .site-nav { display: none; }
  .header-inner { gap: 12px; }
  .brand-tool { display: none; }
  .preset-grid, .syntax-grid { grid-template-columns: minmax(0, 1fr); }
  .preset-strip { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
  .preset-strip .chip { flex: none; }
  .studio-tools { width: 100%; justify-content: space-between; }
  .studio-actions .btn { flex: 1 1 calc(50% - 7px); }
  .action-note { display: none; }
  .facts div { padding: 2px 14px; }
}

@media (max-width: 420px) {
  .wrap { padding: 0 16px; }
  h1 { font-size: clamp(2.1rem, 10.6vw, 2.7rem); }
  .hero-lede { font-size: 0.95rem; }
  .facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
  .facts div { padding: 0 8px 0 10px; }
  .facts div:first-child { padding-left: 0; }
  .facts dt { font-size: 0.8rem; }
  .facts dd { font-size: 0.66rem; line-height: 1.45; }
  .preset-strip { gap: 6px; }
  .chip { font-size: 0.74rem; padding: 6px 9px; }
  .studio-bar { padding: 9px 10px; }
  .meta-note, .meta-sep { display: none; }
  .pane-head { padding: 7px 10px; }
  .diag-head { font-size: 0.58rem; }
  .stage, .host { max-width: none; }
  .zoom-pct { width: 44px; }
  .funnel-card { padding: 16px; }
  .funnel-title { font-size: 1.22rem; }
  .toast { left: 16px; right: 16px; bottom: 16px; transform: translateY(12px); }
  .toast.is-on { transform: none; }
}
