:root {
  --bg: #050810;
  --bg2: #0a0f1e;
  --card: #0d1225;
  --card-raised: #111835;
  --border: #1a2344;
  --border-glow: rgba(0, 229, 255, 0.15);
  --text: #f0f4fc;
  --text-bright: #ffffff;
  --text-dim: #7a8baa;
  --text-muted: #4a5a78;
  --orange: #ff9944;
  --orange-glow: rgba(255, 153, 68, 0.25);
  --cyan: #00e5ff;
  --cyan-glow: rgba(0, 229, 255, 0.2);
  --teal: #2ee0c0;
  --teal-glow: rgba(46, 224, 192, 0.2);
  --blue: #5599ff;
  --blue-glow: rgba(85, 153, 255, 0.2);
  --green: #30e888;
  --green-glow: rgba(48, 232, 136, 0.2);
  --amber: #f0a030;
  --amber-glow: rgba(240, 160, 48, 0.2);
  --red: #ff5068;
  --red-glow: rgba(255, 80, 104, 0.2);
  --mono: "JetBrains Mono", monospace;
  --font: "IBM Plex Sans", "IBM Plex Sans Thai", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(0, 229, 255, 0.04), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(46, 224, 192, 0.03), transparent);
}

/* ═══════════ HEADER ═══════════ */
.hdr {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 8, 16, 0.92);
  backdrop-filter: blur(20px);
  position: sticky; top: 0; z-index: 50;
  font-size: 0.85rem;
}
.hdr::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--teal), transparent);
  opacity: 0.4;
}

.hdr-left { display: flex; align-items: center; gap: 0.7rem; }
.hdr-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--orange), #ff6622);
  display: flex; align-items: center; justify-content: center;
  color: #000; font-weight: 900; font-size: 1rem;
  box-shadow: 0 0 16px var(--orange-glow);
}
.hdr-title { font-size: 1.05rem; font-weight: 700; color: var(--text-bright); line-height: 1.2; }
.hdr-sub { font-size: 0.7rem; color: var(--text-dim); }

.hdr-center { text-align: center; }
.hdr-time {
  font-family: var(--mono);
  font-size: 1.4rem; font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan-glow);
  letter-spacing: 0.06em;
}
.hdr-date { font-size: 0.7rem; color: var(--text-dim); display: block; }

