:root,
[data-skin="medieval"] {
  --bg: #141c12;
  --bg-elev: #243022;
  --ink: #f6efe0;
  --muted: #cbbfa4;
  --line: #3d4a34;
  --accent: #e2b657;
  --accent-ink: #2a2112;
  --node: #f7edd6;
  --node-ink: #2a2118;
  --node-line: #a68445;
  --node-done: #e7f0dc;
  --muted-node: #6d5b3e;
  --edge: #d7b56a;
  --danger: #a33b32;
  --ok: #2f7d4a;
  --map: #1a2414;
  --map-glow: rgba(226, 182, 87, 0.16);
  --grid: transparent;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --node-radius: 16px;
  --font: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
}

[data-skin="rounded"] {
  --bg: #e7eef8;
  --bg-elev: #ffffff;
  --ink: #1c2430;
  --muted: #5c6b82;
  --line: #d5deea;
  --accent: #3c5bfd;
  --accent-ink: #ffffff;
  --node: #ffffff;
  --node-ink: #1c2430;
  --node-line: #c5d2e6;
  --node-done: #e7f8ee;
  --muted-node: #6a7890;
  --edge: #8ea0bf;
  --danger: #c2413b;
  --ok: #1f8a4c;
  --map: #d9e4f2;
  --map-glow: rgba(255, 255, 255, 0.9);
  --grid: transparent;
  --shadow: 0 14px 34px rgba(28, 45, 80, 0.12);
  --radius: 22px;
  --node-radius: 22px;
  --font: "Avenir Next", "Segoe UI", sans-serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
}

[data-skin="tech"] {
  --bg: #070b10;
  --bg-elev: #101820;
  --ink: #dff8ff;
  --muted: #87a0ae;
  --line: #1c3344;
  --accent: #2de2c5;
  --accent-ink: #04221c;
  --node: #0d1722;
  --node-ink: #e9fbff;
  --node-line: #1d4f4c;
  --node-done: #10261c;
  --muted-node: #7f9aa4;
  --edge: #27d6c2;
  --danger: #ff5d6c;
  --ok: #7dffb3;
  --map: #060a0e;
  --map-glow: rgba(45, 226, 197, 0.08);
  --grid: rgba(45, 226, 197, 0.08);
  --shadow: 0 0 0 1px rgba(45, 226, 197, 0.25), 0 16px 40px rgba(0, 0, 0, 0.45);
  --radius: 8px;
  --node-radius: 6px;
  --font: "Segoe UI", sans-serif;
  --sans: "Segoe UI", sans-serif;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.45;
}
h1, h2, h3 { font-family: var(--font); font-weight: 650; letter-spacing: -0.03em; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}
.skip {
  position: absolute; left: 12px; top: -40px; background: var(--accent); color: var(--accent-ink);
  padding: 8px 12px; z-index: 5;
}
.skip:focus { top: 12px; }

