:root {
  --bg: #f6f5f2;
  --bg2: #ffffff;
  --bg3: #eeece7;
  --line: #dcd9d2;
  --line2: #c9c5bc;
  --fg: #1d1c1a;
  --fg2: #5c5952;
  --fg3: #8a867d;
  --accent: #6b4cff;
  --accent-fg: #ffffff;
  --good: #1f8a4c;
  --warn: #b7791f;
  --bad: #c9362b;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --r: 8px;
  --side: 236px;
  --st-idea: #8a867d;
  --st-draft: #b7791f;
  --st-settled: #1f8a4c;
  --st-built: #2f6fd6;
  --st-cut: #c9362b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214; --bg2: #191a1d; --bg3: #222327; --line: #2c2e33; --line2: #3a3d44;
    --fg: #ecebe8; --fg2: #a9a7a1; --fg3: #75736e; --accent: #8b74ff;
    --good: #4cc27e; --warn: #e3a948; --bad: #ff6b5e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.35);
    --st-idea: #8d8b86; --st-draft: #e3a948; --st-settled: #4cc27e; --st-built: #6aa1ff; --st-cut: #ff6b5e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111214; --bg2: #191a1d; --bg3: #222327; --line: #2c2e33; --line2: #3a3d44;
  --fg: #ecebe8; --fg2: #a9a7a1; --fg3: #75736e; --accent: #8b74ff;
  --good: #4cc27e; --warn: #e3a948; --bad: #ff6b5e;
  --st-idea: #8d8b86; --st-draft: #e3a948; --st-settled: #4cc27e; --st-built: #6aa1ff; --st-cut: #ff6b5e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.45 Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
code, .mono, kbd { font-family: "JetBrains Mono", Consolas, ui-monospace, monospace; font-size: 12px; }
kbd { border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--fg3); background: var(--bg2); }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 8px; }
h3 small, h2 small { color: var(--fg3); font-weight: 400; font-size: 12px; }
.dim { color: var(--fg3); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.bad { color: var(--bad); }
.sub { color: var(--fg2); margin: 0; max-width: 760px; }
[hidden] { display: none !important; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%;
  outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { resize: vertical; min-height: 38px; }
input[type="checkbox"] { width: auto; }
input[type="color"] { padding: 2px; width: 44px; height: 34px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); background: var(--bg2);
  border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; font-weight: 500;
}
.btn:hover { border-color: var(--fg3); color: var(--fg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-fg); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.small { padding: 3px 9px; font-size: 12px; }
.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--fg2); text-decoration: underline; text-underline-offset: 2px; }
.icon-btn { background: none; border: 0; font-size: 20px; cursor: pointer; display: none; }
.x { background: none; border: 0; cursor: pointer; color: var(--fg3); font-size: 16px; line-height: 1; padding: 0 4px; }
.x:hover { color: var(--bad); }

/* Layout */
#app { display: flex; height: 100vh; }
#side {
  width: var(--side); flex: none; background: var(--bg2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 14px 14px 12px; }
.brand img { width: 34px; height: 34px; border-radius: 8px; image-rendering: pixelated; }
.brand b { display: block; font-size: 15px; }
.brand small { color: var(--fg3); font-size: 12px; }
#nav, #layer-nav { display: flex; flex-direction: column; padding: 0 8px; }
#nav a, #layer-nav a {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 6px; color: var(--fg2);
}
#nav a:hover, #layer-nav a:hover { background: var(--bg3); color: var(--fg); }
#nav a.active, #layer-nav a.active { background: var(--bg3); color: var(--fg); font-weight: 600; }
#nav i { width: 16px; text-align: center; font-style: normal; color: var(--fg3); }
.count { margin-left: auto; font-size: 11px; font-weight: 600; background: var(--bg3); border-radius: 10px; padding: 0 7px; color: var(--fg2); }
.count.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.count.dim { background: none; color: var(--fg3); font-weight: 400; }
.side-head { padding: 16px 16px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg3); }
.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.side-foot { margin-top: auto; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); }
.live { color: var(--fg3); font-size: 10px; }
.live.on { color: var(--good); }

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#top { display: flex; gap: 10px; align-items: center; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.search-btn {
  flex: 1; max-width: 520px; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; color: var(--fg3); cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.search-btn:hover { border-color: var(--line2); }
