:root {
  --green: #2d4a35;
  --green-2: #3d5f45;
  --copper: #b8794f;
  --ink: #1d221e;
  --muted: #687068;
  --line: #e2e4de;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-solid: #ffffff;
  --bg: #e9ece5;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(24, 32, 26, 0.14), 0 1px 3px rgba(24, 32, 26, 0.08);
  --serif: 'Marcellus', 'Trajan Pro', Georgia, serif;
  --script: 'Pinyon Script', cursive;
  --sans: 'Jost', 'Futura', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* Pins */
#pins { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.pin {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  border: 0;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--green);
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: background 0.15s, color 0.15s, transform 0.15s;
  white-space: nowrap;
}
.pin:hover { background: var(--green); color: #fff; }
.pin.active { background: var(--copper); color: #fff; transform: translate(-50%, -50%) scale(1.12); }
.pin.hidden { display: none; }

/* Panel */
#panel {
  position: fixed; z-index: 5;
  top: 16px; left: 16px;
  width: 360px; max-height: calc(100% - 32px);
  overflow-y: auto;
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 16px;
  scrollbar-width: thin;
}
.sheet-handle { display: none; }
.brand .eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--copper);
}
.brand h1 {
  font-weight: 400; margin: 8px 0 6px; line-height: 1; color: var(--green);
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 10px;
}
.brand h1 .caps { font-family: var(--serif); font-size: 27px; letter-spacing: 0.14em; }
.brand h1 em { font-family: var(--script); font-style: normal; font-size: 34px; color: var(--copper); line-height: 0.8; }
.brand .sub { margin: 0; color: var(--muted); font-size: 13px; }

