@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600&display=swap');

/* ── Theme variables ──────────────────────────────── */
:root {
  --bg: #0e0e0f;
  --bg-elevated: rgba(22, 22, 22, 0.78);
  --bg-panel: rgba(14, 14, 15, 0.95);
  --bg-surface: rgba(255, 255, 255, 0.02);
  --bg-surface-hover: rgba(255, 255, 255, 0.04);
  --bg-input: #1a1a1a;
  --border: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --text: #eee;
  --text-muted: #888;
  --text-dim: #555;
  --text-ghost: #333;
  --text-label: #444;
  --node-off: rgba(255, 255, 255, 0.04);
  --node-off-hover: rgba(255, 255, 255, 0.1);
  --wire-opacity: 0.08;
  --playhead-color: rgba(255, 255, 255, 0.45);
  --playhead-glow: rgba(255, 255, 255, 0.1);
  --logo-color: #0e0e0f;
  --logo-shadow: -1px -1px 1px rgba(255,255,255,0.05), 1px 1px 3px rgba(0,0,0,0.7);
  --knob-body: #1a1a1a;
  --knob-ring: #2a2a2a;
  --knob-stroke: #333;
  --knob-indicator: #ccc;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #e4e4e6;
  --bg-elevated: rgba(218, 218, 222, 0.82);
  --bg-panel: rgba(225, 225, 228, 0.95);
  --bg-surface: rgba(0, 0, 0, 0.04);
  --bg-surface-hover: rgba(0, 0, 0, 0.07);
  --bg-input: #d5d5d8;
  --border: rgba(0, 0, 0, 0.08);
  --border-subtle: rgba(0, 0, 0, 0.05);
  --text: #1a1a1a;
  --text-muted: #666;
  --text-dim: #999;
  --text-ghost: #bbb;
  --text-label: #888;
  --node-off: rgba(0, 0, 0, 0.06);
  --node-off-hover: rgba(0, 0, 0, 0.12);
  --wire-opacity: 0.1;
  --playhead-color: rgba(0, 0, 0, 0.35);
  --playhead-glow: rgba(0, 0, 0, 0.08);
  --logo-color: #e4e4e6;
  --logo-shadow: -1px -1px 1px rgba(255,255,255,0.8), 1px 1px 3px rgba(0,0,0,0.12);
  --knob-body: #e0e0e2;
  --knob-ring: #ccc;
  --knob-stroke: #bbb;
  --knob-indicator: #333;
  color-scheme: light;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.4s ease, color 0.3s ease, border-color 0.4s ease, box-shadow 0.4s ease, -webkit-text-stroke 0.4s ease;
}

*::before, *::after {
  transition: background-color 0.4s ease, border-color 0.4s ease, opacity 0.4s ease;
}

/* Exclude interactive sequencer elements from theme transition */
.node, .cell, .playhead, .node *, .cell * {
  transition: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  min-height: 100vh;
  user-select: none;
  overflow-x: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 16px;
  transition: margin-left 0.25s;
  position: relative;
  z-index: 1;
}

/* editor sidebar removed — per-row popovers replace it */

/* ── Ghost watermark logo ─────────────────────────── */
.logo {
  position: fixed;
  bottom: 100px;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 0;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 11.5vw;
  letter-spacing: 0.04em;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px color-mix(in srgb, var(--text) 5%, transparent);
  text-transform: uppercase;
  white-space: nowrap;
}

[data-theme="light"] .logo-text {
  -webkit-text-stroke: 1.5px color-mix(in srgb, var(--text) 8%, transparent);
}

/* Top center wrapper */
.top-center {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 300;
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  transition: gap 0.25s ease, border-color 0.6s ease;
}

.top-bar:hover:not(:has(.cs.open)) {
  gap: 6px;
}

.top-bar.save-flash {
  border-color: #5bc0be;
  transition: border-color 0.1s ease;
}

.top-preset {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.top-preset .preset-menu {
  bottom: auto;
  top: 100%;
  margin-top: 8px;
  margin-bottom: 0;
}

.top-controls {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 6px;
  z-index: 300;
}

.top-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.top-btn:hover {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--bg-surface-hover);
}

.top-btn.active {
  color: var(--text);
  background: var(--bg-surface-hover);
}

/* ── Buttons ──────────────────────────────────────── */
button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 400;
  padding: 6px 16px;
  cursor: pointer;
  border-radius: 20px;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

button:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

button.active {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--bg-surface-hover);
}

