:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --accent: #0284c7;
  --mag-45: #facc15;
  --mag-5: #fb923c;
  --mag-6: #ef4444;
  --mag-7: #9f1239;
  --plate: #7c3aed;
  --panel-width: 360px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { -webkit-text-size-adjust: 100%; background: var(--surface); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #38bdf8; outline-offset: 2px; }
a { color: var(--accent); }

.app { height: 100dvh; display: grid; grid-template-columns: var(--panel-width) 1fr; }
.map { min-height: 0; background: #aad3df; }

.panel { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); box-shadow: 2px 0 12px rgba(15, 23, 42, .06); z-index: 1; }
.panel-header { padding: 16px 16px 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 2px; color: var(--accent); font-size: .68rem; font-weight: 800; letter-spacing: .14em; }
h1 { margin: 0; font-size: 1.05rem; line-height: 1.4; }

.icon-button { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); font-weight: 700; cursor: pointer; }
.icon-button:hover { background: var(--surface-soft); }
.text-button { padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: .78rem; cursor: pointer; }
.text-button:hover { background: var(--surface-soft); }
.text-button:disabled { opacity: .5; cursor: progress; }

.controls { padding: 14px 16px; display: grid; gap: 14px; border-bottom: 1px solid var(--line); }
.control-label { margin: 0 0 6px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.segmented { padding: 3px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; border-radius: 8px; background: #f1f5f9; }
.segmented a { padding: 6px 0; border-radius: 6px; text-align: center; text-decoration: none; color: var(--muted); font-size: .88rem; font-weight: 600; }
.segmented a:hover { color: var(--ink); }
.segmented a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }

.magnitude label { display: block; font-size: .88rem; }
.magnitude output { display: inline-block; min-width: 2.4em; text-align: center; font-weight: 800; font-size: 1.05rem; }
.magnitude input { width: 100%; margin: 8px 0 4px; accent-color: var(--mag-6); }
.legend { display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i, .quake-mag { border-radius: 50%; }
.legend i { display: inline-block; width: 10px; height: 10px; }
.mag-45 { background: var(--mag-45); }
.mag-5 { background: var(--mag-5); }
.mag-6 { background: var(--mag-6); }
.mag-7 { background: var(--mag-7); }
.quake-mag.mag-6, .quake-mag.mag-7 { color: #fff; }

.toggles { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .84rem; }
.toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

.status { padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); background: var(--surface-soft); font-size: .82rem; }
.status p { margin: 0; }
#summary { font-weight: 700; }
.status.error #summary { color: #b91c1c; }
.updated { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); white-space: nowrap; }

.list-header { padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list-toggle { padding: 0; border: 0; background: none; font-size: .84rem; font-weight: 700; cursor: pointer; }
.list-toggle:disabled { color: inherit; cursor: default; }
.list-header select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: .8rem; }
.list-wrap { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.quake-list { margin: 0; padding: 0 8px 12px; list-style: none; }
.quake-list button { width: 100%; padding: 8px; display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 10px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.quake-list button:hover { background: var(--surface-soft); }
.quake-mag { width: 40px; height: 40px; display: grid; place-items: center; font-weight: 800; font-size: .9rem; }
.quake-place { display: block; font-size: .86rem; font-weight: 600; line-height: 1.35; }
.quake-meta { display: block; margin-top: 2px; color: var(--muted); font-size: .75rem; }
.quake-tsunami { margin-left: 6px; padding: 0 5px; border-radius: 4px; background: #e0f2fe; color: #0369a1; font-weight: 700; }
.empty { padding: 24px 16px; color: var(--muted); font-size: .86rem; text-align: center; }

.quake-marker { display: grid; place-items: center; }
.quake-marker span { width: 100%; height: 100%; border: 1.5px solid rgba(15, 23, 42, .55); border-radius: 50%; opacity: .85; }
.quake-marker.recent::before { position: absolute; inset: -6px; content: ""; border: 2px solid var(--mag-6); border-radius: 50%; animation: ripple 1.8s ease-out infinite; }
@keyframes ripple { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

.quake-cluster { display: grid; place-items: center; border: 3px solid rgba(255, 255, 255, .85); border-radius: 50%; color: var(--ink); font-weight: 800; font-size: .8rem; box-shadow: 0 1px 4px rgba(15, 23, 42, .35); }
.quake-cluster.mag-7, .quake-cluster.mag-6 { color: #fff; }

.leaflet-control-home a { font-size: 16px; }
.country-tooltip { padding: 2px 8px; font-size: .8rem; font-weight: 600; }
.leaflet-popup-content { margin: 12px 14px; min-width: 240px; font-size: .84rem; line-height: 1.5; }
.popup-title { margin: 0 0 8px; font-size: .95rem; }
.popup-table { width: 100%; border-collapse: collapse; }
.popup-table th, .popup-table td { padding: 4px 0; border-top: 1px solid var(--line); vertical-align: top; text-align: left; }
.popup-table th { width: 7em; color: var(--muted); font-weight: 600; }

.info { width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 24px; border: 0; border-radius: 12px; box-shadow: 0 24px 60px rgba(15, 23, 42, .3); font-size: .9rem; line-height: 1.75; }
.info::backdrop { background: rgba(15, 23, 42, .45); }
.info h2 { margin: 0 0 8px; font-size: 1.2rem; }
.info h3 { margin: 20px 0 4px; font-size: 1rem; }
.info ul { padding-left: 1.2em; }
.info dl { margin: 0; display: grid; grid-template-columns: 6em 1fr; gap: 4px 12px; }
.info dt { color: var(--muted); font-weight: 600; }
.info dd { margin: 0; }
.info-close { position: absolute; top: 12px; right: 12px; }
.contact summary { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--accent); font-size: .84rem; font-weight: 700; cursor: pointer; list-style: none; }
.contact summary::-webkit-details-marker { display: none; }
.contact summary::after { content: "▼"; font-size: .65em; transition: transform .2s; }
.contact summary:hover { background: var(--surface-soft); }
.contact[open] summary { margin-bottom: 12px; }
.contact[open] summary::after { transform: rotate(180deg); }
.contact-form { display: grid; gap: 10px; }
.contact-form label { display: grid; gap: 4px; font-size: .84rem; font-weight: 600; }
.contact-form input, .contact-form textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-weight: 400; }
.contact-form textarea { resize: vertical; }
.optional, .required { margin-left: 4px; font-size: .72rem; font-weight: 600; color: var(--muted); }
.required { color: #b91c1c; }
.honeypot { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.submit-button { justify-self: start; padding: 8px 20px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.submit-button:disabled { opacity: .6; cursor: progress; }
.form-status { margin: 0; font-size: .84rem; }
.form-status.success { color: #047857; }
.form-status.error { color: #b91c1c; }
.credit { margin-top: 20px; color: var(--muted); font-size: .78rem; text-align: center; }

@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .status { flex-wrap: wrap; row-gap: 2px; }
  .map { grid-row: 1; }
  .panel { grid-row: 2; max-height: 62dvh; border-top: 1px solid var(--line); border-right: 0; box-shadow: 0 -2px 12px rgba(15, 23, 42, .08); padding-bottom: env(safe-area-inset-bottom); }
  .panel-header { padding: 10px 14px 8px; }
  .eyebrow { display: none; }
  h1 { font-size: .95rem; }
  .controls { padding: 10px 14px; gap: 10px; }
  .status { padding: 8px 14px; }
  .list-header { padding: 6px 14px; }
  .list-toggle::after { content: " ▲"; font-size: .7em; }
  .list-toggle[aria-expanded="true"]::after { content: " ▼"; }
  .list-wrap { display: none; }
  .panel.expanded .list-wrap { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .quake-marker.recent::before { animation: none; transform: scale(1.2); }
}
