h1 {
  font-size: 14px;
  text-align: center;
}

:root {
  --bg: #0b0e14;
  --panel: #111522;
  --panel2: #0f1320;
  --ink: #e8ecf4;
  --muted: #9aa3b2;
  --accent: #8be9fd;
  --recFlat: #ff3b30; /* REC */
  --odub: #ff9f0a; /* OVERDUB */
  --stopFlat: #c40030; /* STOP */
  --playBg: #121a18; /* PLAY neutral bg */
  --ok: #30d158;
  --line: rgba(255, 255, 255, 0.1);
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, Segoe UI, Roboto, Helvetica, Arial;
}
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

/* App grid */
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
}
.grid > .card {
  min-width: 0;
}
@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  position: relative;
}
.subcard {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

select,
button,
input[type="range"],
input[type="number"],
.pill {
  background: #0e1324;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}
button {
  cursor: pointer;
}
button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
label {
  font-size: 12px;
  color: #9aa3b2;
}
.pill {
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.danger {
  border-color: rgba(255, 77, 79, 0.35);
  color: #ffb3b6;
}
.ok {
  border-color: rgba(48, 209, 88, 0.35);
  color: #b6ffd1;
}
.pill.icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pill.iconOnly {
  width: 40px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  flex: 0 0 40px;
  text-align: center;
}
.mutebtn {
  min-width: 40px;
  flex: 0 0 40px;
}
.odSlider {
  flex: 1 1 160px;
  min-width: 120px;
}

/* Dial + orb section */
.dialWrap {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: center;
}
.dial {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  background: #121725;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.dialCol {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.dialCenter {
  display: grid;
  justify-items: start;
  row-gap: 8px;
}

/* ===== Small-screen fixes (≤720px) ===== */
@media (max-width: 720px) {
  .wrap {
    padding: 10px;
  }
  .dial.dialWrap {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .dialCol {
    order: 1;
    align-items: center;
  }
  .dialCenter {
    order: 2;
    width: 100%;
  }
  #metroBox {
    width: 100%;
    margin-top: 8px;
  }

  #mainCard {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 8px 6px !important;
  }
  .dial {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
  }
  #countInView {
    border: none !important;
  }

  .odubRow {
    justify-content: center;
  }
}

.dialStack {
  position: relative;
  width: 240px;
  height: 240px;
  display: grid;
  place-items: center;
  margin: 0 auto;
}
.ring {
  --p: 0;
  --beats: 4;
  --bpb: 4;
  --ringColor: var(--accent);
  position: absolute;
  inset: 0;
  margin: auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: conic-gradient(
    var(--ringColor) calc(var(--p) * 1turn),
    rgba(255, 255, 255, 0.06) 0
  );
  -webkit-mask: radial-gradient(
    circle at 50% 50%,
    transparent 58px,
    #000 59px,
    #000 100%
  );
  mask: radial-gradient(
    circle at 50% 50%,
    transparent 58px,
    #000 59px,
    #000 100%
  );
  pointer-events: none;
  z-index: 0;
}
.ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(
      from -90deg,
      rgba(255, 255, 255, 0.18) 0 calc(1turn / var(--bpb) - 1deg),
      transparent 0 calc(1turn / var(--bpb))
    ),
    repeating-conic-gradient(
      from -90deg,
      rgba(255, 255, 255, 0.1) 0 calc(1turn / var(--beats) - 0.5deg),
      transparent 0 calc(1turn / var(--beats))
    );
  -webkit-mask: radial-gradient(
    circle at 50% 50%,
    transparent 58px,
    #000 59px,
    #000 100%
  );
  mask: radial-gradient(
    circle at 50% 50%,
    transparent 58px,
    #000 59px,
    #000 100%
  );
  pointer-events: none;
}

/* Main round button */
#fsMain {
  position: relative;
  z-index: 1;
}
.btnMain {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.6px;
  line-height: 1;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  user-select: none;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.btnMain.rec {
  background: var(--recFlat);
  border-color: rgba(255, 255, 255, 0.18);
}
.btnMain.odub {
  background: var(--odub);
  border-color: rgba(255, 255, 255, 0.18);
}
.btnMain.play {
  background: var(--playBg);
  border-color: rgba(48, 209, 88, 0.45);
}
.btnMain.stop {
  background: var(--stopFlat);
  border-color: rgba(255, 255, 255, 0.22);
}
.btnMain[disabled] {
  opacity: 0.55;
}
.btnMain .icon {
  font-size: 24px;
  line-height: 1;
}
.btnMain .txt {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
}
.btnMain.pressable:not([disabled]):hover {
  opacity: 0.94;
}

@keyframes breathe {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.08);
  }
}
.btnMain.breathing {
  animation: breathe 1.2s ease-in-out infinite;
}

