/* ============================================================
   PULSR — neon hardware drum machine
   ============================================================ */

:root {
  --bg: #07070d;
  --text: #e9e9f4;
  --dim: #8b8ba3;
  --line: rgba(255, 255, 255, 0.08);
  --panel: rgba(255, 255, 255, 0.04);
  --accent: #7c5cff;
  --accent2: #00e5ff;
  --cell: 42px;
  --cell-gap: 6px;
  --group-gap: 14px;
  --label-w: 214px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- layered ambient background --- */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -2;
  background:
    radial-gradient(40% 50% at 18% 20%, rgba(124, 92, 255, 0.16), transparent 65%),
    radial-gradient(45% 55% at 85% 15%, rgba(0, 229, 255, 0.10), transparent 65%),
    radial-gradient(50% 60% at 50% 110%, rgba(255, 77, 166, 0.10), transparent 60%),
    var(--bg);
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1); }
  100% { transform: translate3d(2%, 2%, 0) scale(1.06); }
}

#bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  opacity: 0.55;
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    rgba(0, 0, 0, 0.12) 2px 3px
  );
  opacity: 0.35;
  mix-blend-mode: overlay;
}

/* --- layout shell --- */
.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 34px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: relative;
  z-index: 1;
}

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* --- header / brand --- */
.top {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-end;
  justify-content: space-between;
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 15px; }

.logo-mark {
  width: 92px;
  height: 92px;
  flex: none;
  filter: drop-shadow(0 2px 13px rgba(124, 92, 255, 0.32));
}

.brand h1 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: clamp(31px, 4.4vw, 46px);
  font-weight: 800;
  letter-spacing: -0.012em;
  line-height: 1;
  color: #f5f5fb;
}

.brand h1 span { color: var(--accent2); }

.tagline {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

/* --- transport --- */
.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  padding: 14px 20px;
}

.play {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(124, 92, 255, 0.7);
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(150deg, #241d47, #101020);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: box-shadow 0.25s, transform 0.1s;
  box-shadow: 0 0 0 rgba(124, 92, 255, 0);
  flex: none;
}

.play svg { width: 24px; height: 24px; fill: var(--text); }
.play .ic-stop { display: none; }
.play:hover { box-shadow: 0 0 24px rgba(124, 92, 255, 0.5); }
.play:active { transform: scale(0.94); }

body.playing .play {
  border-color: var(--accent2);
  box-shadow: 0 0 26px rgba(0, 229, 255, 0.55), 0 0 60px rgba(0, 229, 255, 0.15);
}
body.playing .play .ic-play { display: none; }
body.playing .play .ic-stop { display: block; fill: var(--accent2); }

.knob { display: flex; flex-direction: column; gap: 7px; min-width: 108px; }

.knob label,
.preset-wrap label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--dim);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.knob output { color: var(--text); }

/* custom range inputs */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 108px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px rgba(124, 92, 255, 0.8);
  transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.25); }

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px rgba(124, 92, 255, 0.8);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.preset-wrap { display: flex; flex-direction: column; gap: 7px; }

select {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 30px 8px 12px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b8ba3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
select:hover { border-color: rgba(124, 92, 255, 0.6); }
select option { background: #14141f; }

.actions { display: flex; gap: 8px; }

.export-wrap { position: relative; }

#exportBtn.open {
  color: var(--text);
  border-color: rgba(0, 229, 255, 0.6);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.25);
}

.export-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  min-width: 210px;
  padding: 7px;
  background: rgba(16, 16, 28, 0.96);
  border: 1px solid rgba(124, 92, 255, 0.35);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 24px rgba(124, 92, 255, 0.18);
  animation: menuIn 0.14s ease-out;
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.export-head {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 6px 10px 8px;
}

.export-menu button {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 8px;
  padding: 9px 11px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.export-menu button span {
  font-weight: 400;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--dim);
}

.export-menu button:hover {
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.22), rgba(0, 229, 255, 0.14));
  color: #fff;
}

.export-menu button:hover span { color: var(--accent2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 60;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: var(--text);
  background: rgba(16, 16, 28, 0.96);
  border: 1px solid rgba(0, 229, 255, 0.45);
  border-radius: 12px;
  padding: 13px 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 22px rgba(0, 229, 255, 0.18);
  max-width: min(90vw, 460px);
  text-align: center;
}

.toast b { color: var(--accent2); font-weight: 700; }

.chip {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.chip:hover {
  color: var(--text);
  border-color: rgba(0, 229, 255, 0.55);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.25);
}

/* --- sequencer machine --- */
.machine {
  padding: 22px 22px 24px;
  overflow-x: auto;
}

.row {
  display: flex;
  align-items: center;
  margin-bottom: 9px;
}
.row:last-child { margin-bottom: 0; }

.row-label {
  flex: none;
  width: var(--label-w);
  display: flex;
  align-items: center;
  gap: 9px;
  padding-right: 16px;
}

.row-label .dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tc);
  box-shadow: 0 0 9px var(--tc);
}

