:root {
  color-scheme: dark;
  --bg: #101820;
  --nav: #0c1319;
  --panel: #16222c;
  --panel-strong: #1d2b36;
  --text: #f6f7f2;
  --muted: #aeb8bb;
  --line: #2d3a42;
  --accent: #ffc857;
  --accent-strong: #ffb627;
  --stage-chord: #ffb627;
  --good: #6ee7b7;
  --danger: #ff7a7a;
  --blue: #8ecae6;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --nav: #ffffff;
  --panel: #ffffff;
  --panel-strong: #eef3f8;
  --text: #111827;
  --muted: #5f6f7a;
  --line: #d5e0e8;
  --accent: #1e88ff;
  --accent-strong: #0b4f9c;
  --good: #047857;
  --danger: #c2414b;
  --blue: #0b6cb8;
  --shadow: 0 18px 50px rgba(16, 24, 32, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(255, 200, 87, 0.08), transparent 28rem),
    radial-gradient(circle at top right, rgba(110, 231, 183, 0.12), transparent 24rem),
    var(--bg);
  color: var(--text);
}

body.stage-active {
  overflow: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

body.member-preview .admin-only {
  display: none !important;
}

body.member-preview .workspace-picker {
  grid-template-columns: 1fr;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

body.stage-active .app-shell {
  grid-template-columns: 1fr;
}

body.stage-active .side-nav {
  display: none;
}

body.stage-active .main-shell {
  height: 100dvh;
  overflow: hidden;
  padding: 0;
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(12, 19, 25, 0.96);
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background-image: url("icons/stagechart-icon.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 88%;
  background-color: #05070d;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.brand p {
  margin: 0;
  font-weight: 900;
}

.wordmark {
  font-size: 1.08rem;
  line-height: 1;
}

.wordmark span:first-child {
  color: var(--text);
}

.wordmark span:last-child {
  color: #38d5bf;
}

.brand small,
.eyebrow,
.next-song,
.summary-text,
label span,
.meta,
.muted {
  color: var(--muted);
}

.summary-text {
  margin: 8px 0 0;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border-radius: 8px;
  margin-bottom: 8px;
  padding: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav-button.active,
.nav-button:hover {
  background: var(--panel-strong);
}

.settings-nav {
  position: static;
  flex: 0 0 44px;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: auto 0 0;
  border: 1px solid rgba(120, 143, 157, 0.42);
  background: rgba(12, 19, 25, 0.72);
  font-size: 0;
  gap: 0;
  backdrop-filter: blur(14px) saturate(1.2);
}

.settings-nav .icon {
  width: 1.12rem;
  height: 1.12rem;
}

.main-shell {
  min-width: 0;
  padding: 24px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

#stageView {
  position: relative;
}

body.stage-active #stageView {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}

.view-header,
.stage-header,
.dialog-header,
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.view-header {
  padding-right: 60px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h3 {
  line-height: 1.22;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 4vw, 4.4rem);
  line-height: 1;
}

h2 {
  margin-bottom: 8px;
}

.action-row,
.stage-controls,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.icon {
  display: inline-block;
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  background: currentColor;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.icon-library { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 4h10a3 3 0 0 1 3 3v13H8a3 3 0 0 1-3-3V4Zm2 2v11a1 1 0 0 0 1 1h8V7a1 1 0 0 0-1-1H7Zm3 3h4v2h-4V9Zm0 4h4v2h-4v-2Z'/%3E%3C/svg%3E"); }
.icon-list { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 6h2v2H5V6Zm4 0h10v2H9V6ZM5 11h2v2H5v-2Zm4 0h10v2H9v-2Zm-4 5h2v2H5v-2Zm4 0h10v2H9v-2Z'/%3E%3C/svg%3E"); }
.icon-grid { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 4h7v7H4V4Zm9 0h7v7h-7V4ZM4 13h7v7H4v-7Zm9 0h7v7h-7v-7Z'/%3E%3C/svg%3E"); }
.icon-play { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 5v14l11-7L8 5Z'/%3E%3C/svg%3E"); }
.icon-back { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m7 12 9-7v14l-9-7Z'/%3E%3C/svg%3E"); }
.icon-metronome { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.6 3h2.8l.6 4.7 3.4 12.3H6.6L10 7.7 10.6 3Zm1.8 2h-.8l-.3 2.5 1.9 1.1-.8-3.6Zm-1 5.1L9.2 18h5.6l-2-7.2-1.4-.7ZM8 20h8v2H8v-2Z'/%3E%3C/svg%3E"); }
.icon-pause { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 5h4v14H7V5Zm6 0h4v14h-4V5Z'/%3E%3C/svg%3E"); }
.icon-plus { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 5h2v6h6v2h-6v6h-2v-6H5v-2h6V5Z'/%3E%3C/svg%3E"); }
.icon-minus { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 11h14v2H5v-2Z'/%3E%3C/svg%3E"); }
.icon-close { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m6.4 5 5.6 5.6L17.6 5 19 6.4 13.4 12l5.6 5.6-1.4 1.4-5.6-5.6L6.4 19 5 17.6l5.6-5.6L5 6.4 6.4 5Z'/%3E%3C/svg%3E"); }
.icon-upload { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 16h2V8l3.2 3.2 1.4-1.4L12 4.2 6.4 9.8l1.4 1.4L11 8v8Zm-5 2h12v2H6v-2Z'/%3E%3C/svg%3E"); }
.icon-download { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 4h2v8l3.2-3.2 1.4 1.4L12 15.8l-5.6-5.6 1.4-1.4L11 12V4ZM6 18h12v2H6v-2Z'/%3E%3C/svg%3E"); }
.icon-archive { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 5h16v4h-1v10H5V9H4V5Zm3 4v8h10V9H7Zm-1-2h12V7H6v0Zm4 4h4v2h-4v-2Z'/%3E%3C/svg%3E"); }
.icon-file { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 3h9l4 4v14H6V3Zm2 2v14h9V8h-3V5H8Zm2 7h5v2h-5v-2Zm0 4h5v2h-5v-2Z'/%3E%3C/svg%3E"); }
.icon-copy { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 7V3h14v14h-4v4H3V7h4Zm2 0h8v8h2V5H9v2Zm-4 2v10h10V9H5Z'/%3E%3C/svg%3E"); }
.icon-text-small { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 18h2l1-3h5l1 3h2L10.5 6h-2L4 18Zm4-5 1.5-4.4L11 13H8Zm8 0h4v2h-4v-2Z'/%3E%3C/svg%3E"); }
.icon-text-large { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 19h3l1.2-3.5h6.6L15 19h3L11.8 5H9.2L3 19Zm5-6 2.5-6 2.5 6H8Zm11-5v3h3v2h-3v3h-2v-3h-3v-2h3V8h2Z'/%3E%3C/svg%3E"); }
.icon-up { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 20h2V8l4.2 4.2 1.4-1.4L12 4.2l-6.6 6.6 1.4 1.4L11 8v12Z'/%3E%3C/svg%3E"); }
.icon-down { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 4h2v12l4.2-4.2 1.4 1.4-6.6 6.6-6.6-6.6 1.4-1.4L11 16V4Z'/%3E%3C/svg%3E"); }
.icon-grip {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 5h2v2H8V5Zm6 0h2v2h-2V5ZM8 11h2v2H8v-2Zm6 0h2v2h-2v-2ZM8 17h2v2H8v-2Zm6 0h2v2h-2v-2Z'/%3E%3C/svg%3E");
}
.icon-settings {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.8 3h2.4l.5 2.4c.6.2 1.1.4 1.6.7l2.1-1.3 1.7 1.7-1.3 2.1c.3.5.5 1 .7 1.6l2.5.6v2.4l-2.5.6c-.2.6-.4 1.1-.7 1.6l1.3 2.1-1.7 1.7-2.1-1.3c-.5.3-1 .5-1.6.7l-.5 2.4h-2.4l-.5-2.4c-.6-.2-1.1-.4-1.6-.7l-2.1 1.3-1.7-1.7 1.3-2.1c-.3-.5-.5-1-.7-1.6L3 13.2v-2.4l2.5-.6c.2-.6.4-1.1.7-1.6L4.9 6.5l1.7-1.7 2.1 1.3c.5-.3 1-.5 1.6-.7L10.8 3Zm1.2 6a3 3 0 1 0 0 6 3 3 0 0 0 0-6Z'/%3E%3C/svg%3E");
}
.icon-info {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 10h2v8h-2v-8Zm0-4h2v2h-2V6Zm1-4a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm0 2a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z'/%3E%3C/svg%3E");
}
.icon-note {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 3h14v12l-6 6H5V3Zm2 2v14h5v-5h5V5H7Zm7 12.6 2.6-2.6H14v2.6ZM9 8h6v2H9V8Zm0 4h5v2H9v-2Z'/%3E%3C/svg%3E");
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.stage-controls button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border-radius: 8px;
  padding: 0 13px;
  color: var(--text);
}

.primary-button {
  background: var(--accent);
  color: #1d1600;
  font-weight: 900;
}

.secondary-button,
.ghost-button,
.stage-controls button,
.small-button {
  background: #253542;
}

.import-help {
  position: relative;
}

.import-help summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #253542;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.import-help summary::-webkit-details-marker {
  display: none;
}

.import-help summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.import-help-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: min(420px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.import-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.import-help-header .small-button {
  width: 40px;
  min-height: 40px;
  padding: 0;
  flex: 0 0 auto;
}

.import-help-panel h2,
.import-help-panel p {
  margin: 0;
}

.import-help-panel h2 {
  font-size: 0.98rem;
}

.import-help-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.import-help-panel pre {
  margin: 12px 0;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  padding: 12px;
  font: 0.86rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.danger-button {
  background: #4a2530;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 240px) auto auto;
  align-items: end;
  gap: 12px;
  margin: 24px 0 14px;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented-control button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border-radius: 0;
  background: #15212b;
  color: var(--muted);
  padding: 0 12px;
}

.segmented-control button.active {
  background: var(--accent);
  color: #1d1600;
  font-weight: 900;
}

label {
  display: grid;
  gap: 7px;
  font-size: 0.88rem;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c141a;
  color: var(--text);
  padding: 11px 12px;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px;
  line-height: 1.2;
  padding-right: 34px;
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.45;
}

.notice {
  border: 1px solid rgba(255, 200, 87, 0.45);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 12px;
  background: rgba(255, 200, 87, 0.08);
}

.notice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.duplicate-groups {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

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

.duplicate-group strong {
  color: var(--accent);
}

.checkbox-control {
  display: flex;
  align-items: center;
  gap: 9px;
  align-self: end;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #15212b;
  padding: 0 12px;
  white-space: nowrap;
}

.checkbox-control input {
  appearance: none;
  width: 14px;
  height: 14px;
  min-height: 0;
  margin: 0;
  border: 1px solid currentColor;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.checkbox-control input:checked {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px #15212b;
}

.song-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.song-grid.list {
  grid-template-columns: 1fr;
}

.song-grid.list .song-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.song-grid.list .tag-row {
  margin: 6px 0 0;
}

.song-card,
.setlist-card,
.queue-row,
.import-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(22, 34, 44, 0.9);
  box-shadow: var(--shadow);
}

.song-card {
  padding: 14px;
}

.song-card.duplicate {
  border-color: var(--accent);
}

.song-card h3,
.setlist-card h3 {
  margin-bottom: 4px;
  padding-bottom: 2px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.tag {
  border-radius: 999px;
  background: #263946;
  color: var(--blue);
  padding: 4px 8px;
  font-size: 0.8rem;
}

.setlist-workspace {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.setlist-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.setlist-card {
  width: 100%;
  padding: 13px;
  color: var(--text);
  text-align: left;
}

.setlist-card.active {
  border-color: var(--accent);
}

.setlist-editor {
  min-height: 68vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(22, 34, 44, 0.78);
  padding: 16px;
}

.builder-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 16px;
}

.queue {
  display: grid;
  gap: 8px;
}

.queue-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.queue-row[draggable="true"] {
  cursor: grab;
}

.queue-row.dragging {
  border-color: var(--accent);
  opacity: 0.62;
}

.queue-row.drop-target {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.queue-index {
  color: var(--accent);
  font-weight: 900;
}

.song-search-results {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 52vh;
  overflow: auto;
}

.song-search-results .queue-row {
  grid-template-columns: 34px minmax(0, 1fr) 96px;
  align-items: center;
}

.song-search-results .queue-row .small-button {
  width: 96px;
  min-height: 48px;
  justify-self: end;
  white-space: nowrap;
}

.stage-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding: 8px 104px 7px;
  background: rgba(12, 19, 25, 0.82);
}

.stage-header > div:first-child {
  min-width: 0;
}

.stage-header h1 {
  margin: 2px 0 3px;
  overflow: hidden;
  font-size: 1.9rem;
  line-height: 1.06;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-header .eyebrow,
.stage-header .next-song {
  margin: 0;
  overflow: hidden;
  font-size: 0.94rem;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.stage-note-button {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 40;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #253542;
  color: var(--text);
}

.stage-note-button.has-notes {
  background: rgba(255, 182, 39, 0.18);
  color: var(--accent);
  border-color: rgba(255, 182, 39, 0.58);
}

.stage-note-button.has-notes::after {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.desktop-stage-nav {
  display: none;
}

.stage-controls output {
  min-width: 34px;
  color: var(--accent);
  font-weight: 900;
  text-align: center;
}

.stage-controls {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 35;
  display: grid;
  grid-template-columns: 54px 54px 54px;
  grid-template-areas: "click scroll more";
  align-items: stretch;
  gap: 6px;
  border: 1px solid rgba(120, 143, 157, 0.42);
  border-radius: 10px;
  background: rgba(12, 19, 25, 0.72);
  padding: 7px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(1.2);
  transition: opacity 240ms ease, transform 240ms ease;
}

.stage-controls #exitStageButton { grid-area: exit; }
.stage-controls .click-stack { grid-area: click; }
.stage-controls .transpose-stack { grid-area: transpose; }
.stage-controls .font-stack { grid-area: font; }
.stage-controls .scroll-stack { grid-area: scroll; }
.stage-controls .speed-control { grid-area: speed; }
.stage-controls #previousSongButton { grid-area: prev; }
.stage-controls #nextSongButton { grid-area: next; }
.stage-controls #stageMoreControlsButton { grid-area: more; }

.control-stack {
  display: none;
  grid-template-rows: 40px 24px 40px;
  gap: 4px;
}

.control-stack button {
  width: 100%;
  min-height: 40px;
}

.control-stack output {
  align-content: center;
  font-size: 1.1rem;
}

.scroll-stack {
  display: grid;
  grid-template-rows: 54px;
  align-items: stretch;
  gap: 4px;
  width: 54px;
}

.click-stack {
  display: grid;
  grid-template-rows: 54px;
  gap: 4px;
  width: 54px;
}

.click-tempo-control {
  display: none;
  grid-template-columns: 24px minmax(28px, 1fr) 24px;
  align-items: center;
  gap: 3px;
}

.click-tempo-control button {
  min-height: 28px;
  width: 24px;
  padding: 0;
}

.click-tempo-control .icon {
  width: 0.8rem;
  height: 0.8rem;
}

.click-tempo-control output {
  min-width: 0;
  font-size: 0.95rem;
}

.click-accent-control {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.click-accent-control input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--accent);
}

.speed-control {
  display: none;
  width: 100%;
  min-width: 0;
  justify-self: stretch;
  align-self: center;
  padding-bottom: 0;
}

.speed-control span {
  display: none;
}

.speed-control input {
  width: 100%;
  min-width: 0;
  height: 32px;
  border: 0;
  background: transparent;
  padding: 0;
}

.stage-chart {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow: auto;
  padding: 16px 28px 118px;
  outline: none;
  font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
  font-size: var(--chart-size, 20px);
  line-height: 1.25;
  touch-action: pan-y;
}

.personal-panel {
  position: absolute;
  top: 96px;
  right: 24px;
  z-index: 20;
  width: min(420px, calc(100vw - 48px));
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(14, 23, 31, 0.97);
  padding: 16px;
  box-shadow: var(--shadow);
}

.personal-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.personal-panel h2 {
  font-size: 1rem;
}

.personal-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.personal-note-field {
  grid-column: 1 / -1;
}

.personal-transpose-button {
  align-self: end;
}

#stageTitle {
  min-width: 0;
  max-width: 100%;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(1.55rem, 3vw, 2.65rem);
}

#stageMeta,
#nextSong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-controls #previousSongButton,
.stage-controls #nextSongButton {
  display: none;
  min-width: 82px;
  min-height: 48px;
  background: var(--accent);
  color: #1d1600;
  font-weight: 900;
}

#exitStageButton {
  position: fixed;
  top: 12px;
  left: 16px;
  z-index: 40;
  min-width: 50px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #253542;
  color: var(--text);
}

@media (hover: hover) and (pointer: fine) {
  .stage-header {
    padding-right: 288px;
  }

  .desktop-stage-nav {
    position: fixed;
    top: 12px;
    right: 72px;
    z-index: 40;
    display: flex;
    gap: 8px;
  }

  .desktop-stage-nav button {
    min-width: 82px;
    min-height: 42px;
    border: 1px solid rgba(255, 182, 39, 0.58);
    border-radius: 8px;
    background: var(--accent);
    color: #1d1600;
    font-weight: 900;
  }

  .desktop-stage-nav button:disabled {
    cursor: not-allowed;
    opacity: 0.42;
  }
}

.stage-controls #scrollToggle {
  min-width: 54px;
  min-height: 54px;
  padding: 0;
  font-size: 0;
  gap: 0;
}

.stage-controls #clickToggle {
  min-width: 54px;
  min-height: 54px;
  padding: 0;
  font-size: 0;
  gap: 0;
}

.stage-controls #stageMoreControlsButton {
  min-width: 54px;
  min-height: 54px;
  padding: 0;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0;
}

.stage-controls #clickToggle.active {
  background: #1b5366;
  color: #ffffff;
}

.stage-controls #clickToggle.beat,
.stage-controls #clickToggle.accent-beat {
  transform: translateY(1px);
  box-shadow: 0 0 0 4px rgba(255, 182, 39, 0.24);
}

.stage-controls #clickToggle.accent-beat {
  background: var(--accent);
  color: #1d1600;
}

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

.stage-tools-open .stage-controls {
  width: min(536px, calc(100vw - 24px));
  grid-template-columns: 170px 78px 78px 78px 24px;
  grid-template-areas: "click transpose font scroll speed";
  align-items: stretch;
  gap: 14px;
  border-color: rgba(55, 210, 245, 0.32);
  border-radius: 12px;
  background: rgba(5, 13, 18, 0.78);
  padding: 20px 26px 24px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px) saturate(1.25);
}

.stage-tools-open .stage-controls #stageMoreControlsButton {
  display: none;
}

.stage-tools-open .click-stack {
  width: 100%;
  grid-template-rows: 62px 88px;
  gap: 4px;
}

.stage-tools-open .scroll-stack {
  width: 100%;
  min-height: 154px;
  grid-template-rows: 1fr;
}

.stage-tools-open .click-tempo-control,
.stage-tools-open .control-stack,
.stage-tools-open .speed-control {
  display: grid;
}

.stage-tools-open .click-tempo-control {
  grid-column: 1;
}

.stage-tools-open .click-tempo-control {
  grid-template-columns: 78px 78px;
  grid-template-rows: 22px 62px;
  justify-content: space-between;
  gap: 4px 14px;
}

.stage-tools-open .click-tempo-control output {
  display: block;
  grid-column: 1 / -1;
  grid-row: 1;
  min-width: 0;
  color: var(--accent);
  font-size: 1.05rem;
  line-height: 1;
}

.stage-tools-open #clickTempoDown {
  grid-column: 1;
  grid-row: 2;
}

.stage-tools-open #clickTempoUp {
  grid-column: 2;
  grid-row: 2;
}

.stage-tools-open .speed-control {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 154px;
  align-self: stretch;
  justify-items: center;
  overflow: visible;
}

.stage-tools-open .speed-control input {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 154px;
  height: 28px;
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center;
  writing-mode: horizontal-tb;
  direction: ltr;
  touch-action: none;
}

.stage-tools-open .control-stack {
  grid-template-rows: 62px 22px 62px;
  gap: 4px;
}

.stage-tools-open .control-stack output {
  display: block;
  min-width: 0;
  color: var(--accent);
  font-size: 1.05rem;
  line-height: 1;
}

.stage-tools-open .control-stack button,
.stage-tools-open .click-tempo-control button,
.stage-tools-open #clickToggle,
.stage-tools-open #scrollToggle {
  width: 100%;
  min-height: 0;
  height: 100%;
  border-radius: 10px;
  background: rgba(37, 53, 66, 0.78);
  color: #ffffff;
}

.stage-tools-open .stage-controls .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.stage-tools-open #clickToggle,
.stage-tools-open #scrollToggle {
  width: 100%;
}

.stage-tools-open #scrollToggle {
  min-height: 154px;
}

.stage-tools-fading .stage-controls {
  opacity: 0;
  transform: translateY(8px) scale(0.98);
}

.chart-line {
  margin-bottom: 0.55em;
}

.chart-line.no-chords {
  margin-bottom: 0.22em;
}

.chord-row,
.lyric-row {
  min-height: 1.2em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chart-line:not(.no-chords) .chord-row,
.chart-line:not(.no-chords) .lyric-row {
  white-space: pre;
  overflow-wrap: normal;
}

.chord-row {
  color: var(--text);
}

.chord-token {
  color: var(--stage-chord);
  font-weight: 900;
}

.lyric-row {
  color: var(--text);
}

.chart-line.no-chords .lyric-row {
  min-height: 1em;
  line-height: 1.08;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.print-output {
  display: none;
}

.print-song {
  break-after: page;
  page-break-after: always;
}

.print-song:last-child {
  break-after: auto;
  page-break-after: auto;
}

.print-song h2 {
  margin-bottom: 4px;
}

.print-chart {
  margin-top: 20px;
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: 12pt;
  line-height: 1.25;
}

.print-chart .chart-line {
  margin-bottom: 0.4em;
}

.song-form {
  display: grid;
  gap: 14px;
}

.settings-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 18px;
  align-items: start;
  max-width: 860px;
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(22, 34, 44, 0.78);
  padding: 18px;
  box-shadow: var(--shadow);
}

.settings-stack {
  display: grid;
  gap: 12px;
}

.workspace-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.workspace-picker .small-button {
  min-height: 42px;
  padding: 0;
}

:root[data-theme="light"] body {
  background:
    linear-gradient(135deg, rgba(30, 136, 255, 0.08), transparent 28rem),
    radial-gradient(circle at top right, rgba(56, 213, 191, 0.14), transparent 24rem),
    var(--bg);
}

:root[data-theme="light"] .side-nav,
:root[data-theme="light"] .settings-panel,
:root[data-theme="light"] .song-card,
:root[data-theme="light"] .setlist-card,
:root[data-theme="light"] .queue-row,
:root[data-theme="light"] .import-row,
:root[data-theme="light"] .setlist-editor,
:root[data-theme="light"] dialog {
  background: rgba(255, 255, 255, 0.92);
}

:root[data-theme="light"] input,
:root[data-theme="light"] textarea,
:root[data-theme="light"] select {
  background: #ffffff;
  color: var(--text);
}


.spotify-import-fields {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 20, 26, 0.58);
  padding: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media print {
  .side-nav,
  .app-shell,
  dialog {
    display: none !important;
  }

  .print-output {
    display: block;
  }

  body {
    background: white;
    color: black;
  }

  .print-output,
  .print-output p,
  .print-output h1,
  .print-output h2,
  .print-output .lyric-row {
    color: #111111 !important;
  }

  .print-output .chord-row {
    color: #111111 !important;
  }

  .print-output .chord-token {
    color: #0b4f9c !important;
    font-weight: 900;
  }

  @page {
    margin: 0.55in;
  }
}

@media (max-width: 1400px) {
  .toolbar {
    grid-template-columns: minmax(260px, 1fr) minmax(180px, 240px);
  }

  .segmented-control,
  .checkbox-control {
    width: 100%;
  }

  .builder-grid {
    grid-template-columns: 1fr;
  }

  .queue-row {
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: start;
  }

  .song-search-results .queue-row {
    grid-template-columns: 34px minmax(0, 1fr) 96px;
    align-items: center;
  }

  .queue-row .inline-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .song-search-results {
    max-height: 34vh;
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
    height: auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 16px;
  }

  .brand {
    margin: 0 10px 0 0;
    flex: 0 0 auto;
  }

  .settings-nav {
    margin: 0 0 0 auto;
    width: 44px;
  }

  .nav-button {
    width: auto;
    margin: 0;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .settings-nav {
    margin: 0 0 0 auto;
    width: 44px;
    height: 44px;
  }

  .settings-nav .icon {
    width: 1.1rem;
    height: 1.1rem;
  }

  .setlist-workspace,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .import-help-panel {
    position: fixed;
    top: 82px;
    left: 16px;
    right: 16px;
    width: auto;
    max-height: calc(100dvh - 104px);
    overflow: auto;
  }

  .stage-header {
    grid-template-columns: 1fr;
  }

  .stage-controls {
    grid-template-columns: 54px 54px 54px;
    grid-template-areas: "click scroll more";
    gap: 6px;
    overflow: visible;
  }

  .stage-tools-open .stage-controls {
    width: min(390px, calc(100vw - 24px));
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "click click transpose font"
      "speed speed scroll scroll";
    gap: 8px;
    padding: 12px;
  }

  .stage-tools-open .click-stack {
    grid-template-rows: 56px 78px;
    min-width: 0;
  }

  .stage-tools-open .click-tempo-control {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: 18px 56px;
    gap: 4px 8px;
  }

  .stage-tools-open .control-stack {
    grid-template-rows: 56px 18px 56px;
  }

  .stage-tools-open .scroll-stack {
    min-height: 58px;
    grid-template-rows: 58px;
  }

  .stage-tools-open #clickToggle,
  .stage-tools-open #scrollToggle {
    min-height: 0;
    font-size: 0.84rem;
    gap: 6px;
  }

  .stage-tools-open #scrollToggle {
    min-height: 58px;
  }

  .stage-tools-open .speed-control {
    height: 58px;
    align-self: stretch;
    align-items: center;
    padding: 0 8px;
  }

  .stage-tools-open .speed-control input {
    position: static;
    width: 100%;
    height: 44px;
    transform: none;
    writing-mode: horizontal-tb;
  }
}

@media (max-width: 680px) {
  .main-shell {
    padding: 16px;
  }

  .view-header,
  .stage-header {
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    grid-template-columns: 1fr;
  }

  #libraryView .segmented-control {
    display: none;
  }

  .song-grid,
  .song-grid.list {
    grid-template-columns: 1fr;
  }

  .song-grid.list .song-card,
  .song-card {
    display: block;
  }

  .song-card .card-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
  }

  .song-card h3 {
    overflow-wrap: anywhere;
  }

  .song-card .meta {
    line-height: 1.35;
  }

  .song-card .inline-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .song-card .inline-actions button {
    width: 100%;
    justify-content: center;
  }

  .stage-chart {
    height: auto;
  }
}

:root[data-theme="light"] .primary-button {
  background: #1e88ff;
  color: #ffffff;
}

:root[data-theme="light"] .secondary-button,
:root[data-theme="light"] .ghost-button,
:root[data-theme="light"] .small-button,
:root[data-theme="light"] .stage-controls button,
:root[data-theme="light"] .import-help summary {
  border: 1px solid #c7d5e0;
  background: #ffffff;
  color: #1f3443;
}

:root[data-theme="light"] .secondary-button:hover,
:root[data-theme="light"] .ghost-button:hover,
:root[data-theme="light"] .small-button:hover,
:root[data-theme="light"] .stage-controls button:hover,
:root[data-theme="light"] .import-help summary:hover {
  background: #eef6ff;
  border-color: #9ec9f8;
}

:root[data-theme="light"] .import-help-panel pre {
  background: #f7fafc;
}

:root[data-theme="light"] .danger-button {
  border: 1px solid #efb8bf;
  background: #fff1f2;
  color: #9f1239;
}

:root[data-theme="light"] .danger-button:hover {
  background: #ffe4e6;
}

:root[data-theme="light"] .tag {
  background: #e8f3ff;
  color: #0b4f9c;
}

:root[data-theme="light"] .segmented-control button {
  background: #ffffff;
  color: #526473;
}

:root[data-theme="light"] .segmented-control button.active {
  background: #1e88ff;
  color: #ffffff;
}

:root[data-theme="light"] .checkbox-control {
  background: #ffffff;
  color: #526473;
}

:root[data-theme="light"] .checkbox-control input:checked {
  box-shadow: inset 0 0 0 3px #ffffff;
}

:root[data-theme="light"] .stage-header {
  background: rgba(255, 255, 255, 0.92);
}

:root[data-theme="light"] .personal-panel {
  background: rgba(255, 255, 255, 0.98);
}

:root[data-theme="light"] .stage-header h1,
:root[data-theme="light"] .stage-header .next-song,
:root[data-theme="light"] #stageMeta {
  color: var(--text);
}

:root[data-theme="light"] .stage-chart {
  color: var(--text);
}

:root[data-theme="light"] .speed-control span,
:root[data-theme="light"] .stage-controls output {
  color: var(--text);
}

:root[data-theme="light"] .stage-controls #previousSongButton,
:root[data-theme="light"] .stage-controls #nextSongButton,
:root[data-theme="light"] .desktop-stage-nav button {
  background: #1e88ff;
  color: #ffffff;
}

:root[data-theme="light"] .click-accent-control {
  border-color: #c7d5e0;
  background: #ffffff;
  color: #1f3443;
}

:root[data-theme="light"] .stage-controls #clickToggle.active {
  background: #0b4f9c;
  color: #ffffff;
}

:root[data-theme="light"] .stage-controls #clickToggle.beat,
:root[data-theme="light"] .stage-controls #clickToggle.accent-beat {
  box-shadow: 0 0 0 4px rgba(30, 136, 255, 0.2);
}

:root[data-theme="light"] .stage-controls #clickToggle.accent-beat {
  background: #1e88ff;
  color: #ffffff;
}

:root[data-theme="light"] #exitStageButton {
  background: #ffffff;
  color: #1f3443;
}

:root[data-theme="light"] .stage-note-button {
  background: #ffffff;
  color: #1f3443;
}

:root[data-theme="light"] .settings-nav {
  border-color: #c7d5e0;
  background: rgba(255, 255, 255, 0.84);
  color: #1f3443;
}

:root[data-theme="light"] .settings-nav:hover,
:root[data-theme="light"] .settings-nav.active {
  border-color: #9ec9f8;
  background: #eef6ff;
  color: #0b4f9c;
}

:root[data-theme="light"] .stage-controls {
  border-color: rgba(120, 143, 157, 0.34);
  background: rgba(255, 255, 255, 0.72);
}

:root[data-theme="light"] .stage-tools-open .stage-controls {
  border-color: rgba(30, 136, 255, 0.28);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 34px rgba(31, 52, 67, 0.16);
}

:root[data-theme="light"] .stage-tools-open .stage-controls button {
  border-color: #c7d5e0;
  background: rgba(255, 255, 255, 0.82);
  color: #1f3443;
}

:root[data-theme="light"] .stage-tools-open .control-stack button,
:root[data-theme="light"] .stage-tools-open .click-tempo-control button,
:root[data-theme="light"] .stage-tools-open #clickToggle,
:root[data-theme="light"] .stage-tools-open #scrollToggle {
  border-color: #c7d5e0;
  background: rgba(255, 255, 255, 0.82);
  color: #1f3443;
}

:root[data-theme="light"] .stage-tools-open .stage-controls button:hover {
  background: #eef6ff;
  border-color: #9ec9f8;
}

:root[data-theme="light"] .stage-tools-open .stage-controls #clickToggle.active {
  background: #1e88ff;
  color: #ffffff;
}

:root[data-theme="light"] .stage-tools-open .click-tempo-control output,
:root[data-theme="light"] .stage-tools-open .control-stack output {
  color: #1e88ff;
}
