/* Layout: two tabs over one shared store. Mind map = a pannable, zoomable stage with the brand's gold hub and four coloured branches; Workshop board = a journey spine of four layers with annotation slots on each route card. Single light theme, by brand choice. */
:root {
  --bg: #F3EEE4;
  --surface: #FFFDF9;
  --sunk: #EAE2D3;
  --ink: #292929;
  --muted: #6B645A;
  --line: #E0D6C3;
  --red: #E7344A;
  --taupe: #C7BA9F;
  --bronze: #AD8B5B;
  --gold: linear-gradient(330deg, rgba(245,223,173,1) 0%, rgba(195,159,115,1) 100%);
  --good: #2E7356;
  --good-soft: #E1EEE6;
  --mid: #B57A12;
  --mid-soft: #F6EAD3;
  --bad: #A8281F;
  --bad-soft: #F6DEDA;
  --scrim: rgba(41, 41, 41, 0.4);
  --font-display: "Kessler Display", "Bodoni Moda", Didot, "Bodoni 72", Georgia, serif;
  --font-body: "General Sans", "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-weight: 500; font-size: 14px; line-height: 1.5; }
.wrap { max-width: 1480px; margin: 0 auto; padding-inline: 20px; padding-block: 28px 64px; display: grid; gap: 20px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* Header */
.top { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-end; justify-content: space-between; }
.top > div { min-width: 0; }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--bronze); }
h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(32px, 4.2vw, 50px); line-height: 1.04; margin: 6px 0 8px; text-wrap: balance; }
.lead { max-width: 66ch; color: var(--muted); margin: 0; font-weight: 400; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-weight: 500; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.save { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--taupe); }
.save[data-state="ok"]::before { background: var(--good); }
.save[data-state="busy"]::before { background: var(--mid); }
.save[data-state="error"]::before { background: var(--bad); }
.env-banner { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 12; background: var(--red); color: #FFFFFF; text-align: center; font-size: 13px; padding: 7px 16px; }
.env-banner b { letter-spacing: 0.1em; text-transform: uppercase; font-size: 11.5px; margin-right: 8px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: transparent; padding: 10px 16px 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--red); }