#new-btn { margin-left: auto; }
#banner { display: flex; gap: 10px; align-items: center; padding: 8px 24px; background: color-mix(in srgb, var(--warn) 16%, var(--bg2)); border-bottom: 1px solid var(--line); }
#banner .x { margin-left: auto; }
#view { flex: 1; overflow-y: auto; padding: 24px 28px 80px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.crumbs { color: var(--fg3); font-size: 12px; margin-bottom: 6px; }
.crumbs a:hover { color: var(--accent); }
h2.section { margin: 28px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.empty { padding: 40px 0; text-align: center; }

/* Pills, chips, badges */
.pill {
  font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 10px; white-space: nowrap;
  background: color-mix(in srgb, var(--fg3) 14%, transparent); color: var(--fg2); letter-spacing: .01em;
}
.pill.st-idea { background: color-mix(in srgb, var(--st-idea) 16%, transparent); color: var(--st-idea); }
.pill.st-draft { background: color-mix(in srgb, var(--st-draft) 16%, transparent); color: var(--st-draft); }
.pill.st-settled { background: color-mix(in srgb, var(--st-settled) 16%, transparent); color: var(--st-settled); }
.pill.st-built { background: color-mix(in srgb, var(--st-built) 16%, transparent); color: var(--st-built); }
.pill.st-cut { background: color-mix(in srgb, var(--st-cut) 16%, transparent); color: var(--st-cut); text-decoration: line-through; }
h1 .pill { font-size: 12px; }
.sdot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--st-idea); }
.sdot.st-draft { background: var(--st-draft); } .sdot.st-settled { background: var(--st-settled); } .sdot.st-built { background: var(--st-built); } .sdot.st-cut { background: var(--st-cut); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
  background: color-mix(in srgb, var(--c, var(--fg3)) 12%, var(--bg2)); border: 1px solid color-mix(in srgb, var(--c, var(--fg3)) 35%, transparent);
  border-radius: 5px; padding: 1px 4px 1px 6px; font-size: 12.5px;
}
.chip a { display: inline-flex; gap: 5px; align-items: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip i { font-style: normal; color: var(--c); }
.chip.missing { --c: var(--bad); border-style: dashed; }
.chip.missing a { color: var(--bad); }
.chip.tag { --c: var(--fg3); padding-right: 2px; }
.chip .x { font-size: 13px; }
.tbadge { font-size: 11.5px; font-weight: 600; color: var(--c); white-space: nowrap; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 22px; }
.stat { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; }
.stat b { font-size: 24px; line-height: 1.1; }
.stat span { color: var(--fg3); font-size: 12px; }
a.stat:hover { border-color: var(--line2); color: inherit; }
.stat.bad b { color: var(--bad); } .stat.warn b { color: var(--warn); } .stat.good b { color: var(--good); }

/* The Stack */
.stack { display: flex; flex-direction: column; gap: 6px; position: relative; }
.band {
  display: grid; grid-template-columns: 44px 1fr minmax(220px, 300px); background: var(--bg2);
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; transition: border-color .12s, transform .12s;
}
.band:hover { border-color: var(--c); color: inherit; transform: translateX(2px); }
.band.offarc { opacity: .8; border-style: dashed; }
.band-strip {
  background: var(--c); display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 18px; text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.band-main { padding: 12px 16px; min-width: 0; }
.band-title { display: flex; gap: 8px; align-items: center; font-size: 16px; }
.band-id { color: var(--fg2); margin: 2px 0 6px; }
.band-gate { display: flex; gap: 18px; font-size: 12.5px; color: var(--fg3); flex-wrap: wrap; }
.band-gate b { color: var(--fg); font-weight: 600; }
.band-gate em { color: var(--bad); font-style: normal; }
.band-side { padding: 12px 16px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.eco span { font-size: 12px; color: var(--fg3); }
.pips { display: flex; gap: 3px; margin-top: 4px; }
.pips i { flex: 1; height: 6px; border-radius: 2px; background: var(--bg3); }
.pips i.ok { background: var(--good); }
.band-counts { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.band-counts span { color: var(--c); font-weight: 600; }
.sbar { display: flex; height: 4px; border-radius: 2px; overflow: hidden; background: var(--bg3); }
.sbar i.st-idea { background: var(--st-idea); } .sbar i.st-draft { background: var(--st-draft); } .sbar i.st-settled { background: var(--st-settled); } .sbar i.st-built { background: var(--st-built); }

.type-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 10px; }
.type-tile { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; }
.type-tile:hover { border-color: var(--c); color: inherit; }
.type-tile i { font-style: normal; color: var(--c); font-size: 18px; grid-row: span 2; }
.type-tile b { font-size: 18px; line-height: 1; }
.type-tile span { color: var(--fg3); font-size: 12px; }

/* Layer page */
.layer-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding-bottom: 16px; border-bottom: 3px solid var(--c); margin-bottom: 4px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eco-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.eco-card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.eco-card:hover { border-color: var(--line2); color: inherit; }
.eco-card b { font-size: 12px; }
.eco-card.ok b { color: var(--good); }
.eco-card.no { border-style: dashed; }
.eco-card.no b, .eco-card em { color: var(--fg3); font-style: normal; }
.eco-card span { color: var(--fg2); }

.beats { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr); gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.beat { background: var(--bg3); border-radius: var(--r); padding: 8px; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.beat-head b { display: block; font-size: 13px; }
.beat-head small { color: var(--fg3); font-size: 11px; line-height: 1.3; display: block; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.card:hover { border-color: var(--accent); color: inherit; }
.card-title { font-weight: 600; font-size: 13px; }
.card-sub { font-size: 12px; color: var(--fg2); margin-top: 2px; }
.card-foot { display: flex; gap: 6px; align-items: center; margin-top: 6px; font-size: 11px; }
.inline-add { background: transparent; border: 1px dashed var(--line2); font-size: 12.5px; padding: 5px 8px; }
.inline-add:focus { background: var(--bg2); border-style: solid; }

.content-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.content-col { background: var(--bg2); border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.col-head { display: flex; gap: 8px; align-items: center; }
.col-head i { font-style: normal; color: var(--c); }
.col-head .dim { margin-left: auto; }
.col-list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 8px; padding: 4px 4px; border-radius: 4px; font-size: 13px; }
.row:hover { background: var(--bg3); color: inherit; }
.row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .dim { font-size: 11.5px; }
.more { font-size: 12px; color: var(--accent); padding: 4px; }
.cut-list { margin-top: 20px; color: var(--fg3); }

/* Entity page */
.entity-head { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 18px; }
.title-row { display: flex; align-items: center; gap: 12px; }
.title-input { font-size: 26px; font-weight: 700; border: 1px solid transparent; background: transparent; padding: 2px 6px; margin-left: -6px; letter-spacing: -.01em; }
.title-input:hover { border-color: var(--line); }
.entity-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.form { display: flex; flex-direction: column; gap: 14px; max-width: 820px; }
.form.compact { gap: 10px; margin: 10px 0; }
.field { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; align-items: start; border-radius: 6px; transition: background .4s; }
.field > label { padding-top: 7px; font-weight: 600; font-size: 13px; color: var(--fg2); }
.field > label small { display: block; font-weight: 400; color: var(--fg3); font-size: 11.5px; line-height: 1.35; margin-top: 2px; }
.form.compact .field { grid-template-columns: 80px 1fr; }
.field.flash { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.field.k-longtext, .field.k-ingredients { grid-template-columns: 190px minmax(0, 1fr); }
.toggle { display: inline-flex; align-items: center; cursor: pointer; padding-top: 6px; }
.toggle input { display: none; }
.toggle span { width: 34px; height: 20px; border-radius: 10px; background: var(--line2); position: relative; transition: background .15s; }
.toggle span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(14px); }
.color-row { display: flex; gap: 8px; }
.color-row .mono { max-width: 120px; }

.picker {
  position: relative; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; min-height: 36px;
}
.picker:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.picker > input { border: 0; padding: 3px 2px; flex: 1; min-width: 120px; width: auto; box-shadow: none !important; background: transparent; }
.pop {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; background: var(--bg2); border: 1px solid var(--line2);
  border-radius: 6px; box-shadow: var(--shadow); padding: 4px; max-height: 320px; overflow-y: auto;
}
.opt { padding: 6px 8px; border-radius: 4px; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.opt i { font-style: normal; }
.opt small { margin-left: auto; color: var(--fg3); font-size: 11.5px; }
.opt.active { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.opt.create { color: var(--accent); }
.ingredients { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ing-row { display: grid; grid-template-columns: 64px auto minmax(0, 1fr) auto; gap: 6px; align-items: center; width: 100%; }
.ing-row .qty { text-align: right; }

.longtext { display: flex; flex-direction: column; gap: 4px; }
.tabs { display: flex; gap: 2px; }
.tab { background: none; border: 0; padding: 2px 8px; border-radius: 4px; cursor: pointer; color: var(--fg3); font-size: 12px; }
.tab.active { background: var(--bg3); color: var(--fg); }
.md { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; min-height: 38px; }
.md p { margin: 6px 0; } .md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md h3, .md h4, .md h5 { margin: 12px 0 4px; }
.md blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--line2); color: var(--fg2); }
.md pre { background: var(--bg3); padding: 8px; border-radius: 4px; overflow-x: auto; }
.md code { background: var(--bg3); padding: 0 4px; border-radius: 3px; }
.wl { color: var(--accent); border-bottom: 1px dotted; }
.wl.missing { color: var(--bad); }
.guide { max-width: 760px; border: 0; background: none; padding: 0; font-size: 14.5px; }
.guide h3 { font-size: 17px; margin-top: 22px; }
.guide li { margin: 4px 0; }

.side-col { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; }
.panel { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.back-group { margin-bottom: 8px; }
.back-group .dim { font-size: 11.5px; margin-bottom: 3px; }
.comments { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; max-height: 420px; overflow-y: auto; }
.comment .c-head { display: flex; gap: 8px; font-size: 12px; margin-bottom: 2px; }
.comment .md { padding: 4px 8px; min-height: 0; background: var(--bg); font-size: 13px; }
.panel textarea { margin-bottom: 6px; }
.meta > div { font-size: 12.5px; margin-bottom: 4px; }
.meta-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.savebar {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 140%); z-index: 40; background: var(--fg); color: var(--bg);
  border-radius: 10px; padding: 8px 8px 8px 16px; display: flex; gap: 8px; align-items: center; box-shadow: var(--shadow); transition: transform .18s ease;
}
.savebar.show { transform: translate(-50%, 0); }
.savebar .btn:not(.primary) { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 40%, transparent); }

/* Votes / questions */
.votes { display: flex; flex-direction: column; gap: 5px; }
.vote {
  position: relative; overflow: hidden; display: flex; justify-content: space-between; gap: 10px; text-align: left;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer;
}
.vote i { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--accent) 14%, transparent); transition: width .25s; }
.vote span { position: relative; }
.vote.mine { border-color: var(--accent); }
.vote.mine .vote-label::before { content: "✓ "; color: var(--accent); }
.vote-who { color: var(--fg3); font-size: 12px; }
.qcard { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; max-width: 860px; }
.qcard p { margin: 0; color: var(--fg2); }
.qcard.closed { opacity: .85; }
.q-head { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.q-head .dim { margin-left: auto; font-size: 12px; }
.ruling { background: color-mix(in srgb, var(--good) 10%, transparent); border-radius: 6px; padding: 8px 10px; }
.ruling p { display: inline; }

/* Browse */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters select, .filters > input { width: auto; min-width: 140px; }
.filters .spacer { flex: 1; }
.tog {
  display: inline-flex; gap: 4px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 3px 10px; cursor: pointer;
  font-size: 12.5px; background: var(--bg2); color: var(--fg2); user-select: none;
}
.tog input { display: none; }
.tog.on { border-color: var(--c, var(--accent)); color: var(--fg); background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--bg2)); }
.quick-add { display: flex; gap: 8px; align-items: center; background: var(--bg2); border: 1px dashed var(--line2); border-radius: var(--r); padding: 8px 10px; margin-bottom: 12px; max-width: 860px; }
.quick-add b { white-space: nowrap; font-size: 13px; color: var(--fg2); }
.quick-add select { width: auto; }
.quick-add .inline-add { border: 0; }
.table-wrap { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; margin-bottom: 12px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th { text-align: left; font-weight: 600; color: var(--fg3); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; user-select: none; }
.grid th.sorted { color: var(--fg); }
.grid th.sorted.asc::after { content: " ↑"; } .grid th.sorted.desc::after { content: " ↓"; }
.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--bg3); }
.clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lname { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }

/* Flow */
.flow-wrap { position: relative; }
.flow-box { height: calc(100vh - 250px); min-height: 420px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
svg.flow { cursor: grab; display: block; user-select: none; }
svg.flow.dragging { cursor: grabbing; }
.lane { fill: color-mix(in srgb, var(--c) 6%, transparent); stroke: var(--line); }
.lane-label { fill: var(--fg2); font-size: 13px; font-weight: 700; }
.node { cursor: pointer; transition: opacity .12s; }
.node .nbox { fill: var(--bg2); stroke: color-mix(in srgb, var(--c) 55%, var(--line)); stroke-width: 1.2; }
.node .nstripe { fill: var(--c); }
.node .nlabel { fill: var(--fg); font-size: 12px; }
.node.st-idea .nbox { stroke-dasharray: 4 3; }
.node:hover .nbox, .node.focus .nbox { stroke: var(--c); stroke-width: 2.2; }
.node.dim { opacity: .25; }
.edge { fill: none; stroke: var(--line2); stroke-width: 1.4; transition: opacity .12s; }
.edge.hot { stroke-width: 2.4; }
.edge.dim { opacity: .12; }
.edge.e-requires, .ah.e-requires { stroke: #8b949e; fill: #8b949e; }
.edge.e-unlocks, .ah.e-unlocks { stroke: #f5c542; fill: #f5c542; }
.edge.e-recipe, .ah.e-recipe { stroke: #58a6ff; fill: #58a6ff; }
.edge.e-drops, .ah.e-drops { stroke: #d2a8ff; fill: #d2a8ff; }
.edge.e-key, .ah.e-key { stroke: #ff7b72; fill: #ff7b72; }
.edge.e-gate, .ah.e-gate { stroke: #ff7b72; fill: #ff7b72; }
.edge { fill: none !important; }
.legend { display: flex; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--fg3); flex-wrap: wrap; }
.legend i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 5px; border-radius: 2px; }
.legend i.e-requires { background: #8b949e; } .legend i.e-unlocks { background: #f5c542; } .legend i.e-recipe { background: #58a6ff; }
.legend i.e-drops { background: #d2a8ff; } .legend i.e-key, .legend i.e-gate { background: #ff7b72; }
.flow-panel {
  position: absolute; top: 12px; right: 12px; width: 280px; background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 12px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100% - 24px); overflow-y: auto;
}
.flow-panel .x { position: absolute; top: 8px; right: 8px; }
.flow-panel h3 { margin: 0; font-size: 16px; }
.flow-panel p { margin: 0; color: var(--fg2); font-size: 13px; }
.flow-panel .dim { font-size: 11.5px; }
.flow-panel .btn { align-self: flex-start; }

/* Checks */
.check-list { display: flex; flex-direction: column; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); }
.check { display: flex; gap: 10px; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.check:last-child { border-bottom: 0; }
.rule { font-family: "JetBrains Mono", Consolas, monospace; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg3); color: var(--fg2); white-space: nowrap; }
.check.lvl-error .rule { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.check.lvl-warn .rule { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
h2.lvl-error { color: var(--bad); } h2.lvl-warn { color: var(--warn); }

/* Activity */
.activity { display: flex; flex-direction: column; gap: 2px; max-width: 900px; }
.act { display: flex; gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.act .when { width: 70px; flex: none; font-size: 12px; }

/* Modal, palette, toasts */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 100; }
.modal { background: var(--bg2); border: 1px solid var(--line2); border-radius: 12px; box-shadow: var(--shadow); padding: 18px; width: min(460px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; }
.modal.wide { width: min(620px, calc(100vw - 32px)); padding: 10px; }
.modal h2 { font-size: 18px; }
.modal p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.pal-input { font-size: 16px; padding: 10px 12px; }
.pal-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 6px; z-index: 200; }
.toast { background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; transition: opacity .3s, transform .3s; }
.toast.good { background: var(--good); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* Narrow screens */
@media (max-width: 1100px) {
  .entity-body { grid-template-columns: 1fr; }
  .side-col { position: static; }
}
@media (max-width: 800px) {
  #side { position: fixed; z-index: 90; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open #side { transform: none; }
  .icon-btn { display: block; }
  #top { padding: 8px 16px; }
  #view { padding: 16px 16px 80px; }
  .search-btn kbd { display: none; }
  .band { grid-template-columns: 36px 1fr; }
  .band-side { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .field, .field.k-longtext, .field.k-ingredients { grid-template-columns: 1fr; gap: 4px; }
  .field > label { padding-top: 0; }
  .layer-head, .page-head { flex-direction: column; align-items: flex-start; }
  h1 { font-size: 22px; }
  .title-input { font-size: 22px; }
}

/* Layers: insert, reorder, remove */
.stack-head { display: flex; justify-content: space-between; align-items: baseline; }
.stack { gap: 0; }
.layer-gap { display: block; width: 100%; height: 10px; border: 0; background: none; cursor: pointer; position: relative; padding: 0; }
.layer-gap span { display: none; position: absolute; inset: 1px 0; align-items: center; justify-content: center; font-size: 11.5px; color: var(--accent); border: 1px dashed var(--accent); border-radius: 6px; background: var(--bg); }
.layer-gap:hover { height: 26px; }
.layer-gap:hover span { display: flex; }
.band-row { position: relative; display: grid; grid-template-columns: 26px 1fr; gap: 4px; align-items: stretch; }
.band-row.dragging { opacity: .4; }
.band-row.over .band { border-color: var(--accent); box-shadow: 0 -3px 0 var(--accent); }
.band-tools { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; opacity: .25; transition: opacity .12s; }
.band-row:hover .band-tools { opacity: 1; }
.band-tools button { border: 0; background: none; cursor: pointer; color: var(--fg3); font-size: 11px; line-height: 1; padding: 2px; }
.band-tools button:hover:not(:disabled) { color: var(--fg); }
.band-tools button:disabled { opacity: .3; cursor: default; }
.band-tools .del:hover { color: var(--bad) !important; }
.grip { cursor: grab; color: var(--fg3); font-size: 14px; }
.check-row { display: flex; gap: 8px; align-items: center; font-size: 13px; }

/* Corkboards */
#view.full { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.board-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.board-bar select { width: auto; padding: 4px 8px; }
.board-pick { font-weight: 600; }
.board-bar .spacer { flex: 1; }
.board-bar .btn.on { background: color-mix(in srgb, #ffe94d 40%, var(--bg2)); border-color: #c9a800; }
.tracks { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.track { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); background: var(--bg2); border-radius: 12px; padding: 2px 10px 2px 6px; font-size: 12px; cursor: pointer; }
.track i { width: 11px; height: 11px; border-radius: 50%; background: var(--tc); box-shadow: inset -2px -2px 0 rgba(0,0,0,.25); }
.track.on { border-color: var(--fg2); font-weight: 600; }
#board-nav { display: flex; flex-direction: column; padding: 0 8px; }
#board-nav a { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 6px; color: var(--fg2); }
#board-nav a:hover, #board-nav a.active { background: var(--bg3); color: var(--fg); }
#board-nav a.active { font-weight: 600; }
#board-nav a i { font-style: normal; width: 16px; text-align: center; font-size: 12px; }
#board-nav a.add { color: var(--fg3); font-size: 12.5px; }

.bwrap { position: relative; flex: 1; min-height: 0; }
.cork {
  position: absolute; inset: 0; overflow: hidden; outline: none; touch-action: none; cursor: grab;
  background: #3f3428;
}
.cork.hl-tool { cursor: crosshair; }
.cworld { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.cworld.glide { transition: transform .26s ease; }
.csections, .cnotes, .ctags { position: absolute; left: 0; top: 0; }
.ctags { z-index: 4; }
.csections { z-index: 1; }
.cnotes { z-index: 2; }
.cstrings { position: absolute; z-index: 3; overflow: visible; pointer-events: none; }
.cstrings-hit { position: absolute; z-index: 1; overflow: visible; pointer-events: none; }
.string-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }

/* Highlighted areas: a marker swipe over the cork */
.hl { position: absolute; border-radius: 14px; background: color-mix(in srgb, var(--hc) 30%, transparent); border: 3px solid color-mix(in srgb, var(--hc) 75%, transparent); }
.hl.sel { border-style: dashed; border-color: var(--hc); background: color-mix(in srgb, var(--hc) 38%, transparent); }
.hl.draft { --hc: #ffe94d; z-index: 5; border-style: dashed; pointer-events: none; }
.hl-tag {
  position: absolute; padding: 5px 14px 6px; background: var(--hc); color: #1d1c1a;
  font: 700 18px/1.1 Inter, "Segoe UI", system-ui, sans-serif; border-radius: 4px; cursor: move; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.hl-tag small { font-weight: 500; font-size: 12px; margin-left: 8px; opacity: .65; }
.hl-resize { position: absolute; right: -6px; bottom: -6px; width: 18px; height: 18px; border-radius: 4px; background: var(--hc); cursor: nwse-resize; opacity: 0; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.hl:hover .hl-resize, .hl.sel .hl-resize { opacity: 1; }

/* Stickies */
.sticky {
  position: absolute; display: flex; flex-direction: column; background: var(--paper); color: #1d1c1a;
  border-radius: 2px; transition: box-shadow .15s, opacity .15s;
  box-shadow: 0 1px 1px rgba(0,0,0,.15), 0 6px 14px rgba(40, 20, 0, .35);
  font: 13.5px/1.42 "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.sticky.lifted { box-shadow: 0 16px 34px rgba(0, 0, 0, .5); }
.sticky.sel { outline: 3px solid #2f6fd6; outline-offset: 3px; }
.sticky.down { outline: 2px solid rgba(47, 111, 214, .7); outline-offset: 2px; }
.sticky.up { outline: 2px dashed rgba(47, 111, 214, .55); outline-offset: 2px; }
.sticky.far { opacity: .45; }
.sticky.off { opacity: .2; }
.sticky.target { outline: 3px solid #2e9e57; outline-offset: 3px; }
.st-bar {
  flex: none; height: 22px; display: flex; align-items: center; gap: 6px; padding: 0 6px 0 5px; cursor: move;
  background: color-mix(in srgb, var(--paper) 82%, #000); user-select: none;
}
.st-close { width: 16px; height: 16px; flex: none; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 3px; font: 700 15px/16px Inter, system-ui, sans-serif; color: rgba(0,0,0,.5); display: inline-flex; align-items: center; justify-content: center; }
.st-close:hover { background: rgba(0,0,0,.12); color: #a3241b; }
.st-label { flex: 0 1 auto; max-width: calc(50% - 22px); min-width: 0; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; color: rgba(0,0,0,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 2px; }
.sticky.collapsed .st-label { max-width: none; flex: 1; padding-left: 14px; }
.st-more { border: 0; background: none; cursor: pointer; padding: 0 2px; color: rgba(0,0,0,.55); font-size: 15px; line-height: 1; }
.st-more:hover { color: #000; }
.st-link { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; padding: 8px 10px 0; font-size: 13.5px; }
.st-link i { font-style: normal; opacity: .6; }
.st-link.missing b { color: #a3241b; }
.st-link .pill { background: rgba(0,0,0,.1); color: rgba(0,0,0,.65); }
.st-text {
  flex: 1; min-height: 0; width: 100%; resize: none; border: 0; outline: none; background: transparent; color: #1d1c1a;
  padding: 8px 10px; font: inherit; box-shadow: none !important; border-radius: 0;
}
.st-text::placeholder { color: rgba(0,0,0,.32); font-style: italic; }
.st-foot { flex: none; display: flex; gap: 6px; justify-content: flex-end; padding: 0 10px; }
.st-plus { font-size: 11px; font-weight: 700; background: rgba(0,0,0,.1); border-radius: 8px; padding: 0 7px; color: rgba(0,0,0,.65); }
.st-track { font-size: 10.5px; font-weight: 700; color: rgba(0,0,0,.55); display: inline-flex; gap: 4px; align-items: center; }
.st-track::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tc); }
.st-resize { position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,.18) 50%); }
.sticky.collapsed .st-link, .sticky.collapsed .st-text, .sticky.collapsed .st-foot, .sticky.collapsed .st-resize { display: none; }
.sticky.collapsed .st-label { color: rgba(0,0,0,.75); font-size: 11.5px; letter-spacing: 0; }

/* Red string and pins */
.string { pointer-events: none; }
.string .shadow { fill: none; stroke: rgba(0,0,0,.28); stroke-width: 3; transform: translate(2px, 4px); }
.string .line { fill: none; stroke: #c8202a; stroke-width: 2.4; stroke-linecap: round; }
.string .chev { fill: none; stroke: #c8202a; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.string.hot .line, .string.hot .chev { stroke: #ff2d37; stroke-width: 3.4; }
.string.sel .line { stroke-dasharray: 8 5; }
.string.dim { opacity: .18; }
.slabel { font: 600 12px Inter, sans-serif; fill: #1d1c1a; paint-order: stroke; stroke: #fdf59c; stroke-width: 5px; }
.sdraft { fill: none; stroke: #c8202a; stroke-width: 2.4; stroke-dasharray: 6 5; }
.pin { pointer-events: auto; cursor: crosshair; }
.pin.dim { opacity: .3; }
.pin-shadow { fill: rgba(0,0,0,.3); }
.pin-head { stroke: rgba(0,0,0,.35); stroke-width: 1; }
.pin:hover .pin-head { stroke: #fff; stroke-width: 2; }
.pin-shine { fill: rgba(255,255,255,.75); }

/* Side panel */
.bpanel {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: 300px; z-index: 20; background: var(--bg2); border: 1px solid var(--line2);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto;
}
.bpanel > .x { position: absolute; top: 8px; right: 8px; }
.bpanel h3 { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg3); }
.bpanel .form.compact { margin: 0; }
.bpanel .plus { align-self: flex-start; }
.kinds { display: flex; flex-wrap: wrap; gap: 4px; }
.kinds .tog { font-size: 12px; padding: 2px 9px; }
.follow { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.follow .btn { justify-content: flex-start; white-space: normal; text-align: left; }
.bhelp { padding: 6px 16px; font-size: 12px; border-top: 1px solid var(--line); background: var(--bg2); }
.track-edit { display: flex; flex-direction: column; gap: 8px; }
.track-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.sw { width: 18px; height: 18px; border-radius: 4px; border: 2px solid rgba(0,0,0,.15); cursor: pointer; padding: 0; }
.swatches.big .sw { width: 26px; height: 26px; }
.sw.round { border-radius: 50%; }
.sw.on { border-color: var(--fg); box-shadow: 0 0 0 2px var(--bg2), 0 0 0 4px var(--fg2); }
.plus { border: 1px solid var(--line2); background: var(--bg2); border-radius: 12px; padding: 2px 10px; font-size: 12px; cursor: pointer; font-weight: 600; color: var(--fg2); }
.plus.mine { background: color-mix(in srgb, var(--accent) 16%, var(--bg2)); border-color: var(--accent); color: var(--accent); }
@media (max-width: 800px) { .bpanel { left: 12px; width: auto; top: auto; max-height: 60%; } .bhelp { display: none; } }

/* How the game should feel (Stack page) */
.vision { background: var(--bg2); border: 1px solid var(--line); border-left: 4px solid #c2effc; border-radius: var(--r); padding: 12px 16px; margin-bottom: 18px; }
.vision-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.vision-head a { color: var(--accent); font-size: 12.5px; }
.vision ul { margin: 4px 0 0; padding-left: 18px; }
.vision li { margin: 3px 0; }
.vision p { margin: 4px 0 0; font-size: 13px; }

.st-text::-webkit-scrollbar { width: 6px; }
.st-text::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 3px; }
.st-text::-webkit-scrollbar-track { background: transparent; }
.st-text { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.2) transparent; }
.st-bar .spacer { flex: 1; }
.st-foot .spacer { flex: 1; }
.st-foot:has(.st-kind, .st-plus, .st-track) { padding-bottom: 6px; }
.st-kind { font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 1px 7px; border-radius: 3px; background: rgba(0,0,0,.1); color: rgba(0,0,0,.6); }
.st-kind.k-vision { background: #1d1c1a; color: #fdf59c; }

/* Board controls: drag moves, double-click types. No stray text selection while dragging. */
.cork, .cork * { -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
.sticky { cursor: grab; }
.sticky:active { cursor: grabbing; }
.sticky:not(.editing) .st-text { pointer-events: none; cursor: inherit; }
.sticky.editing { cursor: default; }
.sticky.editing .st-text { -webkit-user-select: text; user-select: text; cursor: text; }
.sticky.editing { outline: 3px solid #2e9e57; outline-offset: 3px; }

/* The pushpin, part of the note so it moves with it. Drag it to tie string. */
.st-pin {
  position: absolute; left: 50%; top: 0; width: 15px; height: 15px; margin: -1px 0 0 -7.5px; border-radius: 50%; z-index: 2;
  background: radial-gradient(circle at 34% 32%, rgba(255,255,255,.85) 0 2px, transparent 3px), var(--pin, #d83a34);
  border: 1px solid rgba(0,0,0,.35); box-shadow: 3px 4px 4px rgba(0,0,0,.35); cursor: crosshair;
}
.st-pin:hover { box-shadow: 0 0 0 3px rgba(255,255,255,.7), 3px 4px 4px rgba(0,0,0,.35); }
.sticky { contain: layout style; }
.cstrings { z-index: 3; }

/* Zoomed out: area names stay readable, notes get cheap to draw. */
.hl-tag { font-size: max(18px, calc(13px / var(--zoom, 1))); }
.hl-tag small { font-size: 0.62em; }
.cork.zoomed-out .sticky { box-shadow: none; transition: none; }
.cork.zoomed-out .st-text, .cork.zoomed-out .st-foot, .cork.zoomed-out .st-link { visibility: hidden; }
.cork.zoomed-out .hl-tag { box-shadow: none; }
.hl-tag { overflow: hidden; text-overflow: ellipsis; }
.board-bar select { max-width: 240px; }

/* Sidebar board list */
#board-nav a .bname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zoom-read { min-width: 52px; justify-content: center; font-variant-numeric: tabular-nums; }
.modal-actions .spacer { flex: 1; }
.snip { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal textarea { width: 100%; }
