:root {
  color-scheme: dark;
  --bg: #08080f;
  --bg2: #0d0d1a;
  --bg3: #12121f;
  --bg4: #191928;
  --bg5: #23233b;
  --purple: #9d7fe8;
  --purple2: #6d3fd4;
  --purple3: #c4aff7;
  --text: #f5f4ff;
  --muted: #928bb5;
  --faint: #56506f;
  --line: rgba(157, 127, 232, 0.2);
  --line2: rgba(157, 127, 232, 0.38);
  --red: #f07070;
  --green: #52d68a;
  --orange: #f0a050;
  --blue: #7fbde8;
  --pink: #e87fa8;
  --lane-h: 58px;
  --lane-label-w: 160px;
}

body.light-theme {
  color-scheme: light;
  --bg: #eef6ff;
  --bg2: #ffffff;
  --bg3: #e7f1fb;
  --bg4: #dbeaf7;
  --bg5: #c8ddf1;
  --purple: #2d8fe3;
  --purple2: #1673c9;
  --purple3: #0f5fa8;
  --text: #112033;
  --muted: #4c647d;
  --faint: #6d8195;
  --line: rgba(22, 115, 201, 0.18);
  --line2: rgba(22, 115, 201, 0.34);
  --blue: #1673c9;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Manrope, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  height: 50px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}

.logo {
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--purple3);
  letter-spacing: 0;
}

.logo span {
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg3);
}

.tab {
  min-height: 30px;
  border: 0;
  border-radius: 5px;
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.tab.on,
.tab:hover {
  background: var(--bg5);
  color: var(--purple3);
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bpm-pill,
.master-volume {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 31px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg3);
  color: var(--faint);
  font-size: 0.68rem;
  text-transform: uppercase;
  font-weight: 800;
}

.bpm-pill #bpmDisplay {
  min-width: 22px;
  text-align: center;
  color: var(--purple3);
  font-weight: 800;
}

.bpm-arrow {
  border: none;
  background: transparent;
  color: var(--purple3);
  font-size: 0.55rem;
  cursor: pointer;
  padding: 0 1px;
  line-height: 1;
  opacity: 0.75;
}
.bpm-arrow:hover { opacity: 1; }

.mini-btn,
.tool-btn,
.add-btn,
.transport-btn {
  border: 1px solid var(--line2);
  border-radius: 7px;
  background: rgba(157, 127, 232, 0.13);
  color: var(--purple3);
  min-height: 31px;
  padding: 0 12px;
  font-size: 0.76rem;
  font-weight: 800;
}

.mini-btn:hover,
.tool-btn:hover,
.add-btn:hover,
.transport-btn:hover {
  background: var(--purple2);
  border-color: var(--purple2);
  color: white;
}

main {
  height: calc(100vh - 50px);
}

.page {
  display: none;
  height: 100%;
  overflow: hidden;
}

.page.on {
  display: flex;
}

.panel {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.panel-title {
  color: var(--faint);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 12px;
  text-transform: uppercase;
}

#page-beat {
  padding: 16px;
}

.beat-panel {
  flex: 1;
  overflow: auto;
}

.seq-grid {
  display: grid;
  gap: 8px;
}

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

.seq-label {
  width: 74px;
  flex: 0 0 74px;
  color: var(--muted);
  text-align: right;
  font-size: 0.72rem;
  font-weight: 800;
}

.seq-cells {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(16, minmax(22px, 1fr));
  gap: 3px;
}

.cell {
  height: 32px;
  border: 1px solid var(--bg5);
  border-radius: 4px;
  background: var(--bg4);
}

.cell:hover {
  border-color: var(--purple3);
}

.cell.on.kick {
  background: var(--purple);
}

.cell.on.snare {
  background: var(--pink);
}

.cell.on.hat {
  background: var(--blue);
}

.cell.on.clap {
  background: var(--orange);
}

.cell.on.perc {
  background: var(--green);
}

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

.round-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--purple2);
  color: white;
  font-size: 0.72rem;
  font-weight: 900;
}

.danger {
  border-color: rgba(240, 112, 112, 0.45);
  color: var(--red);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.status-text {
  color: var(--muted);
  font-size: 0.78rem;
}

.add-btn {
  margin-left: auto;
}

#page-note {
  padding: 16px;
}

