:root {
  color-scheme: dark;
  --page: #032020;
  --panel: #0d1722;
  --panel-soft: rgba(255, 255, 255, 0.045);
  --line: rgba(113, 255, 207, 0.20);
  --text: #eef7f8;
  --muted: #93a1ac;
  --cyan: #31d7ff;
  --blue: #168dff;
  --green: #4bea8b;
  --yellow: #ece524;
  --orange: #ff8c24;
  --red: #ff4f33;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(700px 460px at 50% 0%, rgba(79, 255, 187, 0.18), transparent 68%),
    radial-gradient(340px 340px at 12% 14%, rgba(49, 215, 255, 0.10), transparent 70%),
    linear-gradient(150deg, #042322 0%, #061017 56%, #021817 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  width: min(430px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px 12px 18px;
}

.thermo-card {
  min-height: calc(100vh - 28px);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 15px 12px 16px;
  background:
    radial-gradient(370px 250px at 50% 20%, rgba(58, 247, 166, 0.11), transparent 72%),
    linear-gradient(180deg, #121d29 0%, #0b141d 58%, #08171b 100%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.56), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.title-block {
  text-align: center;
  padding-top: 14px;
}

.title-block p {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 4px;
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.12;
  letter-spacing: 0;
}

.sensor-switch {
  width: min(238px, 100%);
  height: 34px;
  margin: 13px auto 0;
  padding: 3px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  border: 1px solid rgba(113, 255, 207, 0.22);
  border-radius: 999px;
  background: rgba(3, 12, 17, 0.42);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.sensor-switch button {
  min-width: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #93a1ac;
  font: inherit;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.sensor-switch button.active {
  background: linear-gradient(135deg, rgba(49, 215, 255, 0.24), rgba(75, 234, 139, 0.28));
  color: #effff9;
  box-shadow: 0 0 18px rgba(75, 234, 139, 0.22);
}

.thermo-icon {
  width: 13px;
  height: 31px;
  margin: 13px auto 0;
  border: 2px solid var(--green);
  border-radius: 9px;
  position: relative;
  box-shadow: 0 0 18px rgba(75, 234, 139, 0.46);
}

.thermo-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 3px;
  height: 17px;
  transform: translateX(-50%);
  border-radius: 4px;
  background: var(--green);
}

.thermo-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 13px;
  height: 13px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--green);
}

.temperature-readout {
  text-align: center;
  margin-top: 16px;
}

.temperature-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 5px;
}

.temperature {
  font-size: clamp(96px, 28vw, 146px);
  line-height: 0.82;
  font-weight: 850;
  letter-spacing: 0;
  color: var(--green);
  text-shadow: 0 0 30px rgba(49, 215, 255, 0.20), 0 0 26px rgba(75, 234, 139, 0.28);
}

.unit {
  padding-bottom: 14px;
  color: #dce7ec;
  font-size: 28px;
  font-weight: 850;
}

.gauge-section {
  position: relative;
  height: 174px;
  margin-top: 16px;
}

#gauge {
  display: block;
  width: 100%;
  height: 158px;
}

.gauge-icons {
  position: absolute;
  left: 118px;
  right: 118px;
  bottom: 31px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 28px;
}

.gauge-icons span:first-child { color: var(--cyan); }
.gauge-icons span:last-child { color: #ffd424; }

.history-panel,
.stats-panel {
  border: 1px solid rgba(164, 187, 202, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-soft), rgba(255,255,255,0.015));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.history-panel {
  padding: 10px 10px 6px;
  margin-top: 9px;
}

.history-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

h2 {
  margin: 0;
  color: #d9e0e5;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
}

.range-switch {
  height: 28px;
  padding: 2px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  border: 1px solid rgba(113, 255, 207, 0.18);
  border-radius: 999px;
  background: rgba(3, 12, 17, 0.38);
}

.range-switch button {
  min-width: 50px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #93a1ac;
  font: inherit;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
  padding: 0 8px;
}

.range-switch button.active {
  background: rgba(49, 215, 255, 0.18);
  color: #eafefe;
  box-shadow: 0 0 14px rgba(49, 215, 255, 0.16);
}

#history {
  display: block;
  width: 100%;
  height: 152px;
}

.stats-panel {
  display: grid;
  grid-template-columns: 1fr 0.82fr 1fr;
  margin-top: 9px;
  min-height: 96px;
}

.stats-panel article {
  min-width: 0;
  padding: 14px 8px 11px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stats-panel article + article {
  border-left: 1px solid rgba(164, 187, 202, 0.17);
}

.stats-panel span {
  color: #73caff;
  font-size: 11px;
  font-weight: 900;
}

.stats-panel strong {
  display: block;
  margin-top: 4px;
  color: var(--cyan);
  font-size: 25px;
  line-height: 1.05;
  letter-spacing: 0;
}

.stats-panel small {
  margin-top: 4px;
  color: #8995a0;
  font-size: 12px;
}

.trend strong {
  color: var(--green);
  font-size: 14px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.trend-icon {
  width: 31px;
  height: 31px;
  margin: 0 auto 6px;
  border: 2px solid var(--green);
  border-radius: 50%;
  color: var(--green);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 900;
}

footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 11px;
  color: #82919d;
  font-size: 12px;
}

.refresh-dot {
  width: 10px;
  height: 10px;
  border: 1px solid var(--green);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(75, 234, 139, 0.62);
}

@media (min-width: 780px) {
  .app-shell {
    width: min(520px, 100%);
    padding-top: 18px;
  }
}

@media (max-width: 360px) {
  .app-shell { padding-inline: 8px; }
  .thermo-card { border-radius: 22px; padding-inline: 10px; }
  .gauge-icons { left: 92px; right: 92px; }
  .history-head { grid-template-columns: 1fr; }
  .range-switch button { min-width: 0; }
  .stats-panel strong { font-size: 21px; }
}
