:root {
  --paper: #eef1ec;
  --surface: #ffffff;
  --ink: #1d2621;
  --muted: #5b6861;
  --line: #d3dad2;
  --pine: #2f5d50;
  --pine-hover: #23473d;
  --pine-text: #2f5d50;
  --on-pine: #ffffff;
  --blaze: #e3a82b;
  --blaze-soft: #f5e4b8;
  --blaze-ink: #6b4a07;
  --danger: #a8412f;
  --danger-soft: #f6dfd9;
  --ok-soft: #dcebdd;
  --ok-ink: #24552d;
  --radius: 6px;
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "Instrument Sans", "Helvetica Neue", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141a17;
    --surface: #1b2320;
    --ink: #e3e9e4;
    --muted: #9aa8a0;
    --line: #2d3833;
    --pine: #3e7a69;
    --pine-hover: #4a8b78;
    --pine-text: #86c2af;
    --blaze-soft: #3d3219;
    --blaze-ink: #f0cd7c;
    --danger: #e38a78;
    --danger-soft: #3b231e;
    --ok-soft: #1f3324;
    --ok-ink: #a6d4ad;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.75rem, 3vw, 2.25rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; font-weight: 500; }
p { margin: 0 0 0.75rem; }
a { color: var(--pine-text); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--blaze); outline-offset: 2px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 12px 24px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 1.35rem var(--display); color: var(--ink); text-decoration: none; }
.brand::before { content: ""; width: 9px; height: 22px; background: var(--blaze); border-radius: 2px; }
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-left: auto; font-size: 0.95rem; }
.nav a { color: var(--ink); text-decoration: none; }
.nav a:hover { color: var(--pine-text); }
.nav a.btn, .nav a.btn:hover { color: var(--on-pine); }
.nav form { margin: 0; }

main.wrap { padding-top: 28px; padding-bottom: 64px; }
.site-footer { border-top: 1px solid var(--line); padding: 20px 0 40px; color: var(--muted); font-size: 0.875rem; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 32px; align-items: start; }
.narrow { max-width: 620px; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 0.95rem var(--body); padding: 9px 16px; border-radius: var(--radius);
  background: var(--pine); color: var(--on-pine); border: 1px solid var(--pine);
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--pine-hover); border-color: var(--pine-hover); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-quiet:hover { background: var(--paper); border-color: var(--muted); }
.btn-blaze { background: var(--blaze); border-color: var(--blaze); color: #2b2003; }
.btn-blaze:hover { background: #cf9620; border-color: #cf9620; }
.btn-link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 0.875rem; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.btn-link:hover { color: var(--ink); }
.btn-danger { color: var(--danger); }
.inline-form { display: inline; margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Flash messages */
.flashes { margin-bottom: 20px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-left: 4px solid var(--pine); background: var(--surface); }
.flash-success { border-color: #3f8f4f; background: var(--ok-soft); color: var(--ok-ink); }
.flash-error { border-color: var(--danger); background: var(--danger-soft); }
.flash-dev, .flash-devlink { border-color: var(--blaze); background: var(--blaze-soft); color: var(--blaze-ink); word-break: break-all; }

/* Forms */
.form { display: grid; gap: 18px; }
.field label, .field legend { display: block; font-weight: 500; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: 0.85rem; margin: 4px 0 0; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local],
input[type=number], input[type=tel], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pine); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pine) 25%, transparent); }
textarea { min-height: 120px; resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; }
.field-error { color: var(--danger); font-size: 0.875rem; margin: 6px 0 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row-2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; }
.check input { margin-top: 5px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; }
.chip span { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 0.9rem; }
.chip input:checked + span { background: var(--pine); border-color: var(--pine); color: var(--on-pine); }
.chip input:focus-visible + span { outline: 3px solid var(--blaze); outline-offset: 2px; }
a.chip-link { display: inline-block; padding: 4px 11px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.85rem; color: var(--ink); text-decoration: none; background: var(--surface); }
a.chip-link.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }

/* Sidebar */
.side-section { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--pine); border-radius: 0 0 var(--radius) var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.side-section h2 { font-size: 1rem; margin-bottom: 10px; }
.side-section p:last-child { margin-bottom: 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 0.95rem; }
.tabs a.active { color: var(--ink); border-color: var(--ink); font-weight: 500; }

/* Posts */
.feed { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.post-row { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 8px; padding: 14px 16px 14px 8px; border-bottom: 1px solid var(--line); }
.post-row:last-child { border-bottom: 0; }
.post-meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.post-meta a { color: var(--muted); }
.post-title { font-size: 1.1rem; margin-bottom: 6px; }
.post-title a { color: var(--ink); text-decoration: none; }
.post-title a:hover { text-decoration: underline; }
.post-foot { font-size: 0.85rem; margin: 0; }
.post-foot a { color: var(--muted); }
.kind { font-weight: 500; color: var(--ink); }
.kind-proposal { color: var(--blaze-ink); }
.kind-recap { color: var(--pine-text); }
.proposal-when { font-size: 0.9rem; margin-bottom: 6px; }

.vote { display: flex; flex-direction: column; align-items: center; gap: 0; }
.vote form { margin: 0; }
.vote-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 6px 10px; border-radius: var(--radius); }
.vote-btn:hover { background: var(--paper); color: var(--ink); }
.vote-btn.active { color: var(--pine-text); }
.vote-btn.down.active { color: var(--danger); }
.score { font-weight: 600; font-size: 0.95rem; font-variant-numeric: tabular-nums; }

