:root {
  --paper: #fbf5ea;
  --paper-2: #f3e8d3;
  --ink: #2b1d16;
  --ink-soft: #6b564a;
  --timber: #4a2e22;
  --brick: #c8452f;
  --coral: #e2574c;
  --mustard: #d9a441;
  --line: #e4d4b8;
  --card: #fffdf8;
  --shadow: 0 6px 24px rgba(74, 46, 34, 0.18);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1d1612;
    --paper-2: #2a1f19;
    --ink: #f1e6d4;
    --ink-soft: #b9a48f;
    --timber: #e9d9c0;
    --brick: #ee7a5f;
    --coral: #f0705f;
    --line: #3d2e25;
    --card: #251b16;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--sans); }
a { color: var(--brick); }
img { max-width: 100%; height: auto; }
h1, h2 { font-family: var(--serif); line-height: 1.15; color: var(--timber); }

/* header with a half-timbered (colombage) rule */
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px max(16px, env(safe-area-inset-left)); background: var(--paper); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand img { display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font: 700 1.45rem var(--serif); color: var(--timber); letter-spacing: 0.01em; }
.brand-tag { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }
.lang-switch { display: flex; gap: 2px; }
.lang-switch a { padding: 6px 9px; border-radius: 8px; text-decoration: none; color: var(--ink-soft); font-size: 0.82rem; font-weight: 600; }
.lang-switch a[aria-current] { background: var(--timber); color: var(--paper); }
.beam { height: 8px; background:
  repeating-linear-gradient(135deg, transparent 0 14px, var(--timber) 14px 17px, transparent 17px 31px) 0 0 / 100% 100%,
  linear-gradient(var(--timber), var(--timber)) 0 100% / 100% 3px no-repeat; opacity: 0.85; }

.btn, .btn-icon { font: inherit; font-weight: 600; border: 0; cursor: pointer; text-decoration: none; }
.btn { display: inline-block; padding: 10px 18px; border-radius: 999px; background: var(--brick); color: #fff; }
.btn:hover { filter: brightness(1.08); }
.btn-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--timber); color: var(--paper); font-size: 1rem; }

/* ----- map page ----- */
body.is-map { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.map-page { position: relative; flex: 1; min-height: 0; }
.map-page .map { position: absolute; inset: 0; }
.map-status { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); margin: 0; padding: 6px 14px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-size: 0.9rem; z-index: 3; }
.map-status:empty, .map-status[hidden] { display: none; }

.controls { position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(74, 46, 34, 0.12); }
.year-row { display: flex; align-items: center; gap: 12px; }
.year-label { font: 600 0.9rem var(--sans); color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.08em; }
.year-label output { font: 700 1.9rem var(--serif); color: var(--brick); margin-left: 6px; letter-spacing: 0; }
.year-slider { width: 100%; margin: 8px 0 2px; height: 36px; accent-color: var(--brick); cursor: pointer; touch-action: pan-y; }
.more summary { cursor: pointer; font-size: 0.85rem; color: var(--ink-soft); padding: 4px 0; }
.legend { list-style: none; margin: 8px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; font-size: 0.82rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.check { display: block; font-size: 0.9rem; padding: 6px 0; }

/* building sheet: bottom sheet on phones, side card on desktop */
.sheet { position: absolute; z-index: 5; left: 12px; right: 12px; bottom: 150px; max-height: 55%; overflow: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border: 1px solid var(--line); }
.sheet[hidden] { display: none; }
.sheet-close { position: absolute; top: 4px; right: 8px; width: 40px; height: 40px; border: 0; background: none; font-size: 1.7rem; color: var(--ink-soft); cursor: pointer; }
.sheet h2 { margin: 0 36px 4px 0; font-size: 1.35rem; }
.sheet .eyebrow { margin: 0; }
.sheet .facts { margin: 8px 0 12px; }
.sheet .thumb { width: 100%; max-height: 160px; object-fit: cover; border-radius: 10px; margin: 6px 0 10px; display: block; }
.sheet p { margin: 6px 0; }
@media (min-width: 820px) {
  .sheet { left: 16px; right: auto; width: 360px; top: 16px; bottom: auto; max-height: calc(100% - 200px); }
  .controls { left: 16px; right: 16px; bottom: 16px; border-radius: var(--radius); border: 1px solid var(--line); max-width: 760px; margin: 0 auto; }
}
.maplibregl-ctrl-group { border-radius: 10px !important; }
.layer-toggle { color: #2b1d16; background-image: none; }

/* ----- house page ----- */
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.74rem; color: var(--brick); font-weight: 700; margin: 0 0 4px; }
.chip { display: inline-block; padding: 3px 11px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line); font-size: 0.85rem; margin: 0 6px 6px 0; }
.chip.warn { background: color-mix(in srgb, var(--brick) 14%, var(--paper)); border-color: var(--brick); }
.chip.muted, .muted { color: var(--ink-soft); }
.house-hero { position: relative; max-width: 1000px; margin: 0 auto; }
.house-hero .hero-img { display: block; width: 100%; max-height: 420px; object-fit: cover; }
.house-hero .hero-text { padding: 18px 16px 4px; }
.house-hero:not(.no-photo) .hero-text { position: relative; margin: -56px 12px 0; padding: 18px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.house-hero h1 { margin: 0 0 8px; font-size: clamp(1.7rem, 5vw, 2.6rem); }
.house-body { max-width: 760px; margin: 0 auto; padding: 8px 16px 64px; }
.house-body h2 { font-size: 1.4rem; margin: 32px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.prose { font-size: 1.05rem; } .prose p { margin: 0 0 1em; } .prose blockquote { margin: 1em 0; padding-left: 14px; border-left: 3px solid var(--mustard); color: var(--ink-soft); }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--mustard); }
.timeline li { padding: 4px 0 10px 16px; position: relative; display: flex; gap: 14px; }
.timeline li::before { content: ""; position: absolute; left: -8px; top: 12px; width: 13px; height: 13px; border-radius: 50%; background: var(--brick); border: 2px solid var(--paper); }
.timeline strong { font-family: var(--serif); color: var(--brick); min-width: 3.2em; }
.plain { padding-left: 1.1em; } .plain li { margin: 4px 0; }
.gallery { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.gallery.wide { grid-template-columns: 1fr; }
@media (min-width: 700px) { .gallery { grid-template-columns: repeat(3, 1fr); } .gallery.wide { grid-template-columns: 1fr 1fr; } }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; display: block; background: var(--paper-2); }
.gallery.wide img { aspect-ratio: auto; object-fit: contain; }
.gallery .cap { display: block; font-size: 0.8rem; color: var(--ink-soft); margin-top: 4px; }
.empty { padding: 28px 18px; text-align: center; background: var(--paper-2); border-radius: var(--radius); color: var(--ink-soft); font-family: var(--serif); font-size: 1.1rem; }
audio { width: 100%; }

