:root {
  color-scheme: dark;
  --bg: #1a1d36;
  --bg-elevated: rgba(37, 41, 74, 0.88);
  --panel: rgba(40, 43, 78, 0.92);
  --panel-strong: #343755;
  --surface: #454861;
  --surface-alt: #3e415e;
  --line: rgba(164, 177, 231, 0.16);
  --line-strong: rgba(164, 177, 231, 0.26);
  --text: #f0f1fb;
  --text-soft: #b4b8d5;
  --primary: #8b72f6;
  --primary-strong: #7b63ea;
  --accent: #6e7bb7;
  --accent-soft: rgba(139, 114, 246, 0.16);
  --danger: #d46b87;
  --shadow: 0 18px 48px rgba(9, 12, 30, 0.42);
  --radius: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --font-body: "Avenir Next", "Segoe UI", sans-serif;
  --font-display: "Gill Sans", "Trebuchet MS", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171a31;
  --bg-elevated: rgba(31, 34, 63, 0.94);
  --panel: rgba(34, 37, 68, 0.96);
  --panel-strong: #2b2e4c;
  --surface: #3c405b;
  --surface-alt: #313551;
  --line: rgba(181, 189, 235, 0.14);
  --line-strong: rgba(181, 189, 235, 0.22);
  --text: #f3f4fd;
  --text-soft: #b8bddb;
  --primary: #9378ff;
  --primary-strong: #8369f0;
  --accent: #6678aa;
  --accent-soft: rgba(147, 120, 255, 0.18);
  --danger: #d86f8a;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #dfe3f6;
  --bg-elevated: rgba(233, 236, 249, 0.92);
  --panel: rgba(241, 243, 252, 0.94);
  --panel-strong: #ffffff;
  --surface: #e7e9f7;
  --surface-alt: #d7dbef;
  --line: rgba(78, 88, 146, 0.16);
  --line-strong: rgba(78, 88, 146, 0.26);
  --text: #1f2445;
  --text-soft: #5d678f;
  --primary: #7f6af0;
  --primary-strong: #6d59de;
  --accent: #6678aa;
  --accent-soft: rgba(127, 106, 240, 0.14);
  --danger: #c85f7d;
  --shadow: 0 18px 48px rgba(40, 51, 96, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(120, 106, 214, 0.14), transparent 24%),
    radial-gradient(circle at bottom right, rgba(92, 118, 185, 0.12), transparent 26%),
    linear-gradient(180deg, rgba(62, 52, 112, 0.1), transparent 22%),
    var(--bg);
  color: var(--text);
}

body {
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="range"] {
  touch-action: manipulation;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.78rem 1rem;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

button:hover,
button:focus-visible {
  background: var(--primary-strong);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.06));
  color: var(--text);
  border: 1px solid var(--line);
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

button.accent {
  background: var(--accent);
}

button.danger {
  background: var(--danger);
}

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

a {
  color: inherit;
  text-decoration: none;
}

input,
select,
textarea {
  width: 100%;
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.86rem 0.95rem;
  min-height: 46px;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}

.shell-sidebar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  backdrop-filter: blur(14px);
  background: rgba(28, 30, 54, 0.92);
  border-bottom: 1px solid var(--line);
}

[data-theme="dark"] .shell-sidebar {
  background: rgba(28, 30, 54, 0.92);
}

[data-theme="light"] .shell-sidebar {
  background: rgba(226, 231, 247, 0.9);
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: linear-gradient(145deg, #9b7aff, #596ea6);
  box-shadow: var(--shadow);
}

.brand h1,
.section-title,
.metric-card strong,
.panel h2,
.page-hero h2 {
  font-family: var(--font-display);
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
}

.brand p {
  margin: 0.2rem 0 0;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.shell-main {
  padding: 1rem 1rem 6rem;
  display: grid;
  gap: 1rem;
}

.nav-tabs,
.mobile-nav {
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar,
.mobile-nav::-webkit-scrollbar,
.timeline-scroll::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-soft);
}

.nav-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 8;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0));
  background: rgba(28, 30, 54, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

[data-theme="dark"] .mobile-nav {
  background: rgba(28, 30, 54, 0.94);
}

[data-theme="light"] .mobile-nav {
  background: rgba(226, 231, 247, 0.94);
}

.mobile-nav button {
  flex: 1;
  font-size: 0.92rem;
  padding-inline: 0.65rem;
}

.page-hero {
  padding: 1.2rem;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(68, 72, 118, 0.96), rgba(149, 123, 255, 0.86)),
    var(--panel);
  color: #fff;
  box-shadow: var(--shadow);
}

.page-hero h2 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.page-hero p {
  margin: 0;
  max-width: 68ch;
  color: rgba(255, 255, 255, 0.88);
}

