:root {
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.85);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --green: #2ecc71;
  --yellow: #f1c40f;
  --orange: #e67e22;
  --red: #e74c3c;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ---------- Header ---------- */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--panel-border);
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 28px;
}

.brand h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.brand h1 span {
  color: var(--accent);
  font-weight: 300;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.outline-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.outline-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.update-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

#refresh-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.3s;
}

#refresh-btn:hover {
  transform: rotate(180deg);
}

/* ---------- Map ---------- */
#map {
  position: absolute;
  top: 60px;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: absolute;
  top: 80px;
  left: 20px;
  width: 320px;
  max-height: calc(100vh - 120px);
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 900;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
}

#count {
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--panel-border);
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.filter-btn.active {
  background: var(--accent);
  color: #0f172a;
  border-color: var(--accent);
  font-weight: 500;
}

.quake-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.quake-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.quake-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-left-color: var(--accent);
}

.mag-badge {
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 700;
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}

.quake-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.place {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.time {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Legend ---------- */
.legend {
  position: absolute;
  bottom: 30px;
  right: 20px;
  z-index: 900;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  font-size: 13px;
}

.legend h3 {
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
}

.legend div {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  color: var(--text-muted);
}

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

/* ---------- Leaflet popup dark ---------- */
.leaflet-popup-content-wrapper {
  background: #0f172a;
  color: var(--text);
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--panel-border);
}

.leaflet-popup-tip {
  background: #0f172a;
}

.leaflet-popup-content {
  margin: 14px;
  font-family: 'Inter', sans-serif;
}

.popup-inner {
  display: flex;
  gap: 14px;
}

.popup-mag {
  min-width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.popup-inner strong {
  font-size: 14px;
}

.popup-inner a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}

.popup-inner a:hover {
  text-decoration: underline;
}

.tsunami {
  color: var(--red);
  font-weight: 600;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .topbar {
    height: 56px;
    padding: 0 12px;
  }
  .brand h1 {
    font-size: 17px;
  }
  .header-actions {
    gap: 6px;
  }
  .outline-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  .update-info span {
    display: none;
  }
  #map {
    top: 56px;
  }
  .sidebar {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 45vh;
    border-radius: 16px 16px 0 0;
    border: none;
    border-top: 1px solid var(--panel-border);
  }
  .filters {
    padding: 8px 12px;
  }
  .quake-item {
    padding: 8px 12px;
  }
  .legend {
    bottom: calc(45vh + 10px);
    right: 10px;
    padding: 10px 12px;
  }
}