/* Controls: buttons, fields, knobs, meters, panels, overlays. */

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--panel-3), var(--panel-2));
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
    color var(--fast) var(--ease), transform 60ms var(--ease), box-shadow var(--fast) var(--ease);
}

.btn:hover {
  border-color: var(--line-2);
  color: var(--text);
  background: linear-gradient(180deg, var(--panel-hi), var(--panel-3));
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  border-color: rgba(255, 196, 107, 0.65);
  color: #1a1206;
  box-shadow: 0 6px 18px rgba(255, 122, 26, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #ffd08a, #ff8f2e);
  color: #1a1206;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-soft);
  color: var(--text);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  border-radius: 8px;
}

.btn-lg {
  height: 48px;
  padding: 0 28px;
  font-size: 14px;
  border-radius: 12px;
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.btn-icon.btn-sm {
  width: 28px;
}

.btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-hi);
}

/* --------------------------------------------------------------- transport */

.transport {
  display: flex;
  align-items: center;
  gap: 6px;
}

.play-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #2a3140, #171c25);
  border: 1px solid var(--line-2);
  color: var(--text);
  box-shadow: var(--shadow-1);
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
    color var(--fast) var(--ease), transform 60ms var(--ease);
}

.play-btn:hover {
  border-color: #3d4a5e;
}

.play-btn:active {
  transform: scale(0.96);
}

.play-btn svg {
  width: 17px;
  height: 17px;
}

.play-btn.is-playing {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  border-color: rgba(255, 196, 107, 0.7);
  color: #1a1206;
  box-shadow: var(--glow);
}

/* ------------------------------------------------------------------ fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.field-label {
  font-size: 8px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
  padding-left: 2px;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  height: 32px;
  padding: 0 26px 0 10px;
  border-radius: 9px;
  background-color: var(--panel-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a94a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 9px;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}

.select:hover {
  border-color: var(--line-2);
  background-color: var(--panel-3);
}

.select:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

.select option {
  background: var(--panel-2);
  color: var(--text);
}

/* ------------------------------------------------------------- drag number */

.dragnum {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 58px;
  height: 42px;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color var(--fast) var(--ease);
}

.dragnum:hover {
  border-color: var(--line-2);
}

.dragnum-value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.dragnum-label {
  font-size: 7px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
}

/* ------------------------------------------------------------------- knobs */

.knob {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: ns-resize;
}

.knob-dial {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
}

.knob-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 225deg,
    var(--accent) calc(var(--p, 0) * 270deg),
    rgba(255, 255, 255, 0.07) 0
  );
  -webkit-mask: radial-gradient(closest-side, transparent 68%, #000 69%);
  mask: radial-gradient(closest-side, transparent 68%, #000 69%);
}

.knob-cap {
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: linear-gradient(180deg, #2c3443, #141922);
  border: 1px solid #333d4e;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.knob-cap::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 3px;
  width: 2px;
  height: 9px;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--accent);
  transform-origin: 50% 12px;
  transform: rotate(calc(-135deg + var(--p, 0) * 270deg));
  box-shadow: 0 0 6px rgba(255, 157, 46, 0.6);
}

.knob.is-dragging .knob-cap {
  border-color: var(--accent-line);
}

.knob-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 0;
  width: 100%;
}

.knob-label {
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.knob-value {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--accent-hi);
  white-space: nowrap;
}

/* -------------------------------------------------------------- param panel */

.param-groups {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.param-group {
  padding: 11px 10px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent 60%), var(--panel-2);
  border: 1px solid var(--line-soft);
}

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
}

.group-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.knob-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 4px;
}

.knob-grid .field {
  grid-column: span 3;
}

/* A lone fourth knob sits centred instead of hanging off the left edge. */
.knob-grid > :nth-child(4):last-child {
  grid-column: 2;
}

.knob-grid > :only-child {
  grid-column: 2;
}

/* -------------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  flex: 0 0 auto;
}

.tab {
  flex: 1;
  height: 30px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.tab:hover {
  color: var(--text-2);
}

.tab.is-active {
  background: linear-gradient(180deg, var(--panel-hi), var(--panel-3));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

/* --------------------------------------------------------------- segmented */

.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.segmented button {
  height: 26px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.segmented button:hover {
  color: var(--text-2);
}

.segmented button.is-active {
  background: var(--accent-soft);
  color: var(--accent-hi);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

/* ------------------------------------------------------------------- meter */

.meter {
  display: flex;
  gap: 3px;
  align-items: stretch;
  height: 30px;
  width: 46px;
  padding: 3px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.meter-bar {
  position: relative;
  flex: 1;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.meter-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(0deg, #3ddc97 0%, #b8e986 55%, #ffd166 78%, #ff5470 100%);
  transition: height 70ms linear;
}

/* ------------------------------------------------------------ pattern tabs */

.pattern-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.pattern-tab {
  position: relative;
  height: 40px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease),
    border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.pattern-tab:hover {
  border-color: var(--line-2);
  color: var(--text-2);
}

.pattern-tab.is-active {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  border-color: rgba(255, 196, 107, 0.6);
  color: #1a1206;
  box-shadow: var(--glow);
}

.pattern-tab .dot {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-2);
  opacity: 0.9;
  display: none;
}

.pattern-tab.has-notes .dot {
  display: block;
}

.pattern-tab.is-active .dot {
  background: #1a1206;
}

/* ----------------------------------------------------------------- presets */

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.preset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  text-align: left;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.preset:hover {
  background: var(--panel-2);
  border-color: var(--line-soft);
}

.preset.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.preset-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.preset.is-active .preset-name {
  color: var(--accent-hi);
}

.preset-tag {
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
}

/* ---------------------------------------------------------------- sidebar */

.side-section {
  padding: 11px 10px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 60%), var(--panel-2);
  border: 1px solid var(--line-soft);
}

.side-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
}

.side-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.side-row {
  display: flex;
  gap: 6px;
}

.side-row .btn {
  flex: 1;
}

.side-note {
  margin-top: 8px;
  font-size: 10px;
  line-height: 1.45;
  color: var(--dim);
}

/* ------------------------------------------------------------------ stage */

.stage-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 2px;
  flex: 0 0 auto;
}

