:root {
  --border-radius-lg: 0px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #f5f4f0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

#wrap {
  width: 100vw; height: 100vh;
  background: #f5f4f0;
  position: relative; overflow: hidden;
  border-radius: var(--border-radius-lg);
  font-family: var(--font-sans);
}
#canvas { position: absolute; inset: 0; cursor: grab; touch-action: none; }
#canvas.drag { cursor: grabbing; }
#inner { position: absolute; top: 0; left: 0; }

.t {
  position: absolute; background: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px;
  cursor: default; overflow: hidden;
}
/* Smooth snapping once placed; instant while actively panning. */
#wrap.ready .t { transition: transform 0.2s cubic-bezier(0.34,1.1,0.64,1), opacity 0.15s; }
#wrap.dragging .t { transition: opacity 0.15s; }
/* Don't let a drag-pan select text under the cursor (e.g. the centre panel). */
#wrap.dragging, #wrap.dragging * { user-select: none; -webkit-user-select: none; }
.t.sel { cursor: pointer; }
.t i { font-size: 18px; z-index: 1; position: relative; pointer-events: none; }
.t span { font-size: 9px; color: #555; z-index: 1; position: relative;
  max-width: 86%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  text-align: center; pointer-events: none; }
.t.dim { opacity: 0.09; pointer-events: none; }
.t.active-tile { outline: 2px solid #7F77DD; outline-offset: -2px; z-index: 2; }

#gridsvg {
  position: absolute; top: 0; left: 0;
  pointer-events: none; overflow: visible; z-index: 1;
}

#cw {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  z-index: 10; pointer-events: none;
}
#cb {
  background: #fff;
  pointer-events: all; display: flex; flex-direction: column; overflow: hidden;
  border: 4px solid #000; border-radius: 10px;
}
/* Scrollable interior: the centre square is small, so let content scroll within
   it rather than being clipped. The title bar (#ctop) stays fixed above this. */
#cbody { flex: 1; min-height: 0; display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden; }
#ctop {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px 6px; border-bottom: 1px solid #e8e8e8; flex-shrink: 0;
}
#ctitle { font-size: 10px; font-weight: 500; color: #888; letter-spacing: 0.06em; }
#cbtns { display: flex; gap: 4px; }
#cbtns button {
  background: none; border: 1px solid #ccc; border-radius: 6px;
  padding: 2px 7px; font-size: 10px; color: #555; cursor: pointer;
  display: flex; align-items: center; gap: 3px; font-family: inherit;
}
#cbtns button:hover { background: #f0f0f0; }

