:root {
  --tg-ink: #1f2a1f;
  --tg-bg: #f7f6f1;
  --tg-accent: #3d6b35;
  --tg-header-h: 44px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 system-ui, -apple-system, sans-serif; color: var(--tg-ink); background: var(--tg-bg); }
.tg-header {
  height: var(--tg-header-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--tg-ink); color: #fff;
}
.tg-header a { color: #fff; text-decoration: none; margin-left: 16px; }
.tg-brand { font-weight: 700; letter-spacing: .02em; margin-left: 0 !important; }
.tg-inline { display: inline; margin-left: 16px; }
.tg-inline button { background: none; border: 0; color: #fff; font: inherit; cursor: pointer; padding: 0; }
.tg-page { max-width: 760px; margin: 32px auto; padding: 0 16px; }
.tg-full main { position: absolute; top: var(--tg-header-h); bottom: 0; left: 0; right: 0; }
#map { position: absolute; inset: 0; }

/* ---- home map: layers box, detail panel, profile ---- */
.tg-layers { position: absolute; top: 10px; right: 10px; z-index: 3; width: 250px; }
.tg-layers-toggle { width: 100%; padding: 6px 10px; border: 1px solid #bbb; border-radius: 6px; background: #fff; font: inherit; cursor: pointer; }
.tg-layers-body { display: none; margin-top: 6px; background: rgba(255,255,255,.96); border: 1px solid #bbb; border-radius: 6px; padding: 10px 12px; box-shadow: 0 2px 10px rgba(0,0,0,.2); font-size: 13px; }
.tg-layers.open .tg-layers-body { display: block; }
.tg-layers-body label { display: block; margin: 6px 0 2px; }
.tg-layers-body select, .tg-layers-body input[type=range] { width: 100%; font: inherit; }
.tg-layers-body .tg-check { display: flex; align-items: center; gap: 6px; }
.tg-layers-body .tg-check input { width: auto; }
.tg-small { font-size: 12px; margin-top: 8px; }
.tg-muted { color: #666; }
.tg-error { color: #a33; }
.tg-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; }
.tg-sw { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 4px; border-radius: 2px; }
.tg-sw.tg-dash { background-image: repeating-linear-gradient(90deg, transparent 0 3px, #fff 3px 6px); }

.tg-panel { position: absolute; top: 10px; left: 50px; bottom: 10px; width: 360px; max-width: calc(100% - 60px); z-index: 3;
  background: rgba(255,255,255,.97); border: 1px solid #bbb; border-radius: 6px; padding: 12px 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.2); overflow-y: auto; display: none; font-size: 14px; }
.tg-panel.open { display: block; }
.tg-panel h2 { font-size: 18px; margin: 2px 0 6px; }
.tg-panel-close { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 20px; cursor: pointer; color: #666; }
.tg-kind { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #555; }
.tg-sub { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #555; margin: 12px 0 4px; }
.tg-stats { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 8px 0; }
.tg-stats dt { color: #666; }
.tg-stats dd { margin: 0; font-variant-numeric: tabular-nums; }
.tg-list { margin: 0; padding-left: 18px; }
.tg-links { margin: 8px 0; font-size: 13px; }
.tg-solo { display: block; margin: 8px 0 0; font-size: 13px; cursor: pointer; }
.tg-desc { white-space: pre-wrap; }
.tg-toggle label { margin-right: 10px; font-size: 13px; }
.tg-profile-box { position: relative; margin-top: 4px; min-height: 40px; }
.tg-profile { display: block; width: 100%; }
.tg-profile .tg-area { fill: #e8ede6; }
.tg-profile .tg-line { fill: none; stroke-width: 2.5px; stroke-linejoin: round; stroke-linecap: round; }
.tg-profile .tg-grid line { stroke: #ddd; }
.tg-profile .tg-grid path { display: none; }
.tg-profile .tg-axis { font-size: 10px; color: #555; }
.tg-profile .tg-axis path, .tg-profile .tg-axis line { stroke: #bbb; }
.tg-profile .tg-cursor line { stroke: #333; stroke-dasharray: 2 2; }
.tg-profile .tg-cursor circle { stroke: #1f2a1f; stroke-width: 1.5px; }
.tg-profile .tg-hit { fill: transparent; cursor: crosshair; }
.tg-tip { position: absolute; top: 6px; background: rgba(31,42,31,.9); color: #fff; font-size: 12px; padding: 4px 7px; border-radius: 4px; pointer-events: none; white-space: nowrap; }
.tg-keys { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: 11px; color: #555; }
.tg-key i { display: inline-block; width: 10px; height: 10px; margin-right: 3px; vertical-align: -1px; border-radius: 2px; }

/* ---- forms ---- */
.tg-form .tg-field { margin: 12px 0; }
.tg-form label { display: block; font-weight: 600; margin-bottom: 3px; }
.tg-form input[type=text], .tg-form select, .tg-form textarea { width: 100%; font: inherit; padding: 6px; }
.tg-form .tg-help { color: #666; font-size: 13px; }
.tg-form .errorlist { color: #a33; margin: 4px 0; padding-left: 18px; }
.tg-form button { font: inherit; padding: 6px 14px; background: var(--tg-accent); color: #fff; border: 0; border-radius: 4px; cursor: pointer; }
@media (max-width: 640px) {
  .tg-panel { left: 10px; top: auto; height: 55%; width: auto; right: 10px; max-width: none; }
  .tg-layers { width: 200px; }
}
.tg-report { background: #eef5ea; border: 1px solid #b9d3ae; border-radius: 4px; padding: 8px 12px; margin: 12px 0; }
.tg-form ul { list-style: none; padding-left: 0; margin: 4px 0; }
.tg-form ul label { font-weight: normal; display: inline; }

/* ---- trail design: alignment panels and the editor ---- */
.tg-panel.tg-wide { width: 560px; }
.tg-legend-title { width: 100%; font-weight: 600; color: #555; margin-top: 2px; }
.tg-sw.tg-dot { background-image: repeating-linear-gradient(90deg, transparent 0 2px, #fff 2px 5px); }
.tg-badge { font-size: 11px; background: #eee; border: 1px solid #ccc; border-radius: 3px; padding: 0 4px; color: #555; }
.tg-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tg-btn { font: inherit; font-size: 13px; padding: 4px 10px; border: 1px solid #aaa; border-radius: 4px; background: #fff; cursor: pointer; }
.tg-btn:hover { background: #f1f1ec; }
.tg-btn:disabled { opacity: .45; cursor: default; }
.tg-btn.tg-primary { background: var(--tg-accent); border-color: var(--tg-accent); color: #fff; }
.tg-btn.tg-danger { color: #a33; border-color: #d9a3a3; }
.tg-btn.tg-on { background: #1f2a1f; border-color: #1f2a1f; color: #fff; }
.tg-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 4px; }
.tg-toolbar .tg-btn { font-size: 12px; padding: 3px 7px; }
.tg-sep { width: 8px; }
.tg-link { background: none; border: 0; color: #06c; cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.tg-title-input { width: 100%; font: 600 17px/1.3 system-ui, sans-serif; border: 1px solid #ccc; border-radius: 4px; padding: 3px 6px; margin: 2px 0 4px; }
.tg-status { background: #f4f4ef; border-radius: 4px; padding: 5px 8px; margin: 6px 0; font-size: 13px; }
.tg-note { color: #7a5a00; margin: 3px 0; }
.tg-spin { display: inline-block; width: 10px; height: 10px; border: 2px solid #aaa; border-top-color: transparent; border-radius: 50%; animation: tgspin .8s linear infinite; vertical-align: -1px; }
@keyframes tgspin { to { transform: rotate(360deg); } }
.tg-metrics { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0; font-variant-numeric: tabular-nums; }
.tg-metrics th { text-align: left; font-weight: normal; color: #555; padding: 2px 6px 2px 0; }
.tg-metrics td { text-align: right; padding: 2px 0 2px 6px; white-space: nowrap; }
.tg-trade tr:first-child th { font-weight: 600; text-align: right; color: #333; }
.tg-trade tr:first-child th:first-child { text-align: left; }
.tg-delta { font-size: 12px; color: #555; }
.tg-delta.tg-better { color: #1f7a33; }
.tg-delta.tg-worse { color: #b3261e; }
.tg-legs, .tg-compare, .tg-bands { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tg-legs th, .tg-compare th, .tg-bands th { text-align: left; font-weight: 600; color: #555; border-bottom: 1px solid #ddd; padding: 3px 4px; white-space: nowrap; }
.tg-legs td, .tg-compare td, .tg-bands td { padding: 3px 4px; border-bottom: 1px solid #eee; vertical-align: top; }
.tg-legs tr[data-leg] { cursor: pointer; }
.tg-legs td.tg-num, .tg-legs th:nth-child(n+3) { text-align: right; white-space: nowrap; }
.tg-legs tr[data-leg]:hover, .tg-compare tr:hover { background: #f6f6f0; }
.tg-compare th[data-k] { cursor: pointer; }
.tg-compare td { white-space: nowrap; text-align: right; }
.tg-compare td:first-child { white-space: normal; text-align: left; min-width: 150px; }
.tg-compare th:not(:first-child) { text-align: right; }
.tg-compare tr.tg-self { background: #fff8d6; }
.tg-scroll { overflow-x: auto; }
.tg-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -1px; }
.tg-more { margin: 8px 0; font-size: 13px; }
.tg-more summary { cursor: pointer; color: #555; }
.tg-bands { margin: 6px 0; }
.tg-legrow { border: 1px solid #e3e3dc; border-radius: 5px; padding: 5px 7px; margin: 5px 0; }
.tg-legrow.tg-sel { border-color: #00b8cc; box-shadow: 0 0 0 1px #00b8cc; }
.tg-legrow-top { display: flex; align-items: center; gap: 6px; }
.tg-legname { flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 2px 4px; border: 1px solid #ccc; border-radius: 3px; }
.tg-legkind { font: inherit; font-size: 12px; }
.tg-legfactor { width: 56px; font: inherit; font-size: 12px; }
.tg-legrow-stats { color: #444; margin: 3px 0 0 18px; }
.tg-legrow-tools { margin: 2px 0 0 18px; color: #555; }
.tg-profile .tg-ghost { fill: none; stroke: #9a9a9a; stroke-width: 1.5px; stroke-dasharray: 3 2; }
.tg-profile .tg-legband { opacity: .9; }
.tg-profile .tg-legrule { stroke: #444; stroke-width: 1px; stroke-dasharray: 2 3; opacity: .6; }
.tg-profile .tg-ctx { fill: #b48a00; opacity: .45; }
.tg-profile .tg-strip-label { font-size: 9px; fill: #555; }
.tg-profile .tg-empty { font-size: 12px; fill: #777; }
.tg-key-sep { font-weight: 600; margin-left: 6px; }
.tg-views { margin: 6px 0 2px; font-size: 13px; }
.tg-views .tg-btn { font-size: 12px; padding: 2px 8px; margin-left: 3px; }

/* The refine tool (tg_refine.js) */
.rf-legs label { display: block; font-size: 13px; margin: 1px 0; }
.rf-factor { border-top: 1px solid #e6e6e0; padding: 6px 0 2px; }
.rf-fhead { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.rf-svg { display: block; user-select: none; -webkit-user-select: none; }
.rf-wrow { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.rf-w { flex: 1; min-width: 120px; accent-color: var(--tg-accent, #2f6b2f); }
.rf-reach { margin: 6px 0 4px; }
.rf-reach input { width: 64px; }
.rf-wn { width: 64px; font-size: 12px; font-variant-numeric: tabular-nums; }
.rf-zero { stroke: #888; stroke-width: 1; }
.rf-band { fill: #e8590c; opacity: 0.10; }
.rf-band-edge { stroke: #e8590c; stroke-width: 6; stroke-opacity: 0.35; cursor: ew-resize; }
.rf-factor.rf-off .rf-curvebox, .rf-factor.rf-off strong { opacity: 0.45; }
.rf-curvebox { position: relative; }
.rf-zoom { position: absolute; right: 12px; top: 4px; display: flex; gap: 2px; z-index: 1; }
.rf-zoom button { font: inherit; font-size: 11px; line-height: 1; padding: 2px 5px; border: 1px solid #ccc; background: #fff; border-radius: 3px; cursor: pointer; opacity: 0.8; }
.rf-zoom button:hover { opacity: 1; border-color: #888; }
.rf-node.rf-clip { stroke-dasharray: 2 2; }
.rf-hist { fill: #e3e3dc; }
.rf-line { fill: none; stroke: var(--tg-accent, #2f6b2f); stroke-width: 2; }
.rf-seg { fill: none; stroke: transparent; stroke-width: 12; cursor: ew-resize; pointer-events: stroke; }
.rf-seg.rf-flat { cursor: ns-resize; }
.rf-node { fill: #fff; stroke: var(--tg-accent, #2f6b2f); stroke-width: 2; cursor: move; }
.rf-node.rf-del { stroke: #b3261e; fill: #f6d5d2; }
.rf-axis text { font-size: 10px; fill: #666; }
.rf-axis path, .rf-axis line { stroke: #bbb; }
.rf-mark { stroke-width: 1.5; stroke-dasharray: 3 2; }
.rf-bar { height: 6px; background: #e6e6e0; border-radius: 3px; overflow: hidden; margin: 5px 0 1px; }
.rf-bar > i { display: block; height: 100%; background: var(--tg-accent, #2f6b2f); }
.rf-params label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin: 3px 0; }
.rf-params input { width: 84px; font: inherit; }
.rf-sw { display: inline-block; width: 14px; height: 4px; vertical-align: middle; margin-right: 3px; }
.rf-notoff { margin: 4px 0 6px 18px; padding: 0; }
.rf-results { font-size: 12px; }
.rf-results th { white-space: nowrap; }
.rf-results th label { white-space: nowrap; cursor: pointer; }
.rf-results td.tg-better { color: #1f7a33; }
.rf-results td.tg-worse { color: #b3261e; }
.rf-prof svg { display: block; }
.tg-notes-edit { width: 100%; min-width: 240px; box-sizing: border-box; font: inherit; font-size: 13px; }
.tg-notes-hint { color: #8a5a00; font-weight: 600; margin: 4px 0; }
.tg-notes-list li { margin: 2px 0; }
.tg-note-pop .maplibregl-popup-content { padding: 10px 12px; }
.tg-choose-pop .maplibregl-popup-content { padding: 8px 10px; }
.tg-choose { display: flex; flex-direction: column; align-items: flex-start; width: 100%; margin-top: 4px;
  padding: 4px 6px; border: 1px solid transparent; border-radius: 4px; background: none; font: inherit;
  color: inherit; text-align: left; cursor: pointer; }
.tg-choose:hover { border-color: currentColor; }
.tg-note-text { white-space: pre-wrap; font-size: 13px; margin-bottom: 4px; }
.tg-note-acts { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.tg-twi { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; padding: 6px 0; margin: 6px 0; }
.tg-twi-ramp { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #666; }
.tg-twi-ramp i { flex: 1; height: 8px; border-radius: 2px;
  background: linear-gradient(to right, rgba(198,233,245,0), rgba(160,215,240,.35) 12%, rgba(79,163,217,.6) 38%, rgba(31,95,191,.8) 75%, rgba(11,42,128,.9)); }

/* Refine factor panels (tg_factors.js) on the shared float panels (ls_panels.css). */
.tgf-prof { left: min(420px, 2vw); top: max(16px, calc(100% - 556px)); width: min(900px, calc(100vw - 32px)); height: 540px; }   /* left/top anchored: ls_float.js */
.tgf-space { left: min(420px, 2vw); top: 16px; width: min(520px, calc(100vw - 32px)); height: 360px; }
.tgf-window { display: none; font-size: 11px; color: #333; padding: 4px 10px 4px; border-top: 1px solid #eee; max-height: 34%; overflow: auto; flex: none; }
.tgf-window table { border-collapse: collapse; width: 100%; }
.tgf-window th { font-weight: 600; color: #666; font-size: 10px; text-align: right; padding: 1px 6px; white-space: nowrap; }
.tgf-window td { text-align: right; padding: 1px 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tgf-window th:first-child, .tgf-window td:first-child { text-align: left; }
.tgf-space-body { flex: 1; min-height: 0; }
.tgf-space-body svg { display: block; width: 100%; height: 100%; cursor: crosshair; }
.tgf-ax { font-size: 11px; color: #555; display: inline-flex; gap: 4px; align-items: center; }
.tgf-ax select { font-size: 11px; padding: 0 2px; }
.profile-header .tgf-space-btn { margin-left: auto; }
.tg-crumb { font-size: 12px; color: #666; margin-bottom: 2px; }
.tg-tree .tg-tree { margin: 2px 0 2px 14px; padding-left: 8px; border-left: 1px solid #ddd; }

/* "lat, lon copied" after a right-click (Ctrl-click) on the map; the same look as landslidescience's */
#coord-toast { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(20,20,20,.88); color: #fff; padding: 6px 12px; border-radius: 4px;
  font-size: 13px; z-index: 5; pointer-events: none; transition: opacity .3s; opacity: 0; }
.tg-tree .sec-head th { text-align: left; background: rgba(127, 127, 127, 0.08); font-weight: 600; padding-top: 6px; }
.tg-tree .sec-toggle { cursor: pointer; }
.tg-tree .sec-acts { font-weight: normal; margin-left: 6px; }
.tg-tree .sec-pick { font-size: 12px; max-width: 110px; }
.asm-pick select { max-width: 230px; font-size: 12px; }
.asm-pick th { white-space: nowrap; }
