/* OPTI JAM — neon groovebox. Single dark theme, phone-capable,
   happiest on a desktop. */

:root {
  --bg: #0b0e17;
  --bg-2: #101527;
  --panel: #131a2e;
  --panel-edge: #1e2a4a;
  --ink: #e8ecff;
  --ink-dim: #8b94b8;
  --teal: #37d6c6;
  --pink: #ff5c7a;
  --purple: #785cff;
  --gold: #f4cb55;
  --blue: #3d9cff;
  --green: #65de72;
  --cell: #1a2340;
  --cell-edge: #263354;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { color-scheme: dark; }

body {
  background:
    radial-gradient(1200px 500px at 70% -10%, rgba(120, 92, 255, .14), transparent 60%),
    radial-gradient(900px 420px at 10% 110%, rgba(55, 214, 198, .10), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  padding-bottom: 40px;
}

button { font-family: inherit; cursor: pointer; }
input[type="text"] { font-family: inherit; }

/* ── header ─────────────────────────────────────────────── */

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(19, 26, 46, .95), rgba(11, 14, 23, .85));
  border-bottom: 1px solid var(--panel-edge);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: baseline; gap: 10px; }

.brand-disc {
  width: 22px; height: 22px; border-radius: 50%;
  border: 4px solid var(--teal);
  box-shadow: 0 0 14px rgba(55, 214, 198, .55), inset 0 0 4px rgba(255, 92, 122, .8);
  align-self: center;
  animation: disc-spin 6s linear infinite;
  background: radial-gradient(circle at center, var(--pink) 0 4px, transparent 5px);
}
@keyframes disc-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .brand-disc { animation: none; } }

.brand-name {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: .12em;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub { font-size: .68rem; color: var(--ink-dim); letter-spacing: .08em; text-transform: uppercase; }

.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-left: auto; }

.big-button {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--cell-edge);
  border-radius: 999px;
  background: var(--cell);
  color: var(--ink);
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .07em;
  padding: 9px 16px;
  transition: transform .1s, box-shadow .2s, background .2s;
}
.big-button:hover { transform: translateY(-1px); }
.big-button:active { transform: translateY(0); }

.big-button.play { border-color: rgba(55, 214, 198, .5); }
.big-button.play .icon-stop, .big-button.play .label-stop { display: none; }
body.playing .big-button.play { background: rgba(55, 214, 198, .18); box-shadow: 0 0 16px rgba(55, 214, 198, .35); }
body.playing .big-button.play .icon-play, body.playing .big-button.play .label-play { display: none; }
body.playing .big-button.play .icon-stop, body.playing .big-button.play .label-stop { display: inline; }

.big-button.rec { border-color: rgba(255, 92, 122, .5); }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pink); }
body.recording .big-button.rec { background: rgba(255, 92, 122, .2); box-shadow: 0 0 16px rgba(255, 92, 122, .45); }
body.recording .rec-dot { animation: rec-blink 1s steps(2) infinite; }
@keyframes rec-blink { 50% { opacity: .15; } }

.big-button.save { border-color: rgba(120, 92, 255, .55); }
.big-button.save:hover { background: rgba(120, 92, 255, .18); }

.knob { display: flex; flex-direction: column; gap: 3px; font-size: .66rem; color: var(--ink-dim); letter-spacing: .06em; }
.knob small b { color: var(--ink); }
.knob input[type="range"] { width: 110px; accent-color: var(--teal); }

.desktop-note {
  text-align: center;
  font-size: .74rem;
  color: var(--ink-dim);
  padding: 8px 16px 0;
}
.desktop-note b { color: var(--teal); font-weight: 600; }

/* ── panels ─────────────────────────────────────────────── */

.panels {
  display: grid;
  gap: 16px;
  max-width: 1180px;
  margin: 14px auto 0;
  padding: 0 14px;
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 13px 14px 15px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .35);
}

