@font-face {
  font-family: Inter;
  src: url("fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Oswald;
  src: url("fonts/oswald-latin.woff2") format("woff2");
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy: #0C1A36;
  --navy-deep: #0B1A3A;
  --navy-key: #0A1733;
  --panel: #122448;
  --panel-2: #152A52;
  --line: rgba(251, 246, 240, 0.12);
  --line-strong: rgba(251, 246, 240, 0.22);
  --bone: #FBF6F0;
  --bone-2: #F3EDE4;
  --muted: #8B97B0;
  --orange: #FD6815;
  --orange-d: #E25A0C;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--navy);
  color: var(--bone);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
  cursor: default;
}

body {
  position: fixed;
  inset: 0;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 10px) calc(var(--safe-b) + 8px) calc(var(--safe-l) + 10px);
  gap: 6px;
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex: 0 0 auto;
  padding: 0 2px 4px;
  border-bottom: 1px solid var(--line);
}

.brand h1 {
  margin: 0;
  font-family: Oswald, Inter, sans-serif;
  font-weight: 500;
  font-size: 24px;
  letter-spacing: 0.08em;
  line-height: 1;
  color: var(--bone);
}
.brand h1 span {
  color: var(--orange);
  letter-spacing: 0.12em;
}
.tag {
  margin: 3px 0 0;
  font-size: 9px;
  letter-spacing: 0.18em;
  font-weight: 600;
  color: var(--muted);
}

.led-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 2px;
}
.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3A4A68;
  box-shadow: inset 0 0 0 1px rgba(251, 246, 240, 0.15);
}
.led.is-ready {
  background: var(--orange);
  box-shadow: 0 0 8px rgba(253, 104, 21, 0.85);
}
.led.is-play {
  background: var(--orange);
  box-shadow: 0 0 10px rgba(253, 104, 21, 1);
}
.led-label {
  font-size: 9px;
  letter-spacing: 0.16em;
  font-weight: 650;
  color: var(--muted);
}

.install-hint,
.silent-hint {
  margin: 0;
  flex: 0 0 auto;
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: var(--muted);
}
.install-hint {
  color: var(--bone);
  background: var(--panel);
  border: 1px solid rgba(253, 104, 21, 0.45);
  border-left: 3px solid var(--orange);
  border-radius: 6px;
  padding: 6px 10px;
  font-weight: 600;
}
.install-hint[hidden] { display: none; }

.modes {
  display: flex;
  gap: 5px;
  flex: 0 0 auto;
}
.mode,
.hold-btn,
.oct-btn,
.scale-btn,
.div-btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--bone);
  font-family: Inter, sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: 6px;
  touch-action: manipulation;
  padding: 7px 0;
}
.mode {
  flex: 1;
  font-size: 10px;
  padding: 8px 0;
}
.mode.is-on,
.scale-btn.is-on,
.div-btn.is-on,
.hold-btn.is-on {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.scale-row { flex: 0 0 auto; }
.seg {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.scale-btn,
.div-btn {
  flex: 1;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 9px;
  letter-spacing: 0.04em;
  padding: 8px 2px;
}
.scale-btn:last-child,
.div-btn:last-child { border-right: 0; }

.util,
.tempo-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.hold-btn {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 0.1em;
}
.oct-wrap,
.root-wrap,
.bpm-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.oct-wrap { flex: 1; justify-content: center; }
.root-wrap { flex: 0 0 auto; }
.oct-btn {
  padding: 7px 8px;
  font-size: 10px;
  white-space: nowrap;
}
.root-step { padding: 7px 9px; }
.oct-btn:disabled { opacity: 0.35; }
.oct-range,
.root-name,
.bpm-val {
  font-family: Oswald, Inter, sans-serif;
  font-size: 15px;
  letter-spacing: 0.04em;
  font-weight: 500;
  min-width: 1.6em;
  text-align: center;
}
.oct-range { min-width: 5.2em; font-size: 14px; }
.mini-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.tempo-row .seg.divs { flex: 0 0 110px; }
.bpm-wrap { margin-left: auto; }
.bpm-val { min-width: 2em; }

.fx {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
  padding: 2px 0 0;
}
.slider {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  touch-action: none;
}
.slider-name {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.slider-track {
  position: relative;
  height: 18px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.slider-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 9px;
  background: linear-gradient(90deg, var(--orange-d), var(--orange));
  pointer-events: none;
}
.slider-thumb {
  position: absolute;
  top: 2px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: var(--bone);
  box-shadow: 0 0 0 1px rgba(12, 26, 54, 0.35);
  pointer-events: none;
}
.slider-val {
  font-size: 10px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--bone);
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pad-wrap {
  position: relative;
  background: var(--navy-deep);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(8, 16, 36, 0.45);
  touch-action: none;
}
#pad {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.pad-readout {
  position: absolute;
  left: 10px;
  bottom: 8px;
  font-family: Oswald, Inter, sans-serif;
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--bone);
  text-shadow: 0 0 8px rgba(253, 104, 21, 0.45);
  pointer-events: none;
}

.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgba(12, 26, 54, 0.94);
  text-align: center;
  touch-action: none;
}
.start-overlay.is-hidden { display: none; }
.start-brand {
  margin: 0;
  font-family: Oswald, Inter, sans-serif;
  font-size: 22px;
  letter-spacing: 0.16em;
  color: var(--bone);
}
.start-brand span { color: var(--orange); }
.start-cta {
  margin: 0;
  font-family: Oswald, Inter, sans-serif;
  font-size: 42px;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: var(--orange);
  text-shadow: 0 0 18px rgba(253, 104, 21, 0.45);
}
.start-sub {
  margin: 8px 0 0;
  max-width: 280px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

button:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

@media (max-height: 700px) {
  .brand h1 { font-size: 20px; }
  .start-cta { font-size: 34px; }
  .silent-hint { display: none; }
}

.loop-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.loop-row .seg.bars { flex: 0 0 96px; }
#loop-btn { min-width: 58px; }
#loop-btn.is-armed {
  background: var(--panel);
  border-color: var(--orange);
  color: var(--orange);
  animation: loop-pulse 1s ease-in-out infinite;
}
#loop-btn.is-rec,
#loop-btn.is-overdub {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}
#loop-btn.is-overdub { animation: loop-pulse 0.7s ease-in-out infinite; }
#loop-btn.is-play {
  background: var(--panel);
  border-color: var(--orange);
  color: var(--orange);
}
@keyframes loop-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(253, 104, 21, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(253, 104, 21, 0); }
}
.loop-meter {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.loop-progress {
  position: relative;
  flex: 1;
  height: 10px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: visible;
}
.loop-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--orange-d), var(--orange));
  pointer-events: none;
}
.loop-progress-head {
  position: absolute;
  top: -2px;
  width: 4px;
  height: 14px;
  margin-left: -2px;
  left: 0%;
  border-radius: 2px;
  background: var(--bone);
  box-shadow: 0 0 8px rgba(253, 104, 21, 0.8);
  pointer-events: none;
}
.loop-status {
  flex: 0 0 2.4em;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-align: right;
}
.loop-status.is-live { color: var(--orange); }
.seg.bars .div-btn:disabled { opacity: 0.35; }

/* v5: manual link */
.man-link { color: var(--orange); text-decoration: none; letter-spacing: inherit; font-weight: 700; margin-left: 6px; border-bottom: 1px solid rgba(253,104,21,0.5); }
.man-link:hover, .man-link:focus-visible { color: #fff; border-bottom-color: #fff; outline: none; }