#page-vocal {
  padding: 16px;
}

.note-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 14px;
  width: 100%;
}

.note-left,
.note-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.big-note {
  min-height: 265px;
  display: grid;
  place-items: center;
  text-align: center;
}

.note-name {
  font-size: clamp(4rem, 12vw, 8rem);
  line-height: 0.9;
  font-weight: 900;
  color: var(--purple3);
}

.note-sub {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 6px;
}

.tune-bar {
  position: relative;
  width: 160px;
  height: 5px;
  margin: 12px auto 0;
  border-radius: 3px;
  background: var(--bg5);
}

.tune-bar span {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: var(--purple3);
}

.chip-grid,
.note-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip,
.note-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg3);
  color: var(--muted);
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 800;
}

.chip.on,
.chip:hover {
  border-color: var(--purple2);
  background: var(--purple2);
  color: white;
}

.note-pill {
  color: var(--purple3);
  border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.record-card {
  min-height: 58px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--bg3);
  color: var(--muted);
  font-weight: 900;
}

.record-card:hover {
  border-color: var(--purple3);
  color: var(--purple3);
}

.record-card.stop {
  border-color: rgba(240, 112, 112, 0.35);
  color: var(--red);
}

.vocal-layout {
  width: 100%;
  display: flex;
}

.vocal-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vocal-meter {
  min-height: 260px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(157, 127, 232, 0.15), rgba(18, 18, 31, 0.82));
}

.vocal-time {
  color: var(--purple3);
  font-size: clamp(4rem, 12vw, 8rem);
  line-height: 0.9;
  font-weight: 900;
}

#page-track {
  flex-direction: column;
}

.transport {
  height: 52px;
  flex: 0 0 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}

.transport-btn {
  background: var(--bg3);
  color: var(--muted);
}

.transport-btn.primary {
  background: var(--purple2);
  color: white;
}

.time-readout {
  min-width: 94px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg3);
  color: var(--purple3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
  font-weight: 800;
}

.master-volume input {
  width: 92px;
}

.track-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.lane-sidebar {
  width: var(--lane-label-w);
  flex: 0 0 var(--lane-label-w);
  background: var(--bg2);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.sidebar-head {
  height: 31px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg3);
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.lane-row {
  height: var(--lane-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
}

.lane-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
}

.lane-info {
  flex: 1;
  min-width: 0;
}

.lane-name {
  overflow: hidden;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lane-type {
  color: var(--faint);
  font-size: 0.65rem;
  text-transform: uppercase;
}

.mute-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg3);
  color: var(--faint);
  font-size: 0.7rem;
  font-weight: 900;
}

.mute-btn.on {
  border-color: var(--red);
  color: var(--red);
}

.delete-lane:hover {
  border-color: var(--red);
  color: var(--red);
}

.timeline-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ruler {
  height: 31px;
  flex: 0 0 31px;
  overflow: hidden;
  position: relative;
  background: var(--bg3);
  border-bottom: 1px solid var(--line);
}

.ruler-inner {
  position: relative;
  height: 31px;
}

.bar-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid rgba(157, 127, 232, 0.25);
  color: var(--faint);
  font-size: 0.65rem;
  padding: 8px 0 0 5px;
}

.timeline-scroll {
  flex: 1;
  overflow: auto;
  background: var(--bg);
}

.timeline-canvas {
  position: relative;
  min-height: 100%;
  background-image: linear-gradient(to right, rgba(157, 127, 232, 0.08) 1px, transparent 1px);
}

.timeline-lane {
  position: relative;
  height: var(--lane-h);
  border-bottom: 1px solid var(--line);
}

.timeline-lane:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.audio-clip {
  position: absolute;
  top: 6px;
  height: calc(var(--lane-h) - 12px);
  min-width: 4px;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: var(--purple3);
  background: rgba(157, 127, 232, 0.18);
  overflow: hidden;
  text-align: left;
}

.audio-clip.selected {
  outline: 2.5px solid var(--purple2);
  outline-offset: 1px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 10px var(--line2);
  z-index: 2;
}

