:root {
  --ink: #16181d; --muted: #6b7079; --line: #e7e8eb; --fill: #f2f3f5; --card: #fff;
  --a: #e8912d; --b: #3b82f6;
  --shadow: 0 1px 2px rgba(16,18,24,.06), 0 6px 24px rgba(16,18,24,.08);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e9eaec; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.app { display: grid; grid-template-columns: minmax(300px, 34%) 1fr; height: 100%; }

/* ---------------------------------------------------------------- places */
.places { display: grid; grid-template-rows: 1fr 1fr; min-height: 0; border-right: 1px solid var(--line); }
.place { display: flex; flex-direction: column; min-height: 0; }
.place + .place { border-top: 1px solid var(--line); }
.place-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--card);
  flex-wrap: wrap;
}
.place-head { position: relative; }
.search {
  flex: 1; min-width: 120px; border: 0; background: var(--fill); border-radius: 8px; padding: 6px 9px;
}
.stats { width: 100%; font-size: 11.5px; color: var(--muted); min-height: 1.45em; }
.stats b { color: var(--ink); font-weight: 600; }
.badge {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  color: #fff; font-weight: 700; font-size: 12px; flex: none;
}
.badge.a { background: var(--a); }
.badge.b { background: var(--b); }

.map { position: relative; flex: 1; min-height: 0; }
.frame {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2;
  pointer-events: none; border: 2px solid var(--a); border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(255,255,255,.28);
}
.frame.b { border-color: var(--b); }
.frame::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: currentColor; }
.frame.a::after { color: var(--a); } .frame.b::after { color: var(--b); }
.spinner {
  position: absolute; right: 10px; top: 10px; z-index: 3; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.15); border-top-color: var(--ink); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- viewer */
.viewer { position: relative; min-width: 0; min-height: 0; }
#scene { display: block; width: 100%; height: 100%; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
/* Summit labels: small and see-through, so they mark summits without hiding them. */
.label {
  position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.88); padding: 2px 8px 2px 3px; border-radius: 999px; box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.label i { font-style: normal; width: 15px; height: 15px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 9.5px; }
.label.a i { background: var(--a); } .label.b i { background: var(--b); }
.label small { font-size: 10px; font-weight: 500; color: var(--muted); }

.card { position: absolute; z-index: 5; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); }
.controls { top: 12px; left: 12px; width: 300px; padding: 11px 12px; max-height: calc(100% - 24px); overflow-y: auto; }
.card-head { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 0; text-align: left; }
.card-head .title { font-size: 15px; font-weight: 600; }
.card-head .chev { margin-left: auto; color: var(--muted); transition: transform .15s; }
.collapsed .chev { transform: rotate(-90deg); }
.collapsed .card-body { display: none; }
.card-body { margin-top: 8px; }
.intro { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 12px; cursor: pointer; }
.check-row input { accent-color: var(--ink); margin: 0; }

