@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;600;800&display=swap');

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

:root { --transition: 0.2s ease; }

[data-theme="dark"] {
  --bg:           #0d0d0f;
  --surface:      #141417;
  --surface2:     #1c1c21;
  --border:       #2a2a32;
  --text:         #e8e8f0;
  --text-muted:   #6b6b80;
  --accent:       #00e5c0;
  --accent2:      #ff6b35;
  --temp-color:   #ff6b35;
  --hum-color:    #00e5c0;
}

[data-theme="light"] {
  --bg:           #f4f4f7;
  --surface:      #ffffff;
  --surface2:     #ebebf0;
  --border:       #d8d8e0;
  --text:         #1a1a28;
  --text-muted:   #8888a0;
  --accent:       #009980;
  --accent2:      #d94f1e;
  --temp-color:   #d94f1e;
  --hum-color:    #009980;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'Syne', sans-serif; font-size: 15px; }
body { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 72px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 20px 0;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar-brand { display: flex; flex-direction: column; align-items: center; margin-bottom: 28px; gap: 4px; }
.brand-icon { font-size: 22px; color: var(--accent); line-height: 1; }
.brand-name { font-family: 'Space Mono', monospace; font-size: 9px; font-weight: 700; color: var(--text-muted); text-align: center; line-height: 1.3; letter-spacing: 0.05em; }
.brand-name small { font-size: 8px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 0 8px; flex: 1; }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 0; border-radius: 8px; text-decoration: none; color: var(--text-muted); transition: all var(--transition); }
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--accent); background: var(--surface2); }
.nav-icon { font-size: 16px; line-height: 1; }
.nav-label { font-size: 9px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.sidebar-footer { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); width: 100%; }
.theme-btn { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 6px; border-radius: 6px; transition: color var(--transition); line-height: 1; }
.theme-btn:hover { color: var(--accent); }
.ext-link { font-family: 'Space Mono', monospace; font-size: 8px; color: var(--text-muted); text-decoration: none; letter-spacing: 0.05em; transition: color var(--transition); }
.ext-link:hover { color: var(--accent); }

/* Main */
.main { margin-left: 72px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; padding: 0 28px 40px; }

/* Topbar */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 24px 0 20px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.topbar-left { display: flex; align-items: baseline; gap: 14px; }
.page-title { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.live-badge { font-family: 'Space Mono', monospace; font-size: 9px; font-weight: 700; letter-spacing: 0.12em; color: var(--accent); animation: blink 2s step-end infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.last-update { font-family: 'Space Mono', monospace; font-size: 11px; color: var(--text-muted); }

/* Hero cards */
.hero-readings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.hero-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px 28px 22px; position: relative; overflow: hidden; }
.hero-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
#card-temp::before     { background: var(--temp-color); }
#card-humidity::before { background: var(--hum-color); }
.hero-label { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 12px; }
.hero-value { font-family: 'Space Mono', monospace; font-size: 56px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
#card-temp .hero-value     { color: var(--temp-color); }
#card-humidity .hero-value { color: var(--hum-color); }
.hero-unit { font-family: 'Space Mono', monospace; font-size: 14px; color: var(--text-muted); margin-top: 4px; margin-bottom: 16px; }
.hero-bar { height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; }
.hero-bar-fill { height: 100%; border-radius: 2px; width: 0%; transition: width 0.6s ease; }
#card-temp .hero-bar-fill     { background: var(--temp-color); }
#card-humidity .hero-bar-fill { background: var(--hum-color); }

/* Secondary */
.secondary-readings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 28px; }
.secondary-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; display: flex; align-items: baseline; gap: 10px; }
.sec-label { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); min-width: 70px; }
.sec-value { font-family: 'Space Mono', monospace; font-size: 22px; font-weight: 700; color: var(--text); }
.sec-unit  { font-family: 'Space Mono', monospace; font-size: 11px; color: var(--text-muted); }

/* Charts */
.charts-section { display: flex; flex-direction: column; gap: 16px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.chart-header { padding: 14px 20px 10px; border-bottom: 1px solid var(--border); }
.chart-title { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.chart-plot { height: 220px; width: 100%; }
.chart-plot--tall { height: 300px; }

/* History controls */
.history-controls { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.control-group { display: flex; flex-direction: column; gap: 6px; }
.ctrl-label { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.ctrl-input { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-family: 'Space Mono', monospace; font-size: 13px; color: var(--text); outline: none; transition: border-color var(--transition); color-scheme: dark; }
.ctrl-input:focus { border-color: var(--accent); }
.load-btn { background: var(--accent); color: var(--bg); border: none; border-radius: 8px; padding: 10px 22px; font-family: 'Syne', sans-serif; font-size: 13px; font-weight: 700; letter-spacing: 0.05em; cursor: pointer; transition: opacity var(--transition); }
.load-btn:hover { opacity: 0.85; }
.empty-state { text-align: center; color: var(--text-muted); font-family: 'Space Mono', monospace; font-size: 13px; padding: 60px 0; }

/* Subscribe */
.subscribe-section { padding-top: 8px; }
.subscribe-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px; max-width: 520px; }
.subscribe-desc { font-size: 14px; color: var(--text-muted); line-height: 1.7; margin-bottom: 24px; }
.subscribe-desc strong { color: var(--text); }
.subscribe-form { display: flex; flex-direction: column; gap: 8px; }
.subscribe-row { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.subscribe-row .ctrl-input { flex: 1; }
.subscribe-msg { margin-top: 12px; font-family: 'Space Mono', monospace; font-size: 12px; padding: 8px 12px; border-radius: 6px; }
.subscribe-msg.success { background: rgba(0,229,192,0.12); color: var(--hum-color); }
.subscribe-msg.error   { background: rgba(255,107,53,0.12); color: var(--temp-color); }

@media (max-width: 640px) {
  .hero-readings, .secondary-readings { grid-template-columns: 1fr; }
  .hero-value { font-size: 42px; }
  .main { padding: 0 16px 32px; }
}
