:root {
  --bg: #eaf4f2;
  --text: #1b3330;
  --muted: #4e6f6a;
  --accent: #1f7a6c;
  --white: #ffffff;
  --chip: #d7e8e4;
  --alert: #f5e4a8;
  --alert-text: #5a4710;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  height: 100dvh;
}

body {
  font-family: ui-sans-serif, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input,
textarea {
  user-select: text;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: min(400px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 0;
  overflow: auto;
  padding: calc(16px + env(safe-area-inset-top)) 0 16px;
}

.note {
  width: 100%;
  background: var(--alert);
  color: var(--alert-text);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.4;
  margin-bottom: 24px;
}

.note strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

.stage {
  position: relative;
  width: min(280px, 78vw);
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  touch-action: none;
}

.viz {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.eject-face {
  position: relative;
  z-index: 2;
  width: 63%;
  aspect-ratio: 1;
  border-radius: 50%;
  color: var(--white);
  background: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  touch-action: manipulation;
}

.eject-face.is-on .duration {
  display: none;
}

#eject {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px 2px;
  touch-action: manipulation;
}

#eject-label {
  font-size: 26px;
  font-weight: 700;
}

#eject-hint {
  font-size: 12px;
  font-weight: 600;
  min-height: 1em;
}

.duration {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

#dur-up,
#dur-down {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  line-height: 1;
  min-width: 44px;
  min-height: 32px;
  padding: 6px 14px;
  cursor: pointer;
  touch-action: manipulation;
}

#dur-input {
  width: 4.2ch;
  border: 0;
  background: rgba(0, 0, 0, 0.16);
  border-radius: 8px;
  color: inherit;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  padding: 2px 6px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

#dur-input:focus {
  background: rgba(0, 0, 0, 0.24);
}

.tone-bar {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
}

#test-sound {
  border: 0;
  border-radius: 999px;
  min-height: 36px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: var(--white);
  cursor: pointer;
  touch-action: manipulation;
}

#test-sound.is-on,
#test-sound.is-next {
  color: var(--white);
  background: var(--accent);
}

#test-sound.is-next {
  animation: test-next 1.6s ease-in-out infinite;
}

@keyframes test-next {
  50% {
    transform: scale(1.05);
  }
}

@media (prefers-reduced-motion: reduce) {
  #test-sound.is-next {
    animation: none;
  }
}

.tone-pill {
  width: min(400px, 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  border-radius: 28px;
  background: var(--white);
}

.hz-edit {
  display: flex;
  align-items: baseline;
  gap: 3px;
  flex-shrink: 0;
  font-size: 16px;
  font-weight: 700;
}

#hz-field {
  width: 5.2ch;
  border: 0;
  background: var(--chip);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  padding: 6px 6px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.hz-edit span {
  color: var(--muted);
}

#hz {
  flex: 1 1 auto;
  min-width: 72px;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
  cursor: pointer;
  touch-action: pan-x;
  -webkit-appearance: none;
  appearance: none;
}

#hz::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: #668880;
}

#hz::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -11px;
  border: 2px solid var(--white);
  border-radius: 50%;
  background: var(--accent);
}

#hz::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: #668880;
}

#hz::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: 2px solid var(--white);
  border-radius: 50%;
  background: var(--accent);
}

#tone-play {
  flex-shrink: 0;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 22px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  background: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
}

#tone-play.is-on {
  background: var(--accent);
}

.bt-sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  border: 0;
  margin: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(27, 51, 48, 0.4);
}

.bt-sheet:not([open]) {
  display: none;
}

.bt-card {
  width: min(360px, 100%);
  background: var(--white);
  color: var(--text);
  border-radius: 20px;
  padding: 20px 18px 16px;
}

.bt-card strong {
  display: block;
  font-size: 18px;
  margin-bottom: 8px;
}

.bt-card p {
  font-size: 15px;
  line-height: 1.4;
  color: var(--muted);
  margin-bottom: 16px;
}

#bt-primary {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  background: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
}

.bt-anyway {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
}

@media (max-height: 620px) {
  .note {
    margin-bottom: 12px;
    padding: 10px 12px;
  }

  .stage {
    width: min(220px, 62vw);
  }

  #eject-label {
    font-size: 22px;
  }
}

button:focus-visible, input:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 3px;
}
#eject:focus-visible, #dur-up:focus-visible, #dur-down:focus-visible, #dur-input:focus-visible {
  outline-color: var(--white);
}