/* ----- header nav, list page, map search ----- */
.site-header { flex-wrap: wrap; }
.main-nav { display: flex; gap: 2px; margin-left: auto; }
.main-nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 600; }
.main-nav a[aria-current] { background: var(--paper-2); color: var(--brick); }
.list-page { max-width: 980px; margin: 0 auto; padding: 8px 16px 64px; }
.list-page h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 18px 0 12px; }
.search { display: flex; gap: 8px; }
.search input[type="search"], .map-search input { flex: 1; min-width: 0; font: inherit; padding: 11px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.search input:focus-visible, .map-search input:focus-visible { outline: 2px solid var(--brick); outline-offset: 1px; }
.eras { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.eras .chip { white-space: nowrap; text-decoration: none; color: var(--ink); margin: 0; }
.eras .chip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.eras .chip.on { background: var(--timber); color: var(--paper); border-color: var(--timber); }
.count { color: var(--ink-soft); font-size: 0.9rem; margin: 10px 0; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.card { display: flex; flex-direction: column; height: 100%; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform 0.15s, box-shadow 0.15s; }
.card:hover, .card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); }
.card img, .card .ph { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--paper-2); }
.card .ph { background: repeating-linear-gradient(135deg, var(--paper-2) 0 10px, var(--paper) 10px 20px); }
.card-body { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 14px; }
.card-body strong { font-family: var(--serif); font-size: 1.05rem; line-height: 1.2; color: var(--timber); }
.card-body .muted { font-size: 0.85rem; }
.map-search { position: absolute; z-index: 4; top: 12px; left: 12px; right: 64px; max-width: 360px; }
.map-search input { width: 100%; box-shadow: var(--shadow); }
.map-search ul { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 40vh; overflow: auto; }
.map-search ul:empty { display: none; }
.map-search li button { display: block; width: 100%; text-align: left; font: inherit; padding: 9px 12px; border: 0; background: none; color: var(--ink); border-radius: 8px; cursor: pointer; }
.map-search li button:hover, .map-search li button:focus-visible { background: var(--paper-2); }
.map-search small { color: var(--ink-soft); display: block; }
@media (min-width: 820px) { .map-search { left: auto; right: 64px; top: 12px; } .sheet { top: 64px; max-height: calc(100% - 260px); } }