.hdr-right { display: flex; align-items: center; gap: 0.5rem; }
.hdr-alert-btn {
  position: relative; background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center;
  justify-content: center; cursor: pointer; color: var(--text-dim); transition: all 0.2s;
}
.hdr-alert-btn:hover { border-color: var(--red); color: var(--red); }
.alert-badge {
  position: absolute; top: -4px; right: -4px; background: var(--red);
  color: #fff; font-size: 0.55rem; font-weight: 700; min-width: 16px; height: 16px;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  padding: 0 4px; font-family: var(--mono);
}
.hdr-alert-btn.has-alerts .alert-badge { display: flex; }
.hdr-alert-btn.has-alerts { color: var(--red); border-color: var(--red); animation: alertPulse 2s infinite; }
@keyframes alertPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 80, 104, 0); }
  50% { box-shadow: 0 0 8px rgba(255, 80, 104, 0.4); }
}
.hdr-online {
  display: flex; align-items: center; gap: 0.3rem; font-size: 0.65rem; color: var(--text-muted);
  font-family: var(--mono); cursor: default;
}
.online-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
  display: inline-block; animation: onlinePulse 2s infinite;
}
@keyframes onlinePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.online-count { min-width: 14px; text-align: center; }
.lang-pill {
  display: inline-flex; gap: 0.15rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: rgba(0,0,0,0.4); padding: 0.15rem;
}
.lang-pill a {
  color: var(--text-dim); text-decoration: none;
  font-size: 0.7rem; font-weight: 700; padding: 0.3rem 0.7rem;
  border-radius: 999px; letter-spacing: 0.06em; transition: all 0.2s;
}
.lang-pill a.act { background: var(--cyan); color: #050810; }
.lang-pill a:hover:not(.act) { color: var(--text-bright); }

/* ═══════════ View Switcher ═══════════ */
.view-switcher {
  display: inline-flex; gap: 0.2rem; padding: 0.2rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
}
.view-btn {
  display: flex; align-items: center; gap: 0.35rem;
  color: var(--text-dim); text-decoration: none; font-size: 0.68rem;
  font-weight: 700; letter-spacing: 0.06em;
  padding: 0.25rem 0.55rem; border-radius: 8px;
  transition: all 0.2s; cursor: pointer;
  background: transparent; border: none;
  font-family: var(--font);
}
.view-btn.is-active { background: var(--cyan); color: #050810; }
.view-btn:hover:not(.is-active) { color: var(--text); }

/* TV Button */
.btn-tv {
  display: flex; align-items: center; justify-content: center;
  gap: 0.3rem; padding: 0.3rem 0.6rem;
  border-radius: 8px; border: 1px solid var(--border);
  color: var(--text-dim); text-decoration: none;
  font-size: 0.68rem; font-weight: 700;
  transition: all 0.2s;
}
.btn-tv:hover { border-color: var(--amber); color: var(--amber); box-shadow: 0 0 10px var(--amber-glow); }

/* Cockpit Button */
.btn-cockpit {
  display: flex; align-items: center; justify-content: center;
  gap: 0.3rem; padding: 0.3rem 0.6rem;
  border-radius: 8px; border: 1px solid var(--border);
  color: var(--text-dim); text-decoration: none;
  font-size: 0.68rem; font-weight: 700;
  transition: all 0.2s;
}
.btn-cockpit:hover { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 10px var(--cyan-glow); }

/* ═══════════ CAMERA + ALERT BANNER ═══════════ */
.cam-banner {
  display: grid; grid-template-columns: 2fr 1fr; gap: 0.75rem;
  padding: 0.75rem 1.5rem;
}
.cam-box {
  border-radius: 14px; overflow: hidden; border: 1px solid var(--border);
  position: relative; background: #000;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.cam-box img { width: 100%; object-fit: cover; display: block; aspect-ratio: 4/3; height: auto; }
.cam-badge {
  position: absolute; top: 0.6rem; left: 0.6rem;
  display: flex; align-items: center; gap: 0.4rem;
  background: rgba(0,0,0,0.75); padding: 0.3rem 0.7rem;
  border-radius: 999px; font-size: 0.72rem; font-weight: 600; color: var(--text-bright);
  border: 1px solid rgba(48, 232, 136, 0.3);
}
.cam-badge-right {
  position: absolute; top: 0.6rem; right: 0.6rem;
  display: flex; align-items: center; gap: 0.4rem;
  background: rgba(0,0,0,0.75); padding: 0.3rem 0.7rem;
  border-radius: 999px; font-size: 0.72rem; font-weight: 600; color: var(--text-bright);
  border: 1px solid rgba(48, 232, 136, 0.3);
  z-index: 10;
}
.cam-badge-right span:last-child { display: none; }
.cam-badge-right::after {
  content: "LIVE";
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-bright);
}
.cam-pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(48,232,136,0.5); }
  50% { opacity: 0.6; box-shadow: 0 0 0 8px rgba(48,232,136,0); }
}

