:root {
  --green: rgb(74, 140, 61);
  --green-bright: rgb(107, 184, 89);
  --lime: rgb(168, 222, 89);
  --bg: rgb(18, 23, 28);
  --bg-elevated: rgb(28, 36, 43);
  --bg-card: rgb(36, 43, 54);
  --text: #fff;
  --text-secondary: rgba(255, 255, 255, 0.72);
  --border: rgba(255, 255, 255, 0.08);
  --danger: rgb(255, 89, 89);
  --warning: rgb(255, 158, 64);
  --purple: rgb(184, 115, 255);
  --info: var(--lime);
  --clear: var(--green-bright);
  --tab-h: calc(56px + env(safe-area-inset-bottom, 0px));
  --header-h: 52px;
  --radius: 18px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { border-radius: 8px; }
.brand-title { font-weight: 700; font-size: 15px; color: var(--lime); }
.brand-sub { font-size: 11px; color: var(--text-secondary); }

.icon-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--lime);
  font-size: 18px;
  cursor: pointer;
}
.icon-btn:active { opacity: 0.7; }

.main {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(16px + var(--tab-h));
}

.tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  max-width: 720px;
  margin: 0 auto;
  background: rgba(18, 23, 28, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 2px;
}
.tab-icon { font-size: 18px; line-height: 1; }
.tab.active { color: var(--lime); }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--lime);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--lime);
  margin: 0 0 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 540px) {
  .grid-2 { gap: 12px; }
}

.metric {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 108px;
  display: flex;
  flex-direction: column;
}
.metric-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.metric-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.metric-unit { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-left: 4px; }
.metric-sub { font-size: 12px; color: var(--text-secondary); margin-top: 6px; line-height: 1.35; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.badge-clear { background: rgba(107, 184, 89, 0.18); color: var(--green-bright); }
.badge-warn { background: rgba(255, 158, 64, 0.18); color: var(--warning); }
.badge-danger { background: rgba(255, 89, 89, 0.18); color: var(--danger); }

.warning-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  min-height: 96px;
}
.warning-card .title { font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.warning-card .detail { font-size: 12px; color: var(--text-secondary); line-height: 1.35; }

.hero-storm {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 6px;
  line-height: 1.2;
}
.hero-meta { font-size: 13px; color: var(--text-secondary); line-height: 1.45; }
.hero-time { font-size: 11px; color: var(--text-secondary); text-align: right; margin-bottom: 8px; }

.segmented {
  display: flex;
  background: var(--bg-elevated);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 14px;
  gap: 2px;
}
.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
}
.segmented button.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { border-color: var(--lime); color: var(--lime); background: rgba(168, 222, 89, 0.1); }
.chip-group-label { font-size: 11px; font-weight: 700; color: var(--text-secondary); margin: 8px 0 4px; }

.media-box {
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
}
.media-box video, .media-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.windy-embed-box {
  aspect-ratio: 16/9;
}
.windy-embed-box iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.media-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.media-strip img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #000;
}

.query-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 540px) {
  .query-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.query-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 12px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  min-height: 88px;
}
.query-tile:active { opacity: 0.85; }
.query-tile .icon { font-size: 22px; margin-bottom: 8px; }
.query-tile .label { font-size: 13px; font-weight: 700; }

.notice-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.notice-row .head { display: flex; gap: 10px; align-items: flex-start; }
.notice-row .icon { font-size: 20px; width: 28px; text-align: center; }
.notice-row .title { font-weight: 600; font-size: 15px; }
.notice-row .time { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.notice-row .detail { font-size: 12px; color: var(--text-secondary); margin: 8px 0 0 38px; line-height: 1.45; display: none; }
.notice-row.expanded .detail { display: block; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }

.map-gallery img {
  width: 100%;
  border-radius: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  background: #000;
}

.day-card {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.day-card .temp { font-size: 20px; font-weight: 800; color: var(--lime); white-space: nowrap; }

.bar-row { margin-bottom: 8px; }
.bar-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-secondary); margin-bottom: 3px; }
.bar-track { height: 6px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--lime); border-radius: 3px; }

.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-root[hidden] {
  display: none !important;
  pointer-events: none !important;
}
.modal-root:not([hidden]) {
  display: flex;
}
@media (min-width: 540px) {
  .modal-root:not([hidden]) { align-items: center; padding: 20px; }
}
.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 720px;
  max-height: 90dvh;
  overflow: auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 540px) {
  .modal { border-radius: 20px; }
}
.modal-close {
  float: right;
  border: 0;
  background: var(--bg-elevated);
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
}
.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal .summary { color: var(--text-secondary); margin-bottom: 12px; }
.modal-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.modal-metric { background: var(--bg-card); border-radius: 10px; padding: 10px; }
.modal-metric .lbl { font-size: 11px; color: var(--text-secondary); }
.modal-metric .val { font-size: 16px; font-weight: 700; margin-top: 2px; }

.install-banner[hidden] {
  display: none !important;
  pointer-events: none !important;
}
.install-banner {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--tab-h) + 8px);
  background: var(--bg-card);
  border: 1px solid var(--lime);
  border-radius: 14px;
  padding: 12px 14px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 696px;
  margin: 0 auto;
}
.install-banner p { margin: 0; font-size: 12px; line-height: 1.4; flex: 1; }
.install-banner button {
  border: 0;
  background: var(--lime);
  color: #111;
  font-weight: 700;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 300;
  max-width: 90%;
  text-align: center;
}
.toast[hidden] {
  display: none !important;
  pointer-events: none !important;
}
.toast:not([hidden]) {
  display: block;
}

.loading-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tone-danger { color: var(--danger); }
.tone-warning { color: var(--warning); }
.tone-purple { color: var(--purple); }
.tone-info { color: var(--info); }
.tone-clear { color: var(--clear); }

.storm-0 { color: var(--green-bright); }
.storm-1 { color: var(--lime); }
.storm-2 { color: var(--warning); }
.storm-3 { color: var(--danger); }

.radar-layout {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--tab-h) - var(--header-h) - 32px);
  margin: -16px;
  padding: 0;
}
.radar-layout .picker-scroll {
  flex-shrink: 0;
  max-height: 180px;
  overflow: auto;
  padding: 8px 16px 0;
}
.radar-layout .media-area {
  flex: 1;
  min-height: 0;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
}
.radar-footer {
  flex-shrink: 0;
  padding: 8px 16px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: 0; }

.fullscreen-media {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fullscreen-media video, .fullscreen-media img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.fullscreen-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  border: 0;
  background: rgba(255,255,255,0.15);
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
}