.clip-label {
  position: absolute;
  left: 8px;
  top: 7px;
  right: 8px;
  overflow: hidden;
  font-size: 0.7rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.waveform {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 7px;
  height: 17px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.waveform span {
  width: 3px;
  min-width: 3px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.65;
}

.playhead {
  position: absolute;
  z-index: 20;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--red);
  pointer-events: none;
}

.playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: -5px;
  border: 6px solid transparent;
  border-top-color: var(--red);
}

.clip-edit-panel {
  min-height: 112px;
  flex: 0 0 112px;
  display: flex;
  align-items: center;
  overflow-x: auto;
  background: var(--bg2);
  border-top: 1px solid var(--line);
}

.clip-hint {
  flex: 1;
  color: var(--faint);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
}

.edit-form {
  display: flex;
  height: 100%;
  min-width: max-content;
}

.edit-col {
  min-width: 128px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  border-right: 1px solid var(--line);
}

.edit-col.wide {
  min-width: 190px;
}

.edit-col label {
  color: var(--faint);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.edit-col input {
  width: 100%;
  min-height: 31px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg4);
  color: var(--text);
  padding: 0 8px;
  outline: 0;
}

.edit-actions {
  flex-direction: row;
  align-items: center;
}

.delete-btn {
  border-color: rgba(240, 112, 112, 0.45);
  color: var(--red);
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: 320px;
  padding: 10px 16px;
  border: 1px solid var(--line2);
  border-radius: 8px;
  background: var(--bg5);
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.18s ease;
  pointer-events: none;
  font-size: 0.82rem;
  font-weight: 800;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 780px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 10px;
  }

  main {
    height: calc(100vh - 96px);
  }

  .top-actions {
    margin-left: 0;
  }

  .note-layout {
    grid-template-columns: 1fr;
    overflow: auto;
  }
}

/* ── Logo as button ── */
.logo {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--purple3);
  letter-spacing: 0;
  flex-shrink: 0;
}
.logo:hover { opacity: 0.8; }

/* ── User pill ── */
.user-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg3);
  min-height: 31px;
}
.user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--purple2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}
.user-name {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

/* ── Modal backdrop ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 8, 15, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 16px;
  padding: 32px 36px 28px;
  width: min(440px, 94vw);
  animation: slideUp 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-sm { width: min(380px, 94vw); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg3);
  color: var(--muted);
  font-size: 0.78rem;
}
.modal-close:hover { color: var(--text); border-color: var(--line2); }
.modal-backdrop.locked .modal-close {
  display: none !important;
}

.modal-logo {
  font-weight: 900;
  font-size: 1.5rem;
  color: var(--purple3);
  margin-bottom: 4px;
}
.modal-logo span { color: var(--text); }

.modal-section-title {
  font-size: 0.88rem;
  font-weight: 900;
  color: var(--purple3);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

/* ── Auth tabs ── */
.auth-tabs {
  display: flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: var(--bg3);
  margin-bottom: 4px;
}
.auth-tab {
  flex: 1;
  min-height: 30px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}
.auth-tab.on {
  background: var(--bg5);
  color: var(--purple3);
}

/* ── Form fields ── */
.auth-form { display: flex; flex-direction: column; gap: 8px; }
.field-label {
  color: var(--faint);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: -4px;
}
.field-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg4);
  color: var(--text);
  padding: 0 12px;
  outline: 0;
  font: inherit;
  font-size: 0.9rem;
}
.field-input:focus { border-color: var(--purple2); }

.auth-submit {
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  background: var(--purple2);
  color: white;
  font-weight: 900;
  font-size: 0.9rem;
  margin-top: 4px;
}
.auth-submit:hover { background: #7b48e0; }

.auth-note {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  margin: 0;
}
.auth-error {
  margin: 0;
  padding: 9px 11px;
  border: 1px solid rgba(240, 112, 112, 0.45);
  border-radius: 8px;
  background: rgba(240, 112, 112, 0.12);
  color: #ffb8b8;
  font-size: 0.78rem;
  font-weight: 800;
}
.link-btn {
  background: none;
  border: none;
  color: var(--purple3);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ── Project list in Load modal ── */
.project-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg3);
}
.project-item-name { flex: 1; font-size: 0.85rem; font-weight: 800; color: var(--text); }
.project-item-date { font-size: 0.7rem; color: var(--muted); }
.project-load-btn {
  border: 1px solid var(--line2);
  border-radius: 6px;
  background: rgba(157,127,232,0.13);
  color: var(--purple3);
  font-size: 0.74rem;
  font-weight: 800;
  padding: 4px 10px;
  min-height: 26px;
}
.project-load-btn:hover { background: var(--purple2); color: white; border-color: var(--purple2); }
.project-del-btn {
  border: 1px solid rgba(240,112,112,0.35);
  border-radius: 6px;
  background: transparent;
  color: var(--red);
  font-size: 0.74rem;
  font-weight: 800;
  padding: 4px 8px;
  min-height: 26px;
}
.project-del-btn:hover { background: rgba(240,112,112,0.18); }