.alert-box {
  border-radius: 14px; border: 1px solid var(--border);
  background: var(--card); padding: 0.85rem 1rem;
  display: flex; flex-direction: column; gap: 0.45rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
.alert-box h3 {
  font-size: 0.65rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--teal); font-weight: 700;
}
.alert-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.25rem;
}
.alert-item { text-align: center; padding: 0.3rem; border-radius: 6px; background: rgba(0,0,0,0.2); }
.alert-label { font-size: 0.58rem; color: var(--text-dim); display: block; text-transform: uppercase; letter-spacing: 0.06em; }
.alert-value { font-family: var(--mono); font-size: 1.15rem; font-weight: 700; color: var(--text-bright); }
.alert-unit { font-size: 0.58rem; color: var(--text-muted); }
.alert-updated {
  display: flex; align-items: center; gap: 0.3rem;
  font-size: 0.6rem; color: var(--text-muted); margin-top: auto;
  padding-top: 0.3rem;
}
.upd-dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--teal);
  box-shadow: 0 0 6px var(--teal-glow);
  animation: pulse 2s ease-in-out infinite;
}

/* ═══════════ AI SUMMARY BANNER ═══════════ */
.ai-summary-banner {
  padding: 0.75rem 1.5rem;
}
.ai-summary-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.06), rgba(46, 224, 192, 0.03));
  border: 1px solid rgba(0, 229, 255, 0.2);
  box-shadow: 0 4px 24px rgba(0, 229, 255, 0.08);
  position: relative;
  overflow: hidden;
}
.ai-summary-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: linear-gradient(180deg, var(--cyan), var(--teal), var(--green));
  border-radius: 0 2px 2px 0;
}
.ai-summary-icon {
  font-size: 2rem;
  flex-shrink: 0;
}
.ai-summary-content {
  flex: 1;
  min-width: 0;
}
.ai-summary-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.ai-summary-text {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-bright);
  margin: 0;
}
.ai-summary-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--mono);
  flex-shrink: 0;
}

/* Status badge */
.ai-status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  transition: all 0.3s;
}
.ai-update-time {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-family: var(--mono);
  white-space: nowrap;
}
.ai-status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
  animation: pulse 2s ease-in-out infinite;
}
.ai-status-dot.error {
  background: var(--red);
  box-shadow: 0 0 8px var(--red-glow);
  animation: pulse 1s ease-in-out infinite;
}
.ai-status-dot.checking {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
  animation: pulse 0.5s ease-in-out infinite;
}
.ai-status-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

/* ═══════════ WIDGET GRID ═══════════ */
.widget-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  padding: 0 1.5rem 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

.widget {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  padding: 1.2rem;
  position: relative;
  transition: all 0.3s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  overflow: hidden;
}
.widget::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0; transition: opacity 0.3s;
}
.widget:hover { border-color: rgba(0, 229, 255, 0.2); box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
.widget:hover::before { opacity: 0.6; }

.widget h2 {
  font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 700; margin-bottom: 0.85rem;
  display: flex; align-items: center; gap: 0.4rem;
  flex-wrap: wrap;
}

/* History button */
.wdg-hist {
  position: absolute; top: 0.85rem; right: 0.85rem;
  background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-dim); cursor: pointer;
  font-size: 0.85rem; padding: 0.2rem 0.4rem;
  transition: all 0.2s; line-height: 1;
}
.wdg-hist:hover { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 12px var(--cyan-glow); background: rgba(0, 229, 255, 0.05); }

