:root {
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: "Bricolage Grotesque", sans-serif;
  --font-body: "Figtree", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

body {
  background:
    radial-gradient(1000px 500px at 90% -10%, var(--accent-soft), transparent 55%),
    radial-gradient(800px 420px at -10% 10%, rgba(255, 255, 255, 0.65), transparent 50%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 45%, var(--bg) 100%);
  background-attachment: fixed;
}

[data-theme="gece"] body,
body[data-theme="gece"] {
  background:
    radial-gradient(900px 480px at 85% -5%, var(--accent-soft), transparent 55%),
    linear-gradient(180deg, #0a0a0a 0%, #050505 100%);
}

.app {
  width: min(1100px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(14px + var(--safe-top)) 14px calc(24px + var(--safe-bottom));
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: rise 0.45s ease both;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 28px var(--accent-soft);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 12px 8px;
  border-top: 2px solid rgba(255, 255, 255, 0.85);
  border-bottom: 2px solid rgba(255, 255, 255, 0.85);
  transform: skewX(-18deg);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 6vw, 2.35rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn.is-spinning svg {
  animation: spin 0.7s linear infinite;
}

.theme-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.theme-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.theme-btn.is-active {
  background: var(--accent);
  color: var(--chip-active-text);
}

.hero-status {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  animation: rise 0.55s ease both;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 700;
  font-size: 0.82rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent);
  animation: pulse 1.6s ease-out infinite;
}

.status-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.status-meta strong {
  color: var(--text);
  font-size: 1.05rem;
}

.dot { margin: 0 4px; }

.insight-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  animation: rise 0.6s ease both;
}

.insight-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.insight-kicker {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.insight-head h2 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.insight-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-btn {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 3%, transparent);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tool-btn.primary {
  background: var(--accent);
  color: var(--chip-active-text);
  border-color: transparent;
}

.tool-btn.is-on {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.tool-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.tool-btn.is-on .tool-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.insight-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background:
    linear-gradient(160deg, var(--accent-soft), transparent 55%),
    color-mix(in srgb, var(--bg-2) 88%, transparent);
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: default;
  min-height: 128px;
  display: grid;
  align-content: start;
  gap: 4px;
}

button.insight-card {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

button.insight-card:active {
  transform: scale(0.98);
}

.insight-card.accent {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.insight-card.big-quake {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.insight-icon {
  width: fit-content;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--accent-2);
  margin-bottom: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
}

.insight-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.insight-card strong {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3.4vw, 1.45rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.insight-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.near-panel {
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 18px;
  padding: 14px;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  display: grid;
  gap: 12px;
}

.near-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.near-top h3 {
  margin: 0;
  font-size: 0.98rem;
  font-family: var(--font-display);
}

.near-top p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.radius-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.radius-chips::-webkit-scrollbar { display: none; }

.radius-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}

.radius-chip.is-active {
  background: var(--accent);
  color: var(--chip-active-text);
  border-color: transparent;
}

.top-quakes {
  display: grid;
  gap: 8px;
}

.top-quake-item {
  width: 100%;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 2%, transparent);
  border-radius: 14px;
  padding: 10px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.top-quake-item:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft);
}

.top-quake-mag {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  background: var(--accent);
}

.top-quake-item h4 {
  margin: 0;
  font-size: 0.9rem;
}

.top-quake-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.share-card {
  margin: 4px 0 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 3%, transparent);
}

.share-title {
  margin: 0 0 10px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
}

.share-preview {
  display: none;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 220px;
  margin-bottom: 10px;
  border-radius: 14px;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--line);
}

.share-preview.is-on {
  display: block;
}

.share-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.share-btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 10px;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  background: var(--accent);
  color: var(--chip-active-text);
}

.share-btn.soft {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.soft-close {
  margin-top: 8px;
  background: transparent !important;
  color: var(--text) !important;
  border: 1px solid var(--line);
}

@media (max-width: 720px) {
  .insight-grid {
    grid-template-columns: 1fr;
  }
}

.map-shell {
  position: relative;
  height: min(52vh, 480px);
  min-height: 280px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.65s ease both;
  scroll-margin-top: 12px;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--map-bg);
}

.map-layers {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.map-layer-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
}

.map-layer-btn.is-active {
  background: var(--accent);
  color: var(--chip-active-text);
}

