:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
  --mag4: #ffd23f;
  --mag5: #ff8c1a;
  --mag6: #ff4466;
  --mag7: #ff2d6f;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { width: 100%; height: 100%; position: relative; }
.screen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.focusable { transition: all 0.15s ease; border: 2px solid transparent; cursor: pointer; outline: none; }
.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.hidden { display: none !important; }

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px 14px;
  background: var(--bg-primary);
  border-bottom: 1px solid #22222e;
  flex-shrink: 0;
}
.title-block { flex: 1; min-width: 0; }
.topbar h1 {
  font-size: 26px; font-weight: 700; letter-spacing: -0.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sub { font-size: 14px; color: var(--text-secondary); margin-top: 3px; }

.pulse {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-muted); flex-shrink: 0;
}
.pulse.live { background: var(--accent-secondary); box-shadow: 0 0 12px var(--accent-secondary); animation: blip 2.4s ease-in-out infinite; }
.pulse.stale { background: var(--mag4); }
.pulse.err { background: var(--danger); }
@keyframes blip { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---- Stats ---- */
.stats {
  display: flex; gap: 10px; padding: 14px 20px; flex-shrink: 0;
}
.stat {
  flex: 1; background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 12px 8px; text-align: center; border: 1px solid #20202c;
}
.stat-num { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-lbl { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ---- Nav row ---- */
.navrow { display: flex; gap: 10px; padding: 0 20px 12px; flex-shrink: 0; }
.navbtn {
  flex: 1; min-height: 52px; border-radius: var(--radius-md);
  background: var(--bg-tertiary); color: var(--text-primary);
  font-size: 17px; font-weight: 600; font-family: inherit;
}
.navbtn:active { transform: scale(0.98); }

/* ---- Quake list ---- */
.list { flex: 1; overflow-y: auto; padding: 4px 16px 20px; }
.list::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-thumb { background: #2a2a38; border-radius: 3px; }

.quake {
  display: flex; align-items: center; gap: 14px;
  min-height: 88px; padding: 12px 14px; margin-bottom: 10px;
  background: var(--bg-secondary); border-radius: var(--radius-md);
}
.mag-badge {
  width: 64px; height: 64px; flex-shrink: 0; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; color: #0a0a0f;
}
.mag-badge .mv { font-size: 24px; line-height: 1; }
.mag-badge .ml { font-size: 10px; font-weight: 700; opacity: 0.7; margin-top: 2px; letter-spacing: 0.5px; }
.q-info { flex: 1; min-width: 0; }
.q-place { font-size: 17px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.q-meta { font-size: 13px; color: var(--text-secondary); margin-top: 5px; display: flex; gap: 10px; flex-wrap: wrap; }
.q-meta .tsu { color: var(--accent); font-weight: 600; }
.q-time { font-size: 14px; color: var(--text-secondary); flex-shrink: 0; text-align: right; }

.empty { text-align: center; color: var(--text-secondary); padding: 50px 20px; font-size: 16px; line-height: 1.5; }

/* ---- Magnitude color buckets ---- */
.m4 { background: var(--mag4); }
.m5 { background: var(--mag5); }
.m6 { background: var(--mag6); }
.m7 { background: var(--mag7); }

/* ---- Detail ---- */
.backbtn {
  min-height: 44px; padding: 8px 16px; border-radius: 10px;
  background: var(--bg-tertiary); color: var(--text-primary);
  font-size: 16px; font-weight: 600; font-family: inherit;
}
.detail-mag-tag {
  margin-left: auto; font-size: 20px; font-weight: 800;
  padding: 6px 14px; border-radius: 10px; color: #0a0a0f;
}
.detail-body { flex: 1; overflow-y: auto; padding: 18px 20px 24px; }
.detail-body::-webkit-scrollbar { width: 6px; }
.detail-body::-webkit-scrollbar-thumb { background: #2a2a38; border-radius: 3px; }

.d-hero { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.d-mag { font-size: 64px; font-weight: 800; line-height: 1; }
.d-magunit { font-size: 18px; color: var(--text-secondary); font-weight: 600; }
.d-place { font-size: 20px; font-weight: 600; line-height: 1.3; margin-bottom: 18px; }

.scalebar { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--mag4), var(--mag5) 45%, var(--mag6) 72%, var(--mag7)); position: relative; margin: 4px 0 6px; }
.scale-marker { position: absolute; top: -5px; width: 4px; height: 24px; background: #fff; border-radius: 2px; box-shadow: 0 0 6px rgba(0,0,0,0.6); transform: translateX(-50%); }
.scale-ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-bottom: 20px; }

.d-rows { display: flex; flex-direction: column; gap: 2px; }
.d-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 13px 4px; border-bottom: 1px solid #1d1d28; }
.d-row:last-child { border-bottom: none; }
.d-key { font-size: 14px; color: var(--text-secondary); flex-shrink: 0; }
.d-val { font-size: 16px; font-weight: 600; text-align: right; }
.d-val.warn { color: var(--accent); }
.d-val.danger { color: var(--danger); }

.alert-pill { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 14px; font-weight: 700; color: #0a0a0f; }
.alert-green { background: var(--accent-secondary); }
.alert-yellow { background: var(--mag4); }
.alert-orange { background: var(--mag5); }
.alert-red { background: var(--mag6); }

/* ---- About ---- */
.about-body { flex: 1; overflow-y: auto; padding: 20px; }
.about-lead { font-size: 18px; line-height: 1.5; margin-bottom: 20px; }
.about-lead strong { color: var(--accent); }
.scale-legend { background: var(--bg-secondary); border-radius: var(--radius-md); padding: 16px; margin-bottom: 20px; }
.leg-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; font-size: 15px; }
.leg-row .dot { width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0; }
.about-note { font-size: 14px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 12px; }
