:root {
  color-scheme: light;
  --bg: #f7fbfb;
  --ink: #152527;
  --muted: #66797c;
  --line: #cde0e2;
  --surface: #ffffff;
  --deep: #0e4f5a;
  --water: #0f6b77;
  --signal: #ff3b30;
  --sun: #f6b44b;
  --ok: #16a36a;
  --shadow: 0 18px 55px rgba(28, 66, 72, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(246, 180, 75, 0.18), transparent 32rem),
    linear-gradient(180deg, #eef8f8 0%, var(--bg) 36%, #edf5f1 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--deep);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

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

.shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 18px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.45rem, 5vw, 2.4rem);
  line-height: 1;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.brand-mark {
  width: 46px;
  height: 46px;
  position: relative;
  border-radius: 50%;
  background: var(--water);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.08);
}

.brand-mark span {
  position: absolute;
  left: 19px;
  top: 7px;
  width: 8px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(var(--signal) 0 38%, #fff 38% 62%, var(--deep) 62%);
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}

.connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b9c4c6;
}

.connection-dot.is-connected {
  background: var(--ok);
}

.hero-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(150px, 0.8fr);
  gap: 18px;
  align-items: center;
  min-height: 280px;
  padding: 24px;
  border: 1px solid rgba(15, 107, 119, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 107, 119, 0.94), rgba(14, 79, 90, 0.98)),
    var(--water);
  box-shadow: var(--shadow);
  color: #fff;
}

.hero-panel.is-alerting {
  animation: alert-flash 0.32s ease-in-out 3;
}

.water-visual {
  position: relative;
  width: min(48vw, 270px);
  aspect-ratio: 1;
  justify-self: center;
}

.float-body {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 122px;
  height: 154px;
  transform: translate(-50%, -34%);
  border-radius: 58% 58% 52% 52%;
  background: linear-gradient(180deg, var(--signal) 0 48%, #f7f8f6 48% 100%);
  box-shadow: 0 22px 42px rgba(3, 24, 29, 0.3), inset 0 -18px 28px rgba(10, 50, 58, 0.15);
}

.float-stem {
  position: absolute;
  left: 50%;
  top: 12px;
  width: 12px;
  height: 210px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, #ff4a40 0 30%, #ffdf5a 30% 38%, #101b1d 38% 100%);
}

.ping-ring {
  position: absolute;
  inset: 8%;
  border: 2px solid rgba(255, 255, 255, 0.26);
  border-radius: 50%;
  animation: ping 2.4s ease-out infinite;
}

.ping-ring-two {
  animation-delay: 1.1s;
}

.bite-readout {
  justify-self: center;
  text-align: center;
}

.readout-label {
  display: block;
  margin-bottom: 2px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
}

.bite-readout strong {
  display: block;
  font-size: clamp(5rem, 24vw, 9rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.hero-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-actions button {
  flex: 1 1 150px;
}

.stats-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.detail-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-grid article,
.detail-grid article,
.intervals,
.control-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 10px 30px rgba(28, 66, 72, 0.08);
}

.stats-grid article,
.detail-grid article {
  min-height: 90px;
  padding: 14px;
}

.stats-grid span,
.detail-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stats-grid strong,
.detail-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1rem, 3.5vw, 1.45rem);
  line-height: 1.15;
}

.control-band {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding: 16px;
}

.control-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.control-row label {
  color: var(--deep);
  font-weight: 800;
}

.control-row input[type="range"] {
  width: 100%;
  accent-color: var(--water);
}

.control-row input[type="checkbox"] {
  width: 30px;
  height: 30px;
  accent-color: var(--water);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button-row button {
  flex: 1 1 130px;
}

.intervals {
  margin-top: 14px;
  padding: 16px;
}

.intervals h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.intervals ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.intervals li {
  min-height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ecf5f5;
  color: var(--deep);
  font-weight: 800;
}

@keyframes ping {
  from {
    transform: scale(0.38);
    opacity: 0.86;
  }

  to {
    transform: scale(1.08);
    opacity: 0;
  }
}

@keyframes alert-flash {
  0%,
  100% {
    box-shadow: var(--shadow);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(255, 59, 48, 0.32), var(--shadow);
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-panel {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .water-visual {
    width: min(68vw, 250px);
  }

  .bite-readout {
    margin-top: -26px;
  }

  .stats-grid,
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .shell {
    padding: 12px;
  }

  .stats-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