/* ═══════════ OUTDOOR WIDGET ═══════════ */
.outdoor-body { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.gauge-wrap { flex-shrink: 0; }
.temp-gauge { width: 190px; height: 190px; }
.gauge-bg { fill: none; stroke: #111830; stroke-width: 10; }
.gauge-fill { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1s ease; filter: drop-shadow(0 0 6px var(--cyan-glow)); }
.gauge-value { font-family: var(--mono); font-size: 36px; font-weight: 700; fill: var(--text-bright); text-shadow: 0 0 10px rgba(255,255,255,0.1); }
.gauge-unit { font-family: var(--mono); font-size: 14px; fill: var(--text-dim); }
.gauge-sub { font-family: var(--mono); font-size: 11px; fill: var(--text-muted); }

.outdoor-meta { flex: 1; min-width: 160px; }
.meta-row {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(26, 35, 68, 0.5);
}
.meta-label { font-size: 0.62rem; color: var(--text-muted); text-transform: uppercase; width: 60px; flex-shrink: 0; letter-spacing: 0.04em; }
.meta-val { font-family: var(--mono); font-size: 1.05rem; font-weight: 600; color: var(--text-bright); }
.meta-hi { color: var(--red) !important; }
.meta-lo { color: var(--blue) !important; }
.meta-sep { color: var(--text-muted); margin: 0 0.2rem; font-weight: 400; }
.meta-unit { font-size: 0.65rem; color: var(--text-muted); margin-left: 0.1rem; }

.compass-wrap {
  display: flex; align-items: center; gap: 1rem;
  margin-top: 0.85rem; padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.compass-svg { width: 120px; height: 120px; flex-shrink: 0; }
.compass-info { flex: 1; }
.c-row { display: flex; justify-content: space-between; padding: 0.3rem 0; }
.c-row span:first-child { font-size: 0.65rem; color: var(--text-dim); font-weight: 600; }
.c-val { font-family: var(--mono); font-size: 0.95rem; font-weight: 700; color: var(--orange); }

/* ═══════════ INDOOR WIDGET ═══════════ */
.indoor-body { display: flex; flex-direction: column; gap: 0.7rem; }
.dual-ring { display: flex; gap: 1.2rem; justify-content: center; }
.ring-svg { width: 130px; height: 130px; }
.ring-bg { fill: none; stroke: #111830; stroke-width: 8; }
.ring-fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.ring-val { font-family: var(--mono); font-size: 22px; font-weight: 700; fill: var(--text-bright); }
.ring-unit { font-family: var(--mono); fill: var(--text-dim); }
.ring-label { fill: var(--text-muted); }

.lightning-block {
  border: 1px solid var(--border); border-radius: 10px; padding: 0.65rem 0.8rem;
  background: rgba(240, 160, 48, 0.03);
}
.lightning-block h3 {
  font-size: 0.7rem; color: var(--amber); font-weight: 700; margin-bottom: 0.45rem;
}
.ln-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; }
.ln-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; }
.ln-item { display: flex; flex-direction: column; padding: 0.25rem 0; }
.ln-item.full { grid-column: 1 / -1; }
.ln-label { font-size: 0.58rem; color: var(--text-muted); text-transform: uppercase; }
.ln-val { font-family: var(--mono); font-size: 0.95rem; font-weight: 600; color: var(--amber); }

.leaf-wet-block {
  border: 1px solid var(--border); border-radius: 10px; padding: 0.65rem 0.8rem;
  background: rgba(48, 232, 136, 0.03);
}
.leaf-wet-block h3 {
  font-size: 0.7rem; color: var(--green); font-weight: 700; margin-bottom: 0.45rem;
}
.leaf-wet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; }
.lw-item { display: flex; flex-direction: column; padding: 0.25rem 0; }
.lw-label { font-size: 0.58rem; color: var(--text-muted); text-transform: uppercase; }
.lw-val { font-family: var(--mono); font-size: 0.95rem; font-weight: 600; color: var(--green); }

.sys-block {
  border: 1px solid var(--border); border-radius: 10px; padding: 0.4rem 0.8rem;
  display: flex; gap: 2rem; background: rgba(0,0,0,0.2);
}
.sys-row { display: flex; justify-content: space-between; flex: 1; font-size: 0.68rem; }
.sys-row span:first-child { color: var(--text-dim); font-weight: 600; }
.sys-val { font-family: var(--mono); font-weight: 600; color: var(--teal); }

/* ═══════════ SUN & MOON WIDGET ═══════════ */
.sunmoon-body { display: flex; flex-direction: column; gap: 0.7rem; }
.sun-arc-wrap { position: relative; }
.sun-arc-svg { width: 100%; height: auto; }
.sun-arc-path { stroke: var(--orange); }
.sun-dot { fill: var(--orange); }
.sun-times {
  display: flex; justify-content: space-between;
  font-size: 0.78rem; color: var(--text-dim); margin-top: 0.2rem;
  font-weight: 600;
}

.solar-uv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.suv-card {
  text-align: center; padding: 0.6rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: rgba(0,0,0,0.2);
}
.suv-label { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; display: block; letter-spacing: 0.04em; }
.suv-value { font-family: var(--mono); font-size: 1.2rem; font-weight: 700; display: block; color: var(--text-bright); }
.suv-unit { font-size: 0.58rem; color: var(--text-muted); }
.suv-tag {
  display: inline-block; font-size: 0.58rem; padding: 0.15rem 0.5rem;
  border-radius: 999px; margin-top: 0.25rem; font-weight: 700;
}

/* ═══════════ RAIN WIDGET ═══════════ */
.rain-body { display: flex; flex-direction: column; gap: 0.5rem; }
.rain-hero { text-align: center; padding: 0.4rem 0; }
.rain-val { font-family: var(--mono); font-size: 2.8rem; font-weight: 700; color: var(--text-bright); }
.rain-unit { font-size: 0.75rem; color: var(--text-muted); margin-left: 0.2rem; }
.rain-table { display: flex; flex-direction: column; gap: 0.2rem; }
.rt-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.45rem 0.6rem; border-radius: 6px;
  background: rgba(0,0,0,0.15);
  border-bottom: 1px solid rgba(26, 35, 68, 0.4);
}
.rt-row:last-child { border-bottom: none; }
.rt-label { font-size: 0.7rem; color: var(--text-dim); font-weight: 600; }
.rt-val { font-family: var(--mono); font-size: 0.95rem; font-weight: 600; color: var(--text-bright); }
.rt-unit { font-size: 0.58rem; color: var(--text-muted); }