input[type="range"] {
  width: 72px;
  accent-color: var(--text-dim);
  height: 2px;
}

/* ── Bottom Dock (toolbar + piano) ─────────────────── */
.dock {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 100;
  padding-bottom: 24px;
  flex-shrink: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 20px;
  background: var(--bg-elevated);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: 14px;
  white-space: nowrap;
  position: relative;
  z-index: 2;
}

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

.tb-sep {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 14px;
  flex-shrink: 0;
}

.tb-btn {
  width: 64px;
  height: 64px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-surface);
}

.tb-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
  border-color: var(--text-dim);
}

.play-btn.active {
  color: var(--text);
  background: var(--bg-surface-hover);
  border-color: var(--text-muted);
}

.rec-btn { font-size: 20px; color: var(--text-dim); }

.rec-btn.active {
  color: #ff4444;
  background: rgba(255, 68, 68, 0.1);
  border-color: rgba(255, 68, 68, 0.2);
  animation: recGlow 1.2s ease-in-out infinite;
}

@keyframes recGlow {
  0%, 100% { background: rgba(255, 68, 68, 0.08); }
  50% { background: rgba(255, 68, 68, 0.16); }
}

/* Knobs */
.knob {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.knob svg { display: block; }

.knob-label {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  line-height: 1;
}

.knob-value {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

/* Presets in toolbar */
.preset-group { position: relative; }

.toolbar button {
  height: 28px;
  font-size: 12px;
  padding: 0 14px;
}

.cs {
  position: relative;
  height: 28px;
  cursor: pointer;
}

.cs-value {
  background: none;
  color: var(--text-muted);
  border: none;
  border-radius: 0;
  padding: 0 0 0 18px;
  font-family: inherit;
  font-size: 12px;
  height: 28px;
  line-height: 28px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 0.15s;
}

.cs-value::after {
  content: '\25BE';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) rotate(0deg);
  font-size: 10px;
  color: var(--text-dim);
  pointer-events: none;
  transition: transform 0.2s ease;
}

.preset-inline-edit {
  background: none;
  border: none;
  border-bottom: 1px solid var(--text-dim);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 0;
  width: 120px;
  outline: none;
}

.cs-value:hover { color: var(--text); }
.cs.open .cs-value { color: var(--text); }
.cs.open .cs-value::after { transform: translateY(-50%) rotate(180deg); }

.cs-drop {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0; right: 0;
  margin-bottom: 4px;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  z-index: 300;
  max-height: 240px;
  overflow-y: auto;
  min-width: 160px;
}

.cs.open .cs-drop { display: block; }

.cs-opt {
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
}

.cs-opt:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}

.cs-opt.active { color: var(--text); }

.cs-sep {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 10px;
}

.cs-opt-explore {
  color: var(--text-dim);
  font-style: italic;
}

.top-preset .cs-drop {
  bottom: auto;
  top: 100%;
  margin-bottom: 0;
  margin-top: 4px;
}

.top-bar-icon {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, opacity 0.2s ease, width 0.25s ease, padding 0.25s ease;
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}

.top-bar:hover .top-bar-icon {
  opacity: 1;
  width: 22px;
  padding: 4px;
  pointer-events: auto;
}

.top-bar:hover .top-bar-icon:nth-child(2) { transition-delay: 0s; }
.top-bar:hover .top-bar-icon:nth-child(3) { transition-delay: 0.04s; }
.top-bar:hover .top-bar-icon:nth-child(4) { transition-delay: 0.08s; }

.explore-btn {
  width: auto;
  height: 38px;
  box-sizing: border-box;
  flex-shrink: 0;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  gap: 0;
  padding: 0 10px;
  transition: border-color 0.2s, color 0.2s, background 0.2s, gap 0.3s ease;
}

.explore-btn:hover {
  gap: 5px;
}

.explore-icon {
  flex-shrink: 0;
  display: block;
}

.explore-label {
  font-size: 11px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  display: inline-block;
  max-width: 0;
  opacity: 0;
  transition: max-width 0.3s ease, opacity 0.2s ease 0.05s;
}

.explore-btn:hover .explore-label {
  max-width: 50px;
  opacity: 1;
}

.top-bar-icon:hover {
  color: var(--text);
}

.top-bar-icon.delete-icon:hover { color: #994444; }

.preset-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 6px;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  z-index: 200;
  min-width: 120px;
}

.preset-menu.open {
  display: flex;
  flex-direction: column;
}

