:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg-main: #060b14;
  --bg-card: rgba(15, 23, 42, 0.72);
  --bg-card-hover: rgba(26, 38, 66, 0.85);
  --border-line: rgba(56, 189, 248, 0.16);
  --border-glow: rgba(56, 189, 248, 0.45);
  
  --primary-cyan: #38bdf8;
  --primary-blue: #2563eb;
  --accent-purple: #818cf8;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --color-ok: #10b981;
  --color-warn: #f59e0b;
  --color-alert: #f43f5e;
  
  --glow-top: #0284c7;
  --glow-bottom: #4f46e5;
  --btn-action-bg: linear-gradient(135deg, #0284c7, #0369a1);
  --btn-action-hover: linear-gradient(135deg, #0369a1, #0284c7);
  --btn-action-shadow: rgba(2, 132, 199, 0.35);
  --font-sans: 'Outfit', 'Inter', 'Noto Sans TC', system-ui, -apple-system, sans-serif;
}

/* 淺色主題 (Light Mode) */
[data-theme="light"] {
  color-scheme: light;
  --bg-main: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #ffffff;
  --border-line: rgba(148, 163, 184, 0.35);
  --border-glow: rgba(2, 132, 199, 0.4);
  
  --primary-cyan: #0284c7;
  --primary-blue: #0369a1;
  --accent-purple: #6366f1;
  
  --text-main: #0f172a;
  --text-muted: #334155;
  --text-dim: #64748b;
  
  --color-ok: #059669;
  --color-warn: #d97706;
  --color-alert: #e11d48;
  
  --glow-top: #bae6fd;
  --glow-bottom: #c7d2fe;
  --btn-action-bg: linear-gradient(135deg, #0284c7, #0369a1);
  --btn-action-hover: linear-gradient(135deg, #0369a1, #0284c7);
  --btn-action-shadow: rgba(2, 132, 199, 0.25);
}

/* 現代明亮 (Clean Light) 專屬高對比適配 (徹底解決更換主題看不見溫度的問題) */
[data-theme="light"] .station-name,
[data-theme="light"] .section-title,
[data-theme="light"] .sensor-name,
[data-theme="light"] .reading-col .num,
[data-theme="light"] .metric-val span,
[data-theme="light"] .meas-digits strong,
[data-theme="light"] .temperature,
[data-theme="light"] .humidity,
[data-theme="light"] #avg-temp,
[data-theme="light"] #avg-hum,
[data-theme="light"] #outdoor-temp,
[data-theme="light"] #outdoor-hum,
[data-theme="light"] #outdoor-wind,
[data-theme="light"] .pin-readings {
  color: #0f172a !important;
}

[data-theme="light"] .weather-wind-detail,
[data-theme="light"] #outdoor-wind-detail {
  color: #0284c7 !important;
  font-weight: 800 !important;
}

[data-theme="light"] .delta-val,
[data-theme="light"] #delta-t-display,
[data-theme="light"] .delta-num {
  color: #0284c7 !important;
  font-weight: 800 !important;
}

[data-theme="light"] .delta-subtext {
  color: #334155 !important;
  font-weight: 700 !important;
}

[data-theme="light"] .advisor-pill,
[data-theme="light"] #advisor-badge {
  background: #fef3c7 !important;
  color: #92400e !important;
  border: 1px solid #f59e0b !important;
  font-weight: 800 !important;
}

[data-theme="light"] .weather-card {
  background: linear-gradient(135deg, rgba(224, 242, 254, 0.95), rgba(255, 255, 255, 0.95)) !important;
  border-color: rgba(56, 189, 248, 0.5) !important;
}
[data-theme="light"] .indoor-card {
  background: linear-gradient(135deg, rgba(237, 233, 254, 0.95), rgba(255, 255, 255, 0.95)) !important;
  border-color: rgba(168, 85, 247, 0.4) !important;
}
[data-theme="light"] .advisor-card {
  background: linear-gradient(135deg, rgba(250, 232, 255, 0.95), rgba(255, 255, 255, 0.95)) !important;
  border-color: rgba(216, 180, 254, 0.5) !important;
}
[data-theme="light"] .health-card {
  background: linear-gradient(135deg, rgba(220, 252, 231, 0.95), rgba(255, 255, 255, 0.95)) !important;
  border-color: rgba(134, 239, 172, 0.5) !important;
}

[data-theme="light"] .measurement,
[data-theme="light"] .metric-box,
[data-theme="light"] .advisor-delta-bar {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
}

[data-theme="light"] .meas-label,
[data-theme="light"] .metric-label,
[data-theme="light"] .delta-label,
[data-theme="light"] .reading-col .label,
[data-theme="light"] .meas-digits small,
[data-theme="light"] .metric-val small,
[data-theme="light"] .reading-col .unit {
  color: #334155 !important;
  font-weight: 700 !important;
}

[data-theme="light"] .advisor-text,
[data-theme="light"] #advisor-advice {
  color: #0f172a !important;
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  border-left: 4px solid #0284c7 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

[data-theme="light"] .advisor-text *,
[data-theme="light"] #advisor-advice * {
  color: #1e293b !important;
}