/* ═══════════ BAROMETER WIDGET ═══════════ */
.baro-body { display: flex; flex-direction: column; gap: 0.4rem; }
.baro-gauge-svg { width: 100%; height: auto; }
.baro-arc-bg { fill: none; stroke: #111830; stroke-width: 10; }
.baro-arc-fill { stroke-width: 10; stroke-linecap: round; filter: drop-shadow(0 0 6px var(--teal-glow)); }
.baro-digital { text-align: center; padding: 0.4rem 0; }
.baro-d-val { font-family: var(--mono); font-size: 2.2rem; font-weight: 700; color: var(--text-bright); }
.baro-d-unit { font-size: 0.68rem; color: var(--text-muted); }
.baro-trend {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  margin-top: 0.2rem;
}
.baro-t-label { font-size: 0.6rem; color: var(--text-muted); }
.baro-t-val { font-size: 0.7rem; font-weight: 700; padding: 0.15rem 0.6rem; border-radius: 999px; color: var(--text-bright); }
.baro-detail { border-top: 1px solid var(--border); padding-top: 0.3rem; }
.bd-row { display: flex; justify-content: space-between; font-size: 0.68rem; }
.bd-l { color: var(--text-dim); font-weight: 600; }
.bd-v { font-family: var(--mono); color: var(--teal); font-weight: 600; }

/* ═══════════ AI ANALYSIS WIDGET ═══════════ */
.ai-body { display: flex; flex-direction: column; gap: 0.6rem; }
.ai-status-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.3rem 0.6rem; border-radius: 8px;
  background: rgba(0,0,0,0.25); border: 1px solid var(--border);
}
.ai-status-text {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; display: flex; align-items: center; gap: 0.4rem;
}
.ai-status-indicator {
  display: inline-flex; align-items: center; gap: 0.35rem;
}
.ai-status-indicator.live::before {
  background: var(--green);
  box-shadow: 0 0 6px var(--green-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}
.ai-status-indicator.cached::before {
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan-glow);
}
.ai-status-indicator.alert::before {
  background: var(--red);
  box-shadow: 0 0 8px var(--red-glow);
  animation: pulse 1s ease-in-out infinite;
}
.ai-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
  transition: all 0.3s;
}
.ai-dot.connected {
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}
.ai-dot.unavailable {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
}
.ai-dot.error {
  background: var(--red);
  box-shadow: 0 0 8px var(--red-glow);
}
.ai-dot.idle {
  background: var(--text-muted);
}
.ai-dot.connecting {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
  animation: pulse-dot 0.5s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 4px var(--green-glow); }
  50% { box-shadow: 0 0 12px var(--green-glow); }
}