.preset-menu button {
  height: auto;
  padding: 8px 12px;
  font-size: 11px;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  text-align: left;
  justify-content: flex-start;
  cursor: pointer;
}

.preset-menu button:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}

#deletePresetBtn { color: #ff4444; }
#deletePresetBtn:hover { background: rgba(255, 68, 68, 0.1); color: #ff4444; }

.add-btn {
  width: 80px;
  height: 80px;
  font-size: 42px;
  font-weight: 200;
  line-height: 1;
  padding: 0;
  color: var(--text-muted);
  border: 2px dashed var(--border);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.add-btn:hover {
  color: var(--text-muted);
  border-color: var(--text-dim);
}

.piano-icon { width: 64px; height: 64px; }
.piano-icon svg { display: block; width: 38px; height: 28px; }
.piano-icon svg rect[stroke], .piano-icon svg line { stroke: var(--text-muted); }
.piano-icon svg rect[fill] { fill: var(--text-muted); }

.piano-icon.active {
  background: var(--bg-surface-hover);
  border-color: var(--text-muted);
}


/* ── Sequencer (unified row layout) ───────────────── */
.grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  max-width: 860px;
  overflow: hidden;
}

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

/* Label — identical in both views */
.seq-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  width: 140px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-label);
  letter-spacing: 1px;
  text-transform: uppercase;
  overflow: hidden;
  white-space: nowrap;
}

.seq-label .name {
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color 0.2s;
  font-weight: 400;
}

.seq-label .name:hover { color: var(--text-muted); }
.seq-label.editing .name { color: var(--text); }

.seq-label .key {
  color: var(--text-dim);
  font-size: 9px;
  flex-shrink: 0;
  font-weight: 600;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  transition: all 0.08s;
}

.seq-label .key.hit {
  background: var(--text-muted);
  color: var(--bg);
  border-color: var(--text-muted);
  transform: scale(0.9);
}

.row-prob {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.row-prob input[type="range"] {
  width: 32px;
  height: 2px;
  accent-color: var(--color);
}

.row-prob span {
  font-size: 8px;
  color: var(--text-ghost);
  width: 24px;
  text-align: right;
}

/* ── Beat ruler ───────────────────────────────────── */
.seq-ruler {
  height: 16px;
  margin-bottom: 2px;
  pointer-events: none;
}

.ruler-cells, .ruler-nodes {
  display: grid;
  flex: 1;
  align-items: center;
  min-width: 0;
}

.ruler-cells {
  grid-template-columns: repeat(var(--step-count, 16), 1fr);
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.ruler-nodes {
  grid-template-columns: repeat(var(--step-count, 16), 1fr);
}

.beat-marker {
  font-size: 8px;
  color: var(--text-ghost);
  text-align: center;
  line-height: 1;
  letter-spacing: 0;
}

.beat-marker.downbeat {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 9px;
}

.app.fullscreen .seq-ruler { display: none; }

/* ── Bar length control ───────────────────────────── */
.bar-length-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
  align-self: flex-end;
  margin-bottom: 4px;
}

.bar-len-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-label);
  font-weight: 500;
  min-width: 44px;
  text-align: center;
}

.bar-len-label input[type="number"] {
  width: 32px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  padding: 0;
  -moz-appearance: textfield;
  outline: none;
}

.bar-len-label input[type="number"]::-webkit-inner-spin-button,
.bar-len-label input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.bar-len-label input[type="number"]:focus {
  border-bottom-color: var(--text-muted);
  color: var(--text);
}

/* ── Polymetric per-row control ──────────────────── */
.poly-ctrl {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: 4px;
}

.poly-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  background: var(--bg-surface);
  cursor: pointer;
}

.poly-btn:hover {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--bg-surface-hover);
}

.poly-val, .poly-val-input {
  font-size: 9px;
  color: var(--text-dim);
  min-width: 16px;
  text-align: center;
  letter-spacing: 0.5px;
}

.poly-val-input {
  width: 28px;
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  font-family: inherit;
  padding: 0;
  -moz-appearance: textfield;
  outline: none;
}

.poly-val-input::-webkit-inner-spin-button,
.poly-val-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.poly-val-input:focus {
  border-bottom-color: var(--text-dim);
  color: var(--text-muted);
}

/* ── Horizontal scroll for wide bars ─────────────── */
.grid.wide-bar .seq-row {
  overflow: visible;
}

