*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --border:    #30363d;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --accent:    #38bdf8;
  --accent-dim:#0ea5e9;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

#test-banner {
  background: #fbbf24;
  color: #1a1300;
  font-weight: 700;
  text-align: center;
  padding: 10px 16px;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

@media (max-width: 600px) {
  #test-banner {
    font-size: 0.75rem;
    padding: 8px 10px;
  }
}

nav {
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

nav .site-name { font-weight: 700; color: var(--accent); font-size: 1rem; }
nav .site-name a { color: var(--accent); }

nav .siblings { display: flex; gap: 20px; }
nav .siblings a { color: var(--muted); }
nav .siblings a:hover { color: var(--text); text-decoration: none; }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

body.map-page main {
  max-width: none;
  margin: 0;
  padding: 0;
}

h1 {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  margin-bottom: 12px;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin: 32px 0 12px;
}

p { color: var(--muted); max-width: 580px; margin-bottom: 16px; }
p:last-child { margin-bottom: 0; }

blockquote {
  border-left: 2px solid var(--border);
  padding-left: 16px;
  margin: 0 0 16px;
  color: var(--muted);
  font-style: italic;
}

footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  font-size: 0.8rem;
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

footer a { color: var(--border); }
footer a:hover { color: var(--muted); text-decoration: none; }

body.map-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

body.map-page #test-banner,
body.map-page nav,
body.map-page footer {
  flex: 0 0 auto;
}

body.map-page main {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
}

#mode-toggle {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}

.mode-button {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.mode-button.active {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

#map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--muted);
}

.map-control-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 6px;
}

.map-control-item:last-child {
  margin-bottom: 0;
}

@media (max-width: 600px) {
  #map-controls {
    font-size: 0.7rem;
    padding: 8px 10px;
  }
}

#map-message {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 1200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#map-message.visible {
  opacity: 1;
}

.leaflet-tooltip.address-label {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #333;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 2px #fff, 0 0 2px #fff;
  pointer-events: none;
  white-space: nowrap;
}

.leaflet-tooltip.address-label::before {
  display: none;
}

#map.hide-address-labels .leaflet-tooltip.address-label {
  display: none;
}

#legend {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-event { background: #f87171; }
.legend-quality { background: #38bdf8; }

@media (max-width: 600px) {
  #legend {
    font-size: 0.7rem;
    padding: 8px 10px;
  }

  .mode-button {
    padding: 8px 10px;
    font-size: 0.75rem;
  }
}

#report-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.2s ease-out, visibility 0.2s;
  z-index: 1100;
  overflow-y: auto;
  padding: 16px;
}

#report-panel.open {
  transform: translateX(0);
  visibility: visible;
}

#report-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

#report-panel-location {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 700;
}

#report-panel-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

#report-form label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 12px 0 4px;
}

#report-form select,
#report-form textarea,
#report-form input[type="file"] {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-size: 0.85rem;
  font-family: inherit;
}

#report-form textarea {
  min-height: 80px;
  resize: vertical;
}

#report-form button[type="submit"] {
  margin-top: 16px;
  width: 100%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

#report-form button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.field-photo-note {
  display: none;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 12px 0 0;
  max-width: none;
}

#report-panel-error {
  color: #f87171;
  font-size: 0.8rem;
  margin-top: 12px;
  min-height: 1em;
}

@media (max-width: 600px) {
  #report-panel {
    top: auto;
    left: 0;
    right: 0;
    width: auto;
    max-height: 80vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
  }

  #report-panel.open {
    transform: translateY(0);
  }
}

#timeline {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--muted);
  width: 220px;
}

#timeline-label {
  display: block;
  margin-bottom: 6px;
}

#timeline-slider {
  width: 100%;
}

#detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.2s ease-out, visibility 0.2s;
  z-index: 1100;
  overflow-y: auto;
  padding: 16px;
}

#detail-panel.open {
  transform: translateX(0);
  visibility: visible;
}

#detail-panel-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  float: right;
}

#detail-content h3 {
  color: var(--accent);
  margin-bottom: 8px;
}

#detail-content .detail-timestamp {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

#detail-content .detail-location {
  font-style: italic;
  margin-bottom: 8px;
}

#detail-content .detail-text {
  margin-top: 8px;
}

#detail-content .detail-photo {
  width: 100%;
  border-radius: 6px;
  margin-top: 12px;
}

@media (max-width: 600px) {
  #timeline {
    width: auto;
    left: 12px;
    right: 12px;
  }

  #detail-panel {
    top: auto;
    left: 0;
    right: 0;
    width: auto;
    max-height: 80vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
  }

  #detail-panel.open {
    transform: translateY(0);
  }
}