.ai-status-time { font-size: 0.6rem; color: var(--text-muted); font-family: var(--mono); }

.ai-text-wrap {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.04), rgba(46, 224, 192, 0.02));
  border: 1px solid rgba(0, 229, 255, 0.12);
  position: relative;
  overflow: hidden;
}
.ai-text-wrap::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--cyan), var(--teal));
  border-radius: 0 2px 2px 0;
}
.ai-text {
  font-size: 0.92rem; font-weight: 500; line-height: 1.6;
  color: var(--text-bright); margin: 0;
}
.ai-text .ai-loading {
  color: var(--text-dim); font-style: italic;
  animation: ai-blink 1.5s ease-in-out infinite;
}
@keyframes ai-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.ai-refresh {
  align-self: flex-end;
  background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-dim); cursor: pointer;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  transition: all 0.3s;
}
.ai-logs-btn {
  align-self: flex-end;
  background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-dim); cursor: pointer;
  padding: 0.3rem 0.7rem; display: flex; align-items: center; gap: 0.3rem;
  font-size: 0.7rem; transition: all 0.3s;
}
.ai-logs-btn:hover {
  border-color: var(--amber); color: var(--amber);
  box-shadow: 0 0 12px rgba(240, 160, 48, 0.15);
}
.view-logs-btn {
  margin-left: auto;
  background: rgba(240, 160, 48, 0.1);
  border: 1px solid var(--amber);
  border-radius: 6px;
  color: var(--amber);
  cursor: pointer;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  transition: all 0.2s;
  font-family: var(--mono);
  white-space: nowrap;
}
.view-logs-btn:hover {
  background: rgba(240, 160, 48, 0.2);
  box-shadow: 0 0 10px rgba(240, 160, 48, 0.3);
}
.ai-refresh:hover {
  border-color: var(--cyan); color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
  transform: rotate(90deg);
}
.ai-refresh:active { transform: rotate(90deg) scale(0.9); }
.ai-refresh.spinning svg {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ═══════════ AI TRENDS WIDGET ═══════════ */
.trends-body { display: flex; flex-direction: column; gap: 0.6rem; position: relative; }
.trend-indicator {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.8rem; border-radius: 10px;
  background: rgba(68, 136, 255, 0.06); border: 1px solid rgba(68, 136, 255, 0.15);
}
.trend-icon { font-size: 1.8rem; flex-shrink: 0; }
.trend-label {
  font-size: 0.85rem; font-weight: 700; color: var(--cyan);
  letter-spacing: 0.04em;
}
.trend-details { padding: 0.4rem 0; }
.trend-desc {
  font-size: 0.82rem; color: var(--text-dim); line-height: 1.5; margin: 0;
}
.trend-prediction {
  padding: 0.7rem 0.9rem; border-radius: 10px;
  background: linear-gradient(135deg, rgba(68, 136, 255, 0.06), rgba(46, 224, 192, 0.03));
  border: 1px solid rgba(68, 136, 255, 0.12);
}
.pred-label {
  font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.1em; font-weight: 700; display: block; margin-bottom: 0.3rem;
}
.pred-text {
  font-size: 0.9rem; font-weight: 500; line-height: 1.5;
  color: var(--text-bright); margin: 0;
}
.ai-sentence {
  position: relative; padding-left: 0.75rem;
}
.ai-sentence::before {
  content: ''; position: absolute; left: 0; top: 0.2em; bottom: 0.2em;
  width: 2px; background: linear-gradient(180deg, var(--cyan), var(--teal));
  border-radius: 1px;
}
.ai-time-badge {
  font-size: 0.68rem;
  color: var(--amber);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
  padding: 0.2rem 0.5rem;
  background: rgba(240, 160, 48, 0.1);
  border-radius: 4px;
  display: inline-block;
}

/* ═══════════ AI SUGGESTIONS WIDGET ═══════════ */
.suggestions-body { display: flex; flex-direction: column; gap: 0.5rem; position: relative; }
.sugg-card {
  padding: 0.75rem 0.85rem; border-radius: 10px;
  background: rgba(48, 232, 136, 0.04); border: 1px solid rgba(48, 232, 136, 0.12);
}
.sugg-header {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem;
}
.sugg-icon { font-size: 1.1rem; }
.sugg-title {
  font-size: 0.72rem; font-weight: 700; color: var(--teal);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.sugg-text {
  font-size: 0.88rem; color: var(--text-bright); line-height: 1.5; margin: 0;
}

/* ═══════════ AI ALERTS WIDGET ═══════════ */
.alerts-body { display: flex; flex-direction: column; gap: 0.6rem; }
.alert-severity { text-align: center; }
.severity-badge {
  display: inline-block; padding: 0.35rem 1rem;
  border-radius: 999px; font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.alert-list {
  display: flex; flex-direction: column; gap: 0.35rem;
  max-height: 240px; overflow-y: auto;
}
.alert-item-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.75rem; border-radius: 8px;
  background: rgba(255, 96, 64, 0.06); border: 1px solid rgba(255, 96, 64, 0.15);
  font-size: 0.8rem; color: var(--text-bright);
}
.alert-ico { font-size: 1.1rem; flex-shrink: 0; }
.alert-msg { flex: 1; }
.no-alerts {
  text-align: center; color: var(--text-muted); font-size: 0.85rem;
  font-style: italic; padding: 1rem 0;
}
.alert-llm {
  padding: 0.7rem 0.9rem; border-radius: 10px;
  background: linear-gradient(135deg, rgba(255, 96, 64, 0.08), rgba(240, 160, 48, 0.04));
  border: 1px solid rgba(255, 96, 64, 0.2);
}
.alert-warning {
  font-size: 0.92rem; font-weight: 600; line-height: 1.5;
  color: var(--red); display: block; margin: 0;
}
.ai-error { color: var(--red); font-style: italic; }

/* ═══════════ MODAL ═══════════ */
.modal { display: none; position: fixed; inset: 0; z-index: 100; }
.modal.show { display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(6px); }
.modal-content {
  position: relative; background: var(--card);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 1.5rem; width: min(740px, 92vw);
  z-index: 1; box-shadow: 0 16px 64px rgba(0,0,0,0.6);
}
.modal-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 50%;
  width: 30px; height: 30px; color: var(--text-dim); font-size: 1.2rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.modal-close:hover { border-color: var(--red); color: var(--red); }
.modal-content h2 { font-size: 0.85rem; color: var(--text-bright); margin-bottom: 0.75rem; font-weight: 700; }
.modal-content canvas { width: 100%; height: 250px; border-radius: 10px; display: block; }
.zoom-content { background: transparent; border: none; border-radius: 0; }
.zoom-content img { max-width: 95vw; max-height: 95vh; object-fit: contain; border-radius: 0; cursor: zoom-in; }
.zoom-content .modal-close { position: fixed; top: 1rem; right: 1rem; background: rgba(0,0,0,0.6); border-color: rgba(255,255,255,0.3); color: #fff; font-size: 1.5rem; width: 40px; height: 40px; z-index: 101; }

/* ═══════════ AI LOGS MODAL ═══════════ */
.ai-logs-content { max-height: 80vh; overflow: hidden; display: flex; flex-direction: column; }
.ai-logs-content h2 { flex-shrink: 0; }
.ai-logs-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; flex-shrink: 0; }
.ai-logs-count { font-size: 0.75rem; color: var(--text-dim); }
.ai-logs-refresh { background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 8px; color: var(--text-dim); padding: 0.3rem 0.7rem; cursor: pointer; font-size: 0.75rem; display: flex; align-items: center; gap: 0.3rem; transition: all 0.2s; }
.ai-logs-refresh:hover { border-color: var(--teal); color: var(--teal); }
.ai-cache-clear-btn { background: rgba(255, 80, 104, 0.15); border: 1px solid var(--red); border-radius: 8px; color: var(--red); padding: 0.3rem 0.7rem; cursor: pointer; font-size: 0.75rem; transition: all 0.2s; font-family: var(--mono); font-weight: 600; }
.ai-cache-clear-btn:hover { background: rgba(255, 80, 104, 0.3); }
.ai-logs-table-wrap { overflow-y: auto; flex: 1; max-height: 60vh; }
.ai-logs-table { width: 100%; border-collapse: collapse; font-size: 0.7rem; }
.ai-logs-table thead { position: sticky; top: 0; z-index: 1; }
.ai-logs-table th { background: var(--card-raised); color: var(--text-dim); padding: 0.5rem; text-align: left; font-weight: 600; border-bottom: 1px solid var(--border); }
.ai-logs-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); color: var(--text-dim); font-family: var(--mono); }
.ai-logs-table tr:hover td { background: rgba(46, 224, 192, 0.03); color: var(--text); }
.ai-logs-table .lang-badge { display: inline-block; padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.65rem; font-weight: 700; }
.ai-logs-table .lang-th { background: rgba(255, 153, 68, 0.15); color: var(--orange); }
.ai-logs-table .lang-en { background: rgba(85, 153, 255, 0.15); color: var(--blue); }
.ai-logs-table .status-success { color: var(--green); }
.ai-logs-table .status-cached { color: var(--amber); }
.ai-logs-table .status-failed, .ai-logs-table .status-error { color: var(--red); }
.ai-logs-table .detail-text { max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 1000px) {
  .cam-banner { grid-template-columns: 1fr; }
  .widget-grid { grid-template-columns: 1fr; }
  .widget { max-width: none; }
  .outdoor-body { flex-direction: column; align-items: center; }
  .gauge-wrap { flex: none; }
  .temp-gauge { width: 170px; height: 170px; }
  .outdoor-meta { min-width: 0; width: 100%; }
  .compass-wrap { flex-direction: row; }
}

