/* ── Plunker · neon theme (shared tokens with Clipper/Shifter) ──────────── */

:root {
  --bg: #0a0e17;
  --bg-2: #0d1322;
  --cyan: #00f0ff;
  --magenta: #ff2d95;
  --violet: #7b5cff;
  --ink: #e8f4ff;
  --ink-dim: #7d8aa5;
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-border: rgba(0, 240, 255, 0.16);
  --glow-cyan: 0 0 12px rgba(0, 240, 255, 0.45);
  --glow-magenta: 0 0 12px rgba(255, 45, 149, 0.45);
  --font: "SF Mono", "Cascadia Code", ui-monospace, "Segoe UI Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(123, 92, 255, 0.14), transparent 60%),
    radial-gradient(900px 400px at 85% 110%, rgba(255, 45, 149, 0.10), transparent 60%),
    radial-gradient(900px 400px at 10% 100%, rgba(0, 240, 255, 0.08), transparent 60%),
    var(--bg);
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 30%, transparent 100%);
}

/* ── Header ── */

.app-header {
  text-align: center;
  padding: 26px 16px 8px;
  position: relative;
}

.logo {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 0 6px rgba(0, 240, 255, 0.6));
}

.app-header h1 {
  margin: 6px 0 2px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.55em;
  text-indent: 0.55em; /* recenters letter-spaced text */
  color: var(--ink);
  text-shadow: 0 0 14px rgba(0, 240, 255, 0.55), 0 0 40px rgba(0, 240, 255, 0.2);
}

.tagline {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  color: var(--ink-dim);
}

/* ── Layout ── */

main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 10px 30px rgba(0, 0, 0, 0.35);
}

[hidden] { display: none !important; }

/* ── Buttons (shared) ── */

.btn {
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.25em;
  text-indent: 0.25em;
  padding: 13px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: box-shadow 0.2s, background 0.2s, transform 0.1s, opacity 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-outline {
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 0.45);
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}

.btn-outline:hover { box-shadow: var(--glow-cyan); }

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(125, 138, 165, 0.35);
  color: var(--ink-dim);
  font-family: inherit;
  cursor: pointer;
  border-radius: 10px;
}

.small-btn {
  font-size: 10px;
  letter-spacing: 0.2em;
  padding: 7px 12px;
}

.btn-primary {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.9), rgba(123, 92, 255, 0.9) 55%, rgba(255, 45, 149, 0.9));
  color: #04070d;
  font-weight: 700;
  width: 100%;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.35), 0 0 34px rgba(255, 45, 149, 0.2);
}

.btn-primary:hover {
  box-shadow: 0 0 26px rgba(0, 240, 255, 0.55), 0 0 48px rgba(255, 45, 149, 0.35);
}

.btn-play-icon {
  width: 0;
  height: 0;
  border-left: 9px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  filter: drop-shadow(0 0 4px rgba(0, 240, 255, 0.7));
  flex-shrink: 0;
}

.btn.playing .btn-play-icon {
  border: none;
  width: 10px;
  height: 12px;
  border-left: 4px solid currentColor;
  border-right: 4px solid currentColor;
}

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

.transport .btn-outline { flex: 1; min-width: 140px; }

/* ── Setup card (voice / key selects) ── */

.field-row {
  display: flex;
  gap: 12px;
}

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

.field-label {
  font-size: 9px;
  letter-spacing: 0.25em;
  text-indent: 0.25em;
  color: var(--ink-dim);
}

.select {
  font-family: inherit;
  font-size: 12px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 10px;
  padding: 10px 10px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--cyan) 50%), linear-gradient(135deg, var(--cyan) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.select:focus-visible { outline: none; box-shadow: var(--glow-cyan); border-color: var(--cyan); }

/* ── Grid card (bar editor) ── */

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

.bar-label {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--ink-dim);
}

.grid-scroll {
  max-height: 46vh;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 240, 255, 0.1);
}

.note-grid {
  display: grid;
  grid-template-columns: 46px repeat(8, 1fr);
}

.grid-row-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 10px;
  color: var(--ink-dim);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  border-right: 1px solid rgba(0, 240, 255, 0.1);
  font-variant-numeric: tabular-nums;
}

.grid-row-label.tonic-row {
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(0, 240, 255, 0.5);
}

