:root {
  color-scheme: light;
  --ink: #15343b;
  --ink-soft: #587078;
  --canvas: #f3f7f7;
  --panel: #ffffff;
  --line: #d8e3e4;
  --line-strong: #bfd0d2;
  --brand: #0f4c5c;
  --brand-dark: #0a3945;
  --brand-soft: #e7f1f2;
  --blue: #1677a8;
  --red: #b83d4b;
  --red-dark: #962f3b;
  --green: #13745a;
  --warning: #8d5a08;
  --warning-bg: #fff7df;
  --danger-bg: #fff0f1;
  --shadow: 0 18px 48px rgba(27, 61, 68, 0.09);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #e9f1f1 0, var(--canvas) 330px),
    var(--canvas);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 22px;
}

.brand,
.connection-actions,
.section-heading,
.program-actions,
.logging-actions,
.notice {
  display: flex;
  align-items: center;
}

.brand {
  gap: 22px;
}

.brand img {
  width: 171px;
  height: 40px;
  object-fit: contain;
}

.brand-copy {
  padding-left: 22px;
  border-left: 1px solid var(--line-strong);
}

.eyebrow,
.section-label {
  margin: 0 0 5px;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
}

h1 span {
  color: var(--ink-soft);
  font-weight: 500;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.connection-actions {
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.status-badge,
.mode-label,
.reading-count {
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.status-online {
  border-color: #9fcebf;
  background: #eaf8f3;
  color: var(--green);
}

.status-demo {
  border-color: #e7c67e;
  background: var(--warning-bg);
  color: var(--warning);
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 730;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible,
.text-button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(22, 119, 168, 0.24);
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  background: var(--brand);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  background: var(--brand-dark);
}

.button-secondary {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
}

.button-secondary:hover:not(:disabled) {
  border-color: #91adb1;
  background: #fff;
}

.button-start {
  flex: 1;
  background: var(--green);
  color: #fff;
}

.button-stop {
  min-width: 120px;
  border-color: #e3aeb4;
  background: var(--danger-bg);
  color: var(--red-dark);
}

.text-button {
  border: 0;
  padding: 4px;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font-weight: 730;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.notice {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  border: 1px solid #ead08f;
  border-radius: 10px;
  padding: 13px 15px;
  background: var(--warning-bg);
  color: #684711;
  font-size: 0.9rem;
}

.notice strong {
  margin-right: 8px;
}

.notice-error {
  border-color: #e4aeb4;
  background: var(--danger-bg);
  color: #812d37;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.overview-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.temperature-card,
.limits-card {
  min-height: 148px;
  padding: 23px 25px;
}

.temperature-card {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  background:
    linear-gradient(120deg, rgba(15, 76, 92, 0.055), transparent 60%),
    var(--panel);
}

.temperature-value {
  margin: 0;
  font-size: clamp(3.2rem, 7vw, 5.15rem);
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  letter-spacing: -0.065em;
  line-height: 0.95;
}

.temperature-value span {
  margin-left: 8px;
  color: var(--ink-soft);
  font-size: 0.32em;
  font-weight: 650;
  letter-spacing: 0;
}

.phase-block {
  max-width: 280px;
  text-align: right;
}

.phase-text {
  margin-bottom: 6px;
  color: var(--ink);
  font-weight: 700;
}

.hold-text {
  min-height: 1.2em;
  margin-bottom: 0;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  font-weight: 700;
}

.limits-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 22px;
  margin: 21px 0 0;
}

.limits-grid div {
  min-width: 0;
}

.limits-grid dt {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 680;
}

.limits-grid dd {
  margin: 3px 0 0;
  font-size: 0.94rem;
  font-weight: 740;
}

.chart-panel {
  padding: 21px 24px 19px;
}

.section-heading {
  justify-content: space-between;
  gap: 20px;
}

.chart-legend {
  display: flex;
  gap: 20px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 680;
}

.chart-legend span::before {
  display: inline-block;
  width: 20px;
  margin-right: 7px;
  border-top: 3px solid var(--blue);
  content: "";
  vertical-align: middle;
}

.chart-legend .legend-target::before {
  border-top-color: var(--red);
  border-top-style: dashed;
}

.chart-wrap {
  position: relative;
  height: 292px;
  margin-top: 18px;
}

#temperatureChart {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-empty {
  position: absolute;
  inset: 50% auto auto 50%;
  margin: 0;
  color: var(--ink-soft);
  transform: translate(-50%, -50%);
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.8fr;
  gap: 18px;
  margin-top: 18px;
}

.program-panel,
.logging-panel {
  padding: 23px 24px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.field-grid label > span:first-child {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.input-with-unit {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fbfdfd;
}

.input-with-unit:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(22, 119, 168, 0.12);
}

.input-with-unit input {
  min-width: 0;
  width: 100%;
  border: 0;
  padding: 12px 4px 12px 12px;
  background: transparent;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 720;
  outline: none;
}

.input-with-unit > span {
  padding: 0 11px 0 6px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  white-space: nowrap;
}

.validation-message {
  min-height: 1.3em;
  margin: 12px 0 4px;
  color: var(--red-dark);
  font-size: 0.82rem;
  font-weight: 650;
}

.program-actions,
.logging-actions {
  gap: 10px;
}

.safety-note {
  margin: 15px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 13px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.5;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 24px 0 21px;
  cursor: pointer;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--brand);
}

.toggle-row span {
  display: grid;
  gap: 4px;
}

.toggle-row small {
  color: var(--ink-soft);
  line-height: 1.4;
}

.logging-actions .button {
  flex: 1;
}

.compatibility-note {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 17px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.compatibility-note strong {
  color: var(--ink);
}

.compatibility-note p {
  margin: 5px 0 0;
}

.demo-link {
  margin-top: 12px;
  font-size: 0.82rem;
}

footer {
  padding: 20px 4px 0;
  color: var(--ink-soft);
  font-size: 0.74rem;
  text-align: center;
}

footer p {
  margin-bottom: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .topbar,
  .temperature-card {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .connection-actions {
    justify-content: flex-start;
  }

  .overview-grid,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .phase-block {
    padding-top: 24px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 24px, 1240px);
    padding-top: 18px;
  }

  .brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .brand-copy {
    border-left: 0;
    padding-left: 0;
  }

  .connection-actions {
    width: 100%;
  }

  .connection-actions .button {
    flex: 1;
  }

  .status-badge {
    width: 100%;
  }

  .notice,
  .temperature-card {
    align-items: stretch;
    flex-direction: column;
  }

  .phase-block {
    max-width: none;
    padding-top: 4px;
    text-align: left;
  }

  .limits-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .chart-panel,
  .program-panel,
  .logging-panel,
  .temperature-card,
  .limits-card {
    padding: 19px;
  }

  .chart-wrap {
    height: 245px;
  }

  .chart-legend {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