/* Proposal meter: trail blazes that fill in as people join */
.meter { margin: 8px 0 10px; }
.blazes { display: flex; gap: 5px; flex-wrap: wrap; align-items: flex-end; }
.blaze { width: 11px; height: 24px; border-radius: 2px; background: transparent; border: 1.5px dashed var(--muted); opacity: 0.55; }
.blaze.on { opacity: 1; }
.blaze.on { background: var(--blaze); border: 1.5px solid var(--blaze); }
.meter-done .blaze.on { background: var(--pine); border-color: var(--pine); }
.bar { height: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--blaze); }
.meter-label { font-size: 0.85rem; color: var(--muted); margin: 6px 0 0; }
.meter-large .blaze { width: 16px; height: 36px; }

/* Post detail */
.post-body { font-size: 1.02rem; max-width: 70ch; }
.detail-grid { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 10px; }
.proposal-box { border: 1px solid var(--line); border-left: 4px solid var(--blaze); background: var(--surface); padding: 16px 18px; margin: 16px 0; }
.proposal-box.converted { border-left-color: var(--pine); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.comments { margin-top: 28px; }
.comment { padding: 12px 0; border-top: 1px solid var(--line); }
.comment .post-meta { margin-bottom: 2px; }

/* Events */
.event-list { display: grid; gap: 0; }
.event-row { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.event-row:first-child { border-top: 0; }
.event-row:hover strong { text-decoration: underline; }
.event-date { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: 4px 0; height: 52px; }
.event-date .mon { font-size: 0.75rem; color: var(--muted); }
.event-date .day { font: 700 1.25rem/1 var(--display); }
.event-info { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); }
.event-info strong { color: var(--ink); font-size: 0.95rem; font-weight: 500; }
.feed .event-row { padding: 14px 16px; }

.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px; margin-top: 10px; }
.person { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--line); flex: none; }
.avatar-lg { width: 96px; height: 96px; }
.avatar-placeholder { display: inline-flex; align-items: center; justify-content: center; font-weight: 600; color: var(--muted); }

.badge { display: inline-block; font-size: 0.8rem; padding: 2px 8px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); color: var(--muted); }
.badge-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok-ink); }
.badge-blaze { background: var(--blaze-soft); border-color: transparent; color: var(--blaze-ink); }

/* Trust checklist */
.levels { display: grid; gap: 14px; }
.level { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.level.unlocked { border-left: 4px solid var(--pine); }
.level-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; }
.done { color: var(--ok-ink); }
.stats { display: flex; gap: 28px; flex-wrap: wrap; margin: 14px 0; }
.stats div { display: flex; flex-direction: column; }
.stats strong { font: 700 1.5rem/1.1 var(--display); }
.stats span { color: var(--muted); font-size: 0.85rem; }

/* Landing */
.hero { padding: 40px 0 36px; max-width: 760px; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); letter-spacing: -0.025em; margin-bottom: 16px; }
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 56ch; }
.how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 12px 0 36px; }
.how div { padding: 20px 22px 20px 0; }
.how div + div { padding-left: 22px; border-left: 1px solid var(--line); }
.how h3 { margin-bottom: 6px; font-weight: 700; }
.how p { color: var(--muted); margin: 0; font-size: 0.95rem; }
@media (max-width: 720px) { .how { grid-template-columns: 1fr; } .how div + div { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; } }

.community-list { display: grid; gap: 0; }
.community-item { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px; border-bottom: 1px solid var(--line); }
.community-item:last-child { border-bottom: 0; }
.community-item h3 { margin-bottom: 2px; }
.community-item h3 a { color: var(--ink); text-decoration: none; }
.community-item p { margin: 0; }

.empty { padding: 28px 20px; text-align: left; }
.empty h2 { font-size: 1.1rem; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 500; color: var(--muted); font-size: 0.85rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Routes */
:root { --route-line: #d9951a; }
@media (prefers-color-scheme: dark) { :root { --route-line: #f0b43c; } }

.route-block { margin: 28px 0; }
.route-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.route-head h2 { margin: 0; }
.route-head p { margin: 0; }
.route-map { height: 360px; margin: 12px 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); overflow: hidden; z-index: 0; }
.route-map-large { height: 460px; }
.route-map-draw { height: 400px; cursor: crosshair; }
.route-map noscript svg { width: 100%; height: 100%; }
@media (max-width: 560px) { .route-map { height: 280px; } .route-map-large, .route-map-draw { height: 340px; } }

/* Keep light map tiles from glaring in dark mode */
@media (prefers-color-scheme: dark) {
  .route-map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85); }
  .route-map .leaflet-control-attribution { background: rgba(27, 35, 32, 0.8); color: var(--muted); }
  .route-map .leaflet-control-attribution a { color: var(--pine-text); }
  .route-map .leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--line); }
}

.route-thumb { flex: none; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.route-thumb path { fill: none; stroke: var(--route-line); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.route-list { display: grid; }
.route-item { display: flex; gap: 16px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.route-item:last-child { border-bottom: 0; }
.route-item:hover strong { text-decoration: underline; }
.route-item-text { display: flex; flex-direction: column; font-size: 0.9rem; color: var(--muted); }
.route-item-text strong { color: var(--ink); font-size: 1.05rem; font-weight: 500; }

.route-picker { border-top: 1px solid var(--line); padding-top: 16px; }
.route-panel { margin-top: 14px; }
.route-panel[hidden] { display: none; }
.route-panel label { display: block; font-weight: 500; margin-bottom: 6px; }
.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented label { position: relative; margin: 0; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 0.9rem; font-weight: 400; }
.segmented input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.segmented input:focus-visible + span { outline: 3px solid var(--blaze); outline-offset: 2px; }
.route-draw-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.route-draw-bar .btn { padding: 5px 12px; font-size: 0.875rem; }
