/* Blue Springs Weather and Natural Disaster - Main Stylesheet */
/* Professional, accessible, SEO-friendly, dark-mode ready */

:root {
  /* Light theme (default) */
  --bg-primary: #f4f7fb;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8eef6;
  --bg-card: #ffffff;
  --text-primary: #1a2332;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --accent: #0b5cab;
  --accent-hover: #094a8c;
  --accent-light: #e6f0fa;
  --danger: #c53030;
  --warning: #d69e2e;
  --success: #276749;
  --border: #d1d9e6;
  --shadow: 0 4px 16px rgba(26, 35, 50, 0.08);
  --shadow-lg: 0 10px 30px rgba(26, 35, 50, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --header-bg: #0b3d6e;
  --header-text: #ffffff;
  --ticker-bg: #0b3d6e;
  --ticker-text: #f0f7ff;
  --alert-bg: #fff5f5;
  --alert-border: #fc8181;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --transition: 0.25s ease;
}

[data-theme="dark"] {
  --bg-primary: #0f1419;
  --bg-secondary: #1a2332;
  --bg-tertiary: #243044;
  --bg-card: #1a2332;
  --text-primary: #e8eef6;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  --accent: #3b9eff;
  --accent-hover: #63b3ed;
  --accent-light: #1a365d;
  --danger: #fc8181;
  --warning: #f6e05e;
  --success: #68d391;
  --border: #2d3748;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
  --header-bg: #0a1929;
  --header-text: #e8eef6;
  --ticker-bg: #0a1929;
  --ticker-text: #bee3f8;
  --alert-bg: #2d1a1a;
  --alert-border: #c53030;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; display: block; }

/* ========== HEADER ========== */
.site-header {
  background: var(--header-bg);
  color: var(--header-text);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--header-text);
  letter-spacing: -0.02em;
}
.logo:hover { color: var(--header-text); opacity: 0.95; }
.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

.nav-main {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.nav-main a {
  color: rgba(255,255,255,0.88);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-main a:hover,
.nav-main a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.theme-toggle {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  transition: background var(--transition);
}
.theme-toggle:hover { background: rgba(255,255,255,0.2); }

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

/* ========== TICKER ========== */
.news-ticker {
  background: var(--ticker-bg);
  color: var(--ticker-text);
  overflow: hidden;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  height: 36px;
  display: flex;
  align-items: center;
  position: relative;
}
.ticker-label {
  background: #c53030;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0 0.75rem;
  height: 100%;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  z-index: 2;
}
.ticker-track {
  display: inline-flex;
  animation: ticker-scroll linear infinite;
  padding-left: 100%;
}
.ticker-track span {
  padding: 0 2.5rem;
  font-size: 0.88rem;
  font-weight: 500;
}
@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* ========== BANNER SLOT ========== */
.banner-slot {
  max-width: 1280px;
  margin: 1rem auto 0;
  padding: 0 1.25rem;
}
.banner-slot:empty { display: none; }
.banner-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.banner-content img {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
}
.banner-content a { display: block; }
.banner-html {
  padding: 1rem 1.25rem;
  text-align: center;
  font-size: 0.95rem;
}

/* ========== LAYOUT ========== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 960px) {
  .main-grid { grid-template-columns: 1fr; }
  .nav-main { display: none; }
  .nav-main.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--header-bg);
    padding: 1rem;
    gap: 0.25rem;
    box-shadow: var(--shadow-lg);
  }
  .menu-toggle { display: block; }
  .header-inner { position: relative; }
}

/* ========== CARDS ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-header {
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.card-header h2, .card-header h3 {
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.card-body { padding: 1.15rem; }

/* ========== ALERT WIDGET ========== */
.alert-widget {
  border: 2px solid var(--alert-border);
  background: var(--alert-bg);
}
.alert-widget .card-header {
  background: linear-gradient(90deg, #c53030, #9b2c2c);
  color: #fff;
  border-bottom: none;
}
.alert-widget .card-header h2 { color: #fff; }
.alert-list { list-style: none; }
.alert-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}
.alert-item:last-child { border-bottom: none; }
.alert-event {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}
.alert-event.tornado-emergency { color: #c53030; font-size: 1.05rem; }
.alert-event.tornado-warning { color: #c53030; }
.alert-event.severe-warning { color: #dd6b20; }
.alert-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.alert-headline {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.45;
}
.no-alerts {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
}
.no-alerts .icon { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.6; }

/* ========== CURRENT CONDITIONS / SPACE WEATHER ========== */
.conditions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: 0.75rem;
}
.condition-box {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  text-align: center;
}
.condition-box .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.condition-box .value {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.condition-box .unit {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.space-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-top: 0.85rem;
}
.space-status .indicator {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(39, 103, 73, 0.25);
}
.space-status .indicator.active {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(214, 158, 46, 0.3);
  animation: pulse 1.5s infinite;
}
.space-status .indicator.severe {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(197, 48, 48, 0.3);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.space-status .text { font-size: 0.9rem; }
.space-status .text strong { display: block; margin-bottom: 0.15rem; }

/* ========== SPACE WEATHER GALLERY ========== */
.space-intro {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.45;
}
.space-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.65rem 0 0.85rem;
  line-height: 1.45;
}
.space-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.space-metric {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  padding: 0.55rem 0.65rem;
  min-width: 0;
}
.space-metric .sm-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.space-metric .sm-value {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.25;
  white-space: normal;
}
.space-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.25rem;
}
.space-shot {
  margin: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.space-shot a {
  display: block;
  background: #000;
}
.space-shot img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  vertical-align: middle;
}
.space-shot figcaption {
  padding: 0.5rem 0.65rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.35;
}
.space-shot figcaption strong {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.82rem;
  color: var(--text-primary);
}
.space-shot figcaption span {
  color: var(--text-muted);
}
.space-gallery-loading {
  grid-column: 1 / -1;
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.space-credits {
  margin: 0.85rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.space-credits a {
  color: var(--accent, #3b82f6);
}
@media (max-width: 720px) {
  .space-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .space-gallery {
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
  }
  .space-shot figcaption {
    padding: 0.4rem 0.5rem 0.5rem;
    font-size: 0.72rem;
  }
  .space-shot figcaption strong { font-size: 0.76rem; }
}
@media (max-width: 420px) {
  .space-metrics {
    grid-template-columns: 1fr 1fr;
  }
  .space-gallery {
    grid-template-columns: 1fr;
  }
  .space-shot img {
    max-height: 70vw;
    margin: 0 auto;
  }
}
@media (min-width: 900px) {
  .space-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .space-metrics {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
@media (min-width: 1200px) {
  .space-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}


/* ========== EARTHQUAKES ========== */
.quake-list { list-style: none; }
.quake-item {
  display: flex;
  gap: 0.85rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.quake-item:last-child { border-bottom: none; }
.mag {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  flex-shrink: 0;
  background: #48bb78;
}
.mag.m3 { background: #ecc94b; color: #1a202c; }
.mag.m4 { background: #ed8936; }
.mag.m5 { background: #e53e3e; }
.mag.m6 { background: #9b2c2c; }
.quake-info { flex: 1; min-width: 0; }
.quake-place { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quake-meta { font-size: 0.78rem; color: var(--text-muted); }

/* ========== ARTICLES / FORECASTS ========== */
.article-card {
  padding: 1.15rem;
  border-bottom: 1px solid var(--border);
}
.article-card:last-child { border-bottom: none; }
.article-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}
.article-card h3 a { color: var(--text-primary); }
.article-card h3 a:hover { color: var(--accent); }
.article-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}
.article-excerpt {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ========== SIDEBAR ========== */
.sidebar .card { margin-bottom: 1.25rem; }
.sidebar .card:last-child { margin-bottom: 0; }

/* ========== FOOTER ========== */
.site-footer {
  margin-top: 3rem;
  background: var(--header-bg);
  color: rgba(255,255,255,0.75);
  padding: 2.5rem 1.25rem 1.5rem;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
}
.footer-brand h3 {
  color: #fff;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}
.footer-brand p { font-size: 0.88rem; line-height: 1.55; max-width: 360px; }
.footer-col h4 {
  color: #fff;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 0.4rem; }
.footer-col a { color: rgba(255,255,255,0.7); font-size: 0.9rem; }
.footer-col a:hover { color: #fff; }
.footer-bottom {
  max-width: 1280px;
  margin: 2rem auto 0;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
@media (max-width: 720px) {
  .footer-inner { grid-template-columns: 1fr; }
}

/* ========== UTILITIES ========== */
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent);
}
.badge.severe { background: #fed7d7; color: #c53030; }
[data-theme="dark"] .badge.severe { background: #742a2a; color: #fc8181; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }
.loading {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

/* ========== PAGE: ARTICLE SINGLE ========== */
.article-full {
  max-width: 760px;
  margin: 0 auto;
}
.article-full h1 {
  font-size: 1.85rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}
.article-full .meta {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
}
.article-full .content {
  font-size: 1.05rem;
  line-height: 1.7;
}
.article-full .content p { margin-bottom: 1.1rem; }
.article-full .content h2 { font-size: 1.35rem; margin: 1.75rem 0 0.75rem; }
.article-full .content ul { margin: 0 0 1.1rem 1.25rem; }

/* ========== ADMIN shared (light overrides) ========== */
.admin-body { background: #f0f4f8; }
[data-theme="dark"] .admin-body { background: #0f1419; }


/* Latest observation widget — responsive CSS grid */
.obs-widget-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem 1rem;
  align-items: start;
}

.obs-widget-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  align-items: baseline;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.obs-widget-date {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
}

.obs-widget-time {
  font-weight: 600;
  justify-self: end;
}

/* Fluid stat grid: 2 → 3 → 6 columns */
.obs-widget-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  width: 100%;
}

@media (min-width: 380px) {
  .obs-widget-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 640px) {
  .obs-widget-stats {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.65rem;
  }
}

.obs-stat {
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: center;
  justify-items: center;
  gap: 0.15rem;
  min-width: 0;
  background: var(--bg-secondary, var(--bg-tertiary, rgba(0,0,0,.04)));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.4rem;
  text-align: center;
}

.obs-stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  line-height: 1.2;
}

.obs-stat-value {
  font-size: clamp(1rem, 2.8vw, 1.2rem);
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  word-break: break-word;
}

@media (max-width: 379px) {
  .obs-widget-meta {
    grid-template-columns: 1fr;
  }
  .obs-widget-time {
    justify-self: start;
  }
}

.ticker-track a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ticker-track a:hover { opacity: 0.9; }
.footer-brand-body p, .footer-col-body p { margin: 0 0 0.5rem; }
.footer-col-body ul { list-style: none; padding: 0; margin: 0; }
.footer-col-body a { color: inherit; }


/* Floating site chatbot */
.bsw-chatbot {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 9990;
  font-family: inherit;
}
.bsw-chatbot-toggle {
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 50%;
  border: 2px solid rgba(11, 61, 110, 0.35);
  cursor: pointer;
  background: #ffffff;
  color: #0b3d6e;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(0,0,0,.22);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.28s ease,
              border-color 0.25s ease,
              background-color 0.25s ease;
  animation: bsw-chatbot-idle 3.2s ease-in-out infinite;
}
.bsw-chatbot-toggle:hover {
  transform: translateY(-4px) scale(1.1);
  box-shadow: 0 10px 28px rgba(11, 61, 110, 0.35), 0 0 0 6px rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  animation: none;
}
.bsw-chatbot-toggle:active {
  transform: translateY(-1px) scale(0.96);
  transition-duration: 0.12s;
}
.bsw-chatbot-robot {
  width: 2.15rem;
  height: 2.15rem;
  display: block;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bsw-chatbot-toggle:hover .bsw-chatbot-robot {
  transform: rotate(-8deg) scale(1.08);
  animation: bsw-chatbot-wiggle 0.55s ease;
}
[data-theme="dark"] .bsw-chatbot-toggle {
  background: #0f172a;
  border-color: rgba(56, 189, 248, 0.45);
}
[data-theme="dark"] .bsw-chatbot-toggle:hover {
  box-shadow: 0 10px 28px rgba(56, 189, 248, 0.35), 0 0 0 6px rgba(56, 189, 248, 0.15);
  border-color: #7dd3fc;
  background: #1e293b;
}
@keyframes bsw-chatbot-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes bsw-chatbot-wiggle {
  0% { transform: rotate(0) scale(1); }
  25% { transform: rotate(10deg) scale(1.1); }
  50% { transform: rotate(-10deg) scale(1.08); }
  75% { transform: rotate(6deg) scale(1.1); }
  100% { transform: rotate(-8deg) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .bsw-chatbot-toggle,
  .bsw-chatbot-robot {
    animation: none !important;
    transition: none !important;
  }
  .bsw-chatbot-toggle:hover {
    transform: none;
  }
}
.bsw-chatbot-panel {
  display: none;
  position: absolute;
  right: 0;
  bottom: 4.1rem;
  width: min(360px, calc(100vw - 2rem));
  max-height: min(520px, 70vh);
  background: var(--bg-card, #fff);
  color: var(--text, #111);
  border: 1px solid var(--border, #ddd);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  flex-direction: column;
  overflow: hidden;
}
.bsw-chatbot.is-open .bsw-chatbot-panel { display: flex; }
.bsw-chatbot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #0b3d6e;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
}
.bsw-chatbot-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}
.bsw-chatbot-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 220px;
  max-height: 340px;
  font-size: 0.88rem;
  line-height: 1.45;
}
.bsw-chatbot-msg {
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  max-width: 95%;
  white-space: pre-wrap;
  word-break: break-word;
}
.bsw-chatbot-msg--bot {
  align-self: flex-start;
  background: var(--bg-muted, #f1f5f9);
}
.bsw-chatbot-msg--user {
  align-self: flex-end;
  background: #0b3d6e;
  color: #fff;
}
.bsw-chatbot-thinking { opacity: 0.7; font-style: italic; }
.bsw-chatbot-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.65rem;
  border-top: 1px solid var(--border, #ddd);
}
.bsw-chatbot-input {
  flex: 1;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border, #ccc);
  border-radius: 8px;
  font: inherit;
}
.bsw-chatbot-send {
  padding: 0.5rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: #0b3d6e;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}
.bsw-chatbot-note {
  font-size: 0.68rem;
  color: var(--text-muted, #666);
  padding: 0 0.75rem 0.5rem;
}


/* Homepage layout polish */
.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding-top: 1.25rem;
  padding-bottom: 2rem;
}
@media (min-width: 960px) {
  .main-grid {
    grid-template-columns: minmax(0, 1.65fr) minmax(260px, 1fr);
    gap: 1.5rem;
    align-items: start;
  }
}
.primary,
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}
.primary > .card,
.sidebar > .card {
  margin-top: 0 !important; /* override inline leftovers */
}
.card-header h2,
.card-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.card-action {
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent, #0b3d6e);
  white-space: nowrap;
}
.card-action:hover { text-decoration: underline; }
.card-conditions .conditions-grid {
  margin: 0;
}
.resource-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
}
.resource-list li {
  margin: 0;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.resource-list li:last-child { border-bottom: none; }
.resource-list a {
  display: block;
  padding: 0.55rem 0;
  text-decoration: none;
  color: inherit;
}
.resource-list a:hover {
  color: var(--accent, #0b3d6e);
}
.nav-main a.nav-admin {
  opacity: 0.75;
  font-size: 0.92em;
}
.site-header .nav-main {
  flex-wrap: wrap;
  gap: 0.15rem 0.35rem;
}
.sidebar .card-body {
  font-size: 0.92rem;
}
/* Reduce visual noise on mobile nav */
@media (max-width: 720px) {
  .nav-main a.nav-admin { display: none; }
}


/* === Responsive: phone / tablet / desktop ===
   Phone:  max-width 639px
   Tablet: 640px – 1023px
   Desktop: 1024px+
*/
:root {
  --page-pad: 1.25rem;
}
.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--page-pad);
  padding-right: var(--page-pad);
  box-sizing: border-box;
}

/* Desktop default (1024+) */
@media (min-width: 1024px) {
  :root { --page-pad: 1.5rem; }
  .main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr);
    gap: 1.5rem;
    align-items: start;
  }
  .nav-main {
    display: flex;
    flex-wrap: wrap;
    max-width: min(720px, 58vw);
  }
  .nav-main a {
    font-size: 0.88rem;
    padding: 0.4rem 0.65rem;
  }
  .menu-toggle { display: none !important; }
  .conditions-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .footer-inner {
    display: grid;
    grid-template-columns: 1.4fr repeat(3, 1fr);
    gap: 1.5rem;
  }
  .bsw-chatbot {
    right: 1.25rem;
    bottom: 1.25rem;
  }
}

/* Tablet (640–1023) */
@media (min-width: 640px) and (max-width: 1023px) {
  :root { --page-pad: 1.15rem; }
  .main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.15rem;
  }
  /* On tablet: nav can wrap or use hamburger if crowded — use collapsible */
  .header-inner {
    flex-wrap: wrap;
  }
  .nav-main {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    order: 5;
    padding: 0.35rem 0 0.5rem;
  }
  .nav-main.open {
    display: flex;
  }
  .nav-main a {
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
  }
  .menu-toggle {
    display: block !important;
  }
  .conditions-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .footer-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
  }
  .footer-brand {
    grid-column: 1 / -1;
  }
  .card-header h2,
  .card-header h3 {
    font-size: 1.02rem;
  }
  .bsw-chatbot-panel {
    width: min(380px, calc(100vw - 2rem));
  }
}

/* Phone (<640) */
@media (max-width: 639px) {
  :root { --page-pad: 0.85rem; }
  .header-inner {
    padding: 0.65rem 0.85rem;
    gap: 0.5rem;
  }
  .logo {
    font-size: 0.98rem;
    gap: 0.45rem;
  }
  .logo-icon {
    width: 30px;
    height: 30px;
    font-size: 1rem;
  }
  .logo span:not(.logo-icon) {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nav-main {
    display: none;
    width: 100%;
    flex-direction: column;
    order: 10;
    background: rgba(0,0,0,0.12);
    margin: 0.25rem -0.15rem 0;
    padding: 0.4rem;
    border-radius: 10px;
  }
  .nav-main.open {
    display: flex;
  }
  .nav-main a {
    padding: 0.75rem 0.9rem;
    font-size: 0.95rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .menu-toggle {
    display: block !important;
    min-width: 44px;
    min-height: 44px;
  }
  .main-grid {
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
    padding-top: 0.85rem;
    padding-bottom: 5.5rem; /* room for floating chatbot */
  }
  .conditions-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
  }
  .condition-box {
    padding: 0.7rem 0.5rem;
  }
  .condition-box .value {
    font-size: 1.15rem;
  }
  .card {
    border-radius: 12px;
  }
  .card-header {
    padding: 0.75rem 0.9rem;
  }
  .card-body {
    padding: 0.85rem 0.9rem;
  }
  .card-header h2,
  .card-header h3 {
    font-size: 0.98rem;
  }
  .news-ticker {
    height: 32px;
  }
  .ticker-track span {
    font-size: 0.8rem;
    padding: 0 1.5rem;
  }
  .footer-inner {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }
  .footer-bottom {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    font-size: 0.78rem;
  }
  .obs-widget-grid,
  .obs-stats {
    grid-template-columns: 1fr 1fr !important;
  }
  .bsw-chatbot {
    right: 0.75rem;
    bottom: 0.75rem;
  }
  .bsw-chatbot-panel {
    width: calc(100vw - 1.5rem);
    max-height: min(70vh, 480px);
    right: 0;
  }
  .site-footer {
    padding-bottom: 1rem;
  }
  /* Touch-friendly forms/buttons on public pages */
  .btn {
    min-height: 44px;
  }
}

/* Very small phones */
@media (max-width: 379px) {
  .conditions-grid {
    grid-template-columns: 1fr 1fr;
  }
  .logo span:not(.logo-icon) {
    max-width: 36vw;
  }
}

/* Large desktop */
@media (min-width: 1280px) {
  .conditions-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* Print: hide chrome */
@media print {
  .site-header .nav-main,
  .menu-toggle,
  .theme-toggle,
  .bsw-chatbot,
  .news-ticker {
    display: none !important;
  }
}


/* Mobile nav panel */
.menu-toggle {
  display: none;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
}
.menu-toggle.is-open {
  background: rgba(255,255,255,0.22);
}
.menu-toggle .menu-icon-close { display: none; }
.menu-toggle.is-open .menu-icon-bars { display: none; }
.menu-toggle.is-open .menu-icon-close { display: inline; }

@media (max-width: 1023px) {
  .menu-toggle {
    display: inline-flex !important;
  }
  .header-inner {
    position: relative;
    flex-wrap: wrap;
    row-gap: 0.35rem;
  }
  .header-actions {
    margin-left: auto;
  }
  .nav-main {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    order: 20;
    flex-basis: 100%;
    max-width: none !important;
    gap: 0.2rem;
    margin: 0.35rem 0 0.15rem;
    padding: 0.4rem;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  }
  .nav-main.open {
    display: flex !important;
  }
  .nav-main a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    color: #fff;
  }
  .nav-main a:hover,
  .nav-main a:focus,
  .nav-main a.active {
    background: rgba(255,255,255,0.16);
    color: #fff;
  }
  body.nav-open {
    overflow: hidden;
  }
}

@media (max-width: 639px) {
  .logo span:not(.logo-icon) {
    font-size: 0.95rem;
  }
  .nav-main a {
    min-height: 52px;
    font-size: 1.05rem;
  }
}


/* Per-visitor widget layout (local only) */
.widget-layout-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 0.25rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-tertiary, rgba(0,0,0,0.04));
  border-radius: 8px;
}
.widget-layout-hint { flex: 1; min-width: 180px; }
.widget-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.widget-header h2,
.widget-header h3 {
  flex: 1;
  min-width: 8rem;
}
.widget-drag {
  cursor: grab;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.25rem 0.35rem;
  line-height: 1;
  border-radius: 4px;
}
.widget-drag:active { cursor: grabbing; }
.widget-drag:hover { background: rgba(0,0,0,0.06); color: var(--text-primary); }
.widget-accordion {
  border: 1px solid var(--border, #ddd);
  background: var(--bg-primary, #fff);
  color: var(--text-secondary);
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
}
.widget-accordion:hover { border-color: var(--accent, #0b3d6e); }
.widget-card.is-collapsed .widget-body { display: none !important; }
.widget-card.is-dragging {
  opacity: 0.55;
  outline: 2px dashed var(--accent, #0b3d6e);
}
.widget-card.drag-over {
  box-shadow: 0 0 0 2px var(--accent, #38bdf8);
}
.widget-move {
  display: none;
  gap: 0.2rem;
}
.widget-move button {
  border: 1px solid var(--border, #ddd);
  background: var(--bg-primary);
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.65rem;
  color: var(--text-muted);
}
@media (max-width: 1023px) {
  .widget-move { display: inline-flex; }
  .widget-drag { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .widget-card { transition: none; }
}


.space-shot.img-failed img {
  opacity: 0.35;
  object-fit: contain;
  background: repeating-linear-gradient(45deg, #222, #222 8px, #2a2a2a 8px, #2a2a2a 16px);
}
.space-shot.img-failed figcaption span::after {
  content: " (temporarily unavailable)";
}
