/* ============================================================================
 * HikQR — USGS quad topographic aesthetic
 * - paper: weathered map paper
 * - trail brown, contour tan, water slate, canopy green
 * - Fraunces (serif) + JetBrains Mono (tech labels, ids, trust scores)
 * ============================================================================ */

:root {
  --ink:        #1f2a1f;
  --ink-soft:   #3a4838;
  --ink-mute:   #6a7868;
  --paper:      #f3eedf;
  --paper-2:    #ebe4d0;
  --paper-3:    #dfd5b8;
  --rule:       #c8bf9e;
  --trail:      #8a5a2b;
  --trail-soft: #b78657;
  --contour:    #b9a673;
  --water:      #6b8aa2;
  --canopy:     #4a6b3a;
  --canopy-2:   #6b8b56;
  --warn:       #a8472b;
  --conflict:   #b9882a;
  --good:       #4a6b3a;

  --shadow:     0 1px 0 #b8af8d, 0 6px 24px -10px rgba(40,50,30,0.35);
  --shadow-sm:  0 1px 0 #b8af8d, 0 2px 6px -2px rgba(40,50,30,0.20);

  --serif:  'Fraunces', Georgia, serif;
  --mono:   'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; height:100%; background: var(--paper); color: var(--ink); }
body {
  font-family: var(--serif);
  font-feature-settings: "ss01","ss02";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(ellipse 600px 220px at 18% 22%, rgba(185,166,115,.10), transparent 70%),
    radial-gradient(ellipse 480px 360px at 84% 78%, rgba(185,166,115,.08), transparent 70%),
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(185,166,115,.04) 38px 39px),
    var(--paper);
}

.hidden { display: none !important; }

/* ====== AUTH OVERLAY ====== */
.auth-overlay {
  position: fixed; inset: 0; z-index: 100;
  background:
    radial-gradient(ellipse 800px 400px at 50% 30%, rgba(74,107,58,.10), transparent 70%),
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(185,166,115,.06) 38px 39px),
    var(--paper);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 460px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
  position: relative;
}
.auth-card::before {
  content: ""; position: absolute; inset: 6px;
  border: 1px dashed var(--rule); border-radius: 4px; pointer-events: none;
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand .mark {
  font-family: var(--serif); font-weight: 900;
  font-size: 44px; letter-spacing: -0.03em; line-height: 1;
}
.auth-brand .mark .q { color: var(--trail); }
.auth-brand .tag {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--ink-mute); margin-top: 6px;
}

.auth-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 22px;
}
.auth-tabs button {
  flex: 1; background: transparent; border: 0;
  padding: 10px 0;
  font-family: var(--mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-mute);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.auth-tabs button.active {
  color: var(--ink);
  border-bottom-color: var(--trail);
}

.auth-form { display: none; flex-direction: column; gap: 12px; }
.auth-form.active { display: flex; }
.auth-form label {
  display: flex; flex-direction: column; gap: 4px;
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-mute);
}
.auth-form input, .auth-form textarea, .auth-form select {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 10px 12px;
  border-radius: 3px;
  font-family: var(--serif); font-size: 15px;
  color: var(--ink);
}
.auth-form input:focus, .auth-form textarea:focus, .auth-form select:focus {
  outline: none; border-color: var(--trail); background: var(--paper);
}

