:root {
  --bg: #0f1420;
  --bg2: #161d2e;
  --card: #1b2336;
  --line: #2a3550;
  --text: #e6ebf4;
  --muted: #94a1bd;
  --accent: #4f8cff;
  --accent2: #6ee7a8;
  --warn: #ffb84d;
  --err: #ff6b6b;
  --ok: #6ee7a8;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* header */
.site-head { border-bottom: 1px solid var(--line); background: var(--bg2); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.brand { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.hub-rail { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.86rem; }
.rail-label { color: var(--muted); }

.hero { padding: 28px 0 8px; }
.hero h1 { margin: 0 0 8px; font-size: 1.9rem; line-height: 1.2; }
.sub { color: var(--muted); margin: 0 0 18px; max-width: 760px; }

/* tool card */
.tool-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

.toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--muted); }
.field select {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; font-size: 0.95rem;
}
.swap {
  cursor: pointer; color: var(--muted); font-size: 1.3rem; padding: 6px 2px; user-select: none;
}
.swap:hover { color: var(--accent); }
.swap:active { color: var(--accent2); transform: scale(0.92); }

button {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 9px 14px; font-size: 0.9rem; cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
}
button:hover { background: #eef1f5; }
button:active { background: #e2e8f0; color: var(--accent); border-color: var(--accent); transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: #3d79e8; }
button.primary:active { background: #2f66d0; color: #fff; border-color: #2f66d0; }

/* pressed flash — a JS-added class (document click delegation) that plays a
   short ring so every button click gives a visible pressed/selected cue. */
button.clicked, .swap.clicked, .preset.clicked { animation: click-flash .3s ease-out; }
@keyframes click-flash {
  0% { box-shadow: 0 0 0 0 rgba(79, 140, 255, 0.55); }
  100% { box-shadow: 0 0 0 9px rgba(79, 140, 255, 0); }
}

/* quick-conversion preset chips */
.presets { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.presets-label { font-size: 0.8rem; color: var(--muted); }
.preset {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 13px; font-size: 0.84rem; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.preset:hover { border-color: var(--accent); color: var(--accent); }
.preset:active { transform: translateY(1px); }
.preset.selected {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}

.detected-row { display: flex; gap: 8px; margin: 12px 0; min-height: 22px; flex-wrap: wrap; }
.pill { font-size: 0.78rem; color: var(--muted); background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.err { color: var(--err); border-color: var(--err); }

/* round-trip verified badge — pops in green after a lossless conversion */
.rt-badge {
  font-size: 0.8rem; font-weight: 600; color: var(--ok);
  background: rgba(110, 231, 168, 0.12); border: 1px solid var(--ok);
  border-radius: 999px; padding: 3px 10px; align-self: center;
}
.rt-badge.pop { animation: badge-pop .45s cubic-bezier(.22, 1.2, .36, 1); }
@keyframes badge-pop {
  0% { transform: scale(0.4); opacity: 0; }
  70% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 760px) { .columns { grid-template-columns: 1fr; } }
.col { display: flex; flex-direction: column; gap: 6px; }
.col label { font-size: 0.82rem; color: var(--muted); }
textarea {
  width: 100%; min-height: 320px; resize: vertical;
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px; font: 0.88rem/1.5 "Cascadia Code", Consolas, "Courier New", monospace;
  tab-size: 2;
}
textarea:focus { outline: none; border-color: var(--accent); }
textarea[readonly] { color: #475569; }

.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
#status { margin-top: 10px; font-size: 0.9rem; }
#status.err { color: var(--err); }
#status.ok { color: var(--ok); }

.share-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.share-row label { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
#share-url {
  flex: 1; min-width: 0; padding: 8px 10px; font: 0.85rem "Cascadia Code", Consolas, monospace;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
}

#roundtrip-panel, #history-panel { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
#roundtrip-panel h2, #history-panel h2 { font-size: 1rem; margin: 0 0 8px; }
#roundtrip[data-equal="true"] { color: var(--ok); }
#roundtrip[data-equal="false"] { color: var(--warn); }
#diff { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: 0.9rem; }
#history { list-style: none; padding: 0; margin: 0; }
#history li { font-size: 0.85rem; color: var(--muted); padding: 4px 0; border-bottom: 1px dashed var(--line); }

.guide-block { margin-top: 26px; padding: 0 4px; }
.guide-block h2 { font-size: 1.15rem; }
.guide-block p { color: var(--muted); }

/* footer */
.site-foot { border-top: 1px solid var(--line); margin-top: 40px; background: var(--panel); }
.foot-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 16px; padding-bottom: 8px; color: var(--muted); font-size: 0.86rem; }
.foot-row nav { display: flex; gap: 12px; flex-wrap: wrap; }
.donate { display: flex; gap: 10px; align-items: center; padding-top: 4px; padding-bottom: 18px; font-size: 0.86rem; color: var(--muted); flex-wrap: wrap; }

/* Advanced views (D.1/D.2/D.3/D.5/D.7/D.11) */
.feature-tabs { margin-top: 26px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.feature-tabs-heading { font-size: 1.1rem; margin: 0 0 4px; }
.feature-tabs-hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 12px; }
.feature-tabs-mount { min-height: 40px; }

.tab-strip { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding-bottom: 4px; flex-wrap: wrap; }
.tab-button { background: transparent; color: var(--muted); border: 1px solid transparent; border-bottom: none; padding: 6px 12px; border-radius: 6px 6px 0 0; cursor: pointer; font: inherit; font-size: 0.9rem; }
.tab-button:hover { color: var(--text); background: var(--bg2); }
.tab-button[aria-selected="true"] { color: var(--text); background: var(--bg2); border-color: var(--line); }
.tab-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tab-content { padding: 14px 4px 4px; }
.tab-content textarea { width: 100%; min-height: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86rem; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.tab-content input[type="text"], .tab-content input[type="password"], .tab-content select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 0.9rem; }
.tab-error { color: var(--err); padding: 8px; border: 1px dashed var(--err); border-radius: 6px; background: rgba(255,107,107,0.06); }

/* Tree (D.1) */
.tree, .tree ul { list-style: none; margin: 0; padding-left: 16px; }
.tree { padding-left: 0; }
.tree-node { padding: 2px 0; }
.tree-header { display: flex; align-items: center; gap: 4px; }
.disclosure { display: inline-block; width: 16px; color: var(--muted); cursor: pointer; user-select: none; text-align: center; }
.tree-leaf .disclosure { visibility: hidden; }
.tree-node[data-open="false"] > .tree-children { display: none; }
.key { color: var(--accent); font-weight: 500; }
.badge { color: var(--muted); font-size: 0.72rem; padding: 0 4px; border: 1px solid var(--line); border-radius: 4px; }
.badge-string { color: var(--ok); border-color: var(--ok); }
.badge-number { color: var(--warn); border-color: var(--warn); }
.badge-boolean, .badge-null { color: var(--muted); }
.count { color: var(--muted); font-size: 0.78rem; margin-left: 4px; }
.leaf-value { margin-left: 4px; }
.tree-children { margin-left: 6px; border-left: 1px dashed var(--line); padding-left: 10px; }
.tree-truncated { color: var(--warn); font-size: 0.8rem; font-style: italic; }

/* Graph (D.5) */
.graph { display: block; max-width: 100%; height: auto; margin: 0 auto; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.graph-toolbar { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.graph-toolbar button { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font: inherit; font-size: 0.85rem; cursor: pointer; }
.graph-toolbar button:hover { border-color: var(--accent); }
.graph [data-node-idx] { cursor: pointer; }
.graph [data-role="graph-toggle"]:focus-visible, .graph [data-role="graph-toggle"]:focus { outline: none; }
.graph [data-role="graph-toggle"]:focus-visible rect { stroke: var(--accent); stroke-width: 2; }
.graph g[data-node-idx]:hover > rect { stroke: var(--accent); stroke-width: 1.5; }

/* CodeGen (D.2) */
.codegen-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.codegen-controls input { flex: 1; min-width: 160px; }
.codegen-controls button { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font: inherit; font-size: 0.85rem; cursor: pointer; }
.codegen-controls button:hover { border-color: var(--accent); }

/* Schema (D.3) */
.schema-tab label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 0.9rem; }
.schema-tab button { background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: 6px 12px; font: inherit; font-size: 0.9rem; cursor: pointer; margin: 8px 0; }
.schema-result { white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: 0.85rem; padding: 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }
.schema-result[data-state="ok"] { color: var(--ok); border-color: var(--ok); }
.schema-result[data-state="err"] { color: var(--err); border-color: var(--err); }

/* Search (D.11) */
.search-tab input { width: 100%; margin-bottom: 8px; }
.search-results { list-style: none; padding: 0; margin: 0; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.search-result { padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 0.85rem; }
.search-result:last-child { border-bottom: none; }
.search-path { color: var(--accent); font-family: ui-monospace, monospace; }
.search-value { color: var(--text); margin-left: 6px; }
.search-empty { padding: 6px 10px; color: var(--muted); font-size: 0.85rem; }

/* AI (D.7) */
.ai-tab { display: grid; gap: 6px; }
.ai-tab label { color: var(--muted); font-size: 0.85rem; }
.ai-tab input, .ai-tab select, .ai-tab textarea { width: 100%; }
.ai-tab textarea { min-height: 60px; font-family: ui-monospace, monospace; font-size: 0.86rem; }
.ai-tab button { background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: 8px 12px; font: inherit; font-size: 0.9rem; cursor: pointer; margin-top: 4px; justify-self: start; }
.ai-tab button:hover { filter: brightness(1.1); }
.ai-tab button:disabled { opacity: 0.6; cursor: not-allowed; }
.ai-result { white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: 0.85rem; padding: 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); margin-top: 4px; min-height: 1.2em; }

/* JWT (D.8) */
.jwt-tab { display: grid; gap: 8px; }
.jwt-tab textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 0.86rem; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); resize: vertical; }
.jwt-tab button { background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: 6px 12px; font: inherit; font-size: 0.9rem; cursor: pointer; justify-self: start; }
.jwt-tab button:hover { filter: brightness(1.1); }
.jwt-result { padding: 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }
.jwt-result[data-state="ok"] { border-color: var(--ok); }
.jwt-result[data-state="err"] { border-color: var(--err); color: var(--err); }
.jwt-error { font-size: 0.9rem; }
.jwt-flags { display: flex; gap: 6px; margin-bottom: 8px; }
.jwt-flag { font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.jwt-flag-ok { color: var(--ok); border-color: var(--ok); }
.jwt-flag-expired { color: var(--err); border-color: var(--err); }
.jwt-flag-future { color: #b8860b; border-color: #b8860b; }
.jwt-section h4 { margin: 8px 0 4px; font-size: 0.85rem; color: var(--muted); }
.jwt-section pre { margin: 0; padding: 6px 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: 4px; font-family: ui-monospace, monospace; font-size: 0.82rem; white-space: pre-wrap; word-break: break-all; }
.jwt-signature { word-break: break-all; }
.jwt-note { margin: 8px 0 0; color: var(--muted); font-size: 0.78rem; }

/* >>> theme-by-name (2026-11-02) >>> */
/* Theme derived from the site's MEANING, not a random variant.
 * Data interchange = graphite with blue and mono numerals. Format is the subject.
 * Ad layout is deliberately NOT set here — container width and rail geometry are
 * measured and verified separately by check-ad-layout.mjs.
 */
:root {
  /* Light, neutral base (2026-11-13). The previous "light" block was still a
     dark theme (--bg #0f1117, --ink #e9ecf2) — the owner reported "too dark,
     sleepy look and feel". Every surface + text token flips together. */
  --bg: #f7f8fa;
  --card: #ffffff;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #5b6675;
  --line: #e2e8f0;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --accent: #4f46e5;
  --radius: 10px;
  --font-sans: 'Space Grotesk', 'Avenir Next', 'Trebuchet MS', sans-serif;
  --bg2: #eef1f5;
  /* These five are read by .brand, .pill.ok/.err, #status, #roundtrip and
     .rt-badge. Left on the dark palette they rendered #e6ebf4 (near-white) on
     a white page — the brand was invisible at 1.06:1. */
  --text: #1c2430;
  --accent2: #0e7490;
  --ok: #047857;
  --err: #b91c1c;
  --warn: #b45309;
}
body { font-family: var(--font-sans); background: var(--bg); color: var(--ink); }
h1, h2, h3 { font-family: var(--font-sans); font-weight: 500; letter-spacing: -0.015em; }
.card, .panel, section[class*="card"] { border-radius: var(--radius); }
/* <<< theme-by-name <<< */

/* Python-import note (2026-11-08) */
.py-badge{display:inline-block;background:#3776ab;color:#fff;font-size:11px;font-weight:700;
  padding:2px 8px;border-radius:999px;margin-right:8px;letter-spacing:.03em;vertical-align:middle}
#python-note-row{align-items:flex-start;background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;
  padding:10px 12px;margin-top:8px;color:#0f172a}
#python-note-row .file-hint{color:#0f172a}
#python-note-row code{background:#e2e8f0;color:#0f172a;padding:1px 4px;border-radius:4px}

/* ── Input/Output layout (2026-11-08, owner's correction) ─────────────────
   BEFORE: the drop zone sat below BOTH boxes, so the page looked like it had
   two places to paste, and the two textareas could differ in height because
   the left column carried the hint and the file row.
   AFTER: the file affordance belongs to the INPUT column only, both textareas
   share one height, and on a narrow screen the output stacks UNDER the input
   rather than beside it. */
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
/* One shared height so the two panes are visually equal on a laptop. The
   textareas are the tallest thing in each column, so a fixed height plus
   flex:1 keeps them aligned whatever sits above. */
.columns .col textarea { height: 340px; min-height: 340px; flex: 0 0 auto; }
/* The two textareas must START AT THE SAME Y. The input column carries a hint
   above its box, which pushed it 28px below the output (measured in the live
   DOM). Reserving a matching line in the output column — rather than deleting
   the hint — keeps the label, the explanation and the box aligned. */
/* Fixed height for BOTH so the two textareas start on the same pixel,
   whatever the hint wraps to. */
/* PIXELS, not em: .hint sets its own font-size, so 2.8em resolved to 37px here
   and 45px there and the two textareas started 8px apart. A fixed height removes
   the whole class of problem. */
.col .hint, .col .hint-spacer { height: 40px; margin: 0 0 4px; line-height: 1.4; overflow: hidden; }
.col .hint-spacer { visibility: hidden; }
.col .file-row { margin-top: 8px; padding: 8px 10px; background: var(--bg2); border-radius: 8px; color: var(--text); }
/* --text-2 was never defined: it resolved to the inherited dark colour on a
   light file-row background — "Python Pasting ... output works too" was light
   text on a light background, unreadable. Measured 2026-11-09, ratio 1.13.
   Defined here as a dark muted grey so it stays readable on both surfaces. */
.col .hint { color: var(--muted); font-size: .82rem; }
@media (max-width: 760px) {
  /* Output BELOW input on mobile, and a shorter box so the toggle is reachable. */
  .columns { grid-template-columns: 1fr; }
  .columns .col textarea { height: 220px; min-height: 220px; }
}

/* Privacy architecture section (2026-11-08) — the selling point of every site. */
.privacy-section{margin-top:34px;padding-top:24px;border-top:2px solid #e2e8f0}
.privacy-section h2{font-size:1.35em;margin-bottom:10px}
.privacy-section h3{font-size:1.05em;margin:20px 0 8px}
.privacy-steps{margin:10px 0 14px;padding-left:22px}
.privacy-steps li{margin-bottom:8px;line-height:1.6}
.privacy-section kbd{background:#f1f5f9;border:1px solid #cbd5e1;border-bottom-width:2px;
  border-radius:4px;padding:1px 5px;font-size:.85em;font-family:ui-monospace,Menlo,monospace;color:#0f172a}