.grid.wide-bar .seq-cells,
.grid.wide-bar .seq-nodes {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.grid.wide-bar .seq-cells::-webkit-scrollbar,
.grid.wide-bar .seq-nodes::-webkit-scrollbar {
  height: 3px;
}

.grid.wide-bar .seq-cells::-webkit-scrollbar-thumb,
.grid.wide-bar .seq-nodes::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ── Node steps (track view) ──────────────────────── */
.seq-nodes {
  display: grid;
  grid-template-columns: repeat(var(--step-count, 16), 1fr);
  flex: 1;
  position: relative;
  align-items: center;
  height: 100%;
  min-width: 0;
}

.seq-nodes::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 6px;
  right: 6px;
  height: 1px;
  background: var(--color);
  opacity: var(--wire-opacity);
  pointer-events: none;
}

.node {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--node-off);
  cursor: pointer;
  position: relative;
  z-index: 1;
  justify-self: center;
  transition: all 0.15s ease;
}

.node::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
}

.node:hover { background: var(--node-off-hover); }
.node.on { background: var(--color); opacity: var(--prob, 1); }
.node.on:hover { box-shadow: 0 0 4px color-mix(in srgb, var(--color) 25%, transparent); }

.node .prob-label {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 7px;
  color: var(--text-label);
  pointer-events: none;
  white-space: nowrap;
  line-height: 1;
  font-weight: 300;
}

.node .playhead {
  position: absolute;
  inset: -3px;
  border: 1px solid var(--playhead-color);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 5px var(--playhead-glow);
  animation: playhead-pulse 0.12s ease-out;
}

@keyframes playhead-pulse {
  from { transform: scale(1.4); opacity: 0.3; }
  to { transform: scale(1); opacity: 1; }
}

.node.triggered { animation: node-trigger 0.15s ease-out; }
@keyframes node-trigger {
  0% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* ── Cell steps (grid view) ───────────────────────── */
.seq-cells {
  display: grid;
  grid-template-columns: repeat(var(--step-count, 16), 1fr);
  gap: 2px;
  min-width: 0;
  flex: 1;
  height: 100%;
}

.cell {
  height: 100%;
  background: var(--bg-surface);
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}

.cell:hover { background: var(--bg-surface-hover); }
.cell.odd-group { background: var(--node-off); }
.cell.odd-group:hover { background: var(--node-off-hover); }
.cell.on { background: var(--color); opacity: var(--prob, 1); }
.cell.on:hover { background: var(--color); filter: brightness(1.1); }
.cell.on.odd-group { background: var(--color); }
.cell.on.odd-group:hover { background: var(--color); filter: brightness(1.1); }

.cell .prob-label {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 7px;
  color: rgba(0,0,0,0.4);
  pointer-events: none;
  line-height: 1;
}

.cell .playhead {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--playhead-color);
  border-radius: 3px;
  pointer-events: none;
}

.cell.triggered { animation: cell-trigger 0.12s ease-out; }
@keyframes cell-trigger {
  0% { filter: brightness(1.4); }
  100% { filter: brightness(1); }
}

/* ── Fullscreen mode ──────────────────────────────── */
.app.fullscreen .main {
  padding: 0;
  justify-content: stretch;
}

.app.fullscreen .logo,
.app.fullscreen .combos { display: none; }

.app.fullscreen .grid {
  max-width: 100vw;
  width: 100vw;
  height: calc(100vh - 90px);
  padding: 2px;
}

.app.fullscreen .seq-label { display: none; }
.app.fullscreen .poly-ctrl { display: none; }
.app.fullscreen .bar-length-ctrl { display: none; }
.app.fullscreen .seq-row { flex: 1; gap: 0; }

.app.fullscreen .seq-cells {
  grid-template-columns: repeat(var(--step-count, 16), 1fr);
  flex: 1;
  height: 100%;
}

.app.fullscreen .seq-cells .cell {
  aspect-ratio: auto;
  border-radius: 2px;
}

.app.fullscreen .seq-nodes {
  height: 100%;
}

/* ── Pads ─────────────────────────────────────────── */
.pads {
  display: flex;
  gap: 8px;
  margin-top: 32px;
  flex-wrap: wrap;
  justify-content: center;
}

.pad {
  width: 64px;
  height: 64px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s;
  gap: 4px;
}

.pad:active,
.pad.hit {
  transform: scale(0.93);
  border-color: var(--color);
  background: var(--bg-surface-hover);
  box-shadow: 0 0 12px color-mix(in srgb, var(--color) 20%, transparent);
}

