  .gg{
  --forest:#123F38; --forest-deep:#0E332D; --teal:#3B6E5F; --teal-soft:#DCEAE4;
  --gold:#C6A15B; --gold-deep:#A08040; --gold-text:#7D6330; --gold-tint:#F3EDDD;
  --ivory:#FAF9F4; --paper:#FFFFFF; --ink:#22332E; --body:#46695F; --sage:#8AA096;
  --hair:rgba(160,128,64,.28); --rose:#B9574A; --clay:#9C6F45;
  --display:"Cormorant Garamond",Georgia,serif; --sans:"Jost","Avenir Next",system-ui,sans-serif;
}
.gg,.gg *,.gg *::before,.gg *::after{box-sizing:border-box}
.gg{font-family:var(--sans);color:var(--body);background:var(--ivory);font-size:15px;line-height:1.5;margin:0 calc(50% - 50vw);width:100vw;max-width:100vw}
.gg button,.gg select,.gg input,.gg textarea{font:inherit;color:inherit}
.gg h1,.gg h2,.gg h3{font-family:var(--display);font-weight:500;color:var(--forest);margin:0;letter-spacing:0;text-transform:none}
.gg p{margin:0}
.gg br{display:none}
.gg p:empty{display:none}
.tools > p,.gg-actions > p,.legend > p{display:contents}
.gg button.btn,.gg button.tool,.gg .zoom button{text-transform:none;letter-spacing:0;box-shadow:none}