/* Controls */
.controls { display: grid; gap: 10px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.ctrl-row { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.ctrl-label { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); min-width: 84px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.key { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.key span { display: inline-flex; align-items: center; gap: 6px; }

/* Status diamond */
.dia { width: 10px; height: 10px; transform: rotate(45deg); border: 1.5px solid var(--taupe); background: transparent; flex: none; display: inline-block; }
.dia[data-s="strength"] { background: var(--good); border-color: var(--good); }
.dia[data-s="mixed"] { background: linear-gradient(135deg, var(--mid) 50%, transparent 50%); border-color: var(--mid); }
.dia[data-s="weakness"] { background: var(--bad); border-color: var(--bad); }
.star { font-size: 15px; line-height: 1; color: var(--red); }
.ldot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }

/* Summary */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.sum { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: grid; gap: 8px; }
.sum-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.sum-name { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.sum-num { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--sunk); }
.bar i { display: block; height: 100%; }
.sum-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Board layers */
.layers { display: grid; gap: 28px; }
.layer { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; position: relative; }
/* Left column runs the full height of the layer: heading block on top, then the dashed line down to the next layer. */
.rail-col { display: flex; flex-direction: column; align-self: stretch; min-width: 0; }
.layer:not(:last-child) .rail-col::after { content: ""; flex: 1 1 auto; min-height: 24px; margin: 14px 0 -28px 6px; border-left: 1px dashed var(--taupe); }
.rail { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 1; background: var(--bg); margin-top: -16px; padding: 16px 0 6px; display: grid; gap: 6px; }
.rail-num { font-family: var(--font-display); font-size: 42px; line-height: 1; display: flex; align-items: center; gap: 12px; }
.rail-num .ldot { width: 14px; height: 14px; }
.rail h2 { margin: 4px 0 0; font-size: 17px; font-weight: 600; line-height: 1.25; }
.rail p { margin: 0; color: var(--muted); font-size: 13px; max-width: 30ch; font-weight: 400; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 12px; align-items: start; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 10px; text-align: left; width: 100%; transition: opacity .2s, border-color .2s; }
.card:hover { border-color: var(--ink); }
.card.dim, .leaf.dim, .bnode.dim { opacity: 0.3; }
.card.prio { border-color: var(--red); box-shadow: 0 0 0 1px var(--red) inset; }
.card-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.card-title { font-weight: 600; font-size: 15px; line-height: 1.3; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-meta { display: flex; align-items: center; gap: 8px; flex: none; }
.status-txt { font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--sunk); color: var(--muted); }
.tag.hit { background: var(--ink); color: var(--bg); }
.items { margin: 0; padding-left: 16px; color: var(--muted); font-size: 13px; display: grid; gap: 2px; font-weight: 400; }
.items li::marker { color: var(--taupe); }
.slots { display: grid; gap: 6px; }
.slot { border: 1px dashed var(--line); border-radius: 6px; padding: 6px 9px; display: grid; gap: 2px; min-height: 44px; }
.slot-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.slot-text { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; overflow-wrap: anywhere; font-weight: 400; }
.slot-empty { font-size: 12.5px; color: var(--muted); opacity: 0.75; font-weight: 400; }
.slot.s.filled { border-style: solid; border-color: transparent; background: var(--good-soft); }
.slot.w.filled { border-style: solid; border-color: transparent; background: var(--bad-soft); }
.slot.e.filled { border-style: solid; border-color: transparent; background: var(--sunk); }
.slot.s .slot-label { color: var(--good); }
.slot.w .slot-label { color: var(--bad); }
.slot.e .slot-label { color: var(--bronze); }
body.compact .items { display: none; }

/* Mind map */
.mapbox { position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: hidden; }
.viewport { position: relative; height: clamp(440px, 74vh, 980px); overflow: hidden; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.viewport.dragging { cursor: grabbing; }
.viewport:focus-visible { outline-offset: -3px; }
body.mapfull { overflow: hidden; }
body.mapfull .mapbox { position: fixed; inset: 0; z-index: 15; border: 0; border-radius: 0; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body.mapfull .viewport { height: 100%; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.stage svg.links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.leaf { position: absolute; width: 360px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; display: grid; gap: 3px; transition: opacity .2s, border-color .15s, box-shadow .15s; }
.leaf:hover { border-color: var(--ink); }
.leaf.prio { border-color: var(--red); box-shadow: 0 0 0 1px var(--red) inset; }
.leaf-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.leaf-name { font-weight: 600; font-size: 15px; line-height: 20px; display: inline-flex; align-items: center; gap: 8px; }
.leaf-brief { font-size: 12.5px; line-height: 18px; color: var(--muted); font-weight: 400; }
.leaf-meta { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.leaf-ev { font-size: 11px; color: var(--bronze); font-weight: 600; font-variant-numeric: tabular-nums; }
.bnode { position: absolute; width: 232px; height: 96px; border-radius: 10px; padding: 14px 20px; display: flex; flex-direction: column; justify-content: center; text-align: left; border: 0; transition: opacity .2s; }
.bnode .bn { font-size: 12px; letter-spacing: 0.1em; opacity: 0.8; font-weight: 600; }
.bnode .bt { font-size: 18px; line-height: 24px; font-weight: 600; }
.bnode .bq { font-size: 13px; opacity: 0.85; font-weight: 400; }
.hub { position: absolute; width: 320px; height: 168px; border-radius: 999px; background: var(--gold); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; box-shadow: 0 0 0 6px var(--bg), 0 0 0 7px var(--taupe); }
.hub small { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.75; }
.hub b { font-family: var(--font-display); font-weight: 400; font-size: 36px; line-height: 44px; }
.zoombar { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 2px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; box-shadow: 0 2px 10px rgba(41,41,41,.08); }
.zoombar button { border: 0; background: transparent; min-width: 36px; height: 36px; border-radius: 999px; padding: 0 10px; font-weight: 600; }
.zoombar button:hover { background: var(--sunk); }
.zoombar .pct { min-width: 52px; text-align: center; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.maphint { position: absolute; left: 12px; bottom: 12px; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; max-width: calc(100% - 300px); }

/* Drawer */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface); border-left: 1px solid var(--line); z-index: 21; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.d-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.d-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.d-head h3 { font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1.08; margin: 2px 0 0; }
.d-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.x { border: 0; background: transparent; font-size: 24px; line-height: 1; padding: 2px 8px; color: var(--muted); }
.icon-btn { border: 1px solid var(--line); background: transparent; border-radius: 999px; height: 34px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.icon-btn:hover { border-color: var(--ink); }
.icon-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.d-body { overflow-y: auto; padding: 16px 20px 28px; display: grid; gap: 18px; align-content: start; }
.d-col { display: grid; gap: 18px; align-content: start; min-width: 0; }

/* Full-screen panel: notes on the left, evidence, links and files get the wide right-hand column. */
.drawer.wide { width: 100%; border-left: 0; }
.drawer.wide .d-head { padding: 18px max(24px, calc((100% - 1360px) / 2)) 14px; }
.drawer.wide .d-body { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 28px 40px; padding: 22px max(24px, calc((100% - 1360px) / 2)) 40px; }
.drawer.wide textarea#fS, .drawer.wide textarea#fW { min-height: 180px; }
.drawer.wide #evText { min-height: 110px; }
.drawer.wide .ev-txt { font-size: 14px; }
.sec { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.d-col > .sec:first-child { padding-top: 0; border-top: 0; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sec-head .flabel { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.sec-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.field { display: grid; gap: 6px; }
.field > label, .field > .flabel { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--line); background: transparent; padding: 8px 4px; font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--sunk); font-weight: 600; }
.toggle { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; background: transparent; width: 100%; text-align: left; }
.toggle[aria-pressed="true"] { border-color: var(--red); background: #FCE9EB; }
textarea, .ev-add input, .ev-add select, .lk-add input, .ev-editbox select { width: 100%; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); padding: 8px 10px; font-size: 13.5px; font-weight: 400; }
textarea { min-height: 92px; resize: vertical; }
.ta-s { border-left: 3px solid var(--good) !important; }
.ta-w { border-left: 3px solid var(--bad) !important; }
.ev-list, .lk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ev-list li, .lk-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; background: var(--sunk); border-radius: 6px; padding: 8px 10px; }
.ev-src { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--bronze); }
.ev-txt { font-size: 13px; overflow-wrap: anywhere; font-weight: 400; white-space: pre-line; }
.ev-del, .ev-edit { border: 0; background: transparent; color: var(--muted); font-size: 12px; line-height: 1; padding: 4px 5px; border-radius: 4px; }
.ev-del { font-size: 16px; }
.ev-del:hover, .ev-edit:hover { color: var(--ink); background: var(--surface); }
.row-tools { display: flex; gap: 2px; align-items: center; }
.ev-editbox { display: grid; gap: 6px; }
.ev-editbox textarea { min-height: 80px; background: var(--surface); }
.ev-editbox select { max-width: 220px; background: var(--surface); }
.ev-editbox .ev-edit-actions { display: flex; gap: 6px; }
.ev-add { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 6px; align-items: start; }
.ev-add textarea { min-height: 64px; }
.ev-add .btn { grid-column: 1 / -1; justify-self: start; }
.lk-add { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) auto; gap: 6px; }
.lk-a { font-size: 13.5px; font-weight: 600; color: var(--ink); text-decoration: underline; text-decoration-color: var(--taupe); text-underline-offset: 3px; overflow-wrap: anywhere; }
.lk-a:hover { text-decoration-color: var(--red); }
.lk-meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.lk-kind { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 6px; border-radius: 999px; background: var(--surface); color: var(--bronze); white-space: nowrap; }
.hint { font-size: 12px; color: var(--muted); margin: 0; font-weight: 400; }
.ro-note { font-size: 12.5px; background: var(--mid-soft); padding: 8px 10px; border-radius: 6px; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 13px; z-index: 30; }
.copybox { width: 100%; min-height: 160px; font-size: 12px; }

@media (max-width: 760px) {
  .layer { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .layer:not(:last-child) .rail-col::after { display: none; }
  .rail { position: static; margin-top: 0; padding-top: 0; }
  .drawer.wide .d-body { grid-template-columns: minmax(0, 1fr); }
  .lk-add { grid-template-columns: minmax(0, 1fr); }
  .lk-add .btn { justify-self: start; }
  .ev-add { grid-template-columns: minmax(0, 1fr); }
  .icon-btn .lbl { display: none; }
  .rail p { max-width: none; }
  .ctrl-label { min-width: 0; width: 100%; }
  .seg { grid-template-columns: repeat(2, 1fr); }
  .seg button:nth-child(2) { border-right: 0; }
  .seg button:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .maphint { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