.row { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; }
.row > span:first-child { flex: 0 0 52px; color: var(--muted); }
.row input[type=range] { flex: 1; }
.row output { flex: 0 0 58px; text-align: right; font-weight: 600; }
.row.buttons { margin-top: 6px; gap: 6px; }
.row.buttons button {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 4px 9px; font-size: 11.5px;
}
.row.buttons button:hover { background: var(--fill); }
.row.buttons button[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
input[type=range] { accent-color: var(--ink); }

.segmented { display: flex; flex: 1; background: var(--fill); border-radius: 8px; padding: 2px; gap: 2px; }
.segmented button {
  flex: 1 1 auto; white-space: nowrap; border: 0; background: transparent; border-radius: 6px;
  padding: 4px 6px; font-size: 12px; color: var(--muted);
}
.segmented button.active { background: var(--card); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.segmented.small { flex: 0 0 auto; }
.segmented.small button { padding: 3px 7px; font-size: 11.5px; }

.looks { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 7px; }
.look { display: flex; align-items: center; gap: 8px; }
.look input[type=range] { flex: 1; min-width: 40px; }
.eye { border: 0; background: none; font-size: 15px; width: 26px; color: var(--ink); }
.eye[aria-pressed=false] { color: #c3c7cd; }

.pairs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; font-size: 11.5px; align-items: center; }
.pairs > span { color: var(--muted); margin-right: 2px; }
.pairs button { border: 0; background: var(--fill); border-radius: 999px; padding: 3px 9px; font-size: 11.5px; }
.pairs button:hover { background: #e4e6ea; }
.fine { margin: 10px 0 0; font-size: 10.5px; color: var(--muted); }
.fine a { color: inherit; }

.view-buttons { position: absolute; right: 12px; bottom: 12px; z-index: 5; display: flex; gap: 6px; }
.view-buttons button {
  display: inline-flex; align-items: center; gap: 6px; box-shadow: var(--shadow);
  border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 4px 10px; font-size: 11.5px;
}
.view-buttons button:hover { background: var(--fill); }
.view-buttons button[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
#rotate .pause, #rotate[aria-pressed=true] .play { display: none; }
#rotate[aria-pressed=true] .pause { display: inline; }
.status {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 6;
  background: rgba(22,24,29,.86); color: #fff; font-size: 12px; padding: 5px 11px; border-radius: 999px;
  opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap;
}
.status.show { opacity: 1; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* profile */
.toggle { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 3px 9px; font-size: 11.5px; }
.toggle[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.profile { left: 12px; right: 12px; bottom: 12px; height: 188px; padding: 8px 10px 6px; display: flex; flex-direction: column; }
.profile-head { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.profile-head .legend { display: flex; gap: 12px; white-space: nowrap; overflow: hidden; }
.profile-head .legend span { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.profile-head .legend i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.profile-head .legend em { font-style: normal; font-weight: 500; color: #b45309; }
.profile-head .legend .hint { font-weight: 400; color: var(--muted); }
.profile-head .readout { flex: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.icon { border: 0; background: none; color: var(--muted); border-radius: 6px; display: grid; place-items: center; }
.icon.close { width: 28px; height: 28px; flex: none; margin: -4px -6px -4px 0; }
.icon:hover { background: var(--fill); color: var(--ink); }
.profile-head .scale { border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 1px 7px; font-size: 11px; font-weight: 600; color: var(--muted); }
.profile-head .scale[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
#profileChart { flex: 1; width: 100%; min-height: 0; display: block; margin-top: 4px; cursor: crosshair; }
.viewer.with-profile .view-buttons { bottom: 212px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 55% 45%; }
  .viewer { grid-row: 1; }
  .places { grid-row: 2; grid-template-rows: 1fr; grid-template-columns: 1fr 1fr; border-right: 0; border-top: 1px solid var(--line); }
  .place + .place { border-top: 0; border-left: 1px solid var(--line); }
  .place-head { padding: 6px; gap: 5px; }
  .search { min-width: 0; padding: 5px 7px; font-size: 12px; }
  .stats { font-size: 10.5px; }
  .controls { left: 8px; right: 8px; top: 8px; width: auto; max-height: calc(100% - 16px); }
  .profile { left: 8px; right: 8px; bottom: 8px; height: 150px; }
  .viewer.with-profile .view-buttons { bottom: 166px; }
}

/* mountain suggestions */
.suggest {
  position: absolute; z-index: 30; left: 40px; right: 10px; top: 42px; margin: 0; padding: 4px;
  list-style: none; background: var(--card); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 260px; overflow-y: auto; overscroll-behavior: contain;
}
.suggest li { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.suggest li b { font-weight: 600; font-size: 13px; }
.suggest li span { grid-row: 2; font-size: 11px; color: var(--muted); }
.suggest li em { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-style: normal; font-size: 12px; color: var(--muted); }
.suggest li[aria-selected=true], .suggest li:hover { background: var(--fill); }
.suggest li.none { display: block; color: var(--muted); font-size: 12px; cursor: default; }
@media (max-width: 820px) { .suggest { left: 6px; right: 6px; top: 36px; } }

/* Full screen: the 3D view takes the whole window; the maps are hidden, not
   unloaded, and come back as they were. */
body.focus .app { grid-template-columns: 1fr; grid-template-rows: 1fr; }
body.focus .places { display: none; }
