* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
}

#map {
  position: absolute;
  inset: 0;
  height: 100dvh;
  width: 100%;
}

#landing, #error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  height: 100dvh;
  text-align: center;
  padding: 1.5em;
  background: #fff;
}

#info-panel {
  position: absolute;
  top: max(0.75em, env(safe-area-inset-top));
  left: 0.75em;
  right: 0.75em;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  padding: 0.75em 1em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-size: 0.9rem;
  line-height: 1.5;
}

#info-summary {
  white-space: pre-line;
}

#fault-toggle {
  margin-top: 0.5em;
  padding: 0.6em 1em;
  font-size: 0.95rem;
  min-height: 44px;
  border: 1px solid #999;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

#fault-toggle[aria-pressed="true"] {
  background: #333;
  color: #fff;
}

#legend {
  position: absolute;
  right: 0.75em;
  bottom: calc(0.75em + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  padding: 0.5em 0.75em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-size: 0.85rem;
  max-width: 55vw;
}

#legend summary {
  cursor: pointer;
  padding: 0.4em 0.2em;
  min-height: 44px;
  display: flex;
  align-items: center;
}

#legend-list {
  list-style: none;
  margin: 0.4em 0 0;
  padding: 0;
}

#legend-list li {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.15em 0;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 0.5px solid #333;
  flex: none;
}

#site-footer {
  position: absolute;
  left: 0.75em;
  bottom: calc(0.75em + env(safe-area-inset-bottom));
  max-width: 40vw;
  font-size: 0.7rem;
  line-height: 1.4;
  color: #333;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  padding: 0.4em 0.6em;
}

#site-footer p {
  margin: 0.1em 0;
}

@media (max-width: 480px) {
  #legend {
    max-width: 60vw;
  }
  #site-footer {
    max-width: 92vw;
    right: 0.75em;
    left: 0.75em;
    bottom: 0.5em;
  }
  #legend {
    bottom: auto;
    top: max(7.5em, calc(env(safe-area-inset-top) + 7em));
  }
}