@media (max-width: 640px) {
  .hdr { flex-wrap: wrap; gap: 0.3rem; justify-content: center; padding: 0.5rem 0.75rem; }
  .hdr-center { order: -1; width: 100%; text-align: center; }
  .hdr-right { width: 100%; flex-wrap: wrap; justify-content: center; gap: 0.3rem; }
  .hdr-right .btn-tv,
  .hdr-right .btn-cockpit { padding: 0.25rem 0.45rem; font-size: 0.62rem; }
  .hdr-time { font-size: 1.2rem; }
  .cam-banner { padding: 0.5rem; }
  .widget-grid { padding: 0 0.6rem 1.5rem; gap: 0.7rem; }
  .widget { padding: 1rem; }
  .gauge-wrap { flex: none; }
  .temp-gauge { width: 155px; height: 155px; }
  .gauge-value { font-size: 28px; }
  .alert-grid { grid-template-columns: repeat(2, 1fr); }
  .solar-uv-grid { grid-template-columns: 1fr; }
  .dual-ring { justify-content: center; }
  .ring-svg { width: 110px; height: 110px; }
  .rain-val { font-size: 2.2rem; }
  .compass-wrap { flex-direction: column; }
  .compass-svg { width: 100px; height: 100px; }
  .baro-d-val { font-size: 1.8rem; }
}
