:root {
  color-scheme: light;
  --ink: #20252b;
  --muted: #69727d;
  --line: #d9e0e7;
  --panel: #ffffff;
  --surface: #f5f7f4;
  --accent: #0f766e;
  --accent-strong: #0b5d57;
  --alert: #b45309;
  --shadow: 0 18px 45px rgba(31, 41, 55, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  min-height: 100vh;
}

.map-stage {
  position: relative;
  min-height: 100vh;
  background: #dbe7e4;
}

.map-view {
  width: 100%;
  height: 100%;
  min-height: inherit;
  background: #dbe7e4;
}

.map-locate-button {
  position: absolute;
  right: 18px;
  bottom: 28px;
  z-index: 700;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 8px 22px rgba(31, 41, 55, 0.18);
  font-size: 20px;
  font-weight: 800;
}

.map-locate-button:hover {
  border-color: #9bd4c7;
  color: var(--accent-strong);
}

/* Leaflet's CDN CSS can be blocked or slow on some networks. These layout
   rules keep tiles positioned correctly even if the external stylesheet fails. */
.leaflet-container {
  overflow: hidden;
  background: #dbe7e4;
  outline-offset: 1px;
  touch-action: none;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container img,
.leaflet-container svg {
  max-width: none;
  max-height: none;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
  user-select: none;
}

.leaflet-tile-container {
  pointer-events: none;
}

.leaflet-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-marker-icon,
.leaflet-marker-shadow {
  display: block;
}

.leaflet-marker-icon {
  z-index: 600;
}

.leaflet-container .leaflet-overlay-pane svg {
  max-width: none;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control-zoom,
.leaflet-control-layers {
  margin: 12px;
}

.leaflet-control-zoom a {
  display: block;
  width: 30px;
  height: 30px;
  color: #20252b;
  background: #fff;
  border-bottom: 1px solid #d9e0e7;
  line-height: 30px;
  text-align: center;
  text-decoration: none;
}

.control-panel {
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-height: 100vh;
  overflow: auto;
  padding: 22px;
  background: rgba(255, 255, 255, 0.96);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel-header,
.spots-header,
.button-row,
.status-card,
.spot-item {
  display: flex;
  align-items: center;
}

.panel-header,
.spots-header,
.status-card {
  justify-content: space-between;
  gap: 14px;
}

.eyebrow,
.label,
.spot-meta {
  color: var(--muted);
  font-size: 12px;
}

.eyebrow {
  margin: 0 0 2px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 17px;
}

.badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f8faf9;
  font-size: 13px;
  font-weight: 700;
}

.badge.is-live {
  color: #064e3b;
  border-color: #9bd4c7;
  background: #dff8ef;
}

.status-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.status-card div {
  min-width: 0;
}

.status-card strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.button-row {
  gap: 10px;
}

.bgm-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.bgm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.small-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bgm-panel label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bgm-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bgm-panel input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.debug-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px dashed #9bd4c7;
  border-radius: 8px;
  color: var(--accent-strong);
  background: #f0fbf7;
  font-size: 14px;
  font-weight: 700;
}

.debug-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.primary-button,
.secondary-button,
.icon-button,
.text-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
}

.primary-button {
  flex: 1;
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  flex: 1;
  color: var(--accent-strong);
  border-color: #9bd4c7;
  background: #e8f6f1;
}

.icon-button {
  width: 44px;
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.text-button {
  min-height: 34px;
  padding: 0 4px;
  color: var(--accent-strong);
  background: transparent;
}

.spot-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.spot-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spot-form span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.spot-form input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.spots-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.spots-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spot-item {
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.spot-item.is-active {
  border-color: #f1c27d;
  background: #fff7ed;
}

.spot-main {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.spot-title {
  max-width: 100%;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spot-play {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid #f1c27d;
  border-radius: 50%;
  color: var(--alert);
  background: #fff7ed;
}

.leaflet-popup-content {
  margin: 10px 12px;
}

.user-dot {
  position: relative;
  z-index: 1;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.18);
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(48vh, 1fr) auto;
  }

  .map-stage {
    min-height: 52vh;
  }

  .control-panel {
    max-height: none;
    border-top: 1px solid var(--line);
    border-left: 0;
    box-shadow: 0 -12px 32px rgba(31, 41, 55, 0.12);
  }
}
