:root {
  color-scheme: dark;
  --bg: #000;
  --fg: #fff;
  --muted: rgba(255, 255, 255, 0.62);
  --panel: #090909;
  --panel-line: rgba(255, 255, 255, 0.22);
  --button-size: 84px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--fg);
  background: var(--bg);
  font-family: "Aptos Display", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.meter-app {
  width: min(100%, 560px);
  min-height: 100svh;
  display: grid;
  grid-template-rows: minmax(250px, 0.85fr) auto auto;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 20px max(22px, env(safe-area-inset-bottom));
}

.readout {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 18px;
}

.current-line {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 18px;
}

.current-value {
  font-size: clamp(7.4rem, 30vw, 11rem);
  font-weight: 520;
  line-height: 0.86;
  letter-spacing: 0;
}

.unit {
  font-size: clamp(5.7rem, 23vw, 8rem);
  font-weight: 520;
  line-height: 1;
  letter-spacing: 0;
}

.status-text {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
  letter-spacing: 0;
  text-align: right;
}

.status-text.error {
  color: #fff;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 9svh;
}

.stat {
  min-width: 0;
  display: grid;
  gap: 34px;
  justify-items: center;
}

.stat-label {
  color: var(--fg);
  font-size: clamp(3rem, 13vw, 4.25rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
}

.stat-value {
  min-height: 1.2em;
  color: var(--fg);
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 520;
  line-height: 1;
  letter-spacing: 0;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 42px;
}

.icon-button {
  width: var(--button-size);
  height: var(--button-size);
  flex: 0 0 var(--button-size);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #000;
  background: #fff;
  cursor: pointer;
  transition:
    transform 140ms ease,
    color 140ms ease,
    background-color 140ms ease,
    outline-color 140ms ease;
}

.icon-button:hover {
  transform: translateY(-2px);
}

.icon-button:active {
  transform: scale(0.96);
}

.icon-button:focus-visible,
.text-button:focus-visible,
.settings-panel input:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.icon-button svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.icon-button.primary {
  transform: translateY(-2px);
}

.icon-button[aria-pressed="true"] {
  color: #fff;
  outline: 2px solid #fff;
  background: #000;
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.52;
  transform: none;
}

.settings-dialog {
  width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  color: #fff;
  background: var(--panel);
  padding: 0;
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.74);
}

.settings-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.settings-panel h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: 0;
}

.settings-panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.settings-panel input {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  color: #fff;
  background: #000;
  padding: 0 12px;
}

.settings-panel input[type="range"] {
  padding: 0;
  accent-color: #fff;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

.text-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #000;
  background: #fff;
  cursor: pointer;
}

@media (max-width: 430px) {
  :root {
    --button-size: 72px;
  }

  .meter-app {
    grid-template-rows: auto auto auto;
    align-content: space-between;
    padding-left: 16px;
    padding-right: 16px;
  }

  .readout {
    padding-top: 10svh;
  }

  .current-value {
    font-size: 7.65rem;
  }

  .unit {
    font-size: 5.75rem;
  }

  .stats {
    gap: 12px;
    margin-bottom: 0;
  }

  .stat-label {
    font-size: 3rem;
  }

  .stat-value {
    font-size: 2rem;
  }

  .controls {
    gap: 24px;
  }
}

@media (min-width: 720px) {
  :root {
    --button-size: 80px;
  }

  .meter-app {
    grid-template-rows: minmax(300px, 1fr) auto auto;
    padding-top: 20px;
    padding-bottom: 20px;
  }

  .current-value {
    font-size: 8.8rem;
  }

  .unit {
    font-size: 6.4rem;
  }

  .stats {
    margin-bottom: 9svh;
  }
}