.gg{container-type:inline-size;display:grid;grid-template-rows:auto 1fr auto;min-height:0;overflow-x:clip}
.gg-head{display:flex;align-items:flex-end;justify-content:space-between;gap:1rem 1.5rem;flex-wrap:wrap;padding:1rem 1.2rem .8rem;border-bottom:1px solid var(--hair);background:var(--ivory)}
.gg-head h1{font-size:1.7rem;line-height:1}
.gg-head h1 em{font-style:italic;color:var(--gold-deep)}
.gg-head p{margin:.3rem 0 0;font-size:.88rem;max-width:60ch}
.gg-actions{display:flex;gap:.4rem;flex-wrap:wrap;justify-content:flex-end;align-items:center}
.savehint{font-size:.8rem;color:var(--sage)}
.btn{border:1px solid var(--hair);background:var(--paper);color:var(--forest);padding:.5rem .9rem;border-radius:6px;cursor:pointer;line-height:1.1}
.gg .btn:hover{border-color:var(--gold);background:var(--gold-tint)}
.btn:focus-visible{outline:2px solid var(--teal);outline-offset:2px}
.btn:disabled{opacity:.5;cursor:default}
.gg .btn-fill{background:var(--teal);color:#fff;border-color:var(--teal)}
.gg .btn-fill:hover{background:var(--forest);border-color:var(--forest);color:#fff}
.gg .btn-danger:hover{border-color:var(--rose);color:var(--rose);background:#fbf1ef}

.gg-bench{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 300px;grid-template-areas:"rail rail" "stage drawer";min-height:0}
.gg-rail{grid-area:rail;background:var(--paper);border-bottom:1px solid var(--hair);padding:.7rem 1.2rem .4rem;display:flex;flex-wrap:wrap;gap:.2rem 2rem;align-items:flex-start}
.gg-drawer{grid-area:drawer;background:var(--paper);border-left:1px solid var(--hair);padding:1rem 1rem 1.5rem}
.rail-group{margin:0 0 .5rem}
.rail-group h2{font-size:1.05rem;margin-bottom:.25rem}
.tools{display:flex;flex-wrap:wrap;gap:.2rem}
.tool{display:flex;align-items:center;gap:.45rem;text-align:left;padding:.32rem .55rem;border:1px solid transparent;border-radius:6px;background:transparent;cursor:pointer;white-space:nowrap}
.tool:hover{background:var(--gold-tint)}
.tool.is-on{border-color:var(--gold);background:var(--gold-tint);color:var(--forest)}
.tool:focus-visible{outline:2px solid var(--teal);outline-offset:1px}
.tool svg{width:26px;height:19px;flex:none}
.tool small{display:none}
.hint{font-size:.8rem;color:var(--sage);margin:.2rem 0 .3rem;flex-basis:100%}
.rail-group .field{margin:0;display:flex;align-items:center;gap:.5rem}
.rail-group .field label{white-space:nowrap}
.rail-group .field select{width:auto}

/* Case notes: the written side of the map */
.gg-case{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:1rem;padding:1.2rem 1.2rem .4rem;background:var(--ivory);border-top:1px solid var(--hair)}
.gg-case[hidden]{display:none}
.case-card{background:var(--paper);border:1px solid var(--hair);border-left:4px solid var(--gold);border-radius:8px;padding:.9rem 1rem}
.case-card h3{font-size:1.15rem;margin-bottom:.35rem}
.case-card p,.case-card li{font-size:.9rem;line-height:1.55;color:var(--body);margin:0}
.case-card ul,.case-card ol{margin:0;padding-left:1.1rem}
.case-card li+li{margin-top:.25rem}
.case-card--pattern{border-left-color:var(--teal)}
@media print{ .gg-case{display:grid!important;order:4;padding:3mm 0 0;gap:3mm} .gg-case[hidden]{display:none!important} .case-card{border-left-width:3px;padding:2mm 3mm} .case-card h3{font-size:9pt} .case-card p,.case-card li{font-size:7.5pt;line-height:1.35} }

/* Legend: the full symbol key, long and always visible */
.gg-legend{background:var(--paper);border-top:1px solid var(--hair);padding:1.2rem 1.2rem 2rem}
.gg-legend h2{font-size:1.4rem;margin-bottom:.2rem}
.gg-legend .hint{margin:0 0 .8rem}
.legend{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:.35rem .9rem;font-size:.86rem}
.legend div{display:flex;align-items:center;gap:.6rem;padding:.3rem .45rem;border-radius:6px;cursor:pointer;border:1px solid transparent}
.legend div:hover{background:var(--gold-tint);color:var(--forest)}
.legend div:focus-visible{outline:2px solid var(--teal);outline-offset:1px}
.legend div.is-on{background:var(--gold-tint);border-color:var(--gold)}
.legend svg{width:50px;height:22px;flex:none}
.legend h3{grid-column:1/-1;font-size:1.1rem;margin:.9rem 0 .1rem;padding-top:.6rem;border-top:1px solid var(--hair)}
.legend h3:first-child{border-top:0;margin-top:0;padding-top:0}

@container (max-width: 860px){
  .gg-bench{grid-template-columns:1fr;grid-template-areas:"rail" "stage";overflow:hidden}
  .gg-drawer{position:fixed;top:0;right:0;bottom:0;width:min(360px,92vw);height:100vh;height:100dvh;max-height:none;overflow:auto;-webkit-overflow-scrolling:touch;padding:0 1rem 5rem;box-shadow:-8px 0 24px rgba(18,63,56,.18);transform:translateX(104%);visibility:hidden;transition:transform .2s ease,visibility 0s .2s;z-index:50}
  .gg-bench .gg-drawer .drawer-top{display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;z-index:2;margin:0 -1rem 1rem;padding:.7rem 1rem;background:var(--paper);border-bottom:1px solid var(--hair);font-family:var(--display);font-size:1.1rem;color:var(--forest)}
  .drawer-top .btn{padding:.4rem .9rem}
  .gg-drawer .drawer-foot{position:sticky;bottom:0;background:var(--paper);padding:.7rem 0;margin-top:1rem;border-top:1px solid var(--hair)}
  .gg-drawer.is-open{transform:none;visibility:visible;transition:transform .2s ease}
  .gg-rail{padding:.6rem .8rem .3rem;gap:.2rem 1rem}
  .gg-legend{padding:1rem .8rem 1.6rem}
  .legend{grid-template-columns:1fr 1fr}
}
@container (max-width: 520px){
  .tool span{font-size:.9rem}
  .legend{grid-template-columns:1fr}
}
.gg-stage{position:relative;overflow:auto;min-width:0;background:radial-gradient(circle at 1px 1px, rgba(18,63,56,.07) 1px, transparent 1.5px) 0 0/24px 24px,var(--ivory)}
.gg-stage > svg{display:block;width:calc(100% * var(--zoom,1));min-width:640px;height:auto;touch-action:none}
.status{position:sticky;left:0;bottom:0;display:inline-block;margin:.6rem;padding:.35rem .7rem;background:var(--forest);color:#F1E7D3;border-radius:999px;font-size:.8rem;pointer-events:none}
.zoom{position:sticky;top:.5rem;float:right;margin:.5rem .5rem 0 0;display:flex;gap:2px;background:var(--paper);border:1px solid var(--hair);border-radius:6px;padding:2px;z-index:2}
.zoom button{border:0;background:transparent;width:30px;height:28px;border-radius:4px;cursor:pointer;color:var(--forest);font-size:1rem}
.zoom button:hover{background:var(--gold-tint)}
.zoom button.fit{width:auto;padding:0 .5rem;font-size:.8rem}

/* map */
.band-line{stroke:var(--gold);stroke-opacity:.45;stroke-dasharray:1 6;stroke-linecap:round}
.band-label{font-family:var(--display);font-style:italic;font-size:17px;fill:var(--gold-deep)}
.node{cursor:grab}
svg.dragging,svg.dragging *{cursor:grabbing!important}
.edge[data-kind="union"] .hit,.edge[data-kind="rail"] .hit{cursor:move}
.edge[data-kind="rail"] .child{pointer-events:none}
.node .shape{fill:var(--paper);stroke:var(--forest);stroke-width:2}
.node .inner{fill:none;stroke:var(--forest);stroke-width:1.5}
.node .mark{fill:var(--rose)}
.node .markline{stroke:var(--rose);stroke-width:1.5;fill:none}
.node .cross{stroke:var(--forest);stroke-width:1.6}
.node .wave{fill:none;stroke:var(--clay);stroke-width:1.6}
.node .halo{fill:none;stroke:var(--gold);stroke-width:2.5}
.node.is-index .shape{fill:var(--gold-tint)}
.txt{paint-order:stroke;stroke:#FAF9F4;stroke-width:5px;stroke-linejoin:round;text-anchor:middle;font-family:var(--sans)}
.nm{font-size:12.5px;fill:var(--ink)}
.yrs{font-size:11px;fill:var(--forest)}
.occ{font-size:10.5px;fill:var(--teal);font-style:italic}
.role{font-size:10px;fill:var(--sage);letter-spacing:.04em}
.age{font-family:var(--display);font-size:15px;fill:var(--forest);text-anchor:middle;dominant-baseline:central;paint-order:stroke;stroke:#fff;stroke-width:3px}
.node.is-selected .shape{stroke:var(--gold-deep);stroke-width:3}
.xbtn{cursor:pointer}
.xbtn circle{fill:#fff;stroke:var(--rose);stroke-width:1.5}
.xbtn path{stroke:var(--rose);stroke-width:1.8}
.xbtn:hover circle{fill:var(--rose)}
.xbtn:hover path{stroke:#fff}
.node.is-pending .shape{stroke:var(--teal);stroke-width:3;stroke-dasharray:4 3}
.union{stroke:var(--forest);stroke-width:2;fill:none}
.union.dotted{stroke-dasharray:2 4}
.slash{stroke:var(--forest);stroke-width:2}
.ulabel{font-size:10.5px;fill:var(--forest)}
.hit{stroke:transparent;stroke-width:22;fill:none;cursor:pointer}
.edge.is-selected .union,.edge.is-selected .child{stroke:var(--gold-deep);stroke-width:3}
.child{stroke:var(--forest);stroke-width:1.8;fill:none}
.child.adopted{stroke-dasharray:6 4}
.child.foster{stroke-dasharray:2 4}
.clabel{font-size:10px;fill:var(--teal);font-style:italic;text-anchor:start}
.rel{fill:none;stroke:var(--teal);stroke-width:1.8}
.rel.distant{stroke-dasharray:5 6}
.rel.conflict,.rel.fusedconflict,.rel.abuse,.rel.cutoff{stroke:var(--rose)}
.rel.cutoff{stroke-dasharray:8 5}
.rel.bars{stroke-dasharray:none}
.edge.is-selected .rel{stroke:var(--gold-deep)}
.tri{fill:rgba(198,161,91,.16);stroke:var(--gold-deep);stroke-width:1.6;stroke-dasharray:5 4;cursor:pointer}
.tri.is-selected{stroke-width:2.6;stroke:var(--teal)}
.trilabel{font-size:11px;fill:var(--gold-text);font-style:italic}
.house{fill:rgba(156,111,69,.05);stroke:var(--clay);stroke-width:2;cursor:pointer}
.house.is-selected{stroke:var(--gold-deep);stroke-width:3}
.hlabel{font-size:11px;fill:var(--clay);font-style:italic}
.callout rect{fill:rgba(255,255,255,.92);stroke:var(--gold);stroke-width:1}
.callout text{font-family:var(--sans);font-size:10.5px;fill:var(--ink);white-space:pre}
.callout{pointer-events:none}
.note{cursor:grab}
.note text{font-size:12px;fill:var(--clay);font-style:italic;letter-spacing:.02em}
.note.is-selected text{fill:var(--gold-deep)}
.note rect{fill:transparent}

.drawer-top{display:none}
.gg-drawer h2{font-size:1.25rem;margin-bottom:.2rem}
.gg-drawer .sub{font-size:.82rem;color:var(--sage);margin:0 0 .9rem}
.field{display:grid;gap:.25rem;margin-bottom:.7rem}
.field label{font-size:.82rem;color:var(--gold-text)}
.field input,.field select,.field textarea{width:100%;padding:.48rem .6rem;border:1px solid var(--hair);border-radius:6px;background:var(--ivory)}
.field input:focus,.field select:focus,.field textarea:focus{outline:2px solid var(--teal);outline-offset:0;border-color:transparent}
.field-row{display:grid;grid-template-columns:1fr 1fr;gap:.6rem}
.check{display:flex;align-items:flex-start;gap:.5rem;font-size:.9rem;color:var(--ink);margin-bottom:.5rem}
.check input{margin-top:.25rem}
.drawer-empty{font-size:.9rem;color:var(--sage);line-height:1.6}
.drawer-empty ol{padding-left:1.1rem;margin:.6rem 0 0}
.drawer-foot{display:flex;gap:.5rem;margin-top:1rem;flex-wrap:wrap}
.toast{position:fixed;left:50%;bottom:1.2rem;transform:translateX(-50%) translateY(20px);opacity:0;background:var(--forest);color:#F1E7D3;padding:.6rem 1rem;border-radius:8px;font-size:.9rem;transition:opacity .25s,transform .25s;pointer-events:none}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}

@media (prefers-reduced-motion:reduce){ .toast,.gg-drawer{transition:none} }
.printonly{display:none}
@media print{
  body *{visibility:hidden!important}
  .gg,.gg *{visibility:visible!important}
  .gg .gg-head,.gg .gg-rail,.gg .gg-drawer,.gg .status,.gg .toast,.gg .zoom,.gg .gg-legend,.gg .gg-legend *,.gg .gg-head *,.gg .gg-rail *,.gg .gg-drawer *{visibility:hidden!important}
  .gg{position:absolute!important;left:0;top:0;margin:0;width:100%;max-width:none;background:#fff}
  .gg-head,.gg-rail,.gg-drawer,.status,.toast,.zoom,.gg-legend{display:none!important}
  .gg,.gg-bench{display:block;height:auto}
  html,body{height:auto;background:#fff}
  .gg{min-height:0}
  .gg-stage{overflow:visible;background:#fff;display:flex;flex-direction:column;min-height:0}
  .gg-stage > svg{width:auto;min-width:0;max-width:100%;height:auto;max-height:108mm;margin:0 auto;order:2}
  .printonly{display:block}
  #printHead{order:1;display:flex;justify-content:space-between;align-items:baseline;font-family:var(--display);color:var(--forest);border-bottom:1px solid var(--hair);padding-bottom:4mm;margin-bottom:3mm}
  #printHead .t{font-size:18pt}
  #printHead .d{font-family:var(--sans);font-size:9pt;color:var(--sage)}
  .printlegend{order:3;display:grid;grid-template-columns:repeat(8,1fr);gap:1pt 8pt;font-size:6.5pt;line-height:1.2;color:var(--body);margin-top:3mm}
  .printlegend div{display:flex;align-items:center;gap:4pt}
  .printlegend svg{width:30pt;height:13pt;flex:none;order:-1}
  .printlegend h3{grid-column:1/-1;font-size:7.5pt;margin:2pt 0 0;color:var(--gold-text)}
  @page{size:landscape;margin:10mm}
}