.stage-hint {
  margin-left: auto;
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------------- pads */

.pads {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px;
  flex: 0 0 auto;
  min-height: 64px;
  scrollbar-width: none;
}

.pads::-webkit-scrollbar {
  display: none;
}

.pad {
  flex: 1 0 52px;
  min-width: 52px;
  height: 60px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--panel-3), var(--panel-2));
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
    border-color var(--fast) var(--ease), transform 60ms var(--ease);
}

.pad:hover {
  border-color: var(--line-2);
}

.pad.is-root {
  border-color: var(--accent-line);
}

.pad.is-down {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  border-color: rgba(255, 196, 107, 0.7);
  color: #1a1206;
  box-shadow: var(--glow);
  transform: translateY(1px);
}

.pad-note {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--mono);
}

.pad-deg {
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 700;
}

.pad.is-down .pad-deg {
  color: rgba(26, 18, 6, 0.65);
}

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 80;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}

@media (max-width: 860px) {
  .toasts {
    right: 12px;
    bottom: 84px;
  }
}

.toast {
  padding: 9px 15px;
  border-radius: 10px;
  background: rgba(20, 24, 33, 0.96);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  font-size: 12px;
  color: var(--text-2);
  animation: toast-in 180ms var(--ease);
}

.toast.is-out {
  animation: toast-out 200ms var(--ease) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

/* ------------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fade-in 160ms var(--ease);
}

.modal {
  width: min(600px, 100%);
  max-height: 82dvh;
  overflow-y: auto;
  padding: 22px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 30%), var(--panel);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  animation: modal-in 200ms var(--ease);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.modal h3 {
  margin: 16px 0 6px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-hi);
  font-weight: 800;
}

.modal p,
.modal li {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
}

.modal ul {
  margin: 0;
  padding-left: 18px;
}

.modal kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  text-align: center;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

/* -------------------------------------------------------------------- boot */

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 500px at 50% 0%, rgba(255, 157, 46, 0.08), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(58, 210, 255, 0.06), transparent 60%),
    var(--bg);
  transition: opacity 420ms var(--ease), visibility 420ms var(--ease);
}

.boot.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
  animation: drift 24s linear infinite;
}

@keyframes drift {
  to {
    background-position: 44px 44px, 44px 44px;
  }
}

.boot-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.boot-mark {
  display: grid;
  grid-template-columns: repeat(3, 12px);
  gap: 4px;
  margin-bottom: 4px;
}

.boot-mark span {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent);
  opacity: 0.18;
  animation: pulse 2.4s var(--ease) infinite;
}

.boot-mark span:nth-child(1) { animation-delay: 0s; }
.boot-mark span:nth-child(2) { animation-delay: 0.12s; }
.boot-mark span:nth-child(3) { animation-delay: 0.24s; }
.boot-mark span:nth-child(4) { animation-delay: 0.36s; }
.boot-mark span:nth-child(5) { animation-delay: 0.48s; }
.boot-mark span:nth-child(6) { animation-delay: 0.6s; }
.boot-mark span:nth-child(7) { animation-delay: 0.72s; }
.boot-mark span:nth-child(8) { animation-delay: 0.84s; }
.boot-mark span:nth-child(9) { animation-delay: 0.96s; }

@keyframes pulse {
  0%, 100% { opacity: 0.16; }
  50% { opacity: 1; box-shadow: 0 0 14px rgba(255, 157, 46, 0.6); }
}

.boot-title {
  font-size: clamp(34px, 8vw, 62px);
  font-weight: 800;
  letter-spacing: 0.2em;
  padding-left: 0.2em;
  line-height: 1;
  background: linear-gradient(180deg, #ffffff 0%, #ffc46b 55%, #ff7a1a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.boot-sub {
  font-size: 13px;
  color: var(--muted);
  max-width: 34ch;
}

.boot-hint {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

/* --------------------------------------------------------------- utilities */

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spacer {
  flex: 1;
}

.mono {
  font-family: var(--mono);
}

.muted {
  color: var(--muted);
}

.dim {
  color: var(--dim);
}

/* Drawer triggers only exist on narrow screens. Declared last so it wins over
   the .btn display rule. */
.only-mobile {
  display: none;
}

@media (max-width: 1080px) {
  .only-mobile {
    display: inline-flex;
  }
}

/* The meter is decorative; on phones the space is better spent on controls. */
@media (max-width: 860px) {
  .meter {
    display: none;
  }
}