[data-theme="light"] .advisor-title {
  color: #0f172a !important;
  font-weight: 800 !important;
}

[data-theme="light"] .advisor-desc {
  color: #334155 !important;
  font-weight: 600 !important;
}

[data-theme="light"] .advisor-desc b {
  color: #0f172a !important;
  font-weight: 800 !important;
}

[data-theme="light"] #hub-status-text {
  color: #065f46 !important;
  font-weight: 800 !important;
}

[data-theme="light"] #network-badge {
  color: #065f46 !important;
  font-weight: 800 !important;
}

[data-theme="light"] #hub-wifi-name {
  background: #e0f2fe !important;
  color: #0369a1 !important;
  border-color: #7dd3fc !important;
  font-weight: 700 !important;
}

[data-theme="light"] .health-info-box p,
[data-theme="light"] .health-info-box span,
[data-theme="light"] #hub-last-seen {
  color: #475569 !important;
  font-weight: 500 !important;
}

[data-theme="light"] .health-num {
  color: #059669 !important;
}

[data-theme="light"] .classroom-layout-card {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .room-boundary {
  background: #f8fafc !important;
  border-color: #94a3b8 !important;
}

[data-theme="light"] .pin-card {
  background: rgba(255, 255, 255, 0.96) !important;
  border-color: #0284c7 !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12) !important;
}
[data-theme="light"] .pin-name {
  color: #475569 !important;
}
[data-theme="light"] .pin-temp {
  color: #0284c7 !important;
}
[data-theme="light"] .pin-hum {
  color: #7c3aed !important;
}

[data-theme="light"] .chart-section {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06) !important;
}
[data-theme="light"] .canvas-wrapper {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}
[data-theme="light"] .chart-controls {
  background: #e2e8f0 !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .tab-btn {
  color: #475569 !important;
}
[data-theme="light"] .tab-btn.active {
  background: #0284c7 !important;
  color: #ffffff !important;
}

/* Light: legend-bar */
[data-theme="light"] .legend-bar {
  background: rgba(226, 232, 240, 0.8) !important;
  border-color: rgba(148, 163, 184, 0.25) !important;
  color: #475569 !important;
}

/* Light: metric-box inside cards */
[data-theme="light"] .metric-box {
  background: rgba(241, 245, 249, 0.9) !important;
  border-color: rgba(148, 163, 184, 0.2) !important;
}

/* Light: sensor card measurement bar */
[data-theme="light"] .meas-bar {
  background: rgba(148, 163, 184, 0.2) !important;
}

/* Light: sensor card footer */
[data-theme="light"] .sensor-card-footer {
  border-top-color: rgba(148, 163, 184, 0.2) !important;
  color: #059669 !important;
}

/* Light: sensor card alert & stale state */
[data-theme="light"] .sensor-card.alert .sensor-card-footer { color: #e11d48 !important; }
[data-theme="light"] .sensor-card.stale .sensor-card-footer { color: #d97706 !important; }

/* Light: comfort pill */
[data-theme="light"] .comfort-pill {
  background: rgba(5, 150, 105, 0.1) !important;
  border-color: rgba(5, 150, 105, 0.3) !important;
  color: #065f46 !important;
}

/* Light: sensor status badge */
[data-theme="light"] .sensor-status-badge {
  background: rgba(5, 150, 105, 0.08) !important;
  border-color: rgba(5, 150, 105, 0.25) !important;
  color: #065f46 !important;
}
[data-theme="light"] .sensor-card.alert .sensor-status-badge {
  background: rgba(225, 29, 72, 0.08) !important;
  border-color: rgba(225, 29, 72, 0.25) !important;
  color: #be123c !important;
}
[data-theme="light"] .sensor-card.stale .sensor-status-badge {
  background: rgba(217, 119, 6, 0.08) !important;
  border-color: rgba(217, 119, 6, 0.25) !important;
  color: #92400e !important;
}

/* Light: measurement container */
[data-theme="light"] .measurement {
  background: rgba(241, 245, 249, 0.9) !important;
  border-color: rgba(148, 163, 184, 0.2) !important;
}

/* Light: alert banner */
[data-theme="light"] .alert-banner {
  background: rgba(217, 119, 6, 0.07) !important;
  border-color: rgba(217, 119, 6, 0.25) !important;
  color: #92400e !important;
}

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

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(14, 116, 144, 0.25) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(30, 58, 138, 0.22) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(15, 23, 42, 0.5) 0px, transparent 100%);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

[data-theme="light"] body {
  background-image: 
    radial-gradient(at 0% 0%, rgba(224, 242, 254, 0.8) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(224, 231, 255, 0.8) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(248, 250, 252, 0.9) 0px, transparent 100%);
}


/* 氛圍背景光點 */
.bg-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(120px);
  z-index: 0;
  opacity: 0.35;
}
.bg-glow.top-left {
  top: -150px;
  left: -150px;
  background: radial-gradient(circle, var(--glow-top), transparent 70%);
}
.bg-glow.bottom-right {
  bottom: -150px;
  right: -150px;
  background: radial-gradient(circle, var(--glow-bottom), transparent 70%);
}