.btn-primary {
  background: var(--ink); color: var(--paper);
  border: 0; padding: 12px 18px;
  font-family: var(--mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.12em;
  border-radius: 3px; cursor: pointer;
  margin-top: 4px;
}
.btn-primary:hover { background: var(--trail); }

.btn-ghost {
  background: transparent; color: var(--ink-soft);
  border: 1px solid var(--rule); padding: 12px 18px;
  font-family: var(--mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.12em;
  border-radius: 3px; cursor: pointer;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); }

.auth-oauth {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 6px; margin-top: 12px;
}
.auth-oauth button {
  background: var(--paper-2); border: 1px solid var(--rule);
  padding: 9px 6px;
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  cursor: pointer; border-radius: 3px;
  color: var(--ink-soft);
}
.auth-oauth button:hover { background: var(--ink); color: var(--paper); }

.auth-skip { margin-top: 16px; text-align: center; }
.auth-skip button {
  background: none; border: 0; cursor: pointer;
  color: var(--trail); font-family: var(--serif);
  font-style: italic; font-size: 14px;
  text-decoration: underline; text-underline-offset: 4px;
}

.auth-foot {
  margin-top: 22px; padding-top: 14px;
  border-top: 1px dashed var(--rule);
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-mute); line-height: 1.5;
}
.auth-foot code {
  background: var(--paper-2); padding: 1px 5px; border-radius: 2px;
  font-size: 10px;
}
.micro {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-mute); margin: 0;
}
.micro code { background: var(--paper-2); padding: 1px 4px; border-radius: 2px; }

/* ====== APP SHELL ====== */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  overflow: hidden;
}

header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand .mark {
  font-family: var(--serif); font-weight: 900;
  font-size: 26px; letter-spacing: -0.02em; line-height: 1;
}
.brand .mark .q { color: var(--trail); }
.brand .sub {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--ink-mute);
}
.brand .sub b { color: var(--ink); font-weight: 500; }

nav.modes {
  display: flex; gap: 4px;
  background: var(--paper-3); padding: 3px;
  border-radius: 999px; border: 1px solid var(--rule);
}
nav.modes button {
  background: transparent; border: 0;
  padding: 6px 14px; border-radius: 999px;
  cursor: pointer;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-soft);
}
nav.modes button.active { background: var(--ink); color: var(--paper); }

.auth-mini {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-soft);
}
.auth-mini .who b { font-family: var(--serif); font-weight: 600; color: var(--ink); font-size: 14px; }
.auth-mini button.linklike {
  background: none; border: 0; cursor: pointer;
  font-family: var(--mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--trail);
  text-decoration: underline; text-underline-offset: 3px;
  padding: 0;
}

.main {
  display: grid;
  grid-template-columns: 380px 1fr 440px;
  min-height: 0;
  overflow: hidden;
}

/* ====== LEFT — TRAIL LIST ====== */
aside.list {
  border-right: 1px solid var(--rule);
  background: var(--paper);
  overflow-y: auto;
  padding: 18px 20px 40px;
}
.list-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px;
}
.list-head h2 {
  font-family: var(--serif); font-weight: 700;
  font-size: 22px; letter-spacing: -0.01em;
  margin: 0;
}
.list-head .count {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-mute);
}
.search { position: relative; margin-bottom: 12px; }
.search input {
  width: 100%;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 10px 12px 10px 32px;
  font-family: var(--mono); font-size: 12px;
  color: var(--ink);
}
.search input:focus { outline: 1px solid var(--trail); }
.search svg {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--ink-mute);
}

