:root {
  --bg: #f5f1e9;
  --card: #ffffff;
  --text: #2b2620;
  --muted: #8a8177;
  --accent: #d96a4a;
  --accent-soft: #fae7de;
  --border: #ece5d9;
  --shadow: 0 2px 12px rgba(70, 55, 40, 0.07);
  --radius: 20px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px;
  background: var(--accent);
  color: #fff;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.header h1 {
  font-family: Georgia, "PT Serif", serif;
  font-size: 24px;
  font-weight: 700;
}
.date { color: var(--muted); font-size: 14px; }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 16px;
}

/* Hero */
.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.hero-label { color: var(--muted); font-size: 14px; }
.badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
}
.hero-temp {
  font-family: Georgia, "PT Serif", serif;
  font-size: 72px;
  font-weight: 700;
  line-height: 1.05;
}
.hero-unit { font-size: 32px; color: var(--muted); margin-left: 4px; }
.hero-meta {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
  flex-wrap: wrap;
}
.hero-meta b { color: var(--text); font-weight: 600; }

/* Stats grid */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.stat .stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat .stat-value {
  font-family: Georgia, "PT Serif", serif;
  font-size: 28px;
  font-weight: 700;
}
.stat .stat-unit { font-size: 14px; color: var(--muted); font-family: inherit; }
.stat .stat-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* Sections */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.section-head h2 {
  font-family: Georgia, "PT Serif", serif;
  font-size: 20px;
}
.pills { display: flex; gap: 8px; }
.pill {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Charts */
.chart-block { margin-bottom: 22px; }
.chart-block:last-child { margin-bottom: 4px; }
.chart-block h3 { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend .dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 5px;
}
.chart-wrap { position: relative; height: 180px; }

/* Precipitation */
.precip-note { font-size: 14px; color: var(--text); margin: -6px 0 14px; }
.badge.level-now { background: #dfe9f5; color: #3a6ea8; }
.badge.level-high { background: var(--accent-soft); color: var(--accent); }
.badge.level-medium { background: #f6efdd; color: #a07c2c; }
.badge.level-low { background: #e6efe2; color: #5d8350; }
.badge.level-neutral { background: #efece5; color: var(--muted); }

/* City picker */
.city-btn { font-size: 13px; }
.city-search { display: none; margin: -6px 0 14px; position: relative; }
.city-search.open { display: block; }
.city-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  background: #faf7f0;
  color: var(--text);
  outline: none;
}
.city-search input:focus { border-color: var(--accent); }
.city-list {
  position: absolute;
  top: 46px; left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 10;
  display: none;
}
.city-list.open { display: block; }
.city-item {
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.city-item:last-child { border-bottom: none; }
.city-item:hover { background: var(--accent-soft); }
.city-item .city-region { color: var(--muted); font-size: 12px; }

/* Forecast */
.hint { font-size: 12px; color: var(--muted); }
.fc-day { cursor: pointer; transition: border-color .15s, background .15s; }
.fc-day.active { border-color: var(--accent); background: var(--accent-soft); }
.hourly-panel { display: none; margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.hourly-panel.open { display: block; }
.hourly-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.hourly-title { font-size: 14px; font-weight: 600; }
.hourly-close {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.hourly-close:hover { border-color: var(--accent); color: var(--accent); }
.hourly-empty { font-size: 14px; color: var(--muted); }
.hourly-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; scrollbar-width: thin; }
.hourly-row {
  display: grid;
  grid-template-columns: 52px 34px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 10px;
  font-size: 14px;
}
.hourly-row:nth-child(odd) { background: #faf7f0; }
.hourly-row .h-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.hourly-row .h-icon { font-size: 18px; }
.hourly-row .h-temp { font-weight: 700; }
.hourly-row .h-extra { color: var(--muted); font-size: 13px; }
.hourly-row .h-precip { color: #5b8ec4; font-size: 13px; min-width: 62px; text-align: right; }
.forecast {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.fc-day {
  min-width: 96px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 10px;
  text-align: center;
  flex-shrink: 0;
}
.fc-day .fc-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.fc-day .fc-icon { font-size: 26px; margin: 6px 0; }
.fc-day .fc-temps { font-size: 14px; }
.fc-day .fc-max { font-weight: 700; }
.fc-day .fc-min { color: var(--muted); margin-left: 6px; }
.fc-day .fc-precip { font-size: 12px; color: #5b8ec4; margin-top: 4px; min-height: 15px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 15px;
  cursor: pointer;
  transition: all .15s;
}
.tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Camera */
.cam-live-wrap {
  display: flex;
  justify-content: center;
  background: #17130f;
  border-radius: 14px;
  overflow: hidden;
}
.cam-live-wrap img {
  max-width: 100%;
  max-height: 62vh;
  display: block;
}
.events { display: flex; flex-direction: column; gap: 8px; }
.event-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color .15s;
}
.event-row:hover { border-color: var(--accent); }
.event-row img {
  width: 56px; height: 74px;
  object-fit: cover;
  border-radius: 10px;
  background: #efece5;
}
.event-row .ev-label { font-weight: 600; font-size: 15px; }
.event-row .ev-time { color: var(--muted); font-size: 13px; margin-top: 2px; }
.event-row .ev-score { color: var(--muted); font-size: 13px; text-align: right; }
.event-row .ev-play { color: var(--accent); font-size: 13px; margin-top: 2px; }
.events-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 16px 0; }

/* Pager */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}
.pager:empty { display: none; }
.pager button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager button:disabled { opacity: 0.4; cursor: default; }
.pager .pager-info { font-size: 13px; color: var(--muted); }

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30, 24, 18, 0.75);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-body {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  padding: 14px;
  max-width: 92vw;
  max-height: 88vh;
  overflow: auto;
}
.modal-body video, .modal-body img {
  max-width: 100%;
  max-height: 78vh;
  border-radius: 12px;
  display: block;
}

/* График работы увлажнителя (модалка) */
.humid-panel { cursor: pointer; }
.climate-chips .climate-chip { cursor: pointer; }
.history-chip { cursor: pointer; }
.light-tile { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.humid-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 4px 6px 12px;
}
.humid-chart-title { font-family: Georgia, serif; font-size: 18px; margin: 0; }
.humid-chart-wrap { width: min(860px, 86vw); height: 340px; position: relative; }
.modal-close {
  position: absolute;
  top: 20px; right: 20px;
  z-index: 2;
  width: 34px; height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(30, 24, 18, 0.6);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

/* Lights */
.light-room { margin-bottom: 16px; }
.light-room h2 {
  font-family: Georgia, "PT Serif", serif;
  font-size: 20px;
  margin-bottom: 12px;
}
.light-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.light-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.light-tile:active { transform: scale(0.97); }
.light-tile .lt-photo {
  margin: 0 0 10px;
}
.light-tile .lt-photo img {
  width: auto;
  max-width: 100%;
  height: 84px;
  margin: 0 auto;
  object-fit: contain;
  display: block;
  filter: grayscale(0.8) brightness(0.75) opacity(0.75);
  transition: filter .35s;
}
.light-tile.on .lt-photo img {
  filter: drop-shadow(0 0 16px rgba(255, 185, 80, 0.8)) saturate(1.15);
}
.light-tile.on {
  box-shadow: 0 0 24px rgba(255, 190, 90, 0.45), var(--shadow);
}
.light-tile .lt-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.light-tile .lt-state { font-size: 12px; color: var(--muted); }
.light-tile.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.light-tile.on .lt-state { color: var(--accent); font-weight: 600; }
.light-tile.unavailable { opacity: 0.5; cursor: default; }
.light-tile.pending { opacity: 0.6; pointer-events: none; }

.credits { font-size: 11px; color: var(--muted); text-align: center; opacity: 0.7; }

/* Balcony sensors */
.balcony-chips {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.balcony-chip {
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #faf7f0;
  font-size: 14px;
}
.balcony-chip .bc-icon { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; color: #a3987f; }
.balcony-chip .bc-icon svg { width: 22px; height: 22px; display: block; }
.balcony-chip .bc-name { font-weight: 600; flex: 1; }
.balcony-chip .bc-state { color: var(--muted); }
.balcony-chip.open { border-color: var(--accent); background: var(--accent-soft); }
.balcony-chip.open .bc-icon { color: var(--accent); }
.balcony-chip.open .bc-state { color: var(--accent); font-weight: 600; }
.climate-chip .bc-icon { color: var(--accent); }

/* Humidifier */
.humid-panel {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #faf7f0;
  transition: all .2s;
}
.humid-panel.on { border-color: #5b8ec4; background: #eef4fa; }
.humid-icon { width: 56px; height: 64px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.humid-icon img { max-width: 56px; max-height: 64px; object-fit: contain; }
.humid-panel:not(.on) .humid-icon { filter: grayscale(0.6); opacity: 0.6; }
.humid-body { flex: 1; min-width: 0; }
.humid-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.humid-title { font-weight: 600; font-size: 15px; }
.humid-info { font-size: 13px; color: var(--muted); }
.humid-jev { font-size: 13px; color: var(--text); margin-top: 6px; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

@media (max-width: 420px) {
  .hero-temp { font-size: 60px; }
  .stat .stat-value { font-size: 24px; }
}
