:root {
  --ink: #252522;
  --paper: #f7f5ef;
  --surface: #ffffff;
  --alpine: #536b57;
  --alpine-dark: #3c5040;
  --line: #dedbd2;
  --muted: #74736c;
  --danger: #8b4038;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif; line-height: 1.55; }
a { color: inherit; text-underline-offset: 3px; }
header { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 18px clamp(20px, 5vw, 72px); border-bottom: 1px solid var(--line); background: rgba(247,245,239,.97); }
.brand { text-decoration: none; display: flex; flex-direction: column; flex: 0 0 auto; }
.brand strong { font-family: Georgia, serif; font-size: 1.45rem; font-weight: 500; }
.brand span { font-size: .72rem; color: var(--muted); letter-spacing: .05em; }
nav { display: flex; gap: 20px; align-items: center; }
nav a, .link { text-decoration: none; font-size: .9rem; white-space: nowrap; }
nav form { margin: 0; }
main { max-width: 1440px; margin: auto; padding: clamp(28px, 5vw, 72px); }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 28px clamp(20px, 5vw, 72px); color: var(--muted); border-top: 1px solid var(--line); font-size: .82rem; }
h1, h2 { font-family: Georgia, serif; font-weight: 400; line-height: 1.08; text-wrap: balance; }
h1 { font-size: clamp(2.5rem, 6vw, 5.6rem); margin: .2em 0; }
h2 { font-size: 1.65rem; }
.hero { max-width: 850px; padding: 3vw 0 5vw; }
.hero.compact { padding-bottom: 2vw; }
.hero > p:last-child { font-size: 1.15rem; color: var(--muted); max-width: 650px; }
.eyebrow { font-size: .72rem; letter-spacing: .15em; color: var(--alpine); font-weight: 700; text-transform: uppercase; }

input, select, textarea { display: block; width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); font: inherit; margin-top: 5px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--alpine) 35%, transparent); outline-offset: 2px; }
input[type="checkbox"] { display: inline-block; width: auto; margin-right: 8px; }
button, .button { display: inline-block; border: 0; border-radius: 4px; background: var(--alpine); color: white; padding: 12px 18px; text-decoration: none; font: inherit; cursor: pointer; text-align: center; }
button:hover, .button:hover { background: var(--alpine-dark); }
button:disabled { opacity: .6; cursor: wait; }
.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.secondary:hover { background: var(--surface); }
.danger { background: var(--danger); }
.link { background: none; color: inherit; padding: 0; }
.link:hover { background: none; }
.wide { width: 100%; margin-top: 10px; }
.stack { display: grid; gap: 14px; }
.stack p { margin: 0; }
.stack label, .filters label, .moderation label { font-size: .78rem; color: var(--muted); }
.helptext { display: block; font-size: .75rem; color: var(--muted); }
.errorlist { color: var(--danger); margin: 4px 0; padding-left: 20px; }
.form-status { min-height: 1.5rem; color: var(--alpine-dark); font-weight: 600; }
.messages { position: sticky; top: 0; z-index: 1001; max-width: 760px; margin: 12px auto; padding: 0 20px; }
.messages p { background: var(--surface); border: 1px solid var(--line); padding: 12px 16px; box-shadow: 0 8px 24px rgba(30,30,25,.08); }