/* ── Home page ── */
#page-home {
  overflow-y: auto;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(109,63,212,0.22) 0%, transparent 70%),
              var(--bg);
}

body.light-theme #page-home {
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(22, 115, 201, 0.16) 0%, transparent 70%),
              var(--bg);
}

.home-wrap {
  position: relative;
  width: min(1060px, 96vw);
  padding: 48px 0 48px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.theme-switcher {
  position: fixed;
  top: 70px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  z-index: 10;
}

.theme-toggle {
  position: relative;
  width: 46px;
  height: 24px;
  display: inline-flex;
  align-items: center;
}

.theme-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-toggle span {
  width: 46px;
  height: 24px;
  border: 1px solid var(--line2);
  border-radius: 999px;
  background: var(--bg3);
}

.theme-toggle span::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--purple3);
  transition: transform 0.16s ease;
}

.theme-toggle input:checked + span::before {
  transform: translateX(22px);
}

.home-hero { text-align: center; }
.home-title {
  font-size: clamp(2.6rem, 7vw, 5rem);
  font-weight: 900;
  line-height: 1;
  color: var(--purple3);
  letter-spacing: -1px;
  margin-bottom: 14px;
}
.home-title span { color: var(--text); }
.home-tagline {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 28px;
}
.home-cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.home-cta {
  padding: 0 28px;
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  background: var(--purple2);
  color: white;
  font-weight: 900;
  font-size: 0.95rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.home-cta:hover { transform: scale(1.03); box-shadow: 0 4px 16px var(--line2); }
.home-cta.ghost {
  background: transparent;
  border: 1px solid var(--line2);
  color: var(--purple3);
}
.home-cta.ghost:hover { background: var(--bg5); }

/* ── Home two-panel row ── */
.home-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 680px) { .home-panels { grid-template-columns: 1fr; } }

.home-panel {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 280px;
}

.panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg4);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  padding: 3px 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  align-self: flex-start;
}

/* ── YouTube embed ── */
.yt-embed-wrap { flex: 1; display: flex; flex-direction: column; }
.yt-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px dashed var(--line2);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
}
.yt-icon { width: 52px; height: auto; opacity: 0.8; }
.yt-hint { color: var(--muted); font-size: 0.8rem; margin: 0; }
.yt-input-row { display: flex; gap: 8px; width: 100%; }
.yt-url-input { flex: 1; min-height: 34px; font-size: 0.78rem; }
.yt-frame { flex: 1; width: 100%; min-height: 210px; border-radius: 10px; }

/* ── Ad panel ── */
.ad-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
}
.ad-icon { font-size: 2.2rem; opacity: 0.5; }
.ad-label { color: var(--muted); font-size: 0.88rem; font-weight: 900; margin: 0; }
.ad-sub { color: var(--faint); font-size: 0.76rem; margin: 0; }

/* ── Feature cards row ── */
.home-feature-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 680px) { .home-feature-row { grid-template-columns: repeat(2, 1fr); } }

.home-footer-credit {
  text-align: left;
  font-size: 11px;
  color: var(--faint);
  margin-top: -16px;
}

.feature-card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.feature-card:hover {
  border-color: var(--purple2);
  background: var(--bg3);
}
.feature-name { font-size: 0.85rem; font-weight: 900; color: var(--text); }
.feature-desc { font-size: 0.74rem; color: var(--muted); line-height: 1.4; }

/* ── Home page tab styling ── */
#appTabs { display: flex; }

/* ══════════════════════════════════════════════
   NOTE BUILDER — new UI
══════════════════════════════════════════════ */

/* Mode toggle */
.nb-mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 2px;
}
.nb-mode-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--bg3);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.nb-mode-btn.on {
  border-color: var(--purple2);
  background: var(--purple2);
  color: #fff;
}