.pad .pad-key {
  font-size: 15px;
  color: var(--color);
  font-weight: 500;
}

.pad .pad-name {
  font-size: 9px;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 400;
}

/* Combos */
.combos {
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-ghost);
  letter-spacing: 1px;
  text-align: center;
  font-weight: 300;
}

.combos strong {
  color: var(--text-dim);
  font-weight: 500;
}

/* ── Row popover (replaces editor sidebar) ────────── */
.row-popover {
  position: fixed;
  width: 220px;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  z-index: 250;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.row-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.row-popover-name {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.row-popover-name:hover { opacity: 0.7; }

.row-popover-rename {
  background: none;
  border: none;
  border-bottom: 1px solid var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0;
  width: 100%;
  outline: none;
}

.row-popover .param {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-width: 0;
}

.row-popover .param-name {
  font-size: 10px;
  color: var(--text-label);
  width: 44px;
  text-align: right;
  flex-shrink: 0;
  font-weight: 400;
  letter-spacing: 0.5px;
}

.row-popover .param input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 2px;
}

.row-popover .param-val {
  font-size: 10px;
  color: var(--text-dim);
  width: 28px;
  flex-shrink: 0;
  text-align: left;
}

.row-popover-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.row-popover-swap {
  flex: 1;
  font-size: 10px;
  padding: 5px 0;
  text-align: center;
  color: var(--text-label);
  border-color: var(--border-subtle);
}

.row-popover-swap:hover {
  color: var(--text-muted);
  border-color: var(--border);
}

.row-popover-delete {
  width: 32px;
  padding: 5px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-ghost);
  border-color: var(--border-subtle);
  flex-shrink: 0;
}

.row-popover-delete:hover {
  color: #994444;
  border-color: rgba(153, 68, 68, 0.3);
}

.row-popover .picker-category {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-label);
  margin: 10px 0 4px;
  font-weight: 500;
}

.row-popover .picker-sound {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.1s;
}

.row-popover .picker-sound:hover { background: var(--bg-surface-hover); }
.row-popover .picker-sound.current { background: var(--bg-surface); }
.row-popover .picker-sound.current .picker-sound-name { color: var(--text); }

.row-popover .picker-sound-name { font-size: 11px; color: var(--text-muted); }

.row-popover .picker-preview {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  border-color: var(--border-subtle);
  opacity: 0;
  transition: opacity 0.15s;
}

.row-popover .picker-sound:hover .picker-preview { opacity: 1; }

.row-popover-sounds {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Sound picker */
.picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.picker-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  font-weight: 500;
}

.picker-close { font-size: 11px; padding: 4px 12px; }

.picker-category {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-label);
  margin: 14px 0 6px;
  font-weight: 500;
}

