:root {
  color-scheme: dark;
  --bg: #000;
  --fg: #fff;
  --muted: #8e8e93;
  --line: #2c2c2e;
  --green: #30d158;
  --red: #ff453a;
  --amber: #ff9f0a;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); color: var(--fg); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

main {
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
}

#time {
  margin: 16vh 0 7vh;
  text-align: center;
  font-size: min(21vw, 100px);
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
#time.long { font-size: min(16vw, 78px); }

.controls { display: flex; justify-content: space-between; padding: 0 4px; }

.round {
  --c: #333;
  width: 84px;
  height: 84px;
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 17px;
  cursor: pointer;
  background: var(--c);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c);
  touch-action: manipulation;
}
.round:active { filter: brightness(1.3); }
.round:disabled { opacity: 0.5; cursor: default; filter: none; }
.gray  { --c: #333336; color: var(--fg); }
.green { --c: #0a2a12; color: var(--green); }
.red   { --c: #330e0c; color: var(--red); }

.auto {
  margin: 28px auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #1c1c1e;
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}
.auto svg { width: 18px; height: 18px; fill: var(--amber); }
.auto.on { border-color: var(--amber); color: var(--amber); }
.auto:disabled { opacity: 0.4; cursor: default; }

#listen { margin-top: 14px; }
.meter {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: #1c1c1e;
  overflow: hidden;
}
#fill { height: 100%; width: 0; background: #48484a; transition: width 60ms linear; }
#fill.loud { background: var(--amber); }
#fill.voice { background: var(--green); }
#mark { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--fg); left: 100%; }

.sens {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.sens input { flex: 1; accent-color: var(--amber); }

#status { min-height: 1.3em; margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 13px; }

#laps {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
#laps li {
  display: flex;
  justify-content: space-between;
  padding: 11px 4px;
  border-top: 0.5px solid var(--line);
}
#laps li:last-child { border-bottom: 0.5px solid var(--line); }
#laps .best  { color: var(--green); }
#laps .worst { color: var(--red); }