/* Ripple */
.pressable {
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.pressable::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%) scale(0);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.45) 0,
    rgba(255, 255, 255, 0.25) 40%,
    rgba(255, 255, 255, 0) 70%
  );
  opacity: 0;
  pointer-events: none;
}
@keyframes rippleCenter {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0.35;
  }
  100% {
    transform: translate(-50%, -50%) scale(18);
    opacity: 0;
  }
}
.pressable:active::after {
  animation: rippleCenter 500ms ease-out;
}
.pressable:focus:not(:active)::after {
  animation: rippleCenter 500ms ease-out;
}
.pressable:focus-visible {
  outline: 2px solid rgba(139, 233, 253, 0.85);
  outline-offset: 2px;
}

/* Overdub CTA */
.odubRow {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.odubBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  min-width: 180px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0e1324;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.4px;
  transition: opacity 0.15s ease, box-shadow 0.15s ease;
}
.odubBtn.enabled {
  border-color: rgba(255, 159, 10, 0.55);
  box-shadow: inset 0 0 0 9999px rgba(255, 159, 10, 0.12);
}
.odubBtn.enabled:hover {
  opacity: 0.94;
}
.odubBtn.disabled {
  opacity: 0.6;
}
.odubBtn.queued {
  border-color: rgba(255, 159, 10, 0.75);
  box-shadow: inset 0 0 0 9999px rgba(255, 159, 10, 0.18);
}

.tempo {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.tempo small {
  font-weight: 600;
  color: #a8b0c2;
  font-size: 13px;
  margin-left: 6px;
}
.phase {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #c2c9dc;
}
.meter {
  width: 120px;
  height: 10px;
  border-radius: 8px;
  background: #151a2b;
  border: 1px solid var(--line);
  overflow: hidden;
}
.meter > .fill {
  height: 100%;
  width: 0;
  background: #7aa6ff;
}

/* Toggle */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  background: #0e1324;
  border: 1px solid var(--line);
  transition: opacity 0.15s ease;
}
.toggle[aria-pressed="true"] {
  border-color: rgba(48, 209, 88, 0.45);
  box-shadow: inset 0 0 0 9999px rgba(48, 209, 88, 0.08);
}
.toggle:hover {
  opacity: 0.94;
}
.toggle .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #394057;
  transition: background 0.15s ease;
}
.toggle[aria-pressed="true"] .dot {
  background: #30d158;
}

/* Onboarding overlay */
.onboard {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 12, 0.75);
  backdrop-filter: blur(6px);
  z-index: 9999;
  padding: 16px;
}
.onboard.hidden {
  display: none;
}
.onboard .panel {
  width: min(560px, 96vw);
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}
.onboard h2 {
  margin: 0 0 8px 0;
  font-size: 18px;
}
.onboard .col {
  display: grid;
  justify-items: stretch;
  gap: 8px;
  max-width: 360px;
  margin: 12px auto 0;
}
.hint {
  color: #9aa3b2;
  font-size: 12px;
}

/* Settings gear */
.gearBtn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #0e1324;
  color: #ink;
  font-size: 16px;
  line-height: 1;
  transition: opacity 0.15s ease;
  z-index: 3;
}
.gearBtn:hover {
  opacity: 0.94;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 12, 0.75);
  backdrop-filter: blur(6px);
  z-index: 9998;
  padding: 16px;
}
.modal.show {
  display: flex;
}
.modal .panel {
  width: min(560px, 96vw);
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.modal h3 {
  margin: 0 0 8px 0;
}
.modal .row {
  margin-top: 8px;
}
.modal .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Settings & Onboarding modal footer */
.modal .modalFooter,
.onboard .modalFooter {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.modal .modalFooter .mailto,
.onboard .modalFooter .mailto {
  color: var(--accent);
  text-decoration: none;
}
.modal .modalFooter .mailto:hover,
.onboard .modalFooter .mailto:hover {
  text-decoration: underline;
}