/* --- accounts --- */
.auth { display: grid; place-items: start center; padding: 32px 16px; }
.auth-card { width: min(100%, 440px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.auth-card h1 { margin-top: 0; font-size: 1.5rem; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: 0.92rem; }
.form input { font: inherit; font-weight: 400; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg, var(--card)); color: var(--ink); }
.form input:focus-visible { outline: 2px solid var(--brick); outline-offset: 1px; }
.form-error { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--brick) 14%, transparent); color: var(--ink); border: 1px solid var(--brick); }
.secret dt { font-weight: 600; margin-top: 8px; }
.secret dd { margin: 2px 0 0; overflow-wrap: anywhere; }

.auth-card:has(.user-list) { width: min(100%, 760px); }
.user-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.user-list li { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.user-list .inactive { opacity: 0.6; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.btn-link { font: inherit; font-size: 0.9rem; padding: 4px 0; border: 0; background: none; color: var(--brick); cursor: pointer; text-decoration: underline; }
.form select { font: inherit; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.temp-password code { display: block; padding: 14px; font-size: 1.2rem; text-align: center; background: var(--card); border: 1px dashed var(--brick); border-radius: 10px; user-select: all; }

/* --- house editing --- */
.auth-card.wide { width: min(100%, 860px); }
.btn.secondary { background: transparent; color: var(--brick); border: 1px solid var(--brick); }
.edit-form fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 14px; display: grid; gap: 8px; }
.edit-form legend { font-weight: 600; padding: 0 6px; }
.edit-form .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.edit-form .row input:not([type=checkbox]) { flex: 1 1 160px; min-width: 0; }
.edit-form .row input.year { flex: 0 0 90px; }
.edit-form .check { display: flex; flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.edit-form textarea { font: inherit; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); width: 100%; box-sizing: border-box; }
.field-error { color: var(--brick); font-weight: 400; font-size: 0.85rem; }
.form-ok, .form-note { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.form-ok { border-color: #3d7a4a; }
.rich-editor { border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; }
.rich-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); }
.rich-bar button { font: inherit; min-width: 36px; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.rich-bar button.on { background: var(--brick); color: #fff; border-color: var(--brick); }
.rich-surface { padding: 10px 14px; min-height: 8rem; }
.rich-surface .ProseMirror { outline: none; min-height: 7rem; }

/* --- media manager --- */
.media-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.media-list li { display: grid; grid-template-columns: 160px 1fr; gap: 14px; padding-top: 14px; border-top: 1px solid var(--line); align-items: start; }
.media-list img { width: 160px; height: auto; border-radius: 8px; }
.media-list audio { width: 160px; }
.media-list .thumb { overflow-wrap: anywhere; }
.media-list .form { gap: 8px; }
@media (max-width: 560px) { .media-list li { grid-template-columns: 1fr; } }

/* --- review --- */
.diff h2 { font-size: 1.05rem; margin: 18px 0 6px; }
.diff-old, .diff-new { margin: 0 0 6px; padding: 8px 12px; border-radius: 8px; border-left: 4px solid; }
.diff-old { background: color-mix(in srgb, #b3261e 10%, transparent); border-color: #b3261e; }
.diff-new { background: color-mix(in srgb, #2e7d32 12%, transparent); border-color: #2e7d32; }
.diff ul.plain { list-style: none; padding: 0; margin: 0; }
.review-actions { display: grid; gap: 16px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.review-actions textarea { font: inherit; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); width: 100%; box-sizing: border-box; }

/* --- contact form and inbox --- */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.auth-card textarea { font: inherit; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); width: 100%; box-sizing: border-box; }
.tabs { display: flex; gap: 14px; }
.tabs a[aria-current="page"] { font-weight: 700; text-decoration: none; color: var(--ink); }
.inbox .msg { white-space: pre-wrap; margin: 6px 0; overflow-wrap: anywhere; }

/* --- documents --- */
.form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form.inline input:not([type=checkbox]) { flex: 1 1 200px; }

/* Photo viewer */
body.lb-open { overflow: hidden; }
.lb { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(20, 12, 8, 0.92); }
.lb[hidden] { display: none; }
.lb-stage { margin: 0; max-width: min(1100px, 100vw - 120px); max-height: 100vh; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 0; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; border-radius: 8px; background: var(--paper-2); }
.lb-stage figcaption { color: #f3e8d3; font-size: 0.95rem; text-align: center; min-height: 1.4em; max-width: 70ch; }
.lb button { border: 0; background: rgba(255, 253, 248, 0.14); color: #fff; cursor: pointer; font-size: 2rem; line-height: 1; border-radius: 999px; width: 48px; height: 48px; }
.lb button:hover, .lb button:focus-visible { background: rgba(255, 253, 248, 0.3); outline: 2px solid var(--mustard); }
.lb-close { position: absolute; top: 14px; right: 14px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }
.lb.single .lb-nav { display: none; }
@media (max-width: 700px) { .lb-stage { max-width: 100vw; padding: 56px 0 16px; } .lb-nav { top: auto; bottom: 18px; transform: none; } }