#panel-drums { border-top: 2px solid var(--pink); }
#panel-bass  { border-top: 2px solid var(--purple); }
#panel-stabs { border-top: 2px solid var(--blue); }
#panel-fx    { border-top: 2px solid var(--green); }

.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.part-toggle {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--cell-edge);
  background: var(--cell);
  color: var(--ink-dim);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  transition: all .15s;
}
.part-toggle.on { color: #06231f; background: var(--teal); border-color: var(--teal); box-shadow: 0 0 12px rgba(55, 214, 198, .5); }

.panel-title strong { font-size: .92rem; letter-spacing: .1em; }
.panel-title small { display: block; color: var(--ink-dim); font-size: .68rem; margin-top: 1px; }

.panel-actions { margin-left: auto; display: flex; gap: 7px; flex-wrap: wrap; }

.ghost-button {
  border: 1px solid var(--cell-edge);
  background: transparent;
  color: var(--ink-dim);
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 6px 12px;
  transition: all .15s;
}
.ghost-button:hover { color: var(--ink); border-color: var(--ink-dim); }
.ghost-button.dl { border-color: rgba(120, 92, 255, .5); color: #b9aaff; }
.ghost-button.dl:hover { background: rgba(120, 92, 255, .16); color: var(--ink); }
.ghost-button:disabled { opacity: .45; cursor: wait; }

.style-row, .slider-row {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 16px;
  margin-top: 10px;
}

.preset-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.preset-pills button {
  border: 1px solid var(--cell-edge);
  background: transparent;
  color: var(--ink-dim);
  border-radius: 999px;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 5px 11px;
  transition: all .15s;
}
.preset-pills button.active { background: var(--teal); border-color: var(--teal); color: #06231f; }
.preset-pills.alt button.active { background: var(--purple); border-color: var(--purple); color: #efeaff; }

.mini-check { display: inline-flex; align-items: center; gap: 6px; font-size: .68rem; color: var(--ink-dim); }
.mini-check input { accent-color: var(--teal); }

/* ── step grids ─────────────────────────────────────────── */

.grid-scroll { margin-top: 11px; overflow-x: auto; padding-bottom: 4px; }

.step-grid { display: grid; grid-template-columns: 74px repeat(16, minmax(26px, 1fr)); gap: 4px; min-width: 560px; }

.row-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink-dim);
  display: flex; align-items: center;
  padding-right: 6px;
  white-space: nowrap;
  position: sticky; left: 0;
  background: linear-gradient(90deg, var(--panel) 78%, transparent);
  z-index: 2;
}

.cell {
  aspect-ratio: 1 / 1.05;
  min-height: 26px;
  border-radius: 6px;
  border: 1px solid var(--cell-edge);
  background: var(--cell);
  padding: 0;
  transition: background .08s, box-shadow .12s;
}
.cell:nth-child(16n + 2), .cell:nth-child(16n + 6), .cell:nth-child(16n + 10), .cell:nth-child(16n + 14) { border-left-color: #35466f; }
.cell.beat-mark { background: #1e2846; }
.cell:hover { border-color: var(--ink-dim); }

.cell.on { background: var(--accent, var(--teal)); border-color: var(--accent, var(--teal)); box-shadow: 0 0 10px color-mix(in srgb, var(--accent, var(--teal)) 55%, transparent); }
.cell.playhead { outline: 2px solid rgba(232, 236, 255, .75); outline-offset: -2px; }

.drums .cell.on { --accent: var(--pink); }
.bass  .cell.on { --accent: var(--purple); }
.stabs .cell.on { --accent: var(--blue); }
.fx    .cell.on { --accent: var(--green); }

/* ── shelf ──────────────────────────────────────────────── */

.panel.shelf { border-top: 2px solid var(--gold); }

.shelf-list { display: grid; gap: 8px; margin-top: 12px; }

.shelf-empty { color: var(--ink-dim); font-size: .78rem; padding: 6px 2px; }
.shelf-empty b { color: var(--ink); }

.shelf-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--cell);
  border: 1px solid var(--cell-edge);
  border-radius: 10px;
  padding: 8px 10px;
}
.shelf-item .tag { font-size: 1.05rem; flex: none; }
.shelf-item .meta { min-width: 0; }
.shelf-item .meta b { font-size: .8rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-item .meta small { color: var(--ink-dim); font-size: .64rem; letter-spacing: .05em; }
.shelf-item .spacer { flex: 1; }
.shelf-item button, .shelf-item a.dl-link {
  border: 1px solid var(--cell-edge);
  background: transparent;
  color: var(--ink-dim);
  border-radius: 999px;
  font-size: .66rem;
  font-weight: 700;
  padding: 5px 11px;
  text-decoration: none;
  transition: all .15s;
  flex: none;
}
.shelf-item button:hover, .shelf-item a.dl-link:hover { color: var(--ink); border-color: var(--ink-dim); }
.shelf-item .play-item.playing { background: rgba(55, 214, 198, .2); color: var(--teal); border-color: var(--teal); }
.shelf-item a.dl-link { color: #b9aaff; border-color: rgba(120, 92, 255, .5); }

/* ── footer ─────────────────────────────────────────────── */

.foot { text-align: center; color: var(--ink-dim); font-size: .7rem; padding: 26px 16px 6px; line-height: 1.7; }
.foot a { color: var(--teal); text-decoration: none; }
.foot b { color: var(--ink); }

/* ── dialog ─────────────────────────────────────────────── */

/* display:flex would otherwise defeat the hidden attribute. */
.dialog-backdrop[hidden] { display: none; }

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 7, 12, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  backdrop-filter: blur(4px);
}
.dialog {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 20px;
  width: min(430px, 100%);
  display: grid; gap: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .6);
}
.dialog h2 { font-size: 1rem; letter-spacing: .08em; }
.dialog-field { display: grid; gap: 7px; font-size: .72rem; color: var(--ink-dim); letter-spacing: .05em; }
.dialog-field input[type="text"] {
  background: var(--cell);
  border: 1px solid var(--cell-edge);
  border-radius: 8px;
  color: var(--ink);
  font-size: .85rem;
  padding: 9px 11px;
  outline: none;
}
.dialog-field input[type="text"]:focus { border-color: var(--teal); }

.icon-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.icon-pick button {
  font-size: 1.05rem;
  background: var(--cell);
  border: 1px solid var(--cell-edge);
  border-radius: 8px;
  width: 38px; height: 38px;
}
.icon-pick button.active { border-color: var(--teal); box-shadow: 0 0 10px rgba(55, 214, 198, .4); }

.save-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--ink); font-size: .78rem; }
.save-checks label { display: inline-flex; gap: 6px; align-items: center; }
.save-checks input { accent-color: var(--teal); }
.save-checks .combined { width: 100%; color: var(--teal); }

.dialog-buttons { display: flex; justify-content: flex-end; gap: 9px; }

/* ── toast ──────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--panel);
  border: 1px solid var(--teal);
  border-radius: 999px;
  color: var(--ink);
  font-size: .76rem;
  padding: 10px 18px;
  box-shadow: 0 0 20px rgba(55, 214, 198, .3);
  max-width: min(92vw, 480px);
  text-align: center;
}

/* ── small screens ──────────────────────────────────────── */

@media (max-width: 700px) {
  .top-bar { padding: 10px 12px; gap: 10px 14px; }
  .brand-sub { display: none; }
  .knob input[type="range"] { width: 84px; }
  .panels { padding: 0 8px; gap: 12px; }
  .panel { padding: 11px 10px 13px; }
  .panel-actions { margin-left: 0; width: 100%; }
  .step-grid { grid-template-columns: 64px repeat(16, minmax(24px, 1fr)); }
  .big-button { padding: 8px 13px; font-size: .72rem; }
}