.filters {
  display: flex; gap: 5px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.filters button {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.filters button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.trail-card {
  border: 1px solid var(--rule);
  background: var(--paper-2);
  border-radius: 3px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.trail-card:hover { background: #efe8d2; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.trail-card.selected {
  background: var(--ink); color: var(--paper);
  border-color: var(--ink);
}
.trail-card.selected .meta,
.trail-card.selected .agent-id { color: rgba(243,238,223,.7); }
.trail-card.selected .badge {
  background: rgba(243,238,223,.10);
  color: var(--paper); border-color: rgba(243,238,223,.30);
}

.trail-card h3 {
  font-family: var(--serif); font-weight: 600;
  font-size: 17px; margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.trail-card .meta {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-mute);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.trail-card .meta .dot { color: var(--rule); }
.trail-card .agent-id {
  font-family: var(--mono); font-size: 9px;
  color: var(--ink-mute);
  text-transform: lowercase; letter-spacing: 0.04em;
  margin-top: 6px;
  opacity: 0.85;
}
.trail-card .badges {
  display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap;
}

.badge {
  font-family: var(--mono); font-size: 9px;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 3px;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
}
.badge.diff-easy     { color: var(--good);     border-color: var(--good); }
.badge.diff-moderate { color: var(--conflict); border-color: var(--conflict); }
.badge.diff-hard     { color: var(--warn);     border-color: var(--warn); }
.badge.contested     { color: var(--conflict); border-color: var(--conflict); background: #f5e9c2; }
.badge.reflexive     { color: var(--water);    border-color: var(--water); background: #e8eef3; }

.list-foot {
  margin-top: 18px; padding-top: 14px;
  border-top: 1px dashed var(--rule);
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-mute);
  line-height: 1.6;
}
.list-foot b {
  font-family: var(--serif); font-weight: 600;
  color: var(--ink); font-size: 13px;
}
.list-foot button {
  background: var(--paper-2); border: 1px solid var(--rule);
  padding: 8px 12px; border-radius: 3px;
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.1em;
  cursor: pointer; color: var(--ink);
  margin-top: 8px;
}
.list-foot button:hover { background: var(--ink); color: var(--paper); }

/* ====== CENTER — MAP ====== */
.map-wrap {
  position: relative; min-height: 0;
  background: var(--paper-3);
  overflow: hidden;
}
#map { position: absolute; inset: 0; background: var(--paper-3); }

.map-controls {
  position: absolute; top: 16px; left: 16px; z-index: 401;
  display: flex; flex-direction: column; gap: 3px;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: 3px; padding: 4px;
  box-shadow: var(--shadow-sm);
}
.map-controls button {
  background: transparent; border: 0;
  padding: 6px 12px;
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-soft); cursor: pointer;
  border-radius: 2px; text-align: left;
}
.map-controls button.active { background: var(--ink); color: var(--paper); }

.map-legend {
  position: absolute; bottom: 16px; left: 16px; z-index: 401;
  background: var(--paper); border: 1px solid var(--rule);
  padding: 10px 12px; border-radius: 3px;
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-soft); line-height: 1.7;
  box-shadow: var(--shadow-sm);
  max-width: 240px;
}
.map-legend b {
  display: block; font-family: var(--serif);
  font-size: 12px; color: var(--ink); margin-bottom: 4px;
  font-weight: 600;
}
.legend-row { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 16px; height: 3px; background: var(--trail); }
.legend-swatch.note { background: none; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--canopy); }
.legend-swatch.connection { background: none; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--water); }

.bandwidth-hint {
  position: absolute; top: 16px; right: 16px; z-index: 401;
  background: var(--paper); border: 1px solid var(--rule);
  padding: 7px 11px; border-radius: 3px;
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.06em;
  display: none;
}
body.mode-trail .bandwidth-hint { display: block; }

/* ====== RIGHT — DETAIL ====== */
aside.detail {
  border-left: 1px solid var(--rule);
  background: var(--paper);
  overflow-y: auto;
  padding: 22px 26px 60px;
}
.empty-detail {
  font-family: var(--serif); font-style: italic;
  color: var(--ink-mute);
  padding: 80px 0; text-align: center;
  font-size: 16px; line-height: 1.6;
}

.detail-header {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.detail-header .agent-id {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.detail-header h1 {
  font-family: var(--serif); font-weight: 700;
  font-size: 28px; letter-spacing: -0.02em; line-height: 1.1;
  margin: 0;
}
.detail-header .subtitle {
  font-family: var(--serif); font-style: italic;
  font-size: 14px;
  color: var(--ink-soft); margin-top: 4px;
}
.detail-header .stats {
  display: flex; gap: 18px; margin-top: 12px;
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-soft);
}
.detail-header .stats div b {
  display: block;
  font-family: var(--serif); font-size: 18px;
  font-weight: 600;
  color: var(--ink); letter-spacing: -0.01em;
  line-height: 1.1;
}

/* External links — alltrails, gmaps */
.ext-links {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px;
}
.ext-links a {
  background: var(--paper-2); border: 1px solid var(--rule);
  padding: 6px 10px; border-radius: 3px;
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  text-decoration: none; color: var(--ink-soft);
}
.ext-links a:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* Q-section */
.q-section {
  margin-bottom: 22px;
  padding: 14px 16px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  position: relative;
}
.q-section.failure { background: #f5e9c2; border-color: var(--conflict); }
.q-section.contested { border-left: 3px solid var(--conflict); }
.q-section.reflexive { border-left: 3px solid var(--water); }

.q-section .q-tag {
  font-family: var(--mono); font-size: 9px;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--trail);
  margin-bottom: 4px;
}
.q-section h3 {
  font-family: var(--serif); font-weight: 600;
  font-size: 16px; letter-spacing: -0.01em;
  margin: 0 0 8px;
}
.q-section .q-body {
  font-family: var(--serif); font-size: 14px; line-height: 1.5;
  color: var(--ink-soft);
}
.q-section .q-body b { color: var(--ink); font-weight: 600; }
.q-section .q-body code {
  font-family: var(--mono); font-size: 11px;
  background: var(--paper); padding: 1px 5px;
  border-radius: 2px;
}

/* Trust strip — the four explicit scores */
.trust-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 4px; margin-top: 10px;
}
.trust-cell {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 6px 8px;
}
.trust-cell .label {
  font-family: var(--mono); font-size: 8px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-mute);
  margin-bottom: 2px;
}
.trust-cell .value {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  color: var(--ink);
}
.trust-cell .bar {
  margin-top: 4px;
  height: 3px; background: var(--paper-3); border-radius: 2px; overflow: hidden;
}
.trust-cell .bar .fill { height: 100%; background: var(--canopy); }
.trust-cell.low  .bar .fill { background: var(--warn); }
.trust-cell.mid  .bar .fill { background: var(--conflict); }

