/* ── Reset & base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --col-sun:     #4caf50;
  --col-shade:   #607d8b;
  --col-unknown: #ff9800;
  --col-night:   #37474f;

  --bg:          #f5f5f5;
  --surface:     #ffffff;
  --text:        #212121;
  --text-muted:  #757575;
  --border:      #e0e0e0;
  --header-bg:   #1a237e;

  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,.10);
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────────────── */
header { background: var(--header-bg); color: #fff; padding: 1.25rem 1.5rem; }
header h1 { font-size: 1.6rem; font-weight: 700; }
header p  { font-size: .9rem; opacity: .8; margin-top: .25rem; }

/* ── Main ────────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Avoid flex-gap whitespace for empty dynamic containers */
#venue-editor:empty,
#record-dialog:empty {
  display: none;
}

/* ── Fallback banner ─────────────────────────────────────────────── */
.fallback-banner {
  background: #fff8e1;
  border: 1px solid #ffc107;
  color: #6d4c00;
  padding: .6rem 1.1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  text-align: center;
}

/* ── Controls ────────────────────────────────────────────────────── */
.controls {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem .8rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

/* ── Time display ────────────────────────────────────────────────── */
#time-display { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; }
.time-label   { font-size: 1.05rem; font-weight: 700; }
.sun-position { font-size: .82rem; color: var(--text-muted); }
.night-text   { color: var(--col-night); }
.weather-summary {
  font-size: .8rem;
  color: var(--header-bg);
  margin-top: .15rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.weather-summary:hover { color: #0d47a1; }
.weather-summary:focus-visible {
  outline: 2px solid var(--header-bg);
  outline-offset: 2px;
  border-radius: 4px;
}
.counts-row,
.map-counts  { display: flex; flex-wrap: wrap; gap: .3rem; }
.count-pill {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
}
.count-pill.sun     { background: var(--col-sun); }
.count-pill.shade   { background: var(--col-shade); }
.count-pill.unknown { background: var(--col-unknown); }
.count-pill.night   { background: var(--col-night); }

/* ── Time row (date + hour scale) ────────────────────────────────── */
.time-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.date-input {
  flex-shrink: 0;
  padding: .45rem .7rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}
.date-input:focus { outline: none; border-color: var(--header-bg); }

/* ── Jump buttons ────────────────────────────────────────────────── */
.jump-btns { display: flex; gap: .35rem; flex-shrink: 0; }
.jump-btn {
  padding: .4rem .75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .12s, color .12s;
}
.jump-btn:hover { border-color: var(--header-bg); color: var(--header-bg); }

/* ── Hour scale ──────────────────────────────────────────────────── */
.hour-scale-wrap {
  flex: 1;
  padding: 24px 0 18px;
}

.hour-scale {
  position: relative;
  height: 18px;
  background: #e8eaf6;
  border-radius: 4px;
  cursor: crosshair;
  overflow: visible;
}

/* day-light gradient overlay */
.hour-scale::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: linear-gradient(
    to right,
    #37474f 0%,        /* midnight */
    #546e7a 8%,        /* 02:00 */
    #90a4ae 17%,       /* 04:00 */
    #ffd54f 25%,       /* 06:00 sunrise */
    #fff9c4 42%,       /* 10:00 */
    #fffde7 50%,       /* 12:00 noon */
    #fff9c4 58%,       /* 14:00 */
    #ffd54f 75%,       /* 18:00 sunset */
    #90a4ae 83%,       /* 20:00 */
    #546e7a 92%,       /* 22:00 */
    #37474f 100%       /* midnight */
  );
  opacity: .4;
}

.hour-tick {
  position: absolute;
  top: 0;
  height: 100%;
  width: 1px;
  background: rgba(0,0,0,.18);
  transform: translateX(-50%);
  pointer-events: none;
}
.tick-label {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  font-size: .62rem;
  color: #9e9e9e;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Hour needles ────────────────────────────────────────────────── */
.hour-needle {
  position: absolute;
  top: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.hour-needle .needle-line {
  width: 2px;
  height: 100%;
}
.hour-needle .needle-label {
  position: absolute;
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Selected needle — label above track */
.sel-needle .needle-line   { background: var(--header-bg); }
.sel-needle .needle-label  {
  bottom: calc(100% + 5px);
  color: var(--header-bg);
}
.sel-needle::before {
  content: '';
  position: absolute;
  top: -6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--header-bg);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* Now needle — label below track */
.now-needle .needle-line  { background: #c62828; }
.now-needle .needle-label {
  top: calc(100% + 5px);
  color: #c62828;
}
.now-needle::after {
  content: '';
  position: absolute;
  bottom: -6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c62828;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* ── Venue type filters ───────────────────────────────────────────── */
.type-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
}
.filter-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: .2rem;
}
.type-toggle { display: contents; }
.type-toggle input { display: none; }

.type-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .65rem .25rem .45rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  border: 2px solid color-mix(in srgb, var(--tc) 40%, transparent);
  background: color-mix(in srgb, var(--tc) 10%, white);
  color: color-mix(in srgb, var(--tc) 80%, black);
  cursor: pointer;
  user-select: none;
  transition: background .12s, border-color .12s, opacity .12s;
}
.type-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tc);
  flex-shrink: 0;
}
.type-toggle input:not(:checked) ~ .type-chip {
  opacity: .45;
  background: transparent;
}
.type-chip:hover { border-color: var(--tc); }

/* ── Status filters (multi-select) ───────────────────────────────── */
.status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}
.status-toggle { display: contents; }
.status-toggle input { display: none; }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .65rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  border: 2px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background .12s, border-color .12s, opacity .12s;
}
.status-chip-sun     { border-color: #f9a825; background: #fff8e1; color: #6d4c00; }
.status-chip-shade   { border-color: #90a4ae; background: #eceff1; color: #37474f; }
.status-chip-unknown { border-color: #ffcc80; background: #fff3e0; color: #bf360c; }
.status-chip-night   { border-color: #b0bec5; background: #f5f5f5; color: #546e7a; }
.status-toggle input:not(:checked) ~ .status-chip {
  opacity: .38;
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.status-chip:hover { filter: brightness(.92); }

/* ── Loading indicator (bar + text) ──────────────────────────────── */
.loading-wrap {
  display: none;
  align-items: center;
  gap: .6rem;
  min-height: 18px;
}
#spinner.htmx-request { display: flex; }
.loading-bar {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--header-bg), transparent);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
.loading-text {
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Map ─────────────────────────────────────────────────────────── */
.map-section { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
/*
 * Make the map wrapper own the height so our absolute-positioned overlays
 * (sun indicator, add-location button) stay anchored even while remote
 * requests / indicators trigger reflow.
 */
.map-wrap    { position: relative; height: 400px; }
#map {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
}

/* Sun direction indicator (top-left, under Leaflet zoom) */
.map-sun {
  position: absolute;
  top: 10px;
  left: 58px; /* place to the right of Leaflet zoom control */
  z-index: 900; /* below our buttons but above map */
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid rgba(0,0,0,.2);
  background: rgba(255,255,255,.92);
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
  position: absolute;
  display: grid;
  place-items: center;
  color: #444;
  overflow: hidden;
  pointer-events: none;
}

.map-weather-icon {
  width: 28px;
  height: 28px;
}

.map-sun-arrow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 0 rgba(230,81,0,.45));
}

/* Map buttons (top-right) */
.map-btns {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.map-btn {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(0,0,0,.2);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
  padding: 0;
  color: #444;
  transition: border-color .12s, background .12s, color .12s;
}
.map-btn svg { width: 17px; height: 17px; }
.map-btn:hover  { border-color: var(--header-bg); color: var(--header-bg); background: #e8eaf6; }
.map-btn.active { background: var(--header-bg); border-color: var(--header-bg); color: #fff; }
.map-btn.loading { border-color: var(--header-bg); color: var(--header-bg); }

/* Add location button (bottom-left, above attribution) */
.map-add-btn {
  position: absolute;
  bottom: 2px;
  left: 2px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .75rem;
  background: var(--header-bg);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  transition: background .12s;
}
.map-add-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.map-add-btn:hover { background: #283593; }
.map-add-btn.active { background: #c62828; }

/* Centred pin for add-location mode */
.map-pin {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  z-index: 1000;
  pointer-events: none;
  display: none;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,.4));
}

/* ── Map markers ─────────────────────────────────────────────────── */
.mwrap {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mdot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  position: relative;
}
.marker-leaf {
  position: absolute;
  right: -8px;
  top: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2e7d32;
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  z-index: 2;
}

/* Per-venue "in sun" badge on map markers */
.marker-sun {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #f9a825;
  font-size: 14px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
  z-index: 2;
  pointer-events: none;
}

/* Per-venue "in shade" badge on map markers */
.marker-shade {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #607d8b;
  font-size: 14px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
  transform: translateX(-1px);
  z-index: 2;
  pointer-events: none;
}

/* Per-venue "no sun" badge on map markers */
.marker-night {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(55,71,79,.95);
  font-size: 15px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
  z-index: 2;
  pointer-events: none;
}
/* Sun: gold thick ring + outer glow halo */
.mwrap-sun .mdot {
  border: 3px solid #f9a825;
  box-shadow: 0 0 0 2px rgba(249,168,37,.35), 0 2px 6px rgba(0,0,0,.3);
}
.mwrap-sun::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 2px solid rgba(253,216,53,.4);
  pointer-events: none;
}
/* Shade: blue-grey border, slightly muted */
.mwrap-shade .mdot {
  border: 2.5px solid rgba(96,125,139,.85);
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
  opacity: 1;
}
/* Unknown: orange dashed border + "?" badge */
.mwrap-unknown .mdot {
  border: 2.5px dashed #ff9800;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  opacity: .9;
}
.mwrap-unknown::after {
  content: '?';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ff9800;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
  pointer-events: none;
}
/* Night/no-sun: dark border, low opacity, "–" badge */
.mwrap-night .mdot {
  border: 2px solid #546e7a;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  opacity: .45;
}
.mwrap-night::after {
  /* Replaced by centered .marker-night element */
  content: none;
}
.legend {
  background: var(--surface);
  padding: .5rem 1rem;
  font-size: .8rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem 1rem;
  color: var(--text-muted);
}
.legend-item { display: inline-flex; align-items: center; gap: .3rem; }
.map-counts {
  align-items: center;
  margin-left: auto;
}
.legend-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.2);
  flex-shrink: 0;
}

/* ── Café grid ───────────────────────────────────────────────────── */
.cafe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.cafe-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  overflow: hidden;
  transition: box-shadow .15s;
  cursor: pointer;
}
.cafe-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.14); }