.page-grid,
.two-column,
.three-column,
.dashboard-grid {
  display: grid;
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel h2,
.panel h3,
.panel h4 {
  margin-top: 0;
}

.section-title {
  font-size: 1.15rem;
  margin: 0 0 0.5rem;
}

.subtext,
.helper-text,
.chip-muted,
.empty-state {
  color: var(--text-soft);
}

.dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(0,0,0,0.05)), var(--surface);
  border: 1px solid var(--line);
}

.metric-card strong {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.grid-list {
  display: grid;
  gap: 0.75rem;
}

.list-card,
.track-card,
.clip-card,
.tool-card,
.note-monitor,
.diagram-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.04)), var(--surface);
  padding: 0.95rem;
}

.list-card.active,
.track-card.active {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.row,
.inline-actions,
.toolbar,
.field-row,
.track-controls,
.transport-row,
.status-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar {
  justify-content: space-between;
}

.field-grid {
  display: grid;
  gap: 0.85rem;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field label,
.stack label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.93rem;
  font-weight: 700;
}

.stack {
  display: grid;
  gap: 0.7rem;
}

.chips {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  font-size: 0.9rem;
}

.chip strong {
  font-weight: 800;
}

.song-viewer {
  display: grid;
  gap: 1rem;
}

.song-sheet {
  border-radius: var(--radius);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  padding: 1.2rem;
  overflow: auto;
  min-height: 280px;
}

.song-sheet.stage-mode {
  font-size: 1.22em;
  line-height: 1.8;
}

.song-section {
  margin-bottom: 1.4rem;
}

.song-section h4 {
  margin: 0 0 0.5rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.lyrics-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.16rem 0.4rem;
  margin-bottom: 0.4rem;
  align-items: flex-end;
}

.lyric-fragment {
  display: inline-flex;
  flex-direction: column;
  min-width: 0.4rem;
}

.inline-chord {
  font-size: 0.82em;
  line-height: 1.1;
  font-weight: 800;
  color: #b8a6ff;
}

.timeline-shell {
  display: grid;
  gap: 0.85rem;
}

.timeline-scroll {
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.timeline-grid {
  min-width: 720px;
  display: grid;
  gap: 0.65rem;
}

.timeline-ruler,
.track-lane {
  display: grid;
  grid-template-columns: 160px repeat(16, minmax(40px, 1fr));
  gap: 0.35rem;
  align-items: center;
}

.ruler-cell,
.lane-cell {
  min-height: 42px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  color: var(--text-soft);
}

.track-label {
  padding: 0.85rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.04)), var(--surface);
  border: 1px solid var(--line);
}

.clip-pill {
  border-radius: 14px;
  color: #fff;
  padding: 0.45rem 0.65rem;
  font-size: 0.83rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meter-grid,
.tools-grid,
.shortcut-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.virtual-keys {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.4rem;
}

.key-pad {
  min-height: 70px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

.key-pad.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.circle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.circle-node {
  padding: 0.85rem;
  border-radius: 16px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.62rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.04)), var(--surface);
  border: 1px solid var(--line);
  font-size: 0.84rem;
  color: var(--text-soft);
}

.finder-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.72rem 1rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.finder-embed-shell {
  min-height: 68vh;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(9, 11, 24, 0.22);
}

.finder-embed-frame {
  width: 100%;
  min-height: 68vh;
  border: 0;
  background: #fff;
}

.status-online::before,
.status-offline::before,
.status-ready::before,
.status-live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.status-online::before,
.status-ready::before,
.status-live::before {
  background: #2da874;
}

.status-offline::before {
  background: #d27b58;
}

.hidden {
  display: none !important;
}

.empty-state {
  padding: 1rem;
  border-radius: 16px;
  border: 1px dashed var(--line);
}

.footer-note {
  font-size: 0.84rem;
  color: var(--text-soft);
}

.error-pre {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
  color: var(--text);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(9, 11, 24, 0.72);
  backdrop-filter: blur(12px);
}

.modal-card {
  width: min(760px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
  border-radius: 28px;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.08)),
    var(--panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
  padding: 1.1rem;
}

.modal-list {
  margin-top: 0.75rem;
}

@media (min-width: 900px) {
  .app-shell {
    grid-template-columns: 280px 1fr;
  }

  .shell-sidebar {
    min-height: 100vh;
    align-items: flex-start;
    justify-content: flex-start;
    flex-direction: column;
    padding: 1.3rem 1rem;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }

  .shell-main {
    padding: 1.3rem 1.3rem 2rem;
  }

  .nav-tabs {
    flex-direction: column;
    width: 100%;
  }

  .nav-tab {
    width: 100%;
    text-align: left;
  }

  .mobile-nav {
    display: none;
  }

  .two-column {
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  }

  .three-column {
    grid-template-columns: minmax(280px, 320px) minmax(0, 1.2fr) minmax(280px, 340px);
  }
}

@media (max-width: 760px) {
  .field-grid.two,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .page-hero {
    padding: 1rem;
  }

  .timeline-ruler,
  .track-lane {
    grid-template-columns: 130px repeat(16, minmax(32px, 1fr));
  }
}