#flist { padding: 9px; display: flex; flex-direction: column; gap: 4px; flex: 1 0 auto; justify-content: center; }
.fb {
  background: #f5f4f0; border: 1px solid #ddd; border-radius: 9px;
  padding: 6px 9px; font-size: 11px; font-weight: 500; color: #222;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  font-family: inherit; transition: background 0.1s;
}
.fb:hover { background: #eae9e4; }
.fb.on { background: #EEEDFE; color: #3C3489; border-color: #AFA9EC; }
.fb i { font-size: 13px; }
.fc { margin-left: auto; font-size: 9px; color: #aaa; font-weight: 400; }

#av { display: none; flex: 1 0 auto; flex-direction: column; align-items: center; justify-content: center; padding: 10px; gap: 7px; }
#av.on { display: flex; }

/* Generic Big-renderer layouts (placeholder.js). Bespoke renderers may use
   their own markup inside #av / #fcnt instead. */
.big-center {
  display: flex; flex-direction: column; flex: 1; width: 100%;
  align-items: center; justify-content: center; gap: 7px; min-height: 0;
}
.big-center .preview {
  width: 100%; flex: 1; border-radius: 10px; background: #f5f4f0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #e0e0e0; min-height: 0;
}
.big-center .name { font-size: 12px; font-weight: 500; color: #111; text-align: center; }
.big-center .meta { font-size: 10px; color: #999; text-align: center; }

.big-full { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; }
.big-full i { font-size: 48px; }
.big-full .name { font-size: 14px; font-weight: 500; color: #111; }
.big-full .meta { font-size: 11px; color: #aaa; }

/* photos ------------------------------------------------------------------ */
.photo-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-big { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; gap: 6px; }
.photo-frame { position: relative; flex: 1; min-height: 0; width: 100%;
  display: flex; align-items: center; justify-content: center; }
.photo-contain { max-width: 100%; max-height: 100%; object-fit: contain; }
.photo-cap { flex-shrink: 0; text-align: center; }
.photo-cap .name { font-size: 12px; font-weight: 500; color: #111; }
.photo-cap .meta { font-size: 10px; color: #999; }

/* "(i)" info overlay + EXIF panel */
.photo-info-btn {
  position: absolute; top: 7px; right: 7px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  border: none; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 20, 22, 0.55); color: #fff;
  backdrop-filter: blur(3px); transition: background 0.12s;
}
.photo-info-btn:hover { background: rgba(20, 20, 22, 0.78); }
.photo-info-btn.on { background: #185FA5; }
.photo-info-btn i { font-size: 15px; }
.photo-exif {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: flex-end; justify-content: stretch;
  background: rgba(20, 20, 22, 0.32);
}
.photo-exif-list {
  width: 100%; margin: 0; padding: 28px 12px 10px;
  background: linear-gradient(to top, rgba(15, 15, 18, 0.9) 60%, rgba(15, 15, 18, 0));
  color: #f3f3f3; display: flex; flex-direction: column; gap: 2px;
}
.photo-exif-row { display: flex; justify-content: space-between; gap: 10px;
  font-size: 10px; line-height: 1.5; }
.photo-exif-row dt { color: #9aa0a6; flex-shrink: 0; }
.photo-exif-row dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* hills — elevation profile, topo map, write-up ---------------------------- */

/* thumbnail: the elevation profile fills the square, name underneath */
.hill-thumb { display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; gap: 2px; padding: 4px; min-height: 0; }
.hill-thumb-plot { position: relative; flex: 1; width: 100%; min-height: 0; }
.hill-thumb-plot .hill-profile { width: 100%; height: 100%; }
.hill-grade { position: absolute; top: 3px; left: 4px; pointer-events: none;
  font-size: 9px; font-weight: 600; color: #15795a; font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,0.78); border-radius: 4px; padding: 0 3px; line-height: 1.4; }
.hill-thumb span { font-size: 9px; color: #555; max-width: 86%; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; text-align: center; }

/* centre / fullscreen view. The shell establishes a query container so the
   inner .hill-view can be promoted to two columns (maps left, write-up right)
   only when the panel is wide enough — in the small centre square it stays
   stacked and readable. */
.hill-shell { width: 100%; height: 100%; min-height: 0; display: flex; container-type: inline-size; }
.hill-view { display: flex; flex-direction: column; gap: 8px;
  width: 100%; height: 100%; min-height: 0; padding: 6px; }
.hill-maps { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; min-width: 0; }
.hill-map { flex: 3 1 0; min-height: 110px; width: 100%; border-radius: 8px;
  overflow: hidden; background: #e8e6e0; z-index: 0; }
.leaflet-container { font-family: var(--font-sans); background: #e8e6e0; }
/* The attribution credit dominates the small centre square, so hide it there
   and only show it once the panel is roomy (maximized / large grid units). */
.leaflet-control-attribution { display: none; font-size: 9px; }

@container (min-width: 560px) {
  .hill-view.two-col { flex-direction: row; }
  .hill-view.two-col .hill-maps { flex: 1.4 1 0; }
  .hill-view.two-col .hill-writeup { flex: 1 1 0; height: 100%; }
  .hill-map .leaflet-control-attribution { display: block; }
}

/* elevation profile */
.hill-profile { position: relative; flex: 1 1 0; min-height: 56px; width: 100%;
  background: #faf9f6; border: 1px solid #e6e4de; border-radius: 8px; overflow: hidden; }
.hill-prof-svg { display: block; width: 100%; height: 100%; }
.hill-prof-area { fill: rgba(29, 158, 117, 0.14); stroke: none; }
.hill-prof-line { fill: none; stroke: #1D9E75; stroke-width: 2; stroke-linejoin: round; }
.hill-prof-cursor { position: absolute; top: 0; bottom: 0; width: 1px;
  background: rgba(40, 40, 44, 0.55); transform: translateX(-0.5px); pointer-events: none; }
.hill-prof-dot { position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: #185FA5; border: 2px solid #fff; box-shadow: 0 0 2px rgba(0,0,0,.4);
  transform: translate(-50%, -50%); pointer-events: none; }
.hill-prof-readout { position: absolute; top: 5px; left: 7px; pointer-events: none;
  font-size: 10px; font-weight: 500; color: #2a2a2c; background: rgba(255,255,255,0.82);
  border-radius: 5px; padding: 1px 6px; font-variant-numeric: tabular-nums; }

/* write-up (markdown) */
.hill-writeup { overflow-y: auto; min-height: 0; padding: 4px 10px 4px 4px;
  font-size: 13px; line-height: 1.5; color: #222; }
.hill-writeup h1, .hill-writeup h2, .hill-writeup h3 { line-height: 1.25; margin: 0.6em 0 0.3em; color: #111; }
.hill-writeup h1 { font-size: 18px; }
.hill-writeup h2 { font-size: 15px; }
.hill-writeup h3 { font-size: 13px; }
.hill-writeup p { margin: 0 0 0.7em; }
.hill-writeup ul, .hill-writeup ol { margin: 0 0 0.7em 1.1em; }
.hill-writeup a { color: #185FA5; }
.hill-writeup img { max-width: 100%; border-radius: 6px; }
.hill-writeup code { background: #f0efea; border-radius: 4px; padding: 0 4px; font-size: 0.9em; }

/* notes — staff notation + audio ------------------------------------------ */
.staff { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.staff svg { display: block; }

.notes-thumb {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; gap: 2px; padding: 4px; min-height: 0;
}
.notes-thumb .staff { flex: 1; min-height: 0; }
.notes-thumb span {
  font-size: 9px; color: #555; max-width: 86%; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; text-align: center;
}

.notes-big { display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; min-height: 0; gap: 10px; padding: 8px; }
.notes-staff { width: 100%; flex: 0 1 auto; max-height: 55%; min-height: 0;
  display: flex; align-items: center; justify-content: center; }
.notes-staff .staff { max-width: 100%; }
.notes-big.max .notes-staff { max-height: 45%; }
.notes-cap { text-align: center; }
.notes-cap .name { font-size: 12px; font-weight: 500; color: #111; }
.notes-cap .meta { font-size: 10px; color: #999; }

.player {
  display: flex; align-items: center; gap: 8px;
  width: 100%; max-width: 280px;
  background: #f5f4f0; border: 1px solid #e0e0e0; border-radius: 11px;
  padding: 6px 10px;
}
.player-btn {
  background: #fff; border: 1px solid #ccc; border-radius: 50%;
  width: 28px; height: 28px; flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: #D85A30;
}
.player-btn:hover { background: #f0f0f0; }
.player-btn i { font-size: 15px; }
.player-seek { flex: 1; min-width: 0; accent-color: #D85A30; }
.player-time { font-size: 9px; color: #999; flex-shrink: 0; font-variant-numeric: tabular-nums; }

#fo { display: none; position: absolute; inset: 0; background: #fff;
  z-index: 20; border-radius: var(--border-radius-lg); flex-direction: column; }
#fo.on { display: flex; }
#fbar { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid #e0e0e0; flex-shrink: 0; }
#fbar span { font-size: 11px; font-weight: 500; color: #666; }
#fbar button { background: none; border: 1px solid #ccc; border-radius: 7px;
  padding: 3px 9px; font-size: 11px; color: #555; cursor: pointer;
  display: flex; align-items: center; gap: 3px; font-family: inherit; }
#fcnt { flex: 1; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px; padding: 20px; }

