:root {
  /* GUI palette - brown-orange family. Deliberately decoupled from the
     map: whatever the interface wears, the map keeps its petrol-teal
     trail pair (see --map-* below). */
  --accent: #b4691d;      /* primary: buttons, titles, banner fills */
  --accent-dark: #7e4a14; /* darker: hover, emphasis, links */
  --green: #2e7d32;       /* done-state accent: completed trails only */
  --green-dark: #1b5e20;  /* its darker sibling (headline numbers) */
  --accent-2: #e2974b;    /* lighter accent: soft highlights */
  --tint: #efc59a;        /* secondary: borders, progress track */
  --grey: #9aa0a6;
  --red: #b71c1c;
  --bg: #fbf2e9;
  --panel: #ffffff;
  --text: #212121;
  --muted: #6b6b6b;

  /* Map palette - must match the trail line colours hard-coded in
     app.js (covered #0b4a54, dashed remaining #21969e). Used by the
     legend swatches so they stay honest whatever the GUI wears. */
  --map-covered: #0b4a54;
  --map-remaining: #21969e;
}

@font-face {
  font-family: "Bitter";
  src: url("/static/fonts/Bitter-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Logo + title above a horizontal rule - no coloured bar. */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0.7rem 1.2rem 0.55rem;
  border-bottom: 1px solid var(--tint);
}
/* The wordmark wears its own face - Bitter SemiBold (self-hosted, OFL;
   licence beside the file): a sturdy slab that reads like a carved
   waymarker. The exact registered weight only: the browser would
   synthesise its own bold from 600 and blur the letterforms. */
header h1 {
  font-size: 1.3rem;
  margin: 0;
  font-weight: 600;
  color: var(--accent);
  font-family: "Bitter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
.header-icon { height: 26px; vertical-align: -5px; border-radius: 5px; margin-right: 0.45rem; }
.header-right { display: flex; align-items: center; gap: 1.1rem; }
.scan-area { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.45rem; }
.scan-area .msg { line-height: 1.3; }
.add-cta { font-size: 1rem; margin: 0 0 0.8rem; color: #333; }
.catalog-sub { font-size: 0.75rem; color: var(--grey); margin: 0.5rem 0 0.4rem; line-height: 1.35; }

.trails-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.9rem; }
.trails-head[hidden] { display: none; }
/* The sort rocker: a two-way switch plate - the resting side sits up
   with a drop shadow, the pressed side sinks into the plate (inset).
   The h2 shares its baseline: the heading's bottom aligns with the
   plate's bottom, not the whole labelled control's centre. */
.trails-head-left { display: flex; align-items: flex-end; gap: 0.7rem; }
#panel .trails-head-left h2 { margin-bottom: 0; }
/* The sort rocker: a two-way switch plate - the resting side sits up
   with a drop shadow, the pressed side sinks into the plate (inset). */
.sort-wrap { display: flex; flex-direction: column; align-items: flex-start; }
.sort-by { font-size: 0.66rem; color: var(--grey); margin: 0 0 0.18rem 0.15rem; letter-spacing: 0.02em; }
.sort-toggle { display: flex; background: #d9dcde; padding: 2px; border-radius: 5px; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.28); }
.sort-toggle button {
  margin-top: 0; min-width: 5.4rem; padding: 0.2rem 0.55rem; font-size: 0.74rem;
  border: 1px solid #c9ccce; background: #f4f5f6; color: #4c5054; border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.32); transition: box-shadow 0.12s, background 0.12s, color 0.12s;
}
.sort-toggle button.on {
  background: #e4e5e6; color: #33383c; border-color: #cccecf;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.38); transform: translateY(1px);
}
.scan-area button { margin-top: 0; }
.scan-area .msg { margin-top: 0; }
.auth-area { font-size: 0.9rem; display: flex; gap: 0.6rem; align-items: center; }
.auth-note { font-size: 0.72rem; color: var(--grey); max-width: 30rem; line-height: 1.35; }

main { display: flex; flex: 1; min-height: 0; }

#panel {
  width: 360px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  padding: 1rem;
}
#panel section { margin-bottom: 1.4rem; }
#panel h2 { font-size: 1rem; margin: 0 0 0.6rem; }

#map { flex: 1; min-width: 0; }

#trail-banners { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.3rem; }

.banner {
  background: var(--panel);
  border: 1px solid var(--tint);
  border-radius: 8px;
  padding: 0.65rem 0.85rem 0.7rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.banner:hover { border-color: var(--accent-2); }
.banner.open {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(180, 105, 29, 0.15);
}
.banner-head { cursor: pointer; position: relative; }
.banner-name { font-weight: 600; font-size: 1.15rem; margin-bottom: 0.15rem; padding-right: 1.1rem; }
.banner-chev {
  position: absolute; right: 0.15rem; top: 0.1rem;
  color: var(--muted); font-size: 0.95rem;
  transition: transform 0.15s ease;
}
.banner.open .banner-chev { transform: rotate(90deg); color: var(--accent); }
.banner-name { font-weight: 600; font-size: 1.15rem; margin-bottom: 0.15rem; }
/* Mapping-completeness warning (below the 90% bar): the GUI's orange,
   sized to the title text it rides. */
.map-warn { color: var(--accent); margin-left: 0.32rem; white-space: nowrap; }
.map-warn svg { vertical-align: -0.08em; }
.banner-headline { display: flex; align-items: baseline; gap: 0.28rem; }
.banner-pct { font-size: 1.45rem; font-weight: 700; color: var(--accent-dark); }
.banner-count { font-size: 1.45rem; font-weight: 700; color: var(--accent); }
.banner-done { color: var(--muted); font-size: 0.88rem; }
.banner-pending { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.banner-bar {
  height: 6px;
  margin-top: 0.5rem;
  background: var(--tint);
  border-radius: 3px;
  overflow: hidden;
}
.banner-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }
.banner-empty { color: var(--muted); font-size: 0.9rem; padding: 0.4rem 0.1rem; }
.cta-steps { margin: 0.2rem 0 0 1.2rem; padding: 0; text-align: left; color: #333; }
.cta-steps li { margin: 0.45rem 0; }
.cta-steps .button { display: inline-block; margin-right: 0.3rem; }

/* Finished trails: grouped above the rest of the list (which keeps its
   most-complete-first order), a warm tinted band and dimmed banners
   reading as "done" with the tick. */
.trails-done { background: #faf7f2; padding: 0.55rem 0.7rem 0.35rem; border-radius: 5px; margin-bottom: 0.9rem; }
.trails-done-head { color: var(--green-dark); font-size: 0.85rem; font-weight: 600; margin-bottom: 0.55rem; }
.trails-done .banner { background: var(--panel); }
/* The done-state's colour: inside the completed group only, the GUI's
   accent greens out - percentage, section count, progress fill, chevron.
   (The GUI orange stays everywhere else; the map's teal is untouched.) */
.trails-done .banner-pct { color: var(--green-dark); }
.trails-done .banner-count { color: var(--green); }
.trails-done .banner-chev { color: var(--green); }
.trails-done .banner.open .banner-chev { color: var(--green-dark); }
.trails-done .banner-fill { background: var(--green); }

/* Full detail, shown inside the expanded banner's body */
#trail-detail { margin-top: 0.75rem; }
#activities-block { margin-top: 1rem; }

details.upload { margin-top: 0.6rem; }
#add-trail details details { margin-top: 0.5rem; padding-left: 1rem; }
/* Sub-items read as children of "Add a trail": indented, normal weight,
   muted. Specificity (id) overrides the bold accent-dark rule above. */
#add-trail details details summary { color: var(--muted); font-weight: 400; }
details.upload summary { cursor: pointer; color: var(--accent-dark); font-weight: 600; margin-bottom: 0.4rem; }
details.upload label { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }
details.upload input {
  width: 100%;
  padding: 0.35rem;
  margin-top: 0.2rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Catalog: importable Scottish routes from OSM */
.catalog-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.catalog-actions button { margin-top: 0; }
.catalog-actions .msg { margin-top: 0; }
.catalog-list {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid #faecde;
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  margin-top: 0.5rem;
  background: #fff;
}
#catalog-hidden { margin-top: 0.5rem; }
#catalog-hidden summary { cursor: pointer; font-size: 0.78rem; color: var(--muted); }
.catalog-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.3rem 0.1rem;
  border-bottom: 1px solid #fcf3eb;
}
.catalog-row:last-child { border-bottom: none; }
.catalog-row button { margin-top: 0; }
.catalog-label { flex: 1; min-width: 0; }
.catalog-name { font-size: 0.85rem; }
.catalog-row.imported .catalog-name { color: var(--muted); }
.catalog-meta { display: block; font-size: 0.72rem; color: var(--muted); }
.catalog-added { font-size: 0.74rem; color: var(--accent); font-weight: 600; }
.catalog-hint { flex-basis: 100%; font-size: 0.72rem; color: var(--muted); font-style: italic; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 0.7rem;
}
button:hover { background: var(--accent-dark); }
button:disabled { background: var(--grey); cursor: wait; }
button.danger { background: #fff; color: var(--red); border: 1px solid var(--red); }
button.danger:hover { background: #fdecea; }
.btn-row { display: flex; gap: 0.5rem; align-items: center; }
.small { padding: 0.15rem 0.5rem; font-size: 0.75rem; margin-top: 0; }
a.button {
  display: inline-block;
  background: #fff;
  color: var(--accent-dark);
  padding: 0.4rem 0.8rem;
  border-radius: 5px;
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--accent-dark);
}

.dist { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.4rem; }

.map-legend {
  display: flex;
  gap: 0.9rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.2rem 0 0.5rem;
}
.map-legend .swatch {
  display: inline-block;
  width: 20px;
  height: 4px;
  border-radius: 2px;
  margin-right: 0.32rem;
  vertical-align: -1px;
}
.swatch-walked { background: var(--map-covered); }
.swatch-unwalked {
  background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--map-remaining) 75%, transparent) 0 6px, transparent 6px 11px);
}

.tolerance-row { display: flex; align-items: center; gap: 0.4rem; margin: 0.3rem 0 0.2rem; }
.tolerance-row label { font-size: 0.8rem; color: var(--muted); }
.tolerance-row input { width: 70px; padding: 0.25rem; border: 1px solid #ccc; border-radius: 4px; }
.tolerance-row button { margin-top: 0; }
button.small { font-size: 0.78rem; padding: 0.25rem 0.6rem; }

.note, .error, .msg { font-size: 0.85rem; }
.error { color: var(--red); margin-bottom: 0.8rem; }
.note { background: #fff8e1; border-radius: 6px; padding: 0.7rem 0.8rem; }
.note code, .upload code { background: #eee; padding: 0 0.2rem; border-radius: 3px; }
.msg { color: var(--muted); margin-top: 0.4rem; min-height: 1em; }

.act-list { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.act-list li { padding: 0.35rem 0.1rem; border-bottom: 1px solid #f0f0f0; }
.act-list a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.act-list a:hover { text-decoration: underline; }
.act-list .act-meta { color: var(--muted); font-size: 0.75rem; }

#activities-title { cursor: help; }

details.overlap { margin-top: 0.4rem; }
details.overlap summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.3rem 0.1rem;
  list-style: none;
  user-select: none;
}
details.overlap summary::before { content: "▸ "; }
details.overlap[open] summary::before { content: "▾ "; }
details.overlap summary:hover { text-decoration: underline; }

.leaflet-tooltip { font-size: 0.8rem; }
/* The hovered-overview name tooltip: petrol, arrowless, matching the
   map palette rather than leaflet's white chips. */
.route-tip {
  background: rgba(11, 74, 84, 0.92);
  border: none;
  color: #fff;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  padding: 0.2rem 0.5rem;
}
.route-tip::before { display: none; }

.trail-tip { padding: 0.3rem 0.5rem; }
.trail-tip .tip-km {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.1rem;
}
.trail-tip ul { margin: 0.1rem 0 0.15rem; padding-left: 1rem; font-size: 0.8rem; }
.trail-tip li { margin-bottom: 0.1rem; }
.trail-tip li strong { color: var(--text); font-weight: 600; }
.trail-tip .tip-date { color: var(--muted); margin-left: 0.35rem; font-size: 0.72rem; }
.trail-tip .tip-note { color: var(--muted); font-size: 0.72rem; }

.trail-popup { font-family: inherit; }
.trail-popup .pop-km {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.trail-popup ul { margin: 0; padding-left: 1rem; font-size: 0.85rem; }
.trail-popup li { margin-bottom: 0.3rem; }
.trail-popup a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.trail-popup a:hover { text-decoration: underline; }
.trail-popup .pop-date { color: var(--muted); margin-left: 0.4rem; font-size: 0.75rem; }
.trail-popup .pop-note { color: var(--muted); font-size: 0.8rem; }

/* Privacy page: one readable column under the shared header. */
.legal {
  display: block;
  flex: 1;
  min-height: 0;
  max-width: 36rem;
  margin: 0 auto;
  padding: 1.6rem 1.2rem 3rem;
  overflow-y: auto;
}
.legal h2 { color: var(--accent); margin: 0; }
.legal h3 { color: var(--accent); font-size: 1.02rem; margin: 1.4rem 0 0.35rem; }
.legal p, .legal li { font-size: 0.92rem; line-height: 1.5; color: #333; }
.legal ul { padding-left: 1.2rem; margin: 0.35rem 0; }
.legal li { margin-bottom: 0.35rem; }
.legal-lead { margin-top: 0.9rem; }
.legal-updated { color: var(--grey); font-size: 0.78rem; margin: 0.25rem 0 1rem; }
header h1 a { color: inherit; text-decoration: none; }
.privacy-link { font-size: 0.9rem; color: var(--accent-dark); }

