:root {
  --red: #b5121b;
  --red-bright: #dc1f2a;
  --orange: #ed6a2c;
  --blue: #143b61;
  --blue-soft: #2e6d9b;
  --ink: #17212b;
  --gray-900: #303941;
  --gray-600: #68737d;
  --gray-300: #cdd4da;
  --gray-100: #eef1f3;
  --paper: #ffffff;
  --shadow: 0 16px 40px rgba(20, 59, 97, .14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, rgba(181,18,27,.035), transparent 25%, rgba(20,59,97,.05)), var(--gray-100);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
}
button, select { font: inherit; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 3000; padding: .7rem 1rem; background: var(--paper); color: var(--blue); }
.skip-link:focus { top: 1rem; }

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 2rem;
  min-height: 112px; padding: 1rem clamp(1rem,4vw,4rem); color: #fff;
  background: linear-gradient(100deg, rgba(8,32,53,.98), rgba(20,59,97,.94)); border-bottom: 6px solid var(--red);
}
.brand { display: flex; align-items: center; gap: 1.3rem; }
.brand img {
  width: 132px;
  height: 82px;
  object-fit: contain;
  transform: scale(1.22);
  transform-origin: center;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .18));
}
.eyebrow { margin: 0 0 .25rem; font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-family: "Barlow Condensed", "Avenir Next Condensed", "Arial Narrow", sans-serif; line-height: 1.05; }
h1 { font-size: clamp(2.2rem,5vw,4.1rem); letter-spacing: -.015em; }
.header-tools { display: grid; justify-items: end; gap: .65rem; }
.header-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; }
.header-button { min-height: 34px; padding: .45rem .72rem; color: #fff; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.28); border-radius: 999px; cursor: pointer; font-size: .74rem; font-weight: 750; }
.header-button:hover, .header-button:focus-visible { background: rgba(255,255,255,.18); }
.header-button[aria-pressed="true"] { color: #082035; background: #d9f4e2; border-color: #77d99b; }
.live-status { display: flex; align-items: center; gap: .7rem; max-width: 340px; padding: .7rem 1rem; border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.09); border-radius: 999px; font-size: .82rem; }
.pulse { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: #77d99b; box-shadow: 0 0 0 5px rgba(119,217,155,.14); }
.alert-toast { position: fixed; z-index: 3000; right: 1rem; bottom: 1rem; width: min(430px,calc(100vw - 2rem)); padding: 1rem 1.1rem; color: #17212b; background: #fff8e8; border: 1px solid #e6c878; border-left: 6px solid var(--red); border-radius: 5px; box-shadow: 0 16px 40px rgba(0,0,0,.22); line-height: 1.45; }
.alert-toast[hidden] { display: none; }
.alert-toast strong { display: block; color: var(--red); }

main { width: min(1680px,100%); margin: 0 auto; }
.notice { display: flex; gap: .75rem; padding: .85rem clamp(1rem,4vw,4rem); color: #53272a; background: #fff5f5; border-bottom: 1px solid #efd4d6; font-size: .88rem; }
.toolbar { display: flex; align-items: end; gap: 1rem; padding: 1rem clamp(1rem,4vw,4rem); background: var(--paper); border-bottom: 1px solid var(--gray-300); }
.toolbar label { display: grid; gap: .35rem; }
.toolbar label span { color: var(--gray-600); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
select, .secondary-button { min-height: 42px; padding: .55rem .8rem; color: var(--ink); background: var(--paper); border: 1px solid var(--gray-300); border-radius: 4px; }
.secondary-button { cursor: pointer; font-weight: 700; }
.layer-button.active { color: #422f00; border-color: #d6a21e; background: #ffd66b; }
#plates-toggle.active { color: #fff; border-color: #6559c7; background: #6559c7; }
.viewer-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.secondary-button:hover, .secondary-button:focus-visible { border-color: var(--blue); color: var(--blue); }

.map-workspace { display: grid; grid-template-columns: minmax(0,1fr) 360px; min-height: 680px; background: var(--paper); box-shadow: var(--shadow); }
.map-shell { position: relative; min-width: 0; }
#map { width: 100%; height: 100%; min-height: 680px; background: #dce5eb; }
.loading-card { position: absolute; z-index: 20; top: 50%; left: 50%; transform: translate(-50%,-50%); display: flex; align-items: center; gap: .8rem; padding: 1rem 1.2rem; background: var(--paper); box-shadow: var(--shadow); border-radius: 4px; font-weight: 700; }
.loading-card[hidden] { display: none; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--gray-300); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.event-focus { padding: 1.4rem; overflow-y: auto; color: #0d1d36; background: #f9fbfd; border-left: 1px solid var(--gray-300); }
.event-focus.selection-highlight { animation: focus-selection 1.4s ease-out; }
@keyframes focus-selection {
  0% { background: #fff0f1; box-shadow: inset 7px 0 var(--red), inset 0 0 0 2px rgba(181,18,27,.35); }
  45% { background: #fff8f8; box-shadow: inset 5px 0 var(--red), inset 0 0 0 1px rgba(181,18,27,.18); }
  100% { background: #f9fbfd; box-shadow: inset 0 0 transparent; }
}
.focus-kicker { margin: 0 0 .35rem; color: var(--gray-600); font-size: .82rem; font-weight: 700; }
.focus-magnitude-line { display: flex; align-items: baseline; gap: .65rem; color: var(--red); }
.focus-magnitude-line strong { font: 800 4.3rem/.9 "Barlow Condensed", "Arial Narrow", sans-serif; }
.focus-magnitude-line span { color: var(--gray-600); font-size: .9rem; }
.event-focus h2 { margin: .75rem 0 1.1rem; font-size: 1.55rem; }
.focus-data { margin: 0; }
.focus-data > div { padding: .7rem 0; border-top: 1px solid #d7e0e8; }
.focus-data dt { color: var(--gray-600); font-size: .76rem; }
.focus-data dd { margin: .18rem 0 0; font-weight: 750; }
.quality-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: .5rem; margin: .8rem 0; }
.quality-grid div { padding: .6rem; background: var(--paper); border: 1px solid #d7e0e8; border-radius: 4px; text-align: center; }
.quality-grid span { display: block; color: var(--gray-600); font-size: .65rem; text-transform: uppercase; }
.quality-grid strong { display: block; margin-top: .15rem; color: var(--blue); }
.arrival-panel { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #d7e0e8; }
.arrival-panel h3 { font-size: 1.15rem; }
.arrival-panel > p { margin: .25rem 0 .65rem; color: var(--gray-600); font-size: .73rem; }
.arrival-list { display: grid; gap: .38rem; }
.arrival-row { display: flex; justify-content: space-between; gap: .75rem; font-size: .82rem; }
.arrival-row span { color: var(--gray-600); }
.intensity-panel { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #d7e0e8; }
.intensity-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.intensity-heading h3 { font-size: 1.15rem; }
.intensity-heading > span { padding: .15rem .38rem; color: #fff; background: var(--red); border-radius: 3px; font-size: .65rem; font-weight: 800; letter-spacing: .08em; }
.intensity-panel > p { margin: .3rem 0 .7rem; color: var(--gray-600); font-size: .7rem; line-height: 1.35; }
.intensity-list { display: grid; gap: .3rem; }
.intensity-row { display: grid; grid-template-columns: minmax(90px,1fr) 34px minmax(72px,.8fr); align-items: center; gap: .45rem; font-size: .76rem; }
.intensity-row > span:first-child { color: var(--gray-600); }
.intensity-row strong { font-size: .72rem; }
.mmi-badge { display: inline-grid; place-items: center; min-width: 30px; min-height: 25px; padding: .15rem; color: #10202d; border: 1px solid rgba(0,0,0,.22); border-radius: 3px; font-weight: 850; }
.mmi-1, .mmi-2 { background: #d9f3ff; }.mmi-3 { background: #9de1f4; }.mmi-4 { background: #7fd286; }
.mmi-5 { background: #e7db54; }.mmi-6 { background: #f0a23e; }.mmi-7 { color: #fff; background: #df5a36; }
.mmi-8 { color: #fff; background: #bd2531; }.mmi-9, .mmi-10 { color: #fff; background: #721325; }
.intensity-empty { padding: .65rem; color: var(--gray-600); background: rgba(104,115,125,.08); border-radius: 4px; font-size: .74rem; }
.focus-id { margin: 1rem 0 0; color: var(--gray-600); font-size: .68rem; word-break: break-all; }

.map-legend { display: grid; grid-template-columns: 1fr 1fr .9fr minmax(280px,1.3fr); gap: 2rem; align-items: center; padding: 1.4rem clamp(1rem,4vw,4rem); background: var(--paper); border-top: 1px solid var(--gray-300); }
.map-legend h2 { margin-bottom: .75rem; color: var(--blue); font-size: 1.1rem; }
.map-legend > p { margin: 0; color: var(--gray-600); line-height: 1.5; }
.magnitude-scale, .depth-scale { display: flex; align-items: end; gap: 1rem; min-height: 48px; }
.magnitude-scale span, .depth-scale span { display: flex; align-items: center; gap: .35rem; color: var(--gray-600); font-size: .74rem; white-space: nowrap; }
.magnitude-scale i { width: var(--size); height: var(--size); display: inline-block; border-radius: 50%; background: var(--red); border: 1px solid #fff; box-shadow: 0 0 0 1px var(--red); }
.depth-scale { align-items: center; }
.depth-scale i { width: 12px; height: 12px; display: inline-block; border-radius: 50%; }
.shallow { background: var(--red-bright); }.medium { background: var(--blue-soft); }.deep { background: var(--blue); }
.fault-scale { display: grid; gap: .45rem; min-height: 48px; align-content: center; }.fault-scale span { display: flex; align-items: center; gap: .5rem; color: var(--gray-600); font-size: .74rem; white-space: nowrap; }.fault-scale i { display: inline-block; width: 30px; height: 0; border-top: 3px dashed #e1a91e; }.fault-scale .fault-subduction { border-top-style: solid; border-top-color: #f06b3e; }.fault-scale .plate-boundary { border-top-style: solid; border-top-color: #6559c7; }

.statistics { display: grid; grid-template-columns: repeat(4,1fr); border-top: 1px solid var(--gray-300); border-bottom: 1px solid var(--gray-300); background: #f4f7fa; }
.statistics article { padding: 1.5rem clamp(1rem,3vw,2.2rem); border-right: 1px solid var(--gray-300); }
.statistics article:last-child { border-right: 0; }
.statistics span, .statistics small { display: block; color: var(--gray-600); }
.statistics strong { display: block; margin: .2rem 0; color: var(--red); font: 800 3.2rem/1 "Barlow Condensed", "Arial Narrow", sans-serif; }

.activity-section, .catalog-section { margin-top: 1.5rem; background: var(--paper); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; padding: 1.5rem clamp(1rem,3vw,2rem); border-bottom: 1px solid var(--gray-300); }
.section-heading h2 { color: var(--blue); font-size: 2rem; }
.section-heading > p { max-width: 550px; margin: 0; color: var(--gray-600); line-height: 1.5; }
.chart-scroll { overflow-x: auto; padding: .5rem 1rem 1rem; }
#event-chart { width: 100%; min-width: 760px; height: 280px; display: block; }
.chart-grid { stroke: #dce3e9; stroke-width: 1; }.chart-axis { fill: var(--gray-600); font-size: 12px; }.chart-circle { cursor: pointer; stroke: white; stroke-width: 1.5; }.chart-circle:hover { stroke: var(--ink); stroke-width: 2.5; }.chart-selected { stroke: var(--ink); stroke-width: 4; }
.chart-tooltip { position: fixed; z-index: 2500; max-width: 280px; padding: .65rem .75rem; color: #fff; background: rgba(8,32,53,.96); border: 1px solid rgba(255,255,255,.2); border-radius: 4px; box-shadow: 0 10px 28px rgba(0,0,0,.25); pointer-events: none; font-size: .76rem; line-height: 1.4; }
.chart-tooltip strong { display: block; font-size: .9rem; }
.event-hover-popup .maplibregl-popup-content { padding: .7rem .8rem; color: #edf4f8; background: rgba(8,32,53,.96); border-radius: 4px; box-shadow: 0 10px 28px rgba(0,0,0,.25); font: 13px/1.4 "IBM Plex Sans", sans-serif; }
.event-hover-popup .maplibregl-popup-tip { border-top-color: rgba(8,32,53,.96); }
.hover-title { display: block; margin-bottom: .15rem; font-weight: 800; }

html[data-theme="dark"] {
  --ink: #eef4f8;
  --gray-900: #d6e0e8;
  --gray-600: #aebbc7;
  --gray-300: #415363;
  --gray-100: #09131d;
  --paper: #142534;
  --shadow: 0 16px 40px rgba(0,0,0,.35);
  color-scheme: dark;
}
html[data-theme="dark"] body { background: radial-gradient(circle at 15% 0, rgba(46,109,155,.18), transparent 32%), #09131d; }
html[data-theme="dark"] .notice { color: #f0c7ca; background: #27191d; border-color: #52343a; }
html[data-theme="dark"] .event-focus { color: #eef4f8; background: #101f2c; }
html[data-theme="dark"] .statistics { background: #0d1b27; }
html[data-theme="dark"] .statistics strong { color: #ff5964; }
html[data-theme="dark"] .table-scroll, html[data-theme="dark"] .chart-scroll { background: #142534; }
html[data-theme="dark"] .activity-section .section-heading h2,
html[data-theme="dark"] .activity-section .section-heading .eyebrow,
html[data-theme="dark"] .activity-section .section-heading > p { color: #f4f8fb; }
html[data-theme="dark"] .chart-axis { fill: #f4f8fb; }
html[data-theme="dark"] tbody tr { border-color: #304351; }
html[data-theme="dark"] tbody tr:hover, html[data-theme="dark"] tbody tr.active { background: #1a3447; }
html[data-theme="dark"] .quality-badge { color: #b9dcf2; background: #203b4d; }
html[data-theme="dark"] .quality-grid strong { color: #ff5964; }
html[data-theme="dark"] .intensity-row strong { color: #f4f8fb; }
html[data-theme="dark"] .event-focus.selection-highlight { animation-name: focus-selection-dark; }
@keyframes focus-selection-dark {
  0% { background: #452128; box-shadow: inset 7px 0 var(--red), inset 0 0 0 2px rgba(255,120,130,.4); }
  45% { background: #2e2028; box-shadow: inset 5px 0 var(--red); }
  100% { background: #101f2c; box-shadow: inset 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .event-focus.selection-highlight { animation-duration: .01ms; }
}

.catalog-title { align-items: center; }
.catalog-title #updated-at { margin: .3rem 0 0; color: var(--gray-600); font-size: .75rem; }
.sort-control { display: flex; padding: 3px; background: var(--gray-100); border: 1px solid var(--gray-300); border-radius: 5px; }
.sort-button { min-height: 40px; padding: .5rem 1rem; color: var(--gray-600); background: transparent; border: 0; border-radius: 3px; cursor: pointer; font-weight: 750; }
.sort-button.active { color: var(--paper); background: var(--blue); }
.table-scroll { max-height: 560px; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
thead { position: sticky; top: 0; z-index: 2; background: var(--blue); color: var(--paper); }
th { padding: .75rem 1rem; text-align: left; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; }
tbody tr { border-bottom: 1px solid #e0e5e9; cursor: pointer; }
tbody tr:hover, tbody tr.active { background: #f1f6fa; }
tbody tr.active { box-shadow: inset 4px 0 var(--red); }
td { padding: .9rem 1rem; vertical-align: middle; }
.table-mag { color: var(--red); font: 800 1.8rem/1 "Barlow Condensed", "Arial Narrow", sans-serif; }
.table-place { font-weight: 750; }.table-sub { display: block; margin-top: .2rem; color: var(--gray-600); font-size: .74rem; }
.quality-badge { display: inline-block; padding: .25rem .4rem; color: var(--blue); background: #edf4f8; border-radius: 3px; font-size: .7rem; font-weight: 750; }
.table-time { white-space: nowrap; font-size: .8rem; }
.catalog-footer { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; color: var(--gray-600); border-top: 1px solid var(--gray-300); font-size: .8rem; }
.empty-row td { padding: 2rem; color: var(--gray-600); text-align: center; }

.method-note { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; margin-top: 1.5rem; padding: 2rem clamp(1rem,4vw,4rem); background: var(--paper); border-top: 1px solid var(--gray-300); }
.method-note h2 { color: var(--blue); font-size: 2rem; }.method-note p { max-width: 950px; margin: 0; color: var(--gray-600); line-height: 1.65; }
footer { display: flex; justify-content: space-between; padding: 1.2rem clamp(1rem,4vw,4rem); color: var(--paper); background: var(--gray-900); font-size: .78rem; }
.maplibregl-popup-content { padding: .7rem .85rem; font-family: inherit; border-left: 4px solid var(--red); }.maplibregl-ctrl-attrib { font-size: 10px; }

html.embed-view, html.embed-view body { width: 100%; height: 100%; overflow: hidden; background: #dce6ee; }
html.embed-view body > :not(main) { display: none !important; }
html.embed-view main { width: 100%; height: 100%; }
html.embed-view main > :not(.map-workspace) { display: none !important; }
html.embed-view .map-workspace { display: grid; grid-template-columns: 1fr; width: 100%; height: 100vh; min-height: 100vh; box-shadow: none; }
html.embed-view .map-shell, html.embed-view #map { width: 100%; height: 100vh; min-height: 100vh; }
html.embed-view .event-focus { display: none; }

@media (max-width: 1050px) {
  .map-workspace { grid-template-columns: 1fr 320px; }
  .map-legend { grid-template-columns: 1fr 1fr; }.map-legend > p { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .site-header { align-items: flex-start; }.brand img { width: 92px; height: 64px; transform: scale(1.12); }.live-status { display: none; }
  .toolbar { flex-wrap: wrap; }.map-workspace { grid-template-columns: 1fr; }#map { min-height: 62vh; height: 62vh; }
  .event-focus { border-left: 0; border-top: 5px solid var(--red); }.statistics { grid-template-columns: 1fr 1fr; }.statistics article:nth-child(2) { border-right: 0; }
  .section-heading { align-items: flex-start; flex-direction: column; }.sort-control { align-self: stretch; }.sort-button { flex: 1; }
  th:nth-child(4), td:nth-child(4) { display: none; }
}
@media (max-width: 560px) {
  .site-header { min-height: 90px; padding: .8rem 1rem; }.brand { gap: .7rem; }.brand img { width: 76px; height: 54px; transform: scale(1.08); }.brand .eyebrow { display: none; }h1 { font-size: 2.2rem; }
  .notice { display: block; }.notice strong { display: block; margin-bottom: .25rem; }.toolbar label { flex: 1 1 45%; }.toolbar select { width: 100%; }.secondary-button { flex: 1 1 45%; }
  .map-legend { grid-template-columns: 1fr; gap: 1.2rem; }.map-legend > p { grid-column: auto; }.magnitude-scale, .depth-scale { justify-content: space-between; gap: .25rem; }
  .statistics article { padding: 1rem; }.statistics strong { font-size: 2.5rem; }.quality-grid { gap: .25rem; }
  th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { display: none; }th, td { padding: .75rem .55rem; }.table-time { white-space: normal; }
  .method-note { grid-template-columns: 1fr; gap: .7rem; }footer { display: grid; gap: .35rem; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; } }