.filters { display: grid; grid-template-columns: minmax(180px, 2fr) repeat(6, minmax(100px, 1fr)) auto; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; align-items: end; }
.browse-tools { display: flex; align-items: center; gap: 12px; min-height: 48px; margin-bottom: 14px; }
.browse-tools #location-status { color: var(--muted); font-size: .84rem; }
.view-toggle { display: none; }
.view-toggle button { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.view-toggle button.active { background: var(--ink); color: white; }
.browse { display: grid; grid-template-columns: minmax(380px, .9fr) minmax(480px, 1.25fr); min-height: 650px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cards { overflow: auto; max-height: 75vh; border-right: 1px solid var(--line); }
.card { display: grid; grid-template-columns: 150px 1fr; min-height: 155px; text-decoration: none; border-bottom: 1px solid var(--line); background: var(--surface); }
.card:hover { background: #fbfaf6; }
.card img { width: 150px; height: 100%; min-height: 155px; object-fit: cover; }
.card > div { padding: 18px; }
.card h2 { margin: 4px 0 12px; font-size: 1.45rem; }
.card p { margin: 4px 0; color: var(--muted); font-size: .88rem; }
.card .eyebrow { color: var(--alpine); font-size: .66rem; }
.card .drive-estimate { color: var(--alpine-dark); font-weight: 700; }
.empty { padding: 40px; }
#map { min-height: 650px; z-index: 1; }
.leaflet-popup-content a { font-weight: 700; color: var(--alpine-dark); }

.detail { max-width: 1240px; margin: auto; }
.detail-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.detail-head h1 { font-size: clamp(2.6rem, 6vw, 5rem); }
.gallery { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 10px; overflow-x: auto; margin: 24px 0; }
.gallery img { width: 100%; height: 380px; object-fit: cover; border-radius: var(--radius); }
.stats { display: grid; grid-template-columns: repeat(6, 1fr); border: 1px solid var(--line); background: var(--surface); margin: 28px 0; border-radius: var(--radius); overflow: hidden; }
.stats div { padding: 20px; border-right: 1px solid var(--line); }
.stats div:last-child { border: 0; }
.stats strong, .stats span { display: block; }
.stats strong { font-size: 1.15rem; }
.stats span { color: var(--muted); font-size: .75rem; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr); gap: clamp(30px, 6vw, 80px); }
.prose { max-width: 70ch; }
.estimate, .moderation { margin: 24px 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.estimate p { margin-bottom: 4px; }
.estimate small { color: var(--muted); }
blockquote { margin: 12px 0; padding: 16px 18px; background: var(--surface); border-left: 3px solid var(--alpine); }
blockquote small { display: block; color: var(--muted); margin-top: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
#route-map { height: 430px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; }
.directions { margin: 18px 0; }
.directions a { display: inline-block; margin: 0 12px 8px 0; color: var(--alpine-dark); font-weight: 700; }
.moderation { display: grid; gap: 12px; }

.narrow, .auth { max-width: 720px; margin: 30px auto; padding: clamp(22px, 5vw, 48px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.auth { max-width: 520px; }
.narrow h1, .auth h1 { font-size: clamp(2.3rem, 5vw, 4rem); }
.photo-manage { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.photo-manage img { width: 100%; height: 130px; object-fit: cover; border-radius: 6px; }
.photo-manage strong { display: block; color: var(--alpine); }

.library-section { padding: 24px 0; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.mini-card { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.mini-card span { color: var(--muted); font-size: .84rem; }
.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }

@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(4, 1fr); }
  .browse { grid-template-columns: minmax(330px, .8fr) 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stats div:nth-child(3) { border-right: 0; }
  .stats div:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 900px) {
  header { align-items: flex-start; }
  .brand span { display: none; }
  nav { gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
  .filters { grid-template-columns: 1fr 1fr; }
  .browse-tools { align-items: flex-start; flex-wrap: wrap; }
  .view-toggle { display: flex; }
  .browse { display: block; min-height: 0; }
  .cards { max-height: none; border-right: 0; }
  .browse #map { display: none; height: 65vh; min-height: 420px; }
  .browse[data-view="map"] .cards { display: none; }
  .browse[data-view="map"] #map { display: block; }
  .detail-grid { grid-template-columns: 1fr; }
  .gallery img { height: 280px; }
}
@media (max-width: 600px) {
  main { padding: 22px 16px; }
  header { padding: 14px 16px; }
  nav { font-size: .8rem; }
  nav a, .link { font-size: .8rem; }
  .filters { grid-template-columns: 1fr; }
  .card { grid-template-columns: 105px 1fr; }
  .card img { width: 105px; min-height: 125px; }
  .card > div { padding: 14px; }
  .hero { padding: 40px 0; }
  .detail-head { display: block; }
  .detail-head .button { margin-top: 12px; }
  .detail-grid { gap: 25px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div, .stats div:nth-child(3) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .stats div:nth-child(even) { border-right: 0; }
  .stats div:nth-last-child(-n+2) { border-bottom: 0; }
  .gallery img { height: 220px; }
  footer { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