.grid-cell {
  position: relative;
  height: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  border-right: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  touch-action: manipulation;
}

.grid-cell:nth-child(9n+3) { border-right-color: rgba(0, 240, 255, 0.12); } /* beat 1 boundary (after col2) */
.grid-cell:nth-child(9n+5) { border-right-color: rgba(0, 240, 255, 0.12); }
.grid-cell:nth-child(9n+7) { border-right-color: rgba(0, 240, 255, 0.12); }

.grid-cell:active { background: rgba(0, 240, 255, 0.08); }

.grid-cell.note-start {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.55), rgba(123, 92, 255, 0.55));
  box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.6);
  border-radius: 7px 0 0 7px;
  z-index: 1;
}

.grid-cell.note-tail {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.3), rgba(123, 92, 255, 0.3));
  z-index: 1;
}

.grid-cell.note-end {
  border-radius: 0 7px 7px 0;
}

.grid-cell.note-start.note-end { border-radius: 7px; }

.note-accidental {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 10px;
  color: #04070d;
  font-weight: 700;
  pointer-events: none;
}

.grid-hint {
  margin: 10px 2px 0;
  font-size: 9.5px;
  letter-spacing: 0.05em;
  color: rgba(125, 138, 165, 0.7);
  text-align: center;
}

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

.nudge {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nudge-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  background: rgba(0, 240, 255, 0.05);
  color: var(--cyan);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.nudge-btn:active {
  background: rgba(0, 240, 255, 0.18);
  box-shadow: var(--glow-cyan);
}

.time-value {
  font-size: 12px;
  color: var(--ink);
  min-width: 2.6em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.time-value.accent {
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
}

.add-bar-btn { margin-top: 14px; }

/* ── Accidental picker popover ── */

.accidental-picker {
  position: fixed;
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--bg-2);
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 12px;
  box-shadow: var(--glow-cyan), 0 10px 24px rgba(0, 0, 0, 0.5);
  z-index: 50;
}

.accidental-picker button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  background: rgba(0, 240, 255, 0.06);
  color: var(--cyan);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
}

.accidental-picker button:active { background: rgba(0, 240, 255, 0.22); }

/* ── Timeline ── */

.timeline {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  -webkit-overflow-scrolling: touch;
}

.timeline:empty { padding: 0; }

.bar-chip {
  flex-shrink: 0;
  width: 74px;
  border-radius: 10px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  background: rgba(0, 240, 255, 0.04);
  padding: 6px;
  cursor: grab;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
  touch-action: pan-y;
}

.bar-chip.editing {
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
}

.bar-chip.dragging {
  opacity: 0.5;
}

.bar-chip-num {
  font-size: 9px;
  color: var(--ink-dim);
  letter-spacing: 0.1em;
  margin-bottom: 3px;
  display: block;
}

.bar-chip-preview {
  height: 30px;
  display: flex;
  align-items: flex-end;
  gap: 1px;
}

.bar-chip-preview span {
  flex: 1;
  background: linear-gradient(180deg, var(--cyan), var(--violet));
  border-radius: 1px;
  min-height: 2px;
  opacity: 0.85;
}

.bar-chip-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 45, 149, 0.5);
  background: var(--bg-2);
  color: var(--magenta);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-phrase-btn { margin-top: 10px; width: 100%; }

/* ── Export card ── */

.export-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.format-picker {
  display: flex;
  gap: 0;
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 12px;
  overflow: hidden;
  align-self: center;
}

.format-btn {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.25em;
  text-indent: 0.25em;
  padding: 10px 26px;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, text-shadow 0.2s;
}

.format-btn.active {
  background: rgba(0, 240, 255, 0.12);
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
}

.export-status {
  margin: 0;
  min-height: 1.2em;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
}

.export-status.ok { color: var(--cyan); text-shadow: 0 0 8px rgba(0, 240, 255, 0.5); }
.export-status.err { color: var(--magenta); text-shadow: 0 0 8px rgba(255, 45, 149, 0.5); }

/* ── Footer ── */

.app-footer {
  text-align: center;
  padding: 10px 16px 18px;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: rgba(125, 138, 165, 0.6);
}

@media (min-width: 480px) {
  .grid-scroll { max-height: 50vh; }
}
