* { box-sizing: border-box; }

body {
  font-family: system-ui, sans-serif;
  margin: 0;
  padding: 1rem;
  background: #f5f5f5;
  color: #222;
}

#resolve-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#url-input {
  flex: 1;
  min-width: 260px;
  padding: 0.5rem;
}

#map-type-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: #555;
  white-space: nowrap;
}

#map-type-select {
  padding: 0.4rem;
}

button {
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* A CSS-only spinner: a ring with one side coloured, spun forever. Sized in em so it rides
   the surrounding text (a button label or the render-status line). */
.spinner {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#error-box {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #ffe0e0;
  border: 1px solid #cc0000;
  color: #900;
}

section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #ddd;
}

section h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.action-bar {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

#zoom-label,
#show-name-label,
#show-boundary-pin-label,
#branding-label,
#realistic-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: #555;
}

/* A template that types its labels hides this toggle (and roadmap hides the
   realistic one); `display` above would otherwise override `hidden`. */
#show-name-label[hidden],
#branding-form[hidden],
#realistic-label[hidden] {
  display: none;
}

#branding-form {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 0.45rem 0.55rem;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  background: #fff;
  font-size: 0.9rem;
  color: #555;
}

#branding-logo-input {
  max-width: 13rem;
}

#branding-company-input,
#branding-whatsapp-input {
  width: 11rem;
  margin-left: 0.25rem;
  padding: 0.35rem;
}

.hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: #666;
}

#video-status {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #555;
}

#boundary-video,
#hotspot-video {
  display: block;
  margin-top: 0.75rem;
  width: min(450px, 80vw);
  aspect-ratio: 9 / 16;
  background: #000;
}

#hotspot-video-status {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #555;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Roads now live INSIDE the hotspot sidebar, so they inherit its fieldset/legend/label
   rules wholesale and need almost nothing of their own. The two groups STACK — the sidebar
   is a ~220px column, and the old side-by-side pair does not fit in it. */
/* Roads sit at the BOTTOM of the sidebar, under the hotspot categories — so the rule that
   separates them from the list above, not below. */
.road-group {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 2px solid #ddd;
}

/* The sidebar capitalises its legends (for "bus_station"), which would turn "NH / bypass"
   into "Nh / Bypass". Roads are already correctly cased, so opt out. */
#sidebar .road-group legend {
  text-transform: none;
}

/* At MAX_ROADS the unticked boxes go disabled; say why rather than just deadening them. */
#roads-cap {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #a15c00;
}

.muted {
  color: #777;
  font-weight: 400;
}

#roads-attribution {
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

/* City nearby: one status line plus its controls, matching the roads section. */
#city-section {
  margin-top: 1rem;
}

#city-section h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

#city-status {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: #333;
}

#city-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

#city-radius-label[hidden] {
  display: none;
}

#city-map-mode {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  border: 0;
  padding: 0;
  margin: 0;
}

#city-map-mode[hidden] {
  display: none;
}

#city-map-mode legend {
  padding: 0;
  margin-right: 0.1rem;
}

#city-radius-input {
  width: 4.5rem;
  margin-left: 0.25rem;
}

#city-query-input {
  width: 14rem;
  margin-left: 0.25rem;
}

#top-n-label,
#sqft-label {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

/* `hidden` must win over the inline-block above when the template wants no sqft. */
#sqft-label[hidden] {
  display: none;
}

#content {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.map-col {
  width: min(450px, 80vw);
}

#section-boundary .map-wrap {
  width: min(450px, 80vw);
}

.map-wrap {
  position: relative;
  width: 100%;
  /* Matches the logo-cropped map content (720x1152); the video itself stays 9:16. */
  aspect-ratio: 5 / 8;
  background: #ddd;
}

.map-wrap img,
.map-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#radius-control,
#boundary-zoom-control,
#custom-hotspot-control {
  margin-top: 0.5rem;
}

#radius-control label,
#boundary-zoom-control label,
#custom-hotspot-control label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

#radius-control input[type="range"],
#boundary-zoom-control input[type="range"] {
  width: 100%;
}

/* Track the boundary map's own width rather than the whole page. */
#boundary-zoom-control {
  width: min(450px, 80vw);
}

#boundary-zoom-control .hint {
  margin: 0.25rem 0 0;
}

.inline-search {
  display: flex;
  gap: 0.4rem;
}

.inline-search input {
  min-width: 0;
  flex: 1;
  padding: 0.45rem;
}

#custom-hotspot-status {
  margin: 0.3rem 0 0;
}

#sidebar {
  flex: 1;
  min-width: 220px;
  max-height: min(800px, 80vh);
  overflow-y: auto;
  background: #fff;
  border: 1px solid #ddd;
  padding: 0.5rem 0.75rem;
}

#sidebar fieldset {
  margin-bottom: 0.5rem;
  border: 1px solid #ddd;
}

#sidebar legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  text-transform: capitalize;
}

#sidebar label {
  display: block;
  font-size: 0.9rem;
  padding: 0.15rem 0;
}

/* One hotspot row: [checkbox] Name — 320 m. The name sits OUTSIDE the label so the
   double-click rename input never toggles the checkbox (see buildSidebar). */
.hotspot-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  padding: 0.15rem 0;
}

.hotspot-row label {
  display: inline-flex;
  padding: 0;
}

.hotspot-name {
  cursor: text;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hotspot-dist {
  color: #555;
  white-space: nowrap;
}

.hotspot-name-input {
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
}

.swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
}

/* --- Background music --- */
#music-section {
  margin-top: 1rem;
}

#music-section h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

#music-select-label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

#music-preview {
  padding: 0.6rem 0.7rem;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  background: #fff;
  max-width: 640px;
}

#music-preview[hidden] {
  display: none;
}

#music-player {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

#music-play-btn {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border-radius: 50%;
  font-size: 0.9rem;
  line-height: 1;
}

#music-wave-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
}

#music-wave {
  display: block;
  width: 100%;
  height: 100%;
  background: #f2f3f5;
  border-radius: 4px;
}

/* The seek bar sits transparently over the waveform. */
#music-seek {
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  margin: 0;
  cursor: pointer;
}

#music-time {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

#music-volume-label {
  display: block;
  font-size: 0.9rem;
  margin: 0.6rem 0 0.35rem;
}

#music-volume {
  width: 100%;
}

#music-volume-value {
  color: #777;
}

/* --- Voiceover / narration --- */
#narration-section {
  margin-top: 1rem;
}

#narration-section h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

#narration-beats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 640px;
}

.vo-beat {
  padding: 0.55rem 0.65rem;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  background: #fff;
}

.vo-beat-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.vo-hint {
  font-size: 0.85rem;
}

.vo-beat-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.vo-record.recording {
  color: #fff;
  background: #c0392b;
}

.vo-upload {
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  border: 1px solid #c9c9c9;
  border-radius: 4px;
}

.vo-status {
  font-size: 0.85rem;
}

.vo-hold-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #555;
}

.vo-hold {
  width: 3.5rem;
}

.vo-preview {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.vo-preview[hidden] {
  display: none;
}

.vo-play {
  flex: none;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  line-height: 1;
}

.vo-seek {
  flex: 1 1 auto;
  min-width: 0;
}

.vo-time {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