.picker-sound {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.picker-sound:hover { background: var(--bg-surface-hover); }

.picker-sound-name { font-size: 12px; color: var(--text-muted); }

.picker-preview {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  border-color: var(--border-subtle);
  opacity: 0;
  transition: opacity 0.15s;
}

.picker-sound:hover .picker-preview { opacity: 1; }

/* ── Sound popover ───────────────────────────────── */
.sound-popover {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  z-index: 300;
  width: 200px;
  max-height: 360px;
  overflow-y: auto;
}

.sound-popover.open { display: block; }
.picker-sound.current { background: var(--bg-surface); }
.picker-sound.current .picker-sound-name { color: var(--text); }

/* ── Piano drawer — extends upward from toolbar ──── */
.piano-drawer {
  background: var(--bg-elevated);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  padding: 12px 20px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1;
  margin-bottom: -1px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
  padding-top: 0;
  padding-bottom: 0;
}

.piano-drawer.open {
  max-height: 300px;
  opacity: 1;
  padding: 12px 20px 8px;
}

.piano-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.piano-octave {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.piano-octave strong { color: var(--text-muted); }

.piano-hint {
  font-size: 10px;
  color: var(--text-label);
  letter-spacing: 0.5px;
}

.piano-keys {
  display: flex;
  position: relative;
  height: 140px;
}

.white-key {
  width: 36px;
  height: 140px;
  background: #ccc;
  border: 1px solid #777;
  border-radius: 0 0 6px 6px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: background 0.06s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 6px;
}

[data-theme="light"] .white-key { background: #f5f5f5; border-color: #ccc; }

.white-key .key-hint {
  font-size: 9px;
  color: #888;
  text-transform: uppercase;
  pointer-events: none;
}

.white-key:hover { background: #ddd; }
[data-theme="light"] .white-key:hover { background: #fff; }

.white-key.key-active {
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

.black-key {
  width: 24px;
  height: 90px;
  background: #1a1a1a;
  border: 1px solid #111;
  border-radius: 0 0 4px 4px;
  cursor: pointer;
  position: absolute;
  z-index: 2;
  transition: background 0.06s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 4px;
}

[data-theme="light"] .black-key { background: #333; border-color: #222; }

.black-key .key-hint {
  font-size: 8px;
  color: #444;
  text-transform: uppercase;
  pointer-events: none;
}

.black-key:hover { background: #2a2a2a; }
.black-key.key-active {
  background: #3a3a3a;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
}

/* ── Explore overlay ─────────────────────────────── */
.explore-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.explore-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.explore-modal {
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: 420px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.25s ease;
}

.explore-overlay.open .explore-modal {
  transform: translateY(0) scale(1);
}

.explore-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  flex-shrink: 0;
}

.explore-title {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}

.explore-sort-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-surface);
  border-radius: 8px;
  padding: 2px;
}

.explore-sort-tab {
  padding: 4px 12px;
  font-size: 11px;
  border: none;
  border-radius: 6px;
  color: var(--text-dim);
  background: none;
  cursor: pointer;
  transition: all 0.15s;
  height: auto;
  letter-spacing: 0.5px;
}

.explore-sort-tab:hover {
  color: var(--text-muted);
}

.explore-sort-tab.active {
  background: var(--bg-surface-hover);
  color: var(--text);
}

.explore-header > .explore-close {
  position: absolute;
  right: 16px;
}

.explore-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  color: var(--text-dim);
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.explore-close:hover {
  color: var(--text);
  background: var(--bg-surface-hover);
}

/* Track list */
.explore-track-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.explore-track-list::-webkit-scrollbar { width: 4px; }
.explore-track-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.explore-track {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.1s;
}

.explore-track:hover {
  background: var(--bg-surface-hover);
}

/* Votes column */
.explore-track-votes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  width: 32px;
}

.vote-btn {
  width: 24px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-ghost);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  line-height: 1;
}

.vote-btn:hover {
  color: var(--text-muted);
  background: var(--bg-surface);
}

.vote-up.voted { color: #5bc0be; }
.vote-down.voted { color: #e85d75; }

.vote-score {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  line-height: 1;
}

/* Track info */
.explore-track-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.explore-track-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}


.explore-track-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.explore-author { color: var(--text-muted); }
.explore-sep { color: var(--text-ghost); }

/* Track action buttons */
.explore-track-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.explore-track:hover .explore-track-actions {
  opacity: 1;
}

.track-action-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  position: relative;
}

.track-action-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}

.track-action-btn.copied {
  color: #5bc0be;
  opacity: 1;
}

.track-action-btn.copied::after {
  content: 'Copied!';
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #5bc0be;
  white-space: nowrap;
  pointer-events: none;
  animation: fade-up 1.2s ease forwards;
}

@keyframes fade-up {
  0% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* Publish bar */
.explore-publish {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.explore-publish-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.explore-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}

.explore-input:focus {
  border-color: var(--text-dim);
}

.explore-input-sm {
  flex: 0 0 100px;
}

.explore-input-error {
  border-color: #e85d75 !important;
  animation: input-shake 0.3s ease;
}

@keyframes input-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.explore-publish-btn {
  height: 32px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.explore-publish-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
  border-color: var(--text-dim);
}

.explore-publish-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Share modal */
.share-modal {
  width: 400px;
  max-width: calc(100vw - 32px);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.25s ease;
}

.explore-overlay.open .share-modal {
  transform: translateY(0) scale(1);
}

.share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
}

.share-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.share-preview {
  width: 100%;
  height: 100px;
  display: block;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg);
}

.share-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
}

.share-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-top: 4px;
}

.share-label:first-child {
  margin-top: 0;
}

.share-input {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.share-input:focus {
  border-color: var(--text-dim);
}

.share-input-error {
  border-color: #e85d75 !important;
  animation: input-shake 0.3s ease;
}

.share-footer {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-publish-btn {
  width: 100%;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.share-publish-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
  border-color: var(--text-dim);
}

.share-publish-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.share-link-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.share-link-input {
  flex: 1;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  outline: none;
  box-sizing: border-box;
}

.share-copy-btn {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.share-copy-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}

/* Loading / empty states */
.explore-loading, .explore-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 13px;
}
