:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --text: #1d1b18;
  --muted: #6b665d;
  --line: #e2ddd3;
  --accent: #b5452b;
  --accent-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --panel: #1f1d1a;
    --text: #ece8e1;
    --muted: #a39d92;
    --line: #34312c;
    --accent: #e0714f;
    --accent-text: #151412;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: grid;
  grid-template-columns: 1fr 380px;
  height: 100vh;
}

#stage { position: relative; min-height: 0; background: #000; }
#pano { position: absolute; inset: 0; }
/* Обрис обʼєкта поверх панорами (#79). */
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 900; }
.hl-shape {
  fill: rgba(255, 179, 71, .18); stroke: #ffb347; stroke-width: 3; stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(255, 179, 71, .9));
}
.hl-shape.far { stroke-dasharray: 10 7; }
.hl-ring { fill: none; stroke: #ffb347; stroke-width: 3; filter: drop-shadow(0 0 6px rgba(255, 179, 71, .9)); }
.hl-dot { fill: #ffb347; }
.hl-label {
  fill: #fff; font: 600 18px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-anchor: middle; paint-order: stroke; stroke: rgba(0, 0, 0, .65); stroke-width: 4px;
}

#stage-note {
  position: absolute; right: 16px; top: 16px; max-width: 60%;
  background: rgba(0, 0, 0, .65); color: #fff; padding: 8px 12px; border-radius: 8px;
  z-index: 1000; /* над картою Leaflet (її шари — до 700) */
}

/* Фото обʼєкта (#75): у куті панорами; велике — на старті, якщо обʼєкт звідси погано видно, або після кліку. */
#photo {
  position: absolute; left: 16px; bottom: 16px; z-index: 1000; margin: 0;
  width: min(45%, 510px); background: #000; border-radius: 10px; overflow: hidden;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45); cursor: zoom-in;
  transition: width .6s ease, left .6s ease, bottom .6s ease, transform .6s ease;
}
#photo.big {
  left: 50%; bottom: 50%; transform: translate(-50%, 50%);
  width: min(70%, 900px); cursor: zoom-out;
}
#photo img { display: block; width: 100%; max-height: 60vh; object-fit: cover; }
#photo figcaption {
  font-size: 11px; line-height: 1.3; color: #ddd; padding: 5px 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#photo figcaption a { color: inherit; }
#panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
header h1 { margin: 0; font-size: 22px; }
.sub, .hint, #card-meta, #route-summary { color: var(--muted); margin: 4px 0 0; }
.hint { font-size: 13px; }

section { display: flex; flex-direction: column; gap: 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
/* Перемикач режиму (#76). */
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { flex: 1; flex-direction: row; justify-content: center; align-items: center; gap: 0; padding: 8px 6px;
  color: var(--text); font-size: 14px; cursor: pointer; }
.seg label + label { border-left: 1px solid var(--line); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -4px; }

button, select, input {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
input { flex: 1; min-width: 0; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }

#card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
#card h2 { margin: 0; font-size: 18px; }
#card-photo { width: 100%; max-height: 180px; object-fit: cover; border-radius: 6px; }
#card-text { white-space: pre-wrap; font-size: 14px; }
summary { cursor: pointer; color: var(--muted); font-size: 13px; }

#map-slot { height: 260px; flex: none; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
#map { width: 100%; height: 100%; }
/* Без ключа Google карта займає головну частину екрана. */
#stage #map { position: absolute; inset: 0; }

#log { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--muted); max-height: 200px; overflow-y: auto; }

.walker {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3);
}

@media (max-width: 760px) {
  #photo { width: 45%; left: 8px; bottom: 8px; }
  #photo.big { width: 92%; }
  body { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  #stage { height: 55vh; }
  #panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
}
