:root {
  --color-one: #1d1a39;
  --color-two: #451952;
  --color-three: #662549;
  --color-four: #ae445a;
  --color-five: #f39f5a;
  --color-six: #e8bcb9;
  --color-seven: #23aa66;
  --danger: #d9534f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-six);
  background-color: var(--color-one);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-four);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--color-six);
}
.topbar h1 span { color: var(--color-five); }

.icon-btn {
  height: 40px;
  width: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-five);
  background: transparent;
  color: var(--color-five);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
}
.icon-btn:hover {
  background: var(--color-five);
  color: var(--color-three);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background-color: var(--color-two);
  border: 1px solid var(--color-four);
  border-radius: 24px;
  padding: 20px;
}

/* Readings */
.readings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.reading-card__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-five);
  margin-bottom: 6px;
}

.reading-card__main {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.reading-card__temp {
  font-size: 40px;
  font-weight: 800;
  color: var(--color-six);
  line-height: 1;
}

.unit {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-six);
  opacity: 0.7;
}

.reading-card__sub {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--color-six);
  opacity: 0.85;
}

.stale-banner {
  display: none;
  text-align: center;
  padding: 10px 16px;
  border-radius: 16px;
  background: rgba(217, 83, 79, 0.15);
  border: 1px solid var(--danger);
  color: var(--color-six);
  font-size: 12px;
  font-weight: 600;
}
.stale-banner.visible { display: block; }

/* Switches */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
}
.switch-row__title { font-weight: 700; color: var(--color-six); }
.switch-row__desc { font-size: 12px; color: var(--color-six); opacity: 0.7; margin-top: 2px; }

.divider {
  height: 1px;
  background: var(--color-four);
  margin: 14px 0;
  opacity: 0.6;
}

.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute;
  inset: 0;
  background: var(--color-one);
  border: 1px solid var(--color-four);
  border-radius: 30px;
  transition: all 0.3s ease;
  cursor: pointer;
}
.switch__thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  background: var(--color-six);
  border-radius: 50%;
  transition: all 0.3s ease;
}
.switch input:checked + .switch__track { background: var(--color-seven); border-color: var(--color-seven); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(22px); background: #fff; }
.switch--danger input:checked + .switch__track { background: var(--danger); border-color: var(--danger); }

/* Manual controls */
.manual-panel__title { font-weight: 700; color: var(--color-six); margin-bottom: 4px; }
.manual-panel__hint { font-size: 12px; color: var(--color-five); margin-bottom: 14px; }
.manual-panel__hint.hidden { display: none; }

.manual-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.manual-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border: 1px solid var(--color-four);
  border-radius: 18px;
  background: var(--color-one);
  color: var(--color-six);
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}
.manual-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.manual-btn:not(:disabled):hover { border-color: var(--color-five); }
.manual-btn__icon { font-size: 22px; color: var(--color-five); }
.manual-btn__label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.manual-btn__state { font-size: 11px; opacity: 0.7; }
.manual-btn.is-on { background: var(--color-three); border-color: var(--color-seven); }
.manual-btn.is-on .manual-btn__icon { color: var(--color-seven); }
.manual-btn.is-on .manual-btn__state { color: var(--color-seven); opacity: 1; font-weight: 700; }

/* Graph */
.graph-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.graph-panel__title { font-weight: 700; }

.range-pills { display: flex; gap: 6px; }
.pill {
  padding: 6px 14px;
  border-radius: 30px;
  border: 1px solid var(--color-four);
  background: transparent;
  color: var(--color-six);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
}
.pill:hover { border-color: var(--color-five); }
.pill.active { background: var(--color-five); color: var(--color-three); border-color: var(--color-five); }

.chart-wrap { position: relative; height: 260px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-size: 11px;
}
.legend__item { display: flex; align-items: center; gap: 6px; opacity: 0.85; }
.legend__dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(29, 26, 57, 0.8);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.visible { display: flex; }

.modal {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--color-two);
  border: 1px solid var(--color-four);
  border-radius: 24px;
  padding: 24px;
}

.modal__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal__header h2 { margin: 0; font-size: 18px; font-weight: 800; }

.modal__body { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--color-five); text-transform: uppercase; letter-spacing: 0.03em; }
.field input {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-transform: none;
  color: var(--color-six);
  background: var(--color-one);
  border: 1px solid var(--color-four);
  border-radius: 14px;
  padding: 10px 14px;
  outline: none;
  transition: all 0.3s ease;
}
.field input:focus { border-color: var(--color-five); }

.modal__footer {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal__status { font-size: 12px; color: var(--color-seven); font-weight: 600; }

.btn-primary {
  padding: 12px 24px;
  border-radius: 30px;
  border: 1px solid var(--color-five);
  background: var(--color-five);
  color: var(--color-three);
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.3s ease;
}
.btn-primary:hover { background: transparent; color: var(--color-five); }

@media (max-width: 480px) {
  .reading-card__temp { font-size: 32px; }
  .manual-grid { gap: 8px; }
}
