/* ---------------------------------------------------------------------------
   Fun Data Playground — shared styles.
   Design language mirrors funui.dev / funapi.dev: cream paper background,
   ink text, orange accent, IBM Plex Sans/Mono, hard 4px offset shadows.
--------------------------------------------------------------------------- */

/* Self-hosted IBM Plex (latin + latin-ext), same as the sibling sites —
   no render-blocking Google Fonts round trips. */
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-display: swap; font-weight: 400; src: url(/fonts/ibm-plex-sans-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-display: swap; font-weight: 500; src: url(/fonts/ibm-plex-sans-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-display: swap; font-weight: 600; src: url(/fonts/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-display: swap; font-weight: 700; src: url(/fonts/ibm-plex-sans-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-display: swap; font-weight: 400; src: url(/fonts/ibm-plex-sans-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-display: swap; font-weight: 500; src: url(/fonts/ibm-plex-sans-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-display: swap; font-weight: 600; src: url(/fonts/ibm-plex-sans-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-display: swap; font-weight: 700; src: url(/fonts/ibm-plex-sans-latin-ext-700-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 400; src: url(/fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 500; src: url(/fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 600; src: url(/fonts/ibm-plex-mono-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 700; src: url(/fonts/ibm-plex-mono-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 400; src: url(/fonts/ibm-plex-mono-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 500; src: url(/fonts/ibm-plex-mono-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 600; src: url(/fonts/ibm-plex-mono-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 700; src: url(/fonts/ibm-plex-mono-latin-ext-700-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: #faf7f0;
  --card-bg: #ffffff;
  --text: #26221a;
  --text-muted: #6d6553;
  --border: #e4ddcd;
  --accent: #e8590c;
  --accent-strong: #c94f09; /* fill behind white text — keeps ≥4.5:1 (AA) */
  --accent-ink: #b4531a;
  --accent-ink-hover: #93430f;
  --focus: #2f74c8; /* darker on the light theme for a ≥3:1 non-text contrast */
  --ok: #2e7d4f;
  --err: #a93434;
  --code-bg: #f0ece2;
  --field-bg: #fbf8f1;
  --input-bg: #ffffff;
  --shadow: 4px 4px 0 var(--border);
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
html[data-theme="dark"] {
  --bg: #151515;
  --focus: #4990e2;
  --card-bg: #25241f;
  --text: #f0eee9;
  --text-muted: #bbb4a8;
  --border: #504b42;
  --accent-ink: #f0a06c;
  --accent-ink-hover: #f5b98f;
  --code-bg: #201e1a;
  --field-bg: #2d2b25;
  --input-bg: #1d1c19;
  --shadow: 4px 4px 0 #0c0c0c;
  --ok: #49cc90;
  --err: #f95d5d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--accent-ink); }
a:hover { color: var(--accent-ink-hover); }
input, textarea, button, select { font-family: inherit; font-size: inherit; color: inherit; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 17px; height: 17px; }
button:focus-visible, [role="button"]:focus-visible, a:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px;
}

.skip-link { position: absolute; left: -9999px; top: 12px; z-index: 100; background: #26221a; color: #faf7f0; font: 600 13px var(--sans); padding: 10px 18px; border-radius: 8px; text-decoration: none; }
.skip-link:focus { left: 12px; }

.page-pad { padding: 28px 32px 60px; max-width: 1180px; margin: 0 auto; }
@media (max-width: 480px) { .page-pad { padding: 20px 18px 48px; } }

/* Header ------------------------------------------------------------------ */
.site-header { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin-bottom: 26px; }
.site-header .brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.site-header .brand span { font-weight: 700; font-size: 19px; color: var(--text); }
.site-header .spacer { flex: 1; }
.header-tagline { color: var(--text-muted); font-size: 13px; }
@media (max-width: 900px) { .header-tagline { display: none; } }
.mobile-nav-toggle { display: none; }
.nav-link {
  font: 600 13px var(--mono);
  color: var(--accent-ink); text-decoration: none;
  border: 1px solid var(--border); background: var(--card-bg);
  padding: 7px 13px; border-radius: 8px;
}
.nav-link:hover { border-color: var(--accent-ink); }
.theme-toggle {
  appearance: none; border: 1px solid var(--border); background: var(--card-bg);
  color: var(--text); border-radius: 8px; padding: 9px 12px; cursor: pointer;
  font-size: 15px; line-height: 1;
}
.theme-toggle:hover { border-color: var(--accent-ink); }
@media (max-width: 900px) {
  .site-header { gap: 8px; margin-bottom: 18px; }
  .site-header .brand span { font-size: 17px; }
  .site-header .spacer { flex: 1; }
  .mobile-nav-toggle { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; justify-content: center; }
  .site-header.nav-ready .nav-link { display: none; width: 100%; padding: 10px 13px; }
  .site-header.nav-ready.nav-open .nav-link { display: block; }
}
.icon { width: 17px; height: 17px; display: inline-block; vertical-align: -3px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn .icon + span, .btn span + .icon { margin-left: 6px; }

/* Buttons ----------------------------------------------------------------- */
.btn {
  appearance: none; cursor: pointer;
  font: 600 13.5px var(--sans);
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--card-bg); color: var(--text);
  padding: 9px 16px;
  transition: transform .12s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--border); }
a.btn { display: inline-block; text-decoration: none; }
.btn:disabled { cursor: not-allowed; opacity: .6; transform: none; box-shadow: none; }
.btn-primary {
  background: var(--accent-strong); border-color: var(--accent-strong); color: #fff;
  box-shadow: var(--shadow);
}
.btn-primary:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--border); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--accent-ink); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-icon { padding: 5px 9px; font-size: 13px; line-height: 1; border-radius: 7px; }

/* Cards ------------------------------------------------------------------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.ref-card { overflow-x: auto; }

/* Breadcrumbs ------------------------------------------------------------- */
.crumbs { font: 500 13px var(--mono); color: var(--text-muted); margin: 4px 0 14px; }
.crumbs a { color: inherit; }
.crumbs span[aria-hidden] { margin: 0 4px; opacity: .6; }

/* Hero -------------------------------------------------------------------- */
.hero h1 { font-size: 30px; line-height: 1.2; margin: 0 0 10px; letter-spacing: -.3px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }
.hero p.lede { color: var(--text-muted); font-size: 15.5px; max-width: 720px; margin: 0 0 6px; }
.hero .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.hero-start { margin-top: 16px; }
.chip {
  font: 600 11.5px var(--mono);
  border: 1px solid var(--border); border-radius: 20px;
  background: var(--card-bg); color: var(--text-muted);
  padding: 4px 11px;
}

/* Generator layout -------------------------------------------------------- */
.gen-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; align-items: start; margin-top: 20px; }
@media (max-width: 1120px) { .gen-grid { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 1121px) {
  .output-card { position: sticky; top: 16px; }
  .gen-grid.preview-expanded { grid-template-columns: minmax(0, 1fr); }
  .gen-grid.preview-expanded .schema-card { display: none; }
  .gen-grid.preview-expanded .output-card { position: static; grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .hero h1 { font-size: 27px; }
  .hero .chips .chip:nth-child(-n+5) { display: none; }
  .hero-start { margin-top: 12px; }
}

.panel-title { font: 700 12px var(--mono); text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin: 0 0 14px; }
.schema-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.schema-panel-head .panel-title { margin-bottom: 5px; color: var(--text); }
.schema-panel-intro { max-width: 430px; margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.45; }
.schema-field-count { flex: none; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--accent-ink); padding: 5px 10px; font: 600 11.5px var(--mono); white-space: nowrap; }

/* Schema builder rows */
.field-row {
  display: grid;
  grid-template-columns: 30px minmax(96px, .75fr) minmax(190px, 1.45fr) minmax(138px, .95fr) 38px;
  gap: 9px; align-items: start;
  margin: 8px 0; padding: 11px 10px;
  position: relative; border: 1px solid var(--border); border-radius: 10px; background: var(--field-bg);
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.field-row:hover { border-color: var(--accent-ink); box-shadow: 2px 2px 0 var(--border); }
.field-row:focus-within { border-color: var(--focus); }
.field-row.dragging { opacity: .45; transform: scale(.99); }
.field-row.drag-over { box-shadow: 0 -3px 0 var(--accent); }
.field-row .name-cell { grid-column: 2; grid-row: 1; }
.field-row .type-cell { grid-column: 3; grid-row: 1; }
.field-row .opts-cell { grid-column: 2 / 4; grid-row: 2; }
.field-row .field-edit-toggle { grid-column: 4; grid-row: 1; }
.field-row .blank-cell { grid-column: 4; grid-row: 2; }
.field-row .field-actions-toggle { grid-column: 5; grid-row: 1; }
.field-cols-head {
  display: grid;
  grid-template-columns: 30px minmax(96px, .75fr) minmax(190px, 1.45fr) minmax(138px, .95fr) 38px;
  gap: 9px;
  font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .8px;
  color: var(--text-muted); margin-top: 14px; padding: 0 10px 6px;
}
.drag-cell { grid-column: 1; grid-row: 1; display: flex; padding-top: 6px; align-items: flex-start; justify-content: center; }
.drag-handle {
  cursor: grab; color: var(--text-muted); font-size: 12px; line-height: 1;
  padding: 3px 6px; user-select: none; -webkit-user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.field-actions { display: none; position: absolute; z-index: 12; top: 51px; right: 9px; width: min(250px, calc(100% - 18px)); flex-wrap: wrap; gap: 6px; align-items: center; padding: 7px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); }
.field-row.actions-open .field-actions { display: flex; }
.field-actions-toggle { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; min-height: 35px; padding: 5px; }
.mobile-action-label { display: inline; font-size: 12px; }
.mini-move {
  appearance: none; border: none; background: none; cursor: pointer;
  color: var(--text-muted); font-size: 12px; line-height: 1; padding: 6px 8px;
  border-radius: 6px;
}
.mini-move:hover { color: var(--accent-ink); }

.text-input, .num-input, .select-input {
  width: 100%;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--input-bg); color: var(--text);
  padding: 7px 9px; font-size: 13.5px;
}
.select-input { cursor: pointer; }
.type-cell { display: flex; gap: 5px; align-items: stretch; min-width: 0; }
.type-cell .type-select { min-width: 0; }
.type-browse { display: none; }
.formula-toggle { flex: none; padding-left: 7px; padding-right: 7px; font-family: var(--mono); }
.formula-toggle.is-active, .formula-toggle[aria-pressed="true"] { color: #fff; border-color: var(--accent-strong); background: var(--accent-strong); }
.num-input { font-family: var(--mono); font-size: 12.5px; }
textarea.text-input { resize: vertical; min-height: 34px; font-family: var(--mono); font-size: 12px; }

.opts-cell { display: none; flex-wrap: wrap; gap: 6px; min-height: 30px; padding-top: 4px; }
.field-row.is-expanded .opts-cell { display: flex; }
.inline-formula-editor { display: none; flex: 1 0 100%; padding-top: 7px; margin-top: 2px; border-top: 1px dashed var(--border); }
.field-row.formula-open .inline-formula-editor { display: block; }
.inline-formula-editor textarea { margin-top: 3px; }
.opt-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 56px; flex: 1 1 62px; }
.opt-wrap.opt-wide { flex: 1 1 100%; }
.opt-label { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.opt-wrap.opt-date { flex: 1 1 128px; min-width: 118px; }
.remove-btn {
  appearance: none; border: none; background: none; cursor: pointer;
  color: var(--text-muted); font-size: 15px; padding: 6px 7px; border-radius: 6px;
}
.name-cell { min-width: 0; }
.mobile-field-label { display: none; color: var(--text-muted); font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .5px; }
.field-actions .mini-move, .field-actions .remove-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 34px; padding: 5px 9px; border: 1px solid var(--border); background: var(--input-bg); }
.remove-btn:hover { color: var(--err); }
.input-dup { border-color: var(--err); }
.mobile-step-toggle, .continue-generate { display: none; }

.blank-cell { display: none; flex-direction: column; align-items: stretch; gap: 7px; padding-top: 4px; }
.field-row.is-expanded .blank-cell { display: flex; }
.null-control { display: flex; align-items: center; gap: 6px; min-width: 0; }
.blank-control { flex-direction: column; align-items: stretch; gap: 2px; }
.blank-cell .num-input { width: 100%; min-width: 0; }
.blank-cell input[type="checkbox"] { flex: none; margin: 0; }
.unique-control { min-height: 24px; cursor: pointer; }

.field-edit-toggle { display: inline-flex; align-items: center; justify-content: space-between; width: 100%; min-height: 35px; padding-left: 9px; padding-right: 9px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1120px) {
  .mobile-step-toggle { display: inline-flex; align-items: center; justify-content: center; margin: 12px 0 2px; border-color: var(--accent-ink); color: var(--accent-ink); }
  .schema-card.is-collapsed .field-cols-head,
  .schema-card.is-collapsed .template-quick-start,
  .schema-card.is-collapsed #schema-rows,
  .schema-card.is-collapsed .schema-builder-footer { display: none; }
  .continue-generate { display: inline-flex; width: 100%; justify-content: center; margin-top: 14px; }
}

@media (max-width: 640px) {
  .card { padding: 18px 16px; }
  .theme-toggle, .btn-icon, .preset-btn { min-width: 44px; min-height: 44px; }
  .field-cols-head { display: none; }
  .field-row { grid-template-columns: minmax(0, 1fr) 46px; }
  .field-row .drag-cell { display: none; }
  .field-row .name-cell { grid-column: 1; grid-row: 1; }
  .field-row .field-actions-toggle { display: inline-flex; grid-column: 2; grid-row: 1 / span 2; justify-self: end; align-self: start; }
  .field-row .field-actions { display: none; position: static; z-index: auto; width: auto; grid-column: 1 / -1; grid-row: 6; flex-direction: row; justify-content: flex-end; justify-self: stretch; padding: 0; background: transparent; border: 0; box-shadow: none; }
  .field-row.actions-open .field-actions { display: flex; }
  /* The type select gets a full-width row of its own so long labels
     ("Pattern (#=digit ?=A-Z ~=a-z)") aren't truncated. */
  .field-row .type-cell { grid-column: 1; grid-row: 2; }
  .type-cell { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .type-cell .mobile-field-label { grid-column: 1 / -1; }
  .mobile-field-label { display: block; margin-bottom: 2px; }
  .field-row .field-edit-toggle { grid-column: 1 / -1; grid-row: 3; }
  .field-row .opts-cell { grid-column: 1 / -1; grid-row: 4; display: none; }
  .field-row .blank-cell { grid-column: 1 / -1; grid-row: 5; display: none; align-items: center; gap: 8px; }
  .field-row.is-expanded .opts-cell { display: flex; }
  .field-row.is-expanded .blank-cell { display: flex; }
  .blank-cell { flex-direction: row; }
  .blank-control { flex: 1; flex-direction: row; align-items: center; }
  .blank-cell .num-input { max-width: 90px; }
  .mini-move, .remove-btn { width: 44px; height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
  .field-actions .mini-move, .field-actions .remove-btn { width: auto; padding: 0 10px; gap: 5px; border: 1px solid var(--border); background: var(--bg); }
  .mobile-action-label { display: inline; font-size: 12px; }
  .mobile-step-toggle { width: 100%; margin: 12px 0 2px; }
  .template-quick-start summary small { display: none; }
  .drag-handle { display: none; } /* no HTML5 drag on touch — ▲▼ still work */
}

.builder-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.builder-actions-spacer { flex: 1; min-width: 0; }
.schema-builder-footer { border: 1px solid var(--border); border-radius: 10px; background: var(--bg); margin-top: 12px; padding: 13px; }
.schema-primary-actions { margin-top: 0; }
.schema-primary-actions .btn-primary { box-shadow: none; }
.schema-primary-actions #ctl-template { display: none; }
.saved-schemas-row { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.saved-schemas-row #ctl-save-name { flex: 1 1 150px; max-width: none !important; }
.saved-schemas-row #ctl-saved-schema { flex: 1 1 170px; max-width: none !important; }
.template-quick-start { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--field-bg); }
.template-quick-start summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; padding: 10px 12px; color: var(--accent-ink); font-weight: 700; }
.template-quick-start summary::-webkit-details-marker { display: none; }
.template-quick-start summary::after { content: '+'; flex: none; font: 700 17px var(--mono); }
.template-quick-start[open] summary::after { content: '−'; }
.template-quick-start summary small { margin-left: auto; color: var(--text-muted); font: 500 11.5px var(--mono); }
.template-quick-body { padding: 0 12px 12px; border-top: 1px solid var(--border); }
.template-quick-start p { margin: 9px 0 10px; color: var(--text-muted); font-size: 12.5px; }
.template-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: 8px; }
.template-card { text-align: left; padding: 10px 12px; }
.template-card strong, .template-card span { display: block; }
.template-card span { margin-top: 2px; color: var(--text-muted); font-size: 11.5px; font-weight: 400; }
.schema-save-label { width: 100%; font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.autosave-note { margin: 9px 0 0; color: var(--text-muted); font-size: 12px; }
.autosave-note::before { content: '✓'; display: inline-block; margin-right: 5px; color: var(--ok); font-weight: 700; }
.schema-tools { margin-top: 10px; }
.schema-tools summary { cursor: pointer; width: max-content; color: var(--accent-ink); font: 600 12.5px var(--mono); }
.schema-tools[open] summary { margin-bottom: 8px; }
.schema-tools .builder-actions { margin-top: 0; }

/* Output controls */
.out-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.ctl { display: flex; flex-direction: column; gap: 3px; }
.ctl label { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); }
.seed-wrap { display: flex; gap: 6px; }
.seed-wrap .text-input { flex: 1; min-width: 0; }
.row-presets { display: flex; gap: 4px; margin-top: 4px; }
.preset-btn {
  appearance: none; cursor: pointer;
  font: 600 11px var(--mono);
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--card-bg); color: var(--text-muted);
  padding: 4px 8px;
}
.preset-btn:hover { color: var(--accent-ink); border-color: var(--accent-ink); }
.gen-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 6px 0 16px; }
.refresh-action { color: var(--accent-ink); }
.gen-note { font: 500 12px var(--mono); color: var(--text-muted); }
.gen-note.ok { color: var(--ok); }
.gen-note.err { color: var(--err); }

/* Preview */
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.preview-tabs { display: flex; gap: 6px; align-items: center; }
.preview-expand { color: var(--accent-ink); }
@media (max-width: 1120px) { .preview-expand { display: none; } }
.tab-btn {
  appearance: none; cursor: pointer;
  font: 600 12px var(--mono);
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg); color: var(--text-muted); padding: 8px 14px;
}
.tab-btn[aria-selected="true"] { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.table-wrap { overflow: auto; max-height: 420px; border: 1px solid var(--border); border-radius: 9px; }
table.preview { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.preview th {
  font: 700 11px var(--mono); text-align: left; text-transform: none;
  background: var(--code-bg); color: var(--text);
  padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.preview td { padding: 6px 10px; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; color: var(--text); }
table.preview tr:last-child td { border-bottom: none; }
table.preview td.null { color: var(--text-muted); font-style: italic; }
pre.raw-out {
  margin: 0; background: var(--code-bg); border: 1px solid var(--border); border-radius: 9px;
  padding: 12px 14px; font: 400 11.5px var(--mono);
  overflow: auto; max-height: 420px; white-space: pre;
}
.table-scroll-hint { display: none; font: 600 11px var(--mono); margin-top: 6px; color: var(--text-muted); }
.table-scroll-hint.show { display: block; }

/* SEO / content sections -------------------------------------------------- */
.content-section { margin-top: 46px; }
.content-section h2 { font-size: 21px; margin: 0 0 12px; }
.content-section h2:not(:first-child) { margin-top: 34px; }
.content-section h3 { font-size: 16px; margin: 22px 0 8px; }
.content-section p, .content-section li { color: var(--text-muted); font-size: 14.5px; }
.reading-main { max-width: 78ch; }
.content-section li strong, .content-section p strong { color: var(--text); }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 18px; }
@media (max-width: 860px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .feature-grid { grid-template-columns: 1fr; } }
.feature-card h3 { margin: 0 0 6px; font-size: 15px; }
.feature-card p { margin: 0; font-size: 13.5px; }

code, .mono { font-family: var(--mono); }
p code, li code, td code {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px; font-size: 12.5px;
}
pre.code-block {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 9px;
  padding: 14px 16px; overflow-x: auto; font: 400 12.5px var(--mono);
}

/* Type reference tables */
table.ref { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.ref th { text-align: left; font: 700 11.5px var(--mono); text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.ref td { padding: 8px 10px; border-bottom: 1px dashed var(--border); vertical-align: top; }
table.ref td:first-child { font-weight: 600; white-space: nowrap; }
table.ref td.example { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.type-tools { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 22px 0 12px; padding: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.type-search { flex: 1 1 240px; }
.type-categories { display: flex; gap: 6px; flex-wrap: wrap; }
.type-categories a { font: 600 11px var(--mono); text-decoration: none; padding: 5px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--card-bg); }
.type-result-count { width: 100%; margin: 0; color: var(--text-muted); font: 500 11.5px var(--mono); }
.type-use { white-space: nowrap; font: 600 11.5px var(--mono); }

/* Searchable field picker */
.type-picker { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 18px; background: rgba(20, 18, 14, .55); }
.type-picker[hidden] { display: none; }
.type-picker-dialog { width: min(760px, 100%); max-height: min(760px, calc(100vh - 36px)); display: flex; flex-direction: column; padding: 20px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: 8px 8px 0 rgba(0,0,0,.22); }
.type-picker-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.type-picker-head h2 { flex: 1; margin: 0; font-size: 19px; }
.type-picker-head .btn-icon { font-size: 22px; min-width: 36px; min-height: 36px; padding: 3px; }
.type-picker-tools { flex: none; padding-bottom: 10px; background: var(--card-bg); }
.type-picker-categories { display: flex; gap: 6px; overflow-x: auto; padding: 8px 1px 2px; scrollbar-width: none; }
.type-picker-categories::-webkit-scrollbar { display: none; }
.type-picker-category { flex: none; appearance: none; cursor: pointer; border: 1px solid var(--border); border-radius: 999px; padding: 5px 9px; background: var(--field-bg); color: var(--text-muted); font: 600 10.5px var(--mono); }
.type-picker-category[aria-pressed="true"] { border-color: var(--accent-strong); background: var(--accent-strong); color: #fff; }
.type-picker-results { overflow: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 2px; }
.type-picker-option { text-align: left; padding: 9px 12px; background: var(--field-bg); }
.type-picker-option strong, .type-picker-option span { display: block; }
.type-picker-option span { color: var(--text-muted); font: 500 11px var(--mono); }
.type-picker-empty { grid-column: 1 / -1; color: var(--text-muted); }
.formula-hint { flex: 1 0 100%; margin: 0; color: var(--text-muted); font: 500 10.5px/1.5 var(--mono); }
.formula-hint a { color: var(--accent-ink); }
.formula-reference { margin: 12px 0 26px; box-shadow: none; }
.formula-reference h3 { margin: 0 0 8px; font-size: 16px; }
.formula-reference p { margin: 6px 0; font-size: 13px; }

@media (max-width: 640px) {
  .gen-actions .btn-primary { width: 100%; justify-content: center; }
  .gen-actions .btn:not(.btn-primary) { flex: 1 1 calc(50% - 5px); }
  .ref-card { padding: 8px 12px; overflow: visible; }
  table.ref, table.ref tbody, table.ref tr, table.ref td { display: block; width: 100%; }
  table.ref thead { display: none; }
  table.ref tr { padding: 10px 0; border-bottom: 1px dashed var(--border); }
  table.ref tr:last-child { border-bottom: 0; }
  table.ref td { padding: 2px 0; border: 0; white-space: normal; }
  table.ref td:first-child { min-width: 0; font-size: 14px; }
  table.ref td:nth-child(2)::before, table.ref td:nth-child(3)::before { display: block; color: var(--text-muted); font: 700 10px var(--mono); text-transform: uppercase; letter-spacing: .5px; }
  table.ref td:nth-child(2)::before { content: 'Description'; }
  table.ref td:nth-child(3)::before { content: 'Example'; margin-top: 5px; }
  .type-use { display: inline-block; margin-top: 6px; }
  .type-tools { top: 6px; }
  .type-categories { flex-wrap: nowrap; width: 100%; overflow-x: auto; padding-bottom: 3px; }
  .type-categories { scrollbar-width: none; }
  .type-categories::-webkit-scrollbar { display: none; }
  .type-picker-results { grid-template-columns: 1fr; }
  .hero-start { width: 100%; text-align: center; }
  .hero .chips { margin-top: 10px; }
  .hero-secondary, .hero .chip:nth-child(-n+5) { display: none; }
}

/* FAQ */
details.faq { border: 1px solid var(--border); border-radius: 9px; background: var(--card-bg); padding: 12px 16px; margin-bottom: 10px; }
details.faq summary { cursor: pointer; font-weight: 600; font-size: 14.5px; }
details.faq p { margin: 10px 0 2px; }

/* Footer ------------------------------------------------------------------ */
.site-footer {
  margin-top: 60px; padding-top: 22px; border-top: 1px solid var(--border);
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
  color: var(--text-muted); font-size: 13px;
}
.site-footer .spacer { flex: 1; }
.site-footer a { color: var(--accent-ink); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

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