* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: #17212b;
  background: #f3f5f7;
  font-family: system-ui, sans-serif;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  padding: 10px 15px;
  color: #fff;
  background: #1768a5;
  font-weight: 650;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #105687;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  color: #253443;
  background: #e8edf1;
}

button.secondary:hover:not(:disabled) {
  background: #dce5eb;
}

.page {
  width: min(100% - 32px, 1120px);
  margin: 0 auto;
  padding: 24px 0 42px;
}

.page-header {
  margin-bottom: 18px;
}

.back-link {
  color: #1768a5;
  font-size: 0.94rem;
}

h1 {
  margin: 12px 0 6px;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.page-header p,
.selection-heading p {
  margin: 0;
  color: #546372;
  line-height: 1.55;
}

.panel {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #d5dce2;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 12px rgb(22 39 55 / 7%);
}

.toolbar,
.zoom-controls,
.timeline-actions,
.download-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar label {
  font-weight: 650;
}

select {
  min-height: 40px;
  border: 1px solid #c8d0d7;
  border-radius: 7px;
  padding: 6px 30px 6px 10px;
  color: #17212b;
  background: #fff;
}

.zoom-controls {
  margin-left: auto;
}

.zoom-controls button {
  min-width: 40px;
  padding: 6px 12px;
  color: #253443;
  background: #e8edf1;
  font-size: 1.3rem;
}

.event-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
  border: 1px solid #d5dce2;
  border-radius: 8px;
  padding: 8px 10px;
}

.event-filters legend {
  padding: 0 5px;
  font-weight: 650;
}

.event-filters label {
  font-size: 0.9rem;
  font-weight: 600;
}

.event-filters input {
  width: 76px;
  min-height: 36px;
  border: 1px solid #c8d0d7;
  border-radius: 7px;
  padding: 5px 7px;
  color: #17212b;
}

#eventFilterStatus {
  flex-basis: 100%;
  color: #536373;
  font-size: 0.85rem;
}

#eventFilterStatus.error {
  color: #a82626;
}

.status {
  min-height: 1.4em;
  margin: 10px 0;
  color: #536373;
  font-size: 0.92rem;
}

.status.error,
#downloadStatus.error {
  color: #a82626;
}

.map-frame {
  overflow: hidden;
  border: 1px solid #b8c5d0;
  border-radius: 8px;
  background: #17355b;
}

#map {
  display: block;
  width: 100%;
  height: clamp(350px, 60vw, 620px);
  touch-action: none;
  cursor: grab;
}

#map:active {
  cursor: grabbing;
}

.map-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 9px 2px 12px;
  color: #4a5967;
  font-size: 0.88rem;
}

.legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 13px;
  border-radius: 8px;
  color: #fff;
  background: rgb(16 28 43 / 91%);
}

.depth-legend {
  width: min(100%, 430px);
}

.depth-legend > span,
.magnitude-legend > span:first-child {
  display: block;
  margin-bottom: 7px;
  font-size: 0.82rem;
  font-weight: 650;
}

.depth-scale {
  height: 12px;
  border: 1px solid rgb(255 255 255 / 55%);
  background: linear-gradient(90deg, #ed1717 0%, #ff7b12 16%, #ffe500 34%, #b8ed00 50%, #05a83d 65%, #08b8ad 79%, #167de6 90%, #19279d 100%);
}

.depth-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-size: 0.73rem;
}

.magnitude-legend {
  display: flex;
  align-items: center;
  gap: 11px;
  white-space: nowrap;
}

.magnitude-legend > span:first-child {
  margin: 0;
}

.magnitude-legend > span:not(:first-child) {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
}

.epicenter-symbol {
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
}

.timeline {
  margin-top: 14px;
}

.timeline-actions label {
  margin-left: auto;
  font-size: 0.9rem;
}

.timeline input {
  width: 100%;
  margin: 12px 0 2px;
  accent-color: #1768a5;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  color: #647381;
  font-size: 0.78rem;
}

.selection-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.selection-heading h2 {
  margin: 0 0 5px;
  font-size: 1.15rem;
}

.selected-count {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 10px;
  color: #145a8d;
  background: #e7f2fa;
  font-size: 0.84rem;
  font-weight: 650;
}

.selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.selection-hint {
  margin: 0 0 10px;
  color: #536373;
  font-size: 0.84rem;
}

.event-list {
  display: grid;
  gap: 7px;
  max-height: 430px;
  overflow-y: auto;
}

.event-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border: 1px solid #e0e5e9;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
}

.event-row:hover {
  background: #f7fafc;
}

.event-row input {
  margin-top: 3px;
  accent-color: #1768a5;
}

.event-info {
  min-width: 0;
}

.event-title {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  align-items: baseline;
  font-weight: 650;
}

.event-title time {
  color: #536373;
  font-size: 0.84rem;
  font-weight: 500;
}

.event-details {
  margin-top: 4px;
  color: #526170;
  font-size: 0.86rem;
  line-height: 1.5;
}

.empty-list {
  margin: 4px 0;
  color: #536373;
}

.download-row {
  margin-top: 14px;
  flex-wrap: wrap;
}

#downloadStatus {
  color: #536373;
  font-size: 0.88rem;
}

footer {
  color: #596875;
  font-size: 0.84rem;
}

footer p {
  margin: 6px 0;
}

footer a {
  color: #1768a5;
}