/* Mic denied banner */
.mic-denied-msg {
  margin-top: 10px;
  background: rgba(220, 80, 60, 0.1);
  border: 1px solid rgba(220, 80, 60, 0.3);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.55;
}

/* Piano keyboard */
.nb-keyboard-panel { padding: 14px 14px 12px; }
.nb-keyboard-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.8;
}
.nb-keyboard-hint kbd {
  display: inline-block;
  background: var(--bg5, var(--bg3));
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.68rem;
  font-family: ui-monospace, monospace;
  margin: 1px;
}
.nb-piano {
  position: relative;
  display: flex;
  height: 112px;
  user-select: none;
  overflow-x: auto;
  padding-bottom: 4px;
  gap: 2px;
}
.nb-white-key {
  position: relative;
  flex-shrink: 0;
  width: 34px;
  height: 108px;
  background: #f8f8f8;
  border: 1.5px solid #bbb;
  border-radius: 0 0 7px 7px;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  font-size: 0.58rem;
  font-weight: 700;
  color: #bbb;
  transition: background 0.07s;
  z-index: 1;
  box-sizing: border-box;
}
.nb-white-key:hover { background: #e8e4ff; color: var(--purple2, #7f6edb); }
.nb-white-key.active { background: var(--purple2, #7f6edb); color: #fff; border-color: var(--purple2, #7f6edb); }

.nb-black-key {
  position: absolute;
  width: 22px;
  height: 68px;
  background: #1a1a1a;
  border-radius: 0 0 5px 5px;
  cursor: pointer;
  z-index: 2;
  top: 0;
  transition: background 0.07s;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 5px;
  font-size: 0.52rem;
  font-weight: 700;
  color: #666;
  box-sizing: border-box;
}
.nb-black-key:hover { background: var(--purple2, #7f6edb); color: #fff; }
.nb-black-key.active { background: var(--purple2, #7f6edb); color: #fff; }

/* Note strip */
.nb-phrase-hint {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
}
.note-pill {
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  position: relative;
}
.note-pill:hover { border-color: var(--purple2); }
.note-pill.np-selected { background: var(--purple2); color: #fff; border-color: var(--purple2); }
.note-pill .np-dur {
  font-size: 0.58rem;
  font-weight: 400;
  opacity: 0.8;
  line-height: 1;
}
.note-pill.np-staccato::after {
  content: '•';
  position: absolute;
  top: -5px;
  right: 3px;
  font-size: 1.1rem;
  color: var(--purple3);
  line-height: 1;
}

/* Per-note editor */
.nb-note-editor {
  border: 1.5px solid var(--purple2) !important;
}
.nb-editor-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.nb-editor-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 64px;
}
.nb-duration-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.nb-dur-btn {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--bg3);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: background 0.1s, border-color 0.1s;
  line-height: 1;
}
.nb-dur-btn span {
  font-size: 0.56rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1;
}
.nb-dur-btn:hover { border-color: var(--purple2); background: var(--bg4, var(--bg3)); }
.nb-dur-btn.nb-dur-selected { background: var(--purple2); border-color: var(--purple2); color: #fff; }
.nb-dur-btn.nb-dur-selected span { color: rgba(255,255,255,0.8); }

.nb-staccato-btn {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: var(--bg3);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.nb-staccato-btn.nb-staccato-on {
  background: var(--purple2);
  border-color: var(--purple2);
  color: #fff;
}
.nb-delete-note-btn {
  margin-top: 4px;
  padding: 7px 16px;
  border-radius: 8px;
  border: 1.5px solid rgba(220,60,60,0.35);
  background: rgba(220,60,60,0.07);
  color: #d95555;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s;
}
.nb-delete-note-btn:hover { background: rgba(220,60,60,0.16); }

/* Timeline empty state */
.timeline-empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.45;
  letter-spacing: 0.01em;
  text-align: center;
  padding: 20px;
}

/* Note Builder sidebar — uniform button sizing */
.nb-side-btn {
  width: 100%;
  min-height: 34px;
  margin-left: 0 !important;
  text-align: center;
}

/* Vocal recorder — Play Take row centered */
.vocal-action-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.vocal-action-row .add-btn {
  margin-left: 0;
}