.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  position: sticky; top: 0; z-index: 4;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand-word { font-family: var(--font); font-size: 28px; letter-spacing: -0.04em; }
.topnav { display: flex; gap: 14px; flex: 1; }
.topnav a { color: var(--muted); text-decoration: none; }
.topnav a[aria-current="page"] { color: var(--ink); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.grove-switch select, .top-actions select { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; }
.text-link { color: var(--ink); text-decoration: none; }

.button, button.button {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
.button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button.danger { background: var(--danger); color: white; }
button { cursor: pointer; }
.banner { margin: 12px 18px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--bg-elev); }
.banner.danger { outline: 1px solid var(--danger); }

.hero, .narrow, .sheet { padding: 28px 22px 64px; max-width: 1100px; margin: 0 auto; }
.narrow, .narrow-sheet { max-width: 560px; }
.hero h1 { display: flex; align-items: center; gap: 12px; font-size: 64px; margin: 8px 0; }
.kicker { text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; color: var(--accent); margin: 0; }
.lede { font-size: 20px; max-width: 640px; color: var(--muted); }
.hero-actions, .inspector-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.feature-grid, .stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.feature-grid article, .stat-grid article, .grove-card {
  background: var(--bg-elev); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; }
label:has(input[type="radio"]),
label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 8px;
}
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
textarea { resize: vertical; }
.optional, .fine { color: var(--muted); font-size: 14px; }
.sheet-head, .inline-create, .filters, .share-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; }
.grove-cards { list-style: none; padding: 0; display: grid; gap: 14px; }
.grove-card { display: grid; gap: 6px; color: inherit; text-decoration: none; }
.bar { display: block; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.workspace { display: flex; min-height: calc(100vh - 62px); }
.pane { background: color-mix(in srgb, var(--bg-elev) 92%, transparent); overflow: auto; }
.pane-left { width: 280px; flex: none; }
.pane-right { width: 320px; flex: none; }
.pane-head, .pane { padding: 12px; }
.pane-head { padding-bottom: 0; }
.resizer { width: 8px; cursor: col-resize; background: transparent; }
.resizer:hover { background: var(--accent); }
.map-column { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; }
.toolbar-group, .skins, .mode-switch { display: flex; gap: 4px; }
.toolbar button, .skins button, .mode-switch button, .combo-browse, .icon-choice {
  background: var(--bg-elev); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px;
}
.skins button[aria-pressed="true"], .mode-switch button[aria-selected="true"], .icon-choice.is-on,
#lock-toggle[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
}
.reveal-control {
  display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px;
}
.reveal-control select {
  background: var(--bg-elev); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 10px;
}
.drag-hint { margin: 0; color: var(--muted); font-size: 13px; flex: 1; min-width: 180px; }
.focus-chip, .share-banner {
  margin: 0 10px 8px; padding: 8px 12px; border-radius: 999px; background: var(--bg-elev);
  display: flex; gap: 10px; align-items: center;
}
.viewport {
  position: relative; flex: 1; min-height: 480px; overflow: hidden; touch-action: none;
  background:
    radial-gradient(ellipse at 50% 35%, var(--map-glow), transparent 58%),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    var(--map);
  background-size: auto, 32px 32px, 32px 32px, auto;
}
#stage { width: 100%; height: 100%; display: block; }
.node-body { fill: var(--node); stroke: var(--node-line); stroke-width: 2; }
.node.is-selected .node-body { stroke: var(--accent); stroke-width: 3.5; }
.node.is-done .node-body { fill: var(--node-done); }
.node.is-drop .node-body { stroke: var(--accent); stroke-width: 4; }
.node.is-match .node-body { stroke: var(--accent); }
.node.is-dragging { pointer-events: none; }
.node-title { fill: var(--node-ink); font-size: 15px; font-family: var(--font); }
.node-state { fill: var(--muted-node); font-size: 12px; font-family: var(--sans); }
.node-icon { color: var(--accent); }
.node-icon path, .node-icon circle, .node-icon line, .node-icon polyline, .node-icon rect {
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.edge { fill: none; stroke: var(--edge); stroke-width: 2.6; stroke-linecap: round; }
.edge.is-frontier { stroke-dasharray: 5 7; animation: ants 0.55s linear infinite; }
.edge.is-drop { stroke: var(--accent); stroke-width: 4.5; }
.edge-handle { cursor: grab; }
.edge-handle:active { cursor: grabbing; }
.edge-handle-hit { fill: transparent; }
.edge-handle-knob { fill: var(--node); stroke: var(--edge); stroke-width: 2; }
.edge-handle-grip {
  fill: none; stroke: var(--edge); stroke-width: 1.5; stroke-linecap: round; pointer-events: none;
}
.edge-handle-label {
  font-size: 11px; font-family: var(--sans); fill: var(--ink);
  stroke: var(--map); stroke-width: 4px; paint-order: stroke;
  opacity: 0; pointer-events: none;
}
.edge-handle:hover .edge-handle-label,
.edge-handle:focus .edge-handle-label { opacity: 1; }
#preview { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 6; display: none; }
#preview.is-on { display: block; }
.plus circle { fill: var(--accent); }
.plus path { stroke: var(--accent-ink); stroke-width: 2.2; fill: none; stroke-linecap: round; }
.plus { cursor: pointer; }
.check circle { fill: var(--node); stroke: var(--node-line); stroke-width: 1.6; }
.is-done .check circle { fill: var(--ok); stroke: var(--ok); }
.check path { fill: none; stroke: white; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.check { cursor: pointer; }
[data-readonly="on"] .plus, [data-readonly="on"] .check { pointer-events: none; }
.lock-mark { opacity: 0.55; pointer-events: none; }
.lock-mark .lock-body,
.lock-mark .lock-shackle { fill: none; stroke: var(--node-ink); stroke-width: 2.6; }
.lock-mark .lock-hole { fill: var(--node-ink); stroke: none; }
[data-locks="off"] .lock-mark { display: none; }
[data-locks="on"] .node.is-locked { opacity: 0.4; }
.node.is-pulse .node-body { animation: pulse 0.8s ease; }

.outline-item {
  width: 100%; text-align: left; background: transparent; color: inherit; border: 0;
  border-radius: 10px; padding: 8px 10px; display: flex; justify-content: space-between; gap: 8px;
}
.outline-item.is-on, .outline-item:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.outline-item small { color: var(--muted); }
.inline-editor {
  position: absolute; transform: translate(-50%, 0); display: flex; gap: 6px; align-items: center;
  background: var(--bg-elev); padding: 8px; border-radius: 14px; box-shadow: var(--shadow); z-index: 2;
}
.inline-editor input { width: 180px; background: var(--bg); color: var(--ink); }
.inline-editor .button { background: var(--accent); color: var(--accent-ink); border: 0; }
.inline-editor .button.ghost {
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
}
.empty-map {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; gap: 8px;
}
.empty-map[hidden], .inline-editor[hidden], .celebrate[hidden], .toast[hidden] { display: none; }
.task-icon svg, .celebrate-icon svg, .icon-choice svg { width: 28px; height: 28px; }
.icon-choice svg { width: 22px; height: 22px; }
.icon-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-choice svg * { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.prereq-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.prereq-list li { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.combo { position: relative; display: flex; }
.combo input { flex: 1; border-radius: 12px 0 0 12px; }
.combo-browse { border-radius: 0 12px 12px 0; }
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 3; margin: 0; padding: 6px;
  list-style: none; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px;
  max-height: 240px; overflow: auto; box-shadow: var(--shadow);
}
.combo-list button { width: 100%; text-align: left; background: transparent; color: inherit; border: 0; border-radius: 8px; padding: 6px 8px; }
.combo-list button.is-highlight, .combo-list button:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.combo-list small { color: var(--muted); font-size: 12px; }
.combo-empty { color: var(--muted); padding: 6px 8px; }
.list-row { display: grid; grid-template-columns: 1.2fr 1.2fr 140px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.add-result { margin-top: 18px; padding: 16px; background: var(--bg-elev); border-radius: var(--radius); }

.stat-hero { display: flex; gap: 18px; align-items: center; }
.ring {
  width: 140px; height: 140px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0);
  display: grid; place-items: center; position: relative;
}
.ring::after {
  content: ""; position: absolute; inset: 16px; border-radius: 50%; background: var(--bg-elev);
}
.ring strong, .ring span { position: relative; z-index: 1; display: block; text-align: center; }
.stat-split { list-style: none; padding: 0; margin: 0; }
.pairs { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; }
.pairs div { display: contents; }
.chain { margin: 0; padding-left: 18px; }
.layer-bars { list-style: none; padding: 0; display: grid; gap: 8px; }
.layer-bars li { display: grid; grid-template-columns: 72px 1fr auto; gap: 8px; align-items: center; }
.icon-counts { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.icon-counts li { background: var(--bg); border-radius: 999px; padding: 6px 10px; display: flex; gap: 8px; }
.wide { grid-column: 1 / -1; }
.plain-list { padding-left: 18px; }

.subnav { display: flex; gap: 14px; margin-bottom: 12px; }
.subnav a { color: var(--muted); text-decoration: none; }
.subnav a[aria-current="page"] { color: var(--ink); }
.overview-row { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); }
.overview-row b { color: var(--ink); font-size: 22px; margin-right: 4px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-edit { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; }
.admin-edit input:not([type="checkbox"]):not([type="hidden"]) { width: 140px; }
.pill { border: 1px solid var(--accent); color: var(--accent); border-radius: 99px; padding: 0 6px; font-size: 12px; }
.pager { display: flex; gap: 12px; }

.celebrate {
  position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.28); z-index: 6;
}
.celebrate-card {
  background: var(--node); color: var(--node-ink); padding: 28px 32px; border-radius: 28px;
  border: 3px solid var(--accent);
  box-shadow: var(--shadow); text-align: center; min-width: 280px; animation: rise 0.45s ease;
}
.celebrate-icon { display: grid; place-items: center; }
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev); color: var(--ink); padding: 10px 14px; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 7;
}

@keyframes flow { to { stroke-dashoffset: -36; } }
@keyframes ants { to { stroke-dashoffset: -24; } }
@keyframes rise { from { transform: translateY(10px) scale(0.98); } to { transform: none; } }
@keyframes pulse { 50% { stroke: var(--accent); stroke-width: 5; } }
@media (prefers-reduced-motion: reduce) {
  .edge, .edge.is-frontier, .celebrate-card, .node.is-pulse .node-body { animation: none; }
}
@media (max-width: 960px) {
  .workspace { flex-direction: column; }
  .pane-left, .pane-right { width: auto !important; max-height: 280px; }
  .resizer { display: none; }
  .topbar { flex-wrap: wrap; }
  .hero h1 { font-size: 42px; }
  .list-row { grid-template-columns: 1fr; }
}