.app-container {
  width: min(1200px, 92vw);
  margin: 0 auto;
  padding: 36px 0 80px;
  position: relative;
  z-index: 1;
}

/* 頂部導航列 */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  padding-bottom: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 30px;
}

[data-theme="light"] .navbar {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-cyan);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--primary-cyan);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--primary-cyan);
  animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.brand-title {
  font-size: clamp(1.9rem, 3.8vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

[data-theme="light"] .brand-title {
  background: linear-gradient(135deg, #0f172a 30%, #334155 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
}

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

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

[data-theme="light"] .status-pill {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
}

.status-indicator {
  width: 8px;
  height: 8px;
  background: var(--color-ok);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--color-ok);
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--btn-action-bg);
  color: #fff;
  border: 1px solid var(--border-glow);
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px var(--btn-action-shadow);
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--btn-action-shadow);
  background: var(--btn-action-hover);
}

.btn-action:disabled {
  opacity: 0.75;
  cursor: wait;
  transform: none;
}

.btn-action.is-loading .icon-refresh {
  animation: spin-refresh 0.75s linear infinite;
}

@keyframes spin-refresh {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 深淺雙主題切換按鈕 */
.btn-theme {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-theme:hover {
  transform: translateY(-1px);
}

[data-theme="light"] .btn-theme {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06) !important;
}

[data-theme="light"] .btn-theme:hover {
  background: #f1f5f9 !important;
  border-color: #0284c7 !important;
  color: #0284c7 !important;
}

.btn-secondary {
  text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

[data-theme="light"] .btn-secondary {
  background: #e2e8f0;
  color: #1e293b;
  border: 1px solid #cbd5e1;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

[data-theme="light"] .btn-secondary:hover {
  background: #cbd5e1;
  color: #0f172a;
}

/* 示範/警告橫幅 (未觸發或隱藏時絕對不佔位) */
[hidden],
.alert-banner[hidden],
.alert-banner:empty {
  display: none !important;
}

.alert-banner {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 24px;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 核心指標總覽 (4大卡片 2x2 對稱完美佈局) */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

@media (max-width: 900px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }
}

.overview-card {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.overview-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(2, 132, 199, 0.12);
}

.weather-card {
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.2), rgba(15, 23, 42, 0.85));
  border-color: rgba(56, 189, 248, 0.25);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.header-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pulse-ring {
  width: 8px;
  height: 8px;
  background: #38bdf8;
  border-radius: 50%;
  box-shadow: 0 0 8px #38bdf8;
}

.weather-pill {
  background: #0284c7;
  color: #fff;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.weather-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.station-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.weather-time {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.weather-readings {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.weather-wind-detail {
  font-size: 0.72rem;
  color: var(--accent-cyan, #38bdf8);
  margin-top: 2px;
  white-space: nowrap;
  font-weight: 600;
}

.reading-col .label {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.reading-col .val-group {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.reading-col .num {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.reading-col .unit {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* 室內平均卡片 */
.indoor-tag {
  color: var(--accent-purple);
}
.indoor-tag .dot-icon {
  width: 8px;
  height: 8px;
  background: var(--accent-purple);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-purple);
}

.comfort-pill {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.indoor-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.metric-box {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 12px 16px;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.metric-val {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.metric-val span {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-main);
}

.metric-val small {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* 設備健康狀態卡片 */
.health-tag {
  color: #10b981;
}
.health-tag .dot-icon.health {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

.cycle-text {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.health-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.health-stat {
  display: flex;
  flex-direction: column;
}

.health-num {
  font-size: 2rem;
  font-weight: 800;
  color: #10b981;
  line-height: 1.1;
}

.health-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.health-info-box p {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* 章節標題 */
.section-container {
  margin-bottom: 38px;
}

.section-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.section-title-wrapper {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 4px;
}

.section-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.section-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.legend-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.legend-item .dot.ok { background: var(--color-ok); box-shadow: 0 0 6px var(--color-ok); }
.legend-item .dot.warn { background: var(--color-alert); box-shadow: 0 0 6px var(--color-alert); }
.legend-item .dot.stale { background: var(--color-warn); box-shadow: 0 0 6px var(--color-warn); }

/* 五大測點卡片網格 */
.sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
}

.sensor-card {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.sensor-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #38bdf8, transparent);
  opacity: 0.6;
}

.sensor-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-glow);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
  background: var(--bg-card-hover);
}

.sensor-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.sensor-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sensor-icon {
  font-size: 1.25rem;
  background: rgba(56, 189, 248, 0.1);
  border-radius: 8px;
  padding: 4px;
}

.sensor-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.sensor-update-time {
  font-size: 0.78rem;
  color: var(--text-dim);
  display: block;
}

.sensor-status-badge {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.sensor-card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.measurement {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 10px 14px;
}

.meas-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.meas-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meas-digits {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.meas-digits strong {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.meas-digits small {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.meas-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.meas-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}

.temp-fill {
  background: linear-gradient(90deg, #38bdf8, #f59e0b);
  width: 50%;
}

.hum-fill {
  background: linear-gradient(90deg, #0284c7, #3b82f6);
  width: 60%;
}

.sensor-card-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-top: 10px;
  font-size: 0.82rem;
  color: #10b981;
  font-weight: 600;
}

/* 狀態特化樣式 */
.sensor-card.alert {
  border-color: rgba(244, 63, 94, 0.5);
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.15);
}
.sensor-card.alert::before {
  background: #f43f5e;
}
.sensor-card.alert .sensor-status-badge {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: #f43f5e;
}
.sensor-card.alert .sensor-card-footer {
  color: #f43f5e;
}

.sensor-card.stale {
  border-color: rgba(245, 158, 11, 0.4);
}
.sensor-card.stale::before {
  background: #f59e0b;
}
.sensor-card.stale .sensor-status-badge {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #f59e0b;
}
.sensor-card.stale .sensor-card-footer {
  color: #f59e0b;
}

/* 趨勢圖表區塊 */
.chart-section {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  backdrop-filter: blur(14px);
  border-radius: 18px;
  padding: 26px 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-controls {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 3px;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: #0284c7;
  color: #fff;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.4);
}

.canvas-wrapper {
  width: 100%;
  position: relative;
  background: rgba(2, 6, 23, 0.5);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* 空間視覺化徽章 */
.badge-spatial {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(56, 189, 248, 0.2));
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #c084fc;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

/* 智慧空調與對流調度建議卡片 */
.advisor-card {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.85), rgba(30, 27, 75, 0.4));
  border-color: rgba(168, 85, 247, 0.3);
}
.advisor-tag {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}
.dot-icon.advisor {
  background: #c084fc;
  box-shadow: 0 0 8px #c084fc;
}
.advisor-pill {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.35);
}
.advisor-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.advisor-delta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 12px;
  border-radius: 8px;
}
.delta-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.delta-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary-cyan, #38bdf8);
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}
.delta-num {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary-cyan, #38bdf8);
}
.delta-subtext {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}
.advisor-text {
  font-size: 0.86rem;
  color: var(--text-main);
  line-height: 1.55;
  background: rgba(56, 189, 248, 0.06);
  border-left: 4px solid var(--accent-purple, #a855f7);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
}
.advisor-title {
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}
.advisor-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.advisor-desc b {
  color: var(--text-main);
}

/* 教室 2D 實境熱點俯視圖 */
.heatmap-section {
  margin-top: 10px;
}
.heatmap-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.dot-cold {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}
.dot-comfort {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}
.dot-warm {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f43f5e;
  box-shadow: 0 0 8px #f43f5e;
}

.classroom-layout-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  position: relative;
  overflow: hidden;
}

.room-boundary {
  width: 100%;
  min-height: 480px;
  background: 
    radial-gradient(ellipse at 15% 50%, rgba(244, 63, 94, 0.12) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 50%, rgba(56, 189, 248, 0.1) 0%, transparent 45%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    #090e1a;
  background-size: 100% 100%, 100% 100%, 30px 30px, 30px 30px;
  border: 2px solid rgba(56, 189, 248, 0.35);
  border-radius: 14px;
  position: relative;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* 前方講台與黑板 */
.room-front {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  position: relative;
  z-index: 2;
}
.blackboard {
  flex: 1;
  background: #064e3b;
  border: 2px solid #047857;
  color: #a7f3d0;
  text-align: center;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5), 0 0 12px rgba(4, 120, 87, 0.3);
}
.podium {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
}
.door {
  background: rgba(2, 132, 199, 0.2);
  border: 1px dashed #38bdf8;
  color: #38bdf8;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 4px;
}

/* 兩側牆面窗戶 */
.window-wall {
  position: absolute;
  top: 70px;
  bottom: 70px;
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.west-wall {
  left: 0;
  background: repeating-linear-gradient(0deg, rgba(244, 63, 94, 0.4), rgba(244, 63, 94, 0.4) 6px, transparent 6px, transparent 14px);
  border-right: 2px solid rgba(244, 63, 94, 0.6);
}
.east-wall {
  right: 0;
  background: repeating-linear-gradient(0deg, rgba(56, 189, 248, 0.3), rgba(56, 189, 248, 0.3) 6px, transparent 6px, transparent 14px);
  border-left: 2px solid rgba(56, 189, 248, 0.5);
}
.wall-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  opacity: 0.85;
}
.west-wall .wall-label { color: #fca5a5; }
.east-wall .wall-label { color: #bae6fd; }

/* 學生課桌椅網格 */
.desks-matrix {
  position: absolute;
  top: 130px;
  bottom: 110px;
  left: 80px;
  right: 80px;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  pointer-events: none;
  opacity: 0.4;
  z-index: 1;
}
.desk-row {
  display: flex;
  justify-content: space-around;
}
.desk {
  width: 48px;
  height: 28px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* 後方走廊 */
.room-rear {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  position: relative;
  z-index: 2;
}
.lockers {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 600;
}

/* 5 處實境測點圖釘 */
.spatial-pin {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), z-index 0.1s;
}
.spatial-pin:hover {
  transform: translate(-50%, -50%) scale(1.08);
  z-index: 10;
}

.pin-front  { top: 22%; left: 50%; flex-direction: column; }
.pin-west   { top: 44%; left: 16%; }
.pin-center { top: 56%; left: 50%; flex-direction: column; }
.pin-east   { top: 44%; left: 84%; flex-direction: row-reverse; }
.pin-back   { top: 80%; left: 50%; flex-direction: column; }

.pin-marker {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0284c7;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.8);
  flex-shrink: 0;
}
.pin-id {
  font-size: 0.85rem;
  font-weight: 900;
  color: #fff;
}
.pulse-wave {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid #38bdf8;
  animation: pinPulse 2s infinite ease-out;
  pointer-events: none;
}
@keyframes pinPulse {
  0% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.pin-card {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 6px 12px;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.pin-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 2px;
}
.pin-readings {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
}
.pin-temp {
  color: #38bdf8;
}
.pin-hum {
  color: #a78bfa;
}

/* 測點特化樣式 (西曬/熱點/離線) */
.spatial-pin.alert .pin-marker {
  background: #e11d48;
  box-shadow: 0 0 18px rgba(244, 63, 94, 0.9);
}
.spatial-pin.alert .pulse-wave {
  border-color: #f43f5e;
}
.spatial-pin.alert .pin-temp {
  color: #f43f5e;
}
.spatial-pin.stale .pin-marker {
  background: #64748b;
  box-shadow: none;
}
.spatial-pin.stale .pulse-wave {
  display: none;
}
.spatial-pin.stale .pin-readings {
  color: #64748b;
}

/* 圖表進階控制群組 */
.chart-controls-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.chart-view-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 3px;
  gap: 4px;
}
.view-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.view-btn.active {
  background: linear-gradient(135deg, #0284c7, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.4);
}

/* 互動式圖表圖例 */
.chart-legend-interactive {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.legend-node-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.legend-node-chip:hover {
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}
.legend-node-chip.muted {
  opacity: 0.35;
  text-decoration: line-through;
}
.legend-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* 戰情全螢幕模式 (Kiosk Mode) */
body.kiosk-mode {
  padding: 0;
  margin: 0;
  overflow-y: auto;
}
body.kiosk-mode .app-container {
  width: 96vw;
  max-width: 1800px;
  padding-top: 18px;
}
body.kiosk-mode .brand-title {
  font-size: 2.2rem;
}
body.kiosk-mode .metric-val {
  font-size: 2.6rem;
}
body.kiosk-mode .btn-secondary,
body.kiosk-mode #notice {
  display: none !important;
}

/* 平板端 RWD 適配 (Tablet 769px - 1024px) */
@media (max-width: 1024px) {
  .app-container {
    width: 94vw;
    padding: 24px 0 60px;
  }
  .overview-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .interactive-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .sensor-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
  }
  .classroom-layout-card {
    padding: 20px 16px;
  }
  .room-boundary {
    min-height: 460px;
  }
}

@media (max-width: 768px) {
  .app-container {
    width: 94vw;
    padding: 16px 0 60px;
  }
  
  .navbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding-bottom: 16px;
    margin-bottom: 22px;
  }
  
  .nav-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }

  .btn-nav-action {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
  
  .section-container {
    margin-bottom: 28px;
  }

  .section-title-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }

  .section-title-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 4px;
  }

  .section-title {
    font-size: 1.25rem;
    line-height: 1.35;
  }

  .badge-spatial {
    font-size: 0.7rem;
    padding: 2px 8px;
    align-self: flex-start;
  }

  .section-desc {
    font-size: 0.82rem;
    line-height: 1.45;
  }

  .heatmap-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  .legend-chip {
    font-size: 0.72rem;
    padding: 3px 8px;
  }

  /* 手機隱藏戰情全螢幕按鈕，保留寶貴空間 */
  @media (max-width: 640px) {
    #toggle-kiosk {
      display: none !important;
    }
  }

  .overview-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .overview-card {
    padding: 16px 14px;
    border-radius: 14px;
  }

  /* 氣象卡 3 欄在手機端等寬精準適配 */
  .weather-readings {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    align-items: flex-start;
  }

  .reading-col .num {
    font-size: 1.55rem;
  }

  .weather-wind-detail {
    font-size: 0.68rem;
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
  }

  .interactive-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .sensor-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .chart-section {
    padding: 16px 12px;
    border-radius: 14px;
  }

  .chart-header {
    gap: 12px;
    margin-bottom: 14px;
  }

  .chart-controls-group {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .chart-view-toggle, .chart-controls {
    width: 100%;
  }

  .view-btn, .tab-btn {
    flex: 1;
    text-align: center;
    padding: 7px 4px;
    font-size: 0.78rem;
  }

  .canvas-wrapper {
    height: 270px;
  }

  /* 2D 教室地圖手機專屬優化 */
  .classroom-layout-card {
    padding: 12px 8px;
    border-radius: 14px;
  }

  .room-boundary {
    min-height: 480px;
    padding: 10px 8px;
    border-radius: 10px;
  }

  .room-front {
    gap: 6px;
    padding-bottom: 8px;
  }

  .blackboard {
    font-size: 0.7rem;
    padding: 6px 8px;
    letter-spacing: 0.02em;
  }

  .podium, .door {
    font-size: 0.65rem;
    padding: 4px 6px;
  }

  .window-wall {
    width: 16px;
    top: 52px;
    bottom: 52px;
  }

  .wall-label {
    font-size: 0.58rem;
    letter-spacing: 0.02em;
  }

  .desks-matrix {
    left: 22px;
    right: 22px;
    top: 96px;
    bottom: 84px;
  }

  .desk {
    width: 30px;
    height: 16px;
    border-radius: 3px;
  }

  .room-rear {
    padding-top: 8px;
  }

  .lockers {
    font-size: 0.65rem;
  }

  /* 5 處實境測點 - 直立堆疊且非線性錯位（徹底避免卡片重疊） */
  .spatial-pin {
    flex-direction: column !important;
    align-items: center !important;
    gap: 3px !important;
    transform: translate(-50%, -50%) !important;
  }

  .spatial-pin:hover {
    transform: translate(-50%, -50%) scale(1.05) !important;
  }

  /* 5 測點精確錨定座標：前中後縱軸 + 東西兩側橫向對稱，垂直高度錯開 18% */
  .pin-front  { top: 20% !important; left: 50% !important; }
  .pin-west   { top: 40% !important; left: 24% !important; }
  .pin-east   { top: 40% !important; left: 76% !important; }
  .pin-center { top: 58% !important; left: 50% !important; }
  .pin-back   { top: 80% !important; left: 50% !important; }

  .pin-marker {
    width: 26px !important;
    height: 26px !important;
    border-width: 1.5px !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.6) !important;
  }

  .pin-id {
    font-size: 0.72rem !important;
  }

  .pulse-wave {
    inset: -4px !important;
  }

  .pin-card {
    padding: 3px 6px !important;
    border-radius: 6px !important;
    text-align: center !important;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35) !important;
    min-width: 56px !important;
  }

  .pin-name {
    font-size: 0.6rem !important;
    margin-bottom: 1px !important;
    line-height: 1.1 !important;
  }

  .pin-readings {
    font-size: 0.68rem !important;
    line-height: 1.1 !important;
    font-weight: 800 !important;
  }
}

/* ====== 各主題特化元件樣式 ====== */

/* 現代明亮風格 (Clean Light) 特化適配 */
[data-theme="light"] .overview-card,
[data-theme="light"] .interactive-card,
[data-theme="light"] .sensor-card,
[data-theme="light"] .chart-section,
[data-theme="light"] .classroom-layout-card {
  background: rgba(255, 255, 255, 0.96) !important;
  border-color: rgba(203, 213, 225, 0.85) !important;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04) !important;
}

[data-theme="light"] .overview-card:hover,
[data-theme="light"] .interactive-card:hover,
[data-theme="light"] .sensor-card:hover {
  background: #ffffff !important;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1) !important;
}

[data-theme="light"] .sensor-name,
[data-theme="light"] .meas-val b,
[data-theme="light"] .overview-card strong,
[data-theme="light"] .heading h2,
[data-theme="light"] .chart-title,
[data-theme="light"] .section-title {
  color: #0f172a !important;
}

[data-theme="light"] .section-desc {
  color: #475569 !important;
}

[data-theme="light"] .legend-chip {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}

[data-theme="light"] .measurement,
[data-theme="light"] .advisor-delta-bar {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .advisor-card {
  background: linear-gradient(145deg, #ffffff, #f1f5f9) !important;
  border-color: #cbd5e1 !important;
}

[data-theme="light"] .advisor-text {
  background: #f0fdf4 !important;
  border-left: 3px solid #059669 !important;
  color: #1e293b !important;
}

/* 2D 教室地圖底板與邊框 */
[data-theme="light"] .room-boundary {
  background: 
    radial-gradient(ellipse at 15% 50%, rgba(244, 63, 94, 0.05) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 50%, rgba(2, 132, 199, 0.05) 0%, transparent 45%),
    linear-gradient(rgba(148, 163, 184, 0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.15) 1px, transparent 1px),
    #f8fafc !important;
  background-size: 100% 100%, 100% 100%, 30px 30px, 30px 30px !important;
  border: 2px solid #cbd5e1 !important;
}

[data-theme="light"] .room-front {
  border-bottom: 1px dashed #cbd5e1 !important;
}

[data-theme="light"] .room-rear {
  border-top: 1px dashed #cbd5e1 !important;
}

[data-theme="light"] .blackboard {
  background: #064e3b !important;
  border-color: #047857 !important;
  color: #a7f3d0 !important;
}

[data-theme="light"] .podium {
  background: #e2e8f0 !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}

[data-theme="light"] .door {
  background: rgba(2, 132, 199, 0.1) !important;
  border-color: #0284c7 !important;
  color: #0284c7 !important;
}

[data-theme="light"] .lockers {
  color: #64748b !important;
}

/* 窗戶牆面明亮化，消除突兀條紋 */
[data-theme="light"] .west-wall {
  background: rgba(244, 63, 94, 0.08) !important;
  border-right: 2px solid rgba(244, 63, 94, 0.5) !important;
}
[data-theme="light"] .west-wall .wall-label {
  color: #e11d48 !important;
  font-weight: 800 !important;
}

[data-theme="light"] .east-wall {
  background: rgba(2, 132, 199, 0.08) !important;
  border-left: 2px solid rgba(2, 132, 199, 0.5) !important;
}
[data-theme="light"] .east-wall .wall-label {
  color: #0284c7 !important;
  font-weight: 800 !important;
}

/* 課桌椅明亮化 */
[data-theme="light"] .desks-matrix {
  opacity: 0.8 !important;
}
[data-theme="light"] .desk {
  background: #ffffff !important;
  border: 1px solid #94a3b8 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
}

/* 測點圖釘與浮動卡片 */
[data-theme="light"] .pin-marker {
  background: #0284c7 !important;
  border: 2px solid #ffffff !important;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.35) !important;
}
[data-theme="light"] .spatial-pin.stale .pin-marker {
  background: #64748b !important;
  box-shadow: none !important;
}
[data-theme="light"] .spatial-pin.alert .pin-marker {
  background: #e11d48 !important;
  box-shadow: 0 0 14px rgba(225, 29, 72, 0.6) !important;
}
[data-theme="light"] .pin-card {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12) !important;
}
[data-theme="light"] .pin-readings {
  color: #0f172a !important;
}
[data-theme="light"] .pin-name {
  color: #475569 !important;
}
[data-theme="light"] .pin-temp {
  color: #0284c7 !important;
}
[data-theme="light"] .pin-hum {
  color: #6366f1 !important;
}

/* 歷史圖表按鈕 */
[data-theme="light"] .chart-view-toggle,
[data-theme="light"] .chart-controls {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

[data-theme="light"] .view-btn,
[data-theme="light"] .tab-btn {
  color: #64748b !important;
}

[data-theme="light"] .view-btn.active,
[data-theme="light"] .tab-btn.active {
  background: #0284c7 !important;
  color: #ffffff !important;
}

[data-theme="light"] .canvas-wrapper {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02) !important;
}

[data-theme="light"] .legend-node-chip {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
  font-weight: 600 !important;
}

[data-theme="light"] .legend-node-chip.muted {
  opacity: 0.45 !important;
  background: #e2e8f0 !important;
  color: #94a3b8 !important;
}

/* 現代明亮 (Clean Light) 適配手機精簡模式 (Lite Mode) */
[data-theme="light"] .lite-node-card {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06) !important;
}

[data-theme="light"] .lite-node-card:hover {
  background: #f8fafc !important;
  border-color: #0284c7 !important;
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.12) !important;
}

[data-theme="light"] .lite-node-name {
  color: #0f172a !important;
}

[data-theme="light"] .lite-node-time {
  color: #475569 !important;
}

[data-theme="light"] .lite-node-icon {
  background: rgba(2, 132, 199, 0.1) !important;
  color: #0284c7 !important;
}

[data-theme="light"] .lite-badge-temp {
  color: #0284c7 !important;
}

[data-theme="light"] .lite-badge-hum {
  color: #475569 !important;
}

[data-theme="light"] .btn-mode-toggle {
  background: rgba(2, 132, 199, 0.08) !important;
  color: #0284c7 !important;
  border: 1px solid rgba(2, 132, 199, 0.35) !important;
}

[data-theme="light"] .btn-mode-toggle:hover {
  background: rgba(2, 132, 199, 0.16) !important;
}


/* ====== 手機精簡面板模式 (Lite Mode) ====== */
.btn-mode-toggle {
  background: rgba(56, 189, 248, 0.15) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.4) !important;
  font-weight: 700;
  transition: all 0.2s ease;
}
.btn-mode-toggle:hover {
  background: rgba(56, 189, 248, 0.25) !important;
  transform: translateY(-1px);
}

body.view-lite #heatmap-section,
body.view-lite #detail-cards-section,
body.view-lite #chart-section {
  display: none !important;
}

body.view-lite #lite-section {
  display: block !important;
  animation: fadeInLite 0.25s ease forwards;
}

@keyframes fadeInLite {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.lite-nodes-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.lite-node-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.lite-node-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(30, 41, 59, 0.95);
  transform: translateY(-2px);
}

.lite-node-card.stale {
  opacity: 0.6;
  border-left: 4px solid #94a3b8;
}

.lite-node-card.alert {
  border-left: 4px solid #f43f5e;
}

.lite-node-card.ok {
  border-left: 4px solid #10b981;
}

.lite-node-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lite-node-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
}

.lite-node-info {
  display: flex;
  flex-direction: column;
}

.lite-node-name {
  font-size: 0.98rem;
  font-weight: 700;
  color: #f8fafc;
}

.lite-node-time {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 2px;
}

.lite-node-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lite-badge-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.lite-badge-temp {
  font-size: 1.25rem;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
  color: #38bdf8;
  line-height: 1.1;
}

.lite-badge-hum {
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
}

.lite-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.lite-node-card.stale .lite-status-dot {
  background: #94a3b8;
  box-shadow: none;
}

.lite-node-card.alert .lite-status-dot {
  background: #f43f5e;
  box-shadow: 0 0 8px #f43f5e;
}

/* 離線警告橫幅優化 */
.offline-banner-active {
  display: flex !important;
  background: rgba(245, 158, 11, 0.18) !important;
  border: 1px solid rgba(245, 158, 11, 0.5) !important;
  color: #fbbf24 !important;
  padding: 12px 18px !important;
  border-radius: 12px !important;
  font-size: 0.88rem !important;
  font-weight: 600 !important;
  align-items: center !important;
  gap: 10px !important;
  margin-bottom: 18px !important;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.15) !important;
}