@media (max-width: 700px) {
  .page {
    width: min(100% - 20px, 1120px);
    padding-top: 16px;
  }

  .panel {
    padding: 12px;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .zoom-controls {
    margin-left: auto;
  }

  .legend {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .depth-legend {
    width: 100%;
  }

  .magnitude-legend {
    flex-wrap: wrap;
  }
}

@media (max-width: 420px) {
  .map-meta {
    flex-direction: column;
    gap: 3px;
  }

  .timeline-actions {
    flex-wrap: wrap;
  }

  .timeline-actions label {
    margin-left: 0;
  }
}

body {
  color: #222;
  background: #fff;
  font-family: sans-serif;
}

button,
select {
  font: inherit;
}

button {
  border: revert;
  border-radius: revert;
  padding: revert;
  color: revert;
  background: revert;
  font-weight: revert;
}

button:hover:not(:disabled) {
  background: revert;
}

button:disabled {
  opacity: 0.6;
}

button.secondary,
button.secondary:hover:not(:disabled) {
  color: revert;
  background: revert;
}

.page {
  width: min(100% - 24px, 680px);
  padding: 8px 0 32px;
}

.page-header {
  margin-bottom: 0;
}

.page-header .site-name {
  margin: 0 0 53px;
}

#siteName a {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 4px;
  background: #f3f3f3;
  box-shadow: 2px 3px 7px rgb(0 0 0 / 24%), -1px -1px 2px #fff;
  color: #555;
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow 0.18s ease, transform 0.18s ease, background-color 0.18s ease;
}

#siteName a:hover {
  transform: translateY(-2px);
  background: #fafafa;
  box-shadow: 3px 6px 12px rgb(0 0 0 / 28%), -1px -1px 2px #fff;
}

#siteName a:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 3px rgb(0 0 0 / 20%);
}

#siteName a:focus-visible {
  outline: 2px solid #4b83bd;
  outline-offset: 3px;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.sub {
  margin: 0 0 16px;
  color: #444;
  line-height: 1.5;
}

.panel {
  margin-bottom: 20px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.toolbar {
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar label {
  font-weight: 400;
}

select {
  min-height: revert;
  border: revert;
  border-radius: revert;
  padding: revert;
  color: revert;
  background: revert;
}

.zoom-controls {
  gap: 8px;
}

.zoom-controls button {
  min-width: 32px;
  padding: 2px 8px;
  color: revert;
  background: revert;
  font-size: 1rem;
}

.status {
  min-height: 1.3em;
  margin: 10px 0 8px;
  color: #555;
  font-size: 0.9em;
}

.map-frame {
  border: 1px solid #bbb;
  border-radius: 0;
}

#map {
  height: clamp(320px, 54vw, 430px);
}

.map-meta {
  margin: 6px 0 10px;
  color: #444;
  font-size: 0.88em;
}

.legend {
  align-items: flex-start;
  gap: 16px;
  padding: 8px 0;
  border-radius: 0;
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  color: #222;
  background: transparent;
}

.depth-legend > span,
.magnitude-legend > span:first-child {
  margin-bottom: 5px;
  font-size: 0.9em;
  font-weight: 400;
}

.depth-scale {
  height: 11px;
  border-color: #555;
}

.depth-ticks {
  font-size: 0.75em;
}

.magnitude-legend {
  flex-wrap: wrap;
  gap: 6px 10px;
}

.magnitude-legend > span:not(:first-child) {
  font-size: 0.82em;
}

.legend-circle {
  border-color: #555;
}

.timeline {
  margin-top: 12px;
}

.timeline-actions {
  gap: 8px;
}

.timeline-actions label {
  font-size: 0.9em;
}

.timeline input {
  margin: 8px 0 2px;
  accent-color: #555;
}

.timeline-labels {
  color: #555;
  font-size: 0.8em;
}

.selection-panel {
  padding-top: 12px;
  border-top: 1px solid #ccc;
}

.selection-heading {
  margin-bottom: 10px;
}

.selection-heading h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.selection-heading p {
  color: #444;
  font-size: 0.9em;
}

.selected-count {
  padding: 0;
  color: #444;
  background: transparent;
  font-size: 0.85em;
  font-weight: 400;
}

.event-list {
  gap: 0;
  max-height: 360px;
  border-top: 1px solid #ddd;
}

.event-row {
  border: 0;
  border-bottom: 1px solid #ddd;
  border-radius: 0;
  padding: 9px 4px;
}

.event-row:hover {
  background: #f7f7f7;
}

.event-row input {
  accent-color: #555;
}

.event-details {
  color: #555;
  font-size: 0.85em;
}

.empty-list {
  color: #555;
}

.download-row {
  margin-top: 12px;
}

#downloadStatus {
  color: #555;
  font-size: 0.85em;
}

.video-progress-track {
  height: 8px;
  margin-top: 12px;
  background: #ddd;
}

.video-progress-bar {
  width: 0%;
  height: 100%;
  background: #555;
  transition: width 0.3s;
}

footer {
  padding-top: 8px;
  border-top: 1px solid #ccc;
  color: #555;
}

footer a {
  color: #06c;
}

@media (max-width: 540px) {
  .page {
    width: min(100% - 24px, 680px);
    padding-top: 8px;
  }

  .legend {
    flex-direction: column;
  }

  .magnitude-legend {
    justify-content: flex-start;
  }
}