.map-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 500;
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  font-size: 0.75rem;
  color: var(--muted);
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lg {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.lg-low { background: var(--low); }
.lg-mid { background: var(--mid); }
.lg-high { background: var(--high); }
.lg-hot { background: var(--hot); }

.filters {
  display: grid;
  gap: 8px;
  animation: rise 0.7s ease both;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}

.chip:active { transform: scale(0.97); }

.chip.is-active {
  color: var(--chip-active-text);
  background: var(--accent);
  border-color: transparent;
}

.source-chips .chip.is-active {
  background: var(--accent-2);
}

.list-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  padding: 14px 12px 8px;
  min-height: 280px;
  animation: rise 0.8s ease both;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 0 6px 10px;
}

.list-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.list-head span {
  color: var(--muted);
  font-size: 0.8rem;
}

.quake-list { display: grid; gap: 8px; }

.quake-item {
  width: 100%;
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--text) 3%, transparent);
  color: inherit;
  border-radius: 16px;
  padding: 12px;
  font: inherit;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.quake-item:hover,
.quake-item.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}

.quake-item:active { transform: scale(0.985); }

.mag {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
  color: #fff;
}

.mag-low { background: var(--low); }
.mag-mid { background: var(--mid); color: #1c1917; }
.mag-high { background: var(--high); }
.mag-hot { background: var(--hot); }

.quake-body h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.25;
}

.quake-body p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.quake-meta {
  text-align: right;
  color: var(--muted);
  font-size: 0.78rem;
  display: grid;
  gap: 4px;
}

.badge {
  display: inline-flex;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 700;
}

.empty,
.error {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

.error { color: var(--danger); }
.hidden { display: none !important; }

.sheet[hidden] { display: none; }
.sheet { position: fixed; inset: 0; z-index: 2000; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  animation: fade 0.2s ease;
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-2);
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  padding: 10px 18px calc(22px + var(--safe-bottom));
  box-shadow: var(--shadow);
  animation: sheetUp 0.28s ease;
  color: var(--text);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 18%, transparent);
  margin: 4px auto 16px;
}

.detail-mag {
  font-family: var(--font-display);
  font-size: 3rem;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--accent);
}

.sheet-panel h3 {
  margin: 8px 0 16px;
  font-size: 1.2rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 0 18px;
}

.detail-grid div {
  padding: 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--text) 4%, transparent);
  border: 1px solid var(--line);
}

.detail-grid dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.detail-grid dd {
  margin: 6px 0 0;
  font-weight: 700;
}

.how-far-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -6px 0 14px;
  min-height: 1.2em;
}

.how-far-link {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.how-far-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.quake-dist {
  display: inline;
  margin-left: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
}

.primary-btn {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-weight: 700;
  background: var(--accent);
  color: var(--chip-active-text);
  cursor: pointer;
}

.map-popup {
  font-family: var(--font-body);
  color: #1c1917;
  line-height: 1.35;
}

.map-popup strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  display: block;
  margin-bottom: 4px;
}

.map-popup-meta {
  color: #57534e;
  font-size: 0.8rem;
  margin-top: 3px;
}

.leaflet-popup-content-wrapper {
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.seo-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.seo-nav a {
  color: var(--accent-2);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.85rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  70% { box-shadow: 0 0 0 12px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 900px) {
  .app {
    grid-template-columns: 1.15fr 0.85fr;
    grid-template-areas:
      "top top"
      "status status"
      "map filters"
      "map list"
      "map summary";
    align-content: start;
    gap: 14px 16px;
    padding-top: calc(22px + var(--safe-top));
  }

  .topbar { grid-area: top; }
  .hero-status { grid-area: status; }
  .insight-panel { grid-area: summary; }
  .map-shell {
    grid-area: map;
    height: calc(100dvh - 140px);
    min-height: 560px;
    position: sticky;
    top: 18px;
  }
  .filters { grid-area: filters; }
  .list-panel {
    grid-area: list;
    max-height: min(52vh, 520px);
    overflow: auto;
  }

  .sheet-backdrop {
    background: transparent;
    pointer-events: none;
  }
  .sheet-panel {
    left: auto;
    right: 18px;
    bottom: 18px;
    width: min(380px, calc(100% - 36px));
    border-radius: 20px;
    border: 1px solid var(--line);
    pointer-events: auto;
  }
}