/* Cohort breakdown bar */
.cohort-bar {
  display: flex; height: 24px;
  border: 1px solid var(--rule);
  border-radius: 2px; overflow: hidden;
  margin: 8px 0;
}
.cohort-bar .seg {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px;
  color: var(--paper);
  min-width: 0;
  white-space: nowrap; overflow: hidden;
}
.cohort-bar .seg.great { background: var(--canopy); }
.cohort-bar .seg.good  { background: var(--canopy-2); color: var(--ink); }
.cohort-bar .seg.poor  { background: var(--warn); }

.cohort-views {
  margin-top: 10px;
}
.cohort-view {
  margin-bottom: 8px;
  padding: 8px 10px;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: 3px;
}
.cohort-view .cohort-name {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.cohort-view .cohort-name .n {
  color: var(--ink-mute);
  font-weight: 400;
}

/* Provenance / lineage */
.lineage {
  margin-top: 8px;
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-mute);
  line-height: 1.5;
}
.lineage .row { display: flex; gap: 6px; }
.lineage .label { color: var(--ink-soft); }

/* Notes list */
.note-list { display: flex; flex-direction: column; gap: 6px; }
.note {
  display: flex; gap: 10px;
  padding: 8px 10px;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: 3px;
}
.note .icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  background: var(--paper-2);
  border-radius: 50%;
  border: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.note .body {
  flex: 1; min-width: 0;
}
.note .body .summary {
  font-family: var(--serif); font-size: 14px; line-height: 1.4;
  color: var(--ink);
}
.note .body .meta {
  font-family: var(--mono); font-size: 9px;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-mute); margin-top: 2px;
}

/* Action row */
.q-action-row {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 10px;
}
.q-action-row button {
  background: var(--paper); border: 1px solid var(--rule);
  padding: 7px 11px; border-radius: 3px;
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink); cursor: pointer;
}
.q-action-row button:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* Representations gallery — rich media */
.rep-gallery {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  margin-top: 10px;
}
.rep-tile {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 24px 12px;
  text-align: center;
  cursor: pointer;
  transition: background .15s;
}
.rep-tile:hover { background: var(--paper-2); }
.rep-tile .icon {
  font-size: 24px; margin-bottom: 6px;
}
.rep-tile .label {
  font-family: var(--mono); font-size: 9px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.rep-tile .label b {
  display: block; color: var(--ink); font-family: var(--serif);
  font-weight: 600; font-size: 12px;
  text-transform: none; letter-spacing: 0;
  margin-bottom: 2px;
}

/* ====== MODALS ====== */
.modal {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(31, 42, 31, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 28px 32px;
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow);
}
.modal-card h3 {
  font-family: var(--serif); font-weight: 700;
  font-size: 22px; margin: 0 0 8px;
}
.modal-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.modal-card label {
  display: flex; flex-direction: column; gap: 4px;
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-mute);
}
.modal-card label.row {
  flex-direction: row; align-items: center; gap: 10px;
}
.modal-card input, .modal-card textarea, .modal-card select {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 9px 11px; border-radius: 3px;
  font-family: var(--serif); font-size: 14px;
  color: var(--ink);
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 6px;
}

/* ====== TOASTS ====== */
.toasts {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--ink); color: var(--paper);
  padding: 10px 14px; border-radius: 3px;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow);
  animation: toastIn .2s ease;
  max-width: 320px;
}
.toast.failure { background: var(--warn); }
.toast.ok { background: var(--canopy); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ====== LEAFLET STYLE OVERRIDES ====== */
.leaflet-container {
  background: var(--paper-3);
  font-family: var(--mono);
}
.leaflet-popup-content-wrapper {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
}
.leaflet-popup-content {
  font-family: var(--serif); font-size: 14px;
  color: var(--ink);
  margin: 12px 14px;
}
.leaflet-popup-content b {
  font-weight: 600;
}
.leaflet-popup-content .id {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-mute);
  margin-top: 4px;
}
.leaflet-popup-tip { background: var(--paper); border: 1px solid var(--rule); }
.leaflet-control-attribution {
  background: rgba(243, 238, 223, 0.85) !important;
  font-family: var(--mono); font-size: 9px;
}
.note-marker {
  background: var(--paper);
  border: 2px solid var(--canopy);
  border-radius: 50%;
  width: 14px; height: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.note-marker.wildlife { border-color: var(--canopy-2); }
.note-marker.sketchy  { border-color: var(--warn); }
.note-marker.best_view, .note-marker.best_spot { border-color: var(--trail); }

/* ====== MODE: MOBILE (preview) ====== */
body.mode-mobile .main {
  grid-template-columns: 1fr;
}
body.mode-mobile aside.list { max-height: 40vh; }
body.mode-mobile aside.detail { display: none; }
body.mode-mobile aside.detail.open-mobile {
  display: block; position: fixed; inset: 0; z-index: 50;
  background: var(--paper);
}

/* ====== MODE: ON-TRAIL — drop bandwidth ====== */
body.mode-trail {
  --paper: #f7f3e6;
  background: var(--paper);
}
body.mode-trail .rep-gallery,
body.mode-trail .map-legend,
body.mode-trail .ext-links,
body.mode-trail .detail-header .subtitle { display: none !important; }
body.mode-trail .map-controls { padding: 2px; }
body.mode-trail .map-controls button { padding: 4px 8px; font-size: 9px; }
body.mode-trail .leaflet-tile { filter: contrast(0.92) brightness(1.02); }
body.mode-trail .q-section { padding: 10px 12px; }
body.mode-trail .trust-strip { display: none; }
body.mode-trail .lineage { display: none; }

/* ====== RESPONSIVE ====== */
@media (max-width: 1200px) {
  .main { grid-template-columns: 340px 1fr; }
  aside.detail { display: none; }
  aside.detail.open-mobile {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: var(--paper);
  }
}
@media (max-width: 720px) {
  .main { grid-template-columns: 1fr; grid-template-rows: 38vh 1fr; }
  aside.list { max-height: none; border-right: 0; border-bottom: 1px solid var(--rule); }
  header.topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  nav.modes button { padding: 5px 10px; font-size: 10px; }
  .auth-mini { width: 100%; justify-content: flex-end; }
}

/* Scrollbars — keep the topographic feel */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb {
  background: var(--rule); border-radius: 4px;
  border: 2px solid var(--paper);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-mute); }