.row-label .name {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 2px;
  text-align: left;
  white-space: nowrap;
  transition: text-shadow 0.2s, color 0.2s;
}
.row-label .name:hover { color: #fff; text-shadow: 0 0 12px var(--tc); }

.row-label .spacer-grow { flex: 1; }

.row-label .mute {
  flex: none;
  font-family: var(--mono);
  font-size: 10px;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--dim);
  cursor: pointer;
  transition: all 0.15s;
}
.row-label .mute:hover { border-color: rgba(255, 94, 94, 0.6); }
.row.muted .row-label .mute {
  background: rgba(255, 94, 94, 0.18);
  border-color: rgba(255, 94, 94, 0.75);
  color: #ff8a8a;
  box-shadow: 0 0 10px rgba(255, 94, 94, 0.35);
}

.row-label .vol {
  width: 58px;
  height: 3px;
  background: rgba(255, 255, 255, 0.16);
}
.row-label .vol::-webkit-slider-thumb {
  width: 11px;
  height: 11px;
  border-color: var(--tc);
  box-shadow: 0 0 8px var(--tc);
}
.row-label .vol::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border-color: var(--tc);
  box-shadow: 0 0 8px var(--tc);
}
.row-label .vol::-moz-range-track { background: rgba(255, 255, 255, 0.16); }

.cells {
  display: flex;
  gap: var(--cell-gap);
  flex: none;
}

/* wider gap between every 4-step group */
.cells > :nth-child(4n):not(:last-child) { margin-right: var(--group-gap); }

.cell {
  flex: none;
  width: var(--cell);
  height: var(--cell);
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  position: relative;
  transition: background 0.12s, box-shadow 0.15s, border-color 0.12s, filter 0.1s;
}

.cell:hover {
  border-color: color-mix(in srgb, var(--tc) 65%, transparent);
  background: rgba(255, 255, 255, 0.07);
}

.cell.on {
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--tc) 88%, #ffffff 6%),
    color-mix(in srgb, var(--tc) 55%, #000000 25%)
  );
  border-color: color-mix(in srgb, var(--tc) 85%, white);
  box-shadow:
    0 0 12px color-mix(in srgb, var(--tc) 65%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.cell.accent {
  box-shadow:
    0 0 20px var(--tc),
    0 0 42px color-mix(in srgb, var(--tc) 45%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.cell.accent::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px #fff;
}

/* playhead column */
.cell.playing {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.10);
}
.cell.on.playing { filter: brightness(1.45) saturate(1.15); }

/* trigger flash */
@keyframes hit {
  0%   { transform: scale(1.22); filter: brightness(2.1); }
  100% { transform: scale(1);    filter: brightness(1); }
}
.cell.hit { animation: hit 0.14s ease-out; }

.row.muted .cell { opacity: 0.32; }

/* --- LED strip --- */
.led-row { margin-bottom: 14px; }
.led-row .spacer { visibility: hidden; }

.led-slot {
  flex: none;
  width: var(--cell);
  display: grid;
  place-items: center;
}

.led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.08s, box-shadow 0.08s;
}

.led-slot.beat .led {
  width: 9px;
  height: 9px;
  background: rgba(255, 255, 255, 0.2);
}

.led.on {
  background: var(--accent2);
  box-shadow: 0 0 10px var(--accent2), 0 0 22px rgba(0, 229, 255, 0.5);
}

/* --- footer --- */
.hints {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--dim);
  padding: 0 6px;
}

kbd {
  font-family: var(--mono);
  font-size: 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 7px;
  margin-right: 5px;
}

.credit { margin-left: auto; opacity: 0.7; }

/* --- responsive --- */
@media (max-width: 980px) {
  :root { --cell: 34px; --label-w: 190px; }
}

@media (max-width: 700px) {
  :root { --cell: 30px; --cell-gap: 4px; --group-gap: 10px; --label-w: 170px; }
  .shell { padding: 22px 14px 40px; }
  .transport { gap: 14px; }
  .credit { margin-left: 0; }
}