h2 {
  font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin: 22px 0 8px;
}
.block-label { font-size: 12px; font-weight: 600; color: var(--green); margin: 14px 0 4px; }
.unit-row {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  border: 0; background: transparent;
  padding: 9px 8px; border-radius: 10px;
  border-bottom: 1px solid var(--line);
}
.unit-row:hover, .unit-row.hover { background: #f1f3ee; }
.unit-row .code {
  font-weight: 600; font-size: 14px; color: var(--green);
  background: #edf1ea; border-radius: 8px; padding: 5px 0; text-align: center;
}
.unit-row .meta { font-size: 13px; color: var(--ink); }
.unit-row .meta small { display: block; color: var(--muted); font-size: 12px; }
.unit-row .area { font-weight: 600; font-size: 14px; white-space: nowrap; }

.link-btn { border: 0; background: none; padding: 0; color: var(--green); font-weight: 600; font-size: 13px; margin-top: 18px; }
.detail-head { display: flex; gap: 14px; align-items: center; margin: 14px 0 12px; }
.unit-code {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 17px; flex: none;
}
.unit-title { font-weight: 600; font-size: 17px; }
.unit-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 14px; }
.stats div { background: #f3f5f0; border-radius: 10px; padding: 9px 11px; }
.stats div.wide { grid-column: span 2; background: #edf1ea; }
.stats dt { font-size: 11px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-weight: 600; font-size: 16px; }
.stats div.wide dd { color: var(--green); font-size: 19px; }
.plan-thumb { display: block; width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 0; overflow: hidden; background: #fff; }
.plan-thumb img { display: block; width: 100%; height: auto; }
.ref-thumb { position: relative; }
.ref-tag { position: absolute; left: 8px; bottom: 8px; background: rgba(255,255,255,0.92); color: var(--green); font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 999px; }
.ref-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ref-strip button { border: 0; padding: 0; border-radius: 6px; overflow: hidden; aspect-ratio: 4 / 3; background: #e6e8e2; }
.ref-strip img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s; }
.ref-strip button:hover img { transform: scale(1.06); }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.btn {
  flex: 1; text-align: center; text-decoration: none;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 600;
}
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn:hover { filter: brightness(0.97); }

.note { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 10px; }
.note p { font-size: 11px; line-height: 1.5; color: var(--muted); margin: 0 0 4px; }
.note .credit { font-weight: 600; }

/* Top bar */
#topbar {
  position: fixed; z-index: 4; top: 16px; right: 16px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
}
.chip {
  border: 0; background: var(--surface); box-shadow: var(--shadow);
  border-radius: 999px; padding: 9px 14px; font-size: 13px; font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--green); color: #fff; }
.lang { display: flex; background: var(--surface); box-shadow: var(--shadow); border-radius: 999px; padding: 3px; }
.lang button { border: 0; background: transparent; border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.lang button[aria-pressed="true"] { background: var(--green); color: #fff; }

/* Dock */
#dock {
  position: fixed; z-index: 4;
  left: calc(50% + 188px); transform: translateX(-50%);
  bottom: 18px;
  display: flex; gap: 10px; align-items: stretch;
  max-width: calc(100% - 420px);
}
.views {
  display: flex; gap: 4px; align-items: center;
  background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius); padding: 6px;
}
.views button {
  border: 0; background: transparent; border-radius: 10px; padding: 9px 12px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.views button:hover { background: #eef1eb; }
.views button.active { background: var(--green); color: #fff; }
.sun {
  background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius);
  padding: 8px 14px 9px; min-width: 300px;
}
.sun-row { display: flex; justify-content: space-between; align-items: baseline; }
.sun-label { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.sun-time { font-size: 13px; font-weight: 600; }
.sun input[type="range"] { width: 100%; accent-color: var(--copper); margin: 4px 0 2px; }
.dates { display: flex; gap: 4px; }
.dates button {
  border: 0; background: #f0f2ed; border-radius: 999px; padding: 4px 9px;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.dates button.active { background: var(--copper); color: #fff; }

#compass {
  position: fixed; z-index: 4; right: 18px; bottom: 22px;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
#compass svg { width: 40px; height: 40px; transition: transform 0.05s linear; }
#compass circle { fill: none; stroke: var(--line); stroke-width: 1.5; }
#compass path { fill: var(--copper); }
#compass text { font: 600 8px var(--sans); fill: var(--green); text-anchor: middle; }

#hint {
  position: fixed; z-index: 3; left: calc(50% + 188px); transform: translateX(-50%);
  bottom: 104px;
  background: rgba(29, 34, 30, 0.72); color: #fff;
  font-size: 12px; padding: 6px 12px; border-radius: 999px;
  pointer-events: none; transition: opacity 0.6s;
}
#hint.gone { opacity: 0; }

#loading {
  position: fixed; inset: 0; z-index: 20; display: flex; gap: 12px; align-items: center; justify-content: center;
  background: var(--bg); color: var(--green); font-weight: 600; transition: opacity 0.5s;
}
#loading.done { opacity: 0; pointer-events: none; }
#loading[hidden] { display: none; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #cfd6cb; border-top-color: var(--green); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#lightbox {
  position: fixed; inset: 0; z-index: 30; background: rgba(250, 251, 249, 0.97);
  display: flex; align-items: center; justify-content: center;
}
#lightbox[hidden] { display: none; }
#lightbox img { max-width: calc(100% - 140px); max-height: calc(100% - 60px); box-shadow: var(--shadow); border-radius: 6px; background: #fff; }
.lb-close { position: absolute; top: 14px; right: 18px; border: 0; background: none; font-size: 34px; color: var(--ink); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); border: 0; background: var(--surface-solid); box-shadow: var(--shadow); width: 46px; height: 46px; border-radius: 50%; font-size: 26px; color: var(--green); }
.lb-nav.prev { left: 18px; }
.lb-nav.next { right: 18px; }
.lb-nav[hidden] { display: none; }

/* Tablet */
@media (max-width: 1180px) {
  #dock { left: auto; right: 16px; transform: none; flex-direction: column; max-width: 340px; bottom: 80px; }
  .views { flex-wrap: wrap; }
  #hint { display: none; }
}

/* Phone */
@media (max-width: 760px) {
  #panel {
    top: auto; bottom: 0; left: 0; right: 0; width: auto;
    max-height: 46%;
    border-radius: 18px 18px 0 0;
    padding: 10px 16px 14px;
    transition: max-height 0.25s ease;
  }
  #panel.collapsed { max-height: 132px; overflow: hidden; }
  .sheet-handle { display: block; width: 44px; height: 5px; border: 0; border-radius: 3px; background: #cfd4cc; margin: 0 auto 10px; padding: 0; }
  .brand h1 .caps { font-size: 22px; }
  .brand h1 em { font-size: 28px; }
  #topbar { top: 10px; right: 10px; left: 10px; gap: 6px; }
  .chip { padding: 7px 11px; font-size: 12px; }
  #dock {
    left: 10px; right: 10px; transform: none; max-width: none;
    bottom: calc(46% + 10px); flex-direction: column; gap: 6px;
  }
  body.sheet-collapsed #dock { bottom: 142px; }
  .views { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .views button { padding: 7px 10px; font-size: 12px; }
  .sun { min-width: 0; padding: 6px 12px 7px; }
  #compass { top: 58px; bottom: auto; right: auto; left: 10px; width: 40px; height: 40px; }
  body:not(.sheet-collapsed) #dock { display: none; }
  .brand { cursor: pointer; }
  #compass svg { width: 34px; height: 34px; }
  #lightbox img { max-width: calc(100% - 20px); }
  .lb-nav { top: auto; bottom: 18px; transform: none; }
}