.venue-stripe { width: 5px; flex-shrink: 0; }

.cafe-body { padding: .8rem .95rem; flex: 1; min-width: 0; }

.cafe-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
}
.cafe-name {
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status indicator — dot + text matching the map legend */
.status-indicator {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .18rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.status-indicator.status-sun     { background: var(--col-sun); }
.status-indicator.status-shade   { background: var(--col-shade); }
.status-indicator.status-unknown { background: var(--col-unknown); }
.status-indicator.status-night   { background: var(--col-night); }

/* The dot inside the status indicator mirrors the map legend dot style */
.legend-marker {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,.7);
  border: 1px solid rgba(255,255,255,.9);
  flex-shrink: 0;
}

.cafe-address {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .28rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-labels,
.popup-labels {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}
.card-labels {
  margin: .45rem 0 .25rem;
}
.popup-labels {
  margin-top: .45rem;
}
.diet-label {
  display: inline-flex;
  align-items: center;
  padding: .13rem .45rem;
  border-radius: 999px;
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  color: #1b5e20;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.25;
}

.cafe-meta { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; align-items: center; }
.meta-chip {
  display: inline-block;
  padding: .13rem .45rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .7rem;
  color: var(--text-muted);
  text-transform: capitalize;
}
.meta-chip.venue-chip {
  background: color-mix(in srgb, var(--vc) 12%, white);
  border-color: color-mix(in srgb, var(--vc) 35%, transparent);
  color: color-mix(in srgb, var(--vc) 80%, black);
  font-weight: 600;
}
.meta-chip.orientation { color: #1a237e; border-color: #9fa8da; background: #e8eaf6; }
.meta-chip.no-orient   { color: #e65100; border-color: #ffcc80; background: #fff3e0; }
.meta-chip.distance-chip { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ── User-set tag (inside orientation chip) ──────────────────────── */
.user-set-tag {
  display: inline-block;
  padding: .05rem .3rem;
  background: #1a237e;
  color: #fff;
  border-radius: 4px;
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  vertical-align: middle;
  margin-left: .15rem;
}

/* ── Inline venue editor ─────────────────────────────────────────── */
#venue-editor:empty { display: none; }
#venue-editor:not(:empty) {
  animation: slideDown .18s ease-out;
}
.venue-form-portlet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Venue editor header (title + close button) */
.ve-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .75rem;
}
.ve-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: .9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.ve-close:hover { background: #ffebee; color: #c62828; border-color: #ef9a9a; }

/* Loading skeleton inside venue editor */
.ve-loading {
  display: flex;
  justify-content: center;
  padding: 1.5rem 0;
}

/* Pin position display in add-venue form */
.pin-pos-display {
  font-size: .82rem;
  color: var(--text-muted);
  background: #e8eaf6;
  border-radius: 6px;
  padding: .4rem .75rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .3rem;
}
.pin-pos-icon { font-size: .95rem; }
.pin-pos-hint { color: var(--text-muted); font-size: .75rem; }

/* ── Edit icon button (card) ─────────────────────────────────────── */
.edit-icon-btn {
  padding: .1rem .4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--header-bg);
  font-size: .88rem;
  line-height: 1.4;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, border-color .12s;
  flex-shrink: 0;
}
.edit-icon-btn:hover { background: #e8eaf6; border-color: #9fa8da; }

/* No-orient chip — clickable */
.meta-chip.no-orient { cursor: pointer; transition: background .12s, border-color .12s; }
.meta-chip.no-orient:hover { background: #fce4d0; border-color: #ff8a65; }

/* ── Edit button inside map popup ────────────────────────────────── */
.popup-edit-btn {
  margin-top: .4rem;
  display: block;
  width: 100%;
  padding: .3rem .6rem;
  border: 1px solid #9fa8da;
  border-radius: 6px;
  background: #e8eaf6;
  color: var(--header-bg);
  font-size: .78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: background .12s;
}
.popup-edit-btn:hover { background: #c5cae9; }
.popup-actions {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin-top: .4rem;
}
.popup-details-btn,
.popup-edit-btn.icon-only {
  border: 1px solid #9fa8da;
  border-radius: 6px;
  background: #e8eaf6;
  color: var(--header-bg);
  font-size: .78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s;
}
.popup-details-btn {
  flex: 1;
  padding: .3rem .6rem;
}
.popup-edit-btn.icon-only {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
}
.popup-details-btn:hover,
.popup-edit-btn.icon-only:hover {
  background: #c5cae9;
}

.popup-edit-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
}
.popup-edit-icon-btn:hover {
  border-color: var(--header-bg);
  background: #e8eaf6;
}

/* ── Loading / empty ─────────────────────────────────────────────── */
.loading-placeholder {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.loader {
  width: 36px; height: 36px;
  border: 4px solid var(--border);
  border-top-color: var(--header-bg);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto .75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }

/* ── Data note ───────────────────────────────────────────────────── */
.data-note {
  font-size: .76rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: .4rem;
  padding: 0 1rem;
}

/* ── Footer ──────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1rem;
  font-size: .78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
footer a { color: var(--header-bg); }

/* ── Orientation edit dialog ─────────────────────────────────────── */
#orient-dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
  padding: 0;
  max-width: 420px;
  width: calc(100% - 2rem);
}
#orient-dialog::backdrop {
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
}

#orient-form-container { padding: 1.5rem; }

.of-header { margin-bottom: 1rem; }
.of-title  { font-size: 1.1rem; font-weight: 700; }
.of-sub    { font-size: .82rem; color: var(--text-muted); margin-top: .2rem; }

.of-osm-info {
  font-size: .8rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .4rem .7rem;
  margin-bottom: 1rem;
}
.of-osm-info strong { color: var(--text); }

/* ── Compass rose ────────────────────────────────────────────────── */
.compass-rose {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .35rem;
  margin-bottom: 1rem;
}
.compass-btn {
  padding: .5rem 0;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: .85rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
  text-align: center;
}
.compass-btn:hover { border-color: var(--header-bg); color: var(--header-bg); background: #e8eaf6; }
.compass-btn.near-active { border-color: #9fa8da; color: var(--header-bg); background: #e8eaf6; }
.compass-btn.active { border-color: var(--header-bg); background: var(--header-bg); color: #fff; }

.compass-center {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 56px;
  height: 56px;
  justify-self: center;
  align-self: center;
  border: 2px solid var(--border);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 0 34%, transparent 35%),
    conic-gradient(from -22.5deg, #e8eaf6 0 45deg, var(--surface) 45deg 90deg, #e8eaf6 90deg 135deg, var(--surface) 135deg 180deg, #e8eaf6 180deg 225deg, var(--surface) 225deg 270deg, #e8eaf6 270deg 315deg, var(--surface) 315deg 360deg);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.compass-center:active {
  cursor: grabbing;
}
.compass-center:focus {
  outline: none;
  border-color: var(--header-bg);
  box-shadow: 0 0 0 3px rgba(63,81,181,.14);
}
.compass-needle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 22px;
  background: var(--header-bg);
  border-radius: 999px 999px 3px 3px;
  transform: translate(-50%, -100%) rotate(var(--needle-deg, 0deg));
  transform-origin: 50% 100%;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  pointer-events: none;
}
.compass-needle::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 8px solid var(--header-bg);
}
.compass-hub {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--header-bg);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  pointer-events: none;
}

/* ── Form text input and select ─────────────────────────────────── */
.of-text-input,
.of-select {
  width: 100%;
  padding: .5rem .75rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .12s;
}
.of-text-input:focus,
.of-select:focus {
  outline: none;
  border-color: var(--header-bg);
}
.of-select { cursor: pointer; }

/* ── Orientation form inputs ─────────────────────────────────────── */
.of-input-row {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1.1rem;
}
.of-input-row label {
  font-size: .8rem;
  color: var(--text-muted);
}
.of-input-row input[type="number"] {
  width: 100%;
  padding: .5rem .75rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .12s;
}
.of-input-row input[type="number"]:focus {
  outline: none;
  border-color: var(--header-bg);
}
.of-radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  font-size: .86rem;
}
.of-radio-row label {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  color: var(--text);
  cursor: pointer;
}

/* ── Orientation form action buttons ─────────────────────────────── */
.of-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.of-btn {
  flex: 1;
  padding: .55rem .75rem;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.of-btn.save   { background: var(--header-bg); color: #fff; }
.of-btn.save:hover { background: #283593; }
.of-btn.reset  { background: var(--bg); color: var(--text); border-color: var(--border); }
.of-btn.reset:hover { border-color: var(--header-bg); color: var(--header-bg); }
.of-btn.cancel { background: var(--bg); color: var(--text-muted); border-color: var(--border); }
.of-btn.cancel:hover { color: var(--text); border-color: var(--text-muted); }

/* ── Save success message ────────────────────────────────────────── */
.save-msg {
  padding: 1rem 1.5rem;
  font-size: .95rem;
  color: #1b5e20;
  background: #e8f5e9;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  animation: saveMsgFade 1s ease-out forwards;
}
@keyframes saveMsgFade {
  0%   { opacity: 1; }
  60%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── OSM force-refresh button (footer) ──────────────────────────── */
.footer-actions { margin-top: .5rem; }
.osm-refresh-btn {
  padding: .25rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.osm-refresh-btn:hover { border-color: var(--header-bg); color: var(--header-bg); }
.osm-refresh-btn.loading { border-color: var(--header-bg); color: var(--header-bg); }
.osm-refresh-btn.loading .refresh-icon {
  display: inline-block;
  animation: spin .8s linear infinite;
}

/* ── Bulk update toggle (footer) ─────────────────────────────────── */
.footer-toggle {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-left: .5rem;
  padding: .22rem .55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.footer-toggle:hover {
  border-color: var(--header-bg);
  color: var(--header-bg);
}
.footer-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
}
.bulk-save-status {
  color: var(--text-muted);
  font-weight: 600;
}

/* ── SQLite footer notice ────────────────────────────────────────── */
.sqlite-notice {
  margin-top: .4rem;
  font-size: .75rem;
  color: #1565c0;
}
.sqlite-notice code {
  background: #e3f2fd;
  border: 1px solid #90caf9;
  border-radius: 3px;
  padding: .05rem .3rem;
  font-size: .78em;
}

/* ── Card-list loading fade ─────────────────────────────────────── */
#cafe-section.cafes-loading { opacity: 0.45; transition: opacity .15s ease; pointer-events: none; }

/* ── Map loading indicator (top-right, third map button) ─────────── */
.map-loading-indicator {
  position: relative;
  width: 36px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 5px rgba(0,0,0,.2);
}
.map-loading-indicator[hidden] {
  display: none;
}
.map-loading-indicator .loader {
  width: 18px;
  height: 18px;
}
.mli-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  background: var(--header-bg);
  color: #fff;
  border-radius: 8px;
  font-size: .6rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  display: none;
}

/* ── Edit form: location details section ────────────────────────── */
.of-details-bar {
  margin: .6rem 0 0;
}
.of-details-toggle {
  background: none;
  border: none;
  color: var(--accent, #1565c0);
  font-size: .82rem;
  font-family: inherit;
  cursor: pointer;
  padding: .2rem 0;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.of-details-toggle:hover { text-decoration: underline; }
.of-details-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .8rem;
  margin-top: .4rem;
  background: var(--bg, #f8f8f8);
}
.of-btn.reposition {
  font-size: .78rem;
  padding: .22rem .6rem;
  margin-left: .3rem;
}
.of-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .8rem;
  margin: .25rem 0 .5rem;
  font-size: .78rem;
  color: var(--text-muted);
}
.of-link-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--header-bg);
  padding: .12rem .55rem;
  font-size: .75rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.of-link-btn:hover {
  border-color: var(--header-bg);
  background: #e8eaf6;
}
.record-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0,0,0,.45);
}
.record-modal {
  position: fixed;
  z-index: 3001;
  top: 5vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(860px, calc(100vw - 2rem));
  max-height: 90vh;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 36px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.record-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}
.record-modal-header h3 {
  font-size: 1rem;
}
.record-modal-header p {
  margin-top: .2rem;
  color: var(--text-muted);
  font-size: .78rem;
}
.record-table-wrap {
  overflow: auto;
  max-height: calc(90vh - 150px);
}
.record-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}
.record-table th,
.record-table td {
  padding: .45rem .65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.record-table th {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
.record-compare-table {
  min-width: max-content;
}
.record-compare-table th,
.record-compare-table td {
  min-width: 220px;
  max-width: 360px;
  overflow-wrap: anywhere;
}
.record-compare-table .record-label-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 170px;
  max-width: 220px;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}
.record-compare-table thead .record-label-col {
  z-index: 3;
  background: var(--bg);
}
.record-compare-table th small {
  display: block;
  margin-top: .18rem;
  color: var(--text-muted);
  font-size: .68rem;
  font-weight: 500;
  line-height: 1.25;
}
.record-scroll-actions {
  display: flex;
  justify-content: flex-end;
  gap: .35rem;
  padding: .45rem .75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.record-scroll-btn {
  width: 30px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--header-bg);
  cursor: pointer;
  font-weight: 700;
}
.record-scroll-btn:hover {
  border-color: var(--header-bg);
  background: #e8eaf6;
}
.record-table code {
  font-size: .78rem;
}
.record-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  header h1 { font-size: 1.3rem; }
  .time-row { flex-direction: column; align-items: stretch; }
  .hour-scale-wrap { padding-top: 28px; }
  .map-wrap { height: 280px; }
  .map-add-btn { font-size: .73rem; padding: .32rem .6rem; }
  .cafe-grid { grid-template-columns: 1fr; }
  #orient-dialog { max-width: 100%; width: calc(100% - 1rem); }
  .record-modal { top: 1rem; max-height: calc(100vh - 2rem); }
}
