/* ============================================================
   DBK Score & Chords — setlists
   ============================================================ */

:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --bg: #ece7dc;
  --glow: rgba(171, 116, 45, 0.14);
  --glow-2: rgba(94, 78, 52, 0.08);
  --surface: rgba(255, 253, 248, 0.7);
  --surface-solid: #fbf8f1;
  --surface-2: rgba(52, 43, 30, 0.045);
  --ink: #211f1a;
  --ink-soft: #4d483e;
  --muted: #7b7365;
  --faint: #9c9385;
  --line: rgba(45, 38, 26, 0.11);
  --line-strong: rgba(45, 38, 26, 0.21);
  --accent: #a5651f;
  --accent-strong: #875016;
  --accent-soft: #f1e1c9;
  --accent-ink: #4b2d0a;
  --paper: #fffdf8;
  --danger: #ae3f2b;
  --header-bg: rgba(242, 237, 227, 0.8);
  --bar-bg: rgba(250, 246, 238, 0.76);
  --brand-fg: #f9f3e7;
  --shadow: 0 28px 70px -26px rgba(55, 42, 20, 0.42), 0 2px 8px rgba(55, 42, 20, 0.07);
  --shadow-soft: 0 12px 34px -20px rgba(55, 42, 20, 0.34);
  --shadow-pop: 0 24px 60px -18px rgba(40, 30, 12, 0.35);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151412;
  --glow: rgba(183, 119, 45, 0.13);
  --glow-2: rgba(90, 72, 46, 0.11);
  --surface: rgba(36, 34, 30, 0.72);
  --surface-solid: #211f1b;
  --surface-2: rgba(255, 248, 235, 0.055);
  --ink: #f1eadd;
  --ink-soft: #cabfae;
  --muted: #9b9181;
  --faint: #756c5c;
  --line: rgba(255, 245, 225, 0.1);
  --line-strong: rgba(255, 245, 225, 0.19);
  --accent: #d79a51;
  --accent-strong: #e8b878;
  --accent-soft: rgba(215, 154, 81, 0.16);
  --accent-ink: #f7e4c6;
  --paper: #fffdf8;
  --danger: #e0836e;
  --header-bg: rgba(22, 21, 18, 0.82);
  --bar-bg: rgba(28, 26, 23, 0.76);
  --brand-fg: #171512;
  --shadow: 0 34px 90px -28px rgba(0, 0, 0, 0.85), 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 16px 40px -22px rgba(0, 0, 0, 0.7);
  --shadow-pop: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

html {
  height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1100px 700px at 88% -12%, var(--glow), transparent 62%),
    radial-gradient(900px 700px at 2% 108%, var(--glow-2), transparent 58%),
    var(--bg);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 180;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
html[data-theme="dark"] body::after { opacity: 0.045; mix-blend-mode: screen; }

button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }

h1, h2, h3, p { margin: 0; }
::selection { background: var(--accent-soft); color: var(--accent-ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

[hidden] { display: none !important; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow {
  display: inline-block;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 17px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--faint);
  font-size: 9px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Frame
   ============================================================ */

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}

.app-header {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  min-height: 60px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(20px) saturate(1.25);
  -webkit-backdrop-filter: blur(20px) saturate(1.25);
}
.header-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  min-width: 0;
}
.viewer-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.viewer-context[hidden] { display: none; }
.app-header.is-viewer .viewer-context {
  display: contents;
}
.app-header.is-viewer .back-btn { order: 1; }
.app-header.is-viewer #songsToggle { order: 2; }
.app-header.is-viewer .header-crumb { order: 3; }
.header-crumb { max-width: 190px; }
.header-crumb .crumb-setlist { font-size: 16px; }
.header-crumb .crumb-song { font-size: 9px; }
.app-header .back-btn {
  width: 100px;
  height: 32px;
  justify-content: center;
  gap: 4px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
}
.app-header .back-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-solid);
  color: var(--ink);
}
.app-header .back-btn span { display: inline; }
.viewer-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.viewer-tools[hidden],
.songs-toggle[hidden],
.ton-group[hidden] { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
  color: var(--ink);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.12));
}
.brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
  line-height: 1.05;
}
.brand-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  white-space: nowrap;
}
.brand-by {
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.015em;
  line-height: 1.1;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Buttons / controls
   ============================================================ */

.icon-btn {
  position: relative;
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  opacity: 0.78;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); opacity: 1; }
.icon-btn:disabled { opacity: 0.3; }
.icon-btn.small { width: 27px; height: 27px; border-radius: 7px; }
.icon-btn.small .icon { width: 15px; height: 15px; }

@media (hover: hover) and (pointer: fine) {
  [data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    z-index: 60;
    padding: 4px 7px;
    border-radius: 5px;
    background: #1f1d18;
    color: #f6f0e5;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-3px);
    transition: opacity 0.12s ease, transform 0.12s ease;
  }
  [data-tip]:hover::after { opacity: 1; transform: none; transition-delay: 0.35s; }
}

/* ============================================================
   Library
   ============================================================ */

.library-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 46px 24px 36px;
}
.library-inner {
  width: min(1080px, 100%);
  margin: 0 auto;
}
.library-head {
  max-width: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.library-load-btn {
  min-width: 104px;
  height: 42px;
  margin-bottom: 3px;
  padding: 0 20px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: var(--accent);
  color: #1d1207;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: filter 0.14s ease, opacity 0.14s ease;
}
.library-load-btn:hover:not(:disabled) { filter: brightness(1.06); }
.library-load-btn:disabled { opacity: 0.34; cursor: default; }
.library-load-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.library-head-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
}
.library-secondary-btn {
  height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.library-secondary-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.library-secondary-btn:disabled { opacity: 0.35; cursor: default; }
.library-secondary-btn.is-danger { color: #d76a5a; }
.selected-setlist-bar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-top: 30px;
  padding: 0 2px 12px;
  border-bottom: 1px solid var(--line);
}
.selected-setlist-name-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.selected-setlist-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.selected-setlist-name {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 600;
  line-height: 1.1;
  outline: none;
}
.selected-setlist-name:focus { box-shadow: 0 1px 0 var(--accent); }
.selected-setlist-count { color: var(--muted); font-size: 11px; white-space: nowrap; }
.library-selection-hint {
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.setlist-songs { margin-top: 22px; }
.setlist-songs-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 300px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.setlist-song-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 5px 7px 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.setlist-song-grip {
  width: 12px;
  height: 18px;
  flex: none;
  color: var(--faint);
  cursor: grab;
  touch-action: none;
}
.setlist-song-item.is-dragging {
  opacity: 0.5;
  z-index: 3;
  box-shadow: var(--shadow-soft);
}
.setlist-song-item.is-dragging .setlist-song-grip { cursor: grabbing; }
.setlist-song-item.drop-before::before,
.setlist-song-item.drop-after::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
}
.setlist-song-item.drop-before::before { top: -2px; }
.setlist-song-item.drop-after::after { bottom: -2px; }
.setlist-songs-list.drop-end { box-shadow: inset 0 -2px 0 var(--accent); }
.setlist-song-remove {
  width: 26px;
  height: 26px;
  flex: none;
  padding: 0;
  border: 1px solid rgba(198, 40, 40, 0.55);
  border-radius: 50%;
  background: rgba(198, 40, 40, 0.16);
  color: #e66a5b;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.setlist-song-remove:hover { background: rgba(198, 40, 40, 0.34); color: #ff8a7a; }
.library-head h1 {
  margin-top: 0;
  font-family: var(--serif);
  font-size: clamp(46px, 5.2vw, 64px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.035em;
}
.setlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 15px;
  margin-top: 32px;
}

.setlist-card {
  position: relative;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 20px 17px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.34), transparent 58%),
    var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28) inset;
  transition: transform 0.2s cubic-bezier(0.2, 0.7, 0.25, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}
html[data-theme="dark"] .setlist-card {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.035), transparent 58%),
    var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
.setlist-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}
.setlist-card:active { transform: translateY(-1px); }
.setlist-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 26%, transparent), var(--shadow-soft);
}

.setlist-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.setlist-folder {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.setlist-folder .icon { width: 14px; height: 14px; }

.setlist-card-title {
  display: block;
  font-family: var(--serif);
  font-size: 31px;
  font-weight: 600;
  line-height: 1.03;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.song-library { margin-top: 42px; }
.library-subhead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.library-subhead-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}
.library-subhead h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.025em;
}
.library-subhead p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
}
.library-search {
  width: min(300px, 42%);
  height: 38px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--faint);
  transition: border-color 0.14s ease;
}
.library-search:focus-within { border-color: var(--accent); color: var(--accent); }
.library-search .icon { width: 15px; height: 15px; flex: none; }
.library-search input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12px;
  outline: none;
}
.library-search input::placeholder { color: var(--faint); }
.song-library-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 460px;
  overflow-y: scroll;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 7px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.song-library-list::-webkit-scrollbar { width: 9px; }
.song-library-list::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--line) 50%, transparent);
  border-radius: 9px;
}
.song-library-list::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 2px solid transparent;
  border-radius: 9px;
  background-clip: padding-box;
}
.song-library-list::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }
.library-song-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 5px 7px 5px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.library-song-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.library-song-title {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-song-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-song-add {
  width: 28px;
  height: 28px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--ink-soft);
  cursor: pointer;
}
.library-song-add .icon { width: 15px; height: 15px; }
.library-song-add:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.library-song-add:disabled { opacity: 0.42; cursor: default; }
.library-song-add.is-added {
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
  background: var(--accent-soft);
  color: var(--accent-ink);
  opacity: 1;
}
.song-library-empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
}

.setlist-preview {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}
.setlist-preview-line {
  display: flex;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.setlist-preview-line .num {
  width: 17px;
  flex: none;
  color: var(--faint);
  font-size: 8.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.setlist-preview-line .name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.setlist-preview-empty { color: var(--faint); font-style: italic; }

.library-empty {
  margin-top: 32px;
  padding: 42px 24px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  text-align: center;
}
.library-empty .empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-solid);
  color: var(--accent);
  box-shadow: var(--shadow-soft);
}
.library-empty h2,
.viewer-empty h2 {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.library-empty p,
.viewer-empty p {
  max-width: 440px;
  margin: 7px auto 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.library-empty strong { color: var(--ink-soft); font-weight: 600; }

/* ============================================================
   Setlist page
   ============================================================ */

.setlist-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.control-bar {
  position: relative;
  z-index: 15;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 18px;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  background: var(--bar-bg);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
}
.control-left {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1 1 auto;
  min-width: 0;
}
.control-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px 10px;
  flex: 0 1 auto;
  min-width: 0;
}

.back-btn {
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 0 8px 0 5px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.back-btn .icon { width: 16px; height: 16px; }
.back-btn:hover { background: var(--surface-2); color: var(--ink); }

.crumb {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  max-width: 310px;
}
.crumb-setlist {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.crumb-song {
  overflow: hidden;
  color: var(--accent);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.crumb-song:empty { display: none; }

.songs-toggle {
  width: 100px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.songs-toggle .icon { width: 15px; height: 15px; }
.songs-toggle:hover { color: var(--ink); border-color: var(--line-strong); }
.songs-toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent-ink);
}
.songs-toggle[aria-pressed="true"] .icon { color: var(--accent); }
.songs-toggle .count-pill { background: rgba(255, 255, 255, 0.45); color: inherit; }
html[data-theme="dark"] .songs-toggle .count-pill { background: rgba(0, 0, 0, 0.16); }

/* Kıta + Ton */

.kita-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.kita-input {
  width: 31px;
  height: 28px;
  padding: 0 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-solid);
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.kita-input:hover { border-color: var(--line-strong); }
.kita-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 16%, transparent); }
.kita-input:disabled { opacity: 0.4; cursor: default; }

.ton-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.control-label {
  display: block;
  color: var(--faint);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1;
  text-transform: uppercase;
}
.ton-group > .control-label { padding: 0 2px; }

.select-wrap { position: relative; display: inline-flex; min-width: 0; }
.select-wrap select {
  height: 28px;
  width: 72px;
  padding: 0 20px 0 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-solid);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}
.select-wrap.narrow select { width: 50px; text-align: center; padding: 0 16px 0 4px; font-size: 14px; }
.select-wrap select:hover { border-color: var(--line-strong); }
.select-wrap select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.select-wrap select:disabled { opacity: 0.45; cursor: default; }
.select-arrow {
  position: absolute;
  right: 5px;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translateY(-50%) rotate(90deg);
  color: var(--faint);
  stroke-width: 2;
  pointer-events: none;
}

.ton-busy {
  width: 11px;
  height: 11px;
  margin: 0 1px;
  flex: none;
  border: 1.5px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* BPM + time */

.meter-group {
  display: flex;
  align-items: center;
  gap: 1px;
  flex: none;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.bpm-chip,
.time-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 9px;
  border-radius: 8px;
}
.bpm-chip { position: relative; }
.bpm-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.bpm-input {
  display: block;
  width: 43px;
  height: 19px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.bpm-input:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.bpm-input:focus {
  background: var(--surface-solid);
  box-shadow: 0 0 0 1px var(--accent);
}
.bpm-input::placeholder { color: var(--faint); }
.bpm-input:disabled { cursor: default; }
.time-chip strong {
  display: block;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.bpm-beats {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 16px;
  flex: none;
}
.bpm-beats.many { gap: 2px; }
.bpm-beat {
  position: relative;
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.28;
  transform: scale(1);
}
.bpm-beat.downbeat { width: 8px; height: 8px; }
.bpm-beat::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  opacity: 0;
}
.bpm-chip.is-pulsing .bpm-beat {
  animation: beat-dot var(--bar-duration, 0.6s) cubic-bezier(0.15, 0.7, 0.3, 1) infinite;
  animation-delay: calc(var(--beat-duration, 0.6s) * var(--beat-index, 0));
}
.bpm-chip.is-pulsing .bpm-beat::after {
  animation: beat-ring var(--bar-duration, 0.6s) cubic-bezier(0.15, 0.7, 0.3, 1) infinite;
  animation-delay: calc(var(--beat-duration, 0.6s) * var(--beat-index, 0));
}
.bpm-beats.many .bpm-beat { width: 5px; height: 5px; }
.bpm-beats.many .bpm-beat.downbeat { width: 7px; height: 7px; }
.bpm-beats.many .bpm-beat::after { inset: -2px; border-width: 1px; }
.bpm-chip.is-pulsing .bpm-input {
  transform-origin: left center;
  animation: bpm-number var(--beat-duration, 0.6s) cubic-bezier(0.15, 0.7, 0.3, 1) infinite;
}
@keyframes beat-dot {
  0% { transform: scale(1.55); opacity: 1; }
  9% { transform: scale(1.65); opacity: 1; }
  24%, 100% { transform: scale(1); opacity: 0.28; }
}
@keyframes beat-ring {
  0% { transform: scale(0.45); opacity: 0.9; }
  13% { transform: scale(2.6); opacity: 0; }
  100% { transform: scale(2.6); opacity: 0; }
}
@keyframes bpm-number {
  0%, 100% { transform: scale(1); color: var(--ink); }
  14% { transform: scale(1.16); color: var(--accent); }
  42% { transform: scale(1); color: var(--ink); }
}
.bpm-chip.is-empty .bpm-beat { background: var(--faint); opacity: 0.22; animation: none; }
.bpm-chip.is-empty .bpm-beat::after { display: none; }
.bpm-chip.is-empty .bpm-input { animation: none; }

.beat-pulse {
  width: 106px;
  height: 40px;
  flex: none;
  border: 2px solid #39ff14;
  border-radius: 11px;
  background: #000000;
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.32);
}
.beat-pulse.is-pulsing {
  animation: beat-blink var(--beat-duration, 0.6s) linear infinite;
}
.beat-pulse.is-empty { border-color: #444444; opacity: 0.35; box-shadow: none; }
@keyframes beat-blink {
  0%, 16% { background-color: #39ff14; box-shadow: 0 0 18px rgba(57, 255, 20, 0.8); }
  20%, 100% { background-color: #000000; box-shadow: 0 0 8px rgba(57, 255, 20, 0.22); }
}

.zoom-group {
  display: flex;
  align-items: center;
  gap: 1px;
  flex: none;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
}
.zoom-value {
  min-width: 42px;
  height: 27px;
  padding: 0 3px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.zoom-value:hover { background: var(--surface-solid); color: var(--ink); }

.chord-size-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 4px 7px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
}
.tool-btn {
  height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.tool-btn:hover:not(:disabled) { background: var(--surface-solid); color: var(--ink); }
.tool-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 38%, transparent);
}
.tool-btn:disabled { opacity: 0.35; cursor: default; }
.chord-size-wrap select {
  width: 62px;
  height: 28px;
  padding: 0 19px 0 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-solid);
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}
.chord-size-wrap select:hover { border-color: var(--line-strong); }
.chord-size-wrap select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chord-size-wrap select:disabled { opacity: 0.45; cursor: default; }

/* ============================================================
   Songs + viewer
   ============================================================ */

.edit-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 13px;
  min-height: 39px;
  padding: 6px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.edit-toolbar[hidden] { display: none; }
.edit-toolbar-holder[hidden] { display: none; }
.edit-toolbar.is-busy { opacity: 0.7; }
.edit-transpose-row {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}
.transpose-select {
  height: 27px;
  max-width: 104px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-solid);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 11px;
  outline: none;
}
.transpose-select.narrow { width: 46px; }
#transposeAccidental[hidden] { display: none; }
.accidental-icons {
  display: flex;
  align-items: center;
  gap: 2px;
}
.accidental-icon {
  width: 29px;
  height: 27px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-solid);
  color: var(--ink-soft);
  font-family: "Times New Roman", serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  cursor: pointer;
}
.accidental-icon:hover { border-color: var(--line-strong); color: var(--ink); }
.accidental-icon.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.accidental-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.transpose-step-btn {
  min-width: 28px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
}
.transpose-select:focus { border-color: var(--accent); }
.transpose-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  white-space: nowrap;
  cursor: pointer;
}
.transpose-check input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.paper > .edit-toolbar {
  margin: 0 calc(-1 * var(--paper-pad)) clamp(10px, 1.4vw, 16px);
  padding: 7px clamp(14px, 2vw, 24px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.song-section.is-editing .score-heading { margin-bottom: 0; }
.songs-view.is-focused-edit .song-section:not(.is-editing) { display: none; }
.songs-view.is-focused-edit .song-section.is-editing .score-heading {
  position: sticky;
  top: 0;
  z-index: 30;
}
.songs-view.is-focused-edit .song-section.is-editing .paper > .edit-toolbar {
  position: sticky;
  top: var(--editing-heading-height, 60px);
  z-index: 29;
}
.edit-tools-group {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: none;
  min-width: 0;
}
.edit-tools-label {
  margin-right: 2px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}
.edit-tool-btn {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-solid);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.14s ease, color 0.14s ease, opacity 0.14s ease;
}
.edit-tool-btn:hover:not(:disabled) { border-color: var(--line-strong); color: var(--ink); }
.edit-tool-btn:disabled { opacity: 0.34; cursor: default; }
.edit-tool-btn.narrow { min-width: 27px; padding: 0 6px; }
.edit-tool-btn.undo-btn { flex: none; margin-left: 2px; }
.measure-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.measure-status.has-selection { color: var(--accent-ink); }
.song-section.is-editing .vf-measure { cursor: pointer; }
.measure-hit { pointer-events: none; }
.song-section.is-editing .measure-hit { pointer-events: all; cursor: pointer; }
.measure-selection {
  fill: #c46a2e;
  fill-opacity: 0.16;
  stroke: #c46a2e;
  stroke-opacity: 0.8;
  stroke-width: 1;
  pointer-events: none;
}

.setlist-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.song-panel {
  position: relative;
  z-index: 8;
  flex: 0 0 25%;
  width: 25%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: flex-basis 0.26s cubic-bezier(0.2, 0.7, 0.25, 1), width 0.26s cubic-bezier(0.2, 0.7, 0.25, 1), border-color 0.26s ease;
}
.setlist-view.songs-closed .song-panel {
  flex-basis: 0;
  width: 0;
  border-right-color: transparent;
}
.song-panel-head,
.song-list { width: 100%; min-width: 210px; flex: none; }
.song-panel-head {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}
.song-head-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.edit-btn {
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.edit-btn:hover:not(:disabled) { border-color: var(--line-strong); color: var(--ink); }
.edit-btn[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.edit-btn:disabled { opacity: 0.35; cursor: default; }

.edit-hint {
  flex: none;
  padding: 7px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.4;
}
html[data-theme="dark"] .edit-hint { background: color-mix(in srgb, var(--accent) 9%, transparent); }

.song-list {
  flex: 1 1 auto !important;
  min-height: 0;
  overflow-y: auto;
  padding: 7px;
}

.song-item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 10px 10px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}
.song-item + .song-item { margin-top: 2px; }
.song-item:hover { background: var(--surface-2); }
.song-item.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: inset 2px 0 0 var(--accent);
}
.drag-grip {
  width: 13px;
  height: 20px;
  flex: none;
  display: none;
  align-self: center;
  color: var(--faint);
  pointer-events: none;
}
.is-editing .drag-grip {
  display: block;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}
.is-editing .song-item {
  touch-action: pan-y;
}
.song-item.is-touch-dragging {
  z-index: 4;
  opacity: 0.72;
  box-shadow: var(--shadow-soft);
}
.song-item.is-touch-dragging .drag-grip { cursor: grabbing; }
.song-item.is-active .drag-grip { color: var(--accent); }
.is-editing .song-item { cursor: grab; user-select: none; }
.is-editing .song-item:active { cursor: grabbing; }
.song-item.dragging { opacity: 0.4; }
.song-skip-btn {
  width: 30px;
  height: 30px;
  flex: none;
  display: none;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}
.is-editing .song-skip-btn { display: inline-flex; }
.song-skip-btn:hover { border-color: #c62828; color: #ff6b6b; }
.song-skip-btn[aria-pressed="true"] {
  border-color: #c62828;
  background: rgba(198, 40, 40, 0.18);
  color: #ff6b6b;
}
.song-item.is-skipped .song-main { opacity: 0.4; }
.song-item.is-skipped .song-title {
  color: var(--faint);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
.song-item.is-skipped .song-meta { opacity: 0.7; }
.song-section.is-skipped .paper {
  opacity: 0.38;
  filter: grayscale(1);
  transition: opacity 0.18s ease, filter 0.18s ease;
}
.song-item.drop-before::before,
.song-item.drop-after::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
}
.song-item.drop-before::before { top: -2px; }
.song-item.drop-after::after { bottom: -2px; }
.song-list.drop-end { box-shadow: inset 0 -2px 0 var(--accent); }

.song-index {
  width: 17px;
  flex: none;
  padding-top: 3px;
  color: var(--faint);
  font-size: 8.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.song-item.is-active .song-index { color: var(--accent); }
.song-main { min-width: 0; flex: 1; }
.song-title {
  display: block;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.012em;
  overflow-wrap: anywhere;
}
.song-item.is-active .song-title { color: var(--accent-ink); }
.song-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.song-meta span { white-space: nowrap; }
.song-meta span + span::before { content: "·"; margin-right: 6px; color: var(--faint); }

.song-panel-empty {
  padding: 20px 14px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.viewer {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.viewer-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 22px clamp(12px, 2.4vw, 34px) 46px;
  overscroll-behavior: contain;
}
.songs-view {
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 3vw, 38px);
}
.song-section {
  position: relative;
  width: 100%;
}
.paper {
  --paper-pad: clamp(10px, 1.8vw, 26px);
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--paper-pad);
  border-radius: 2px;
  background: var(--paper);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}
.score-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin: calc(-1 * var(--paper-pad)) calc(-1 * var(--paper-pad)) clamp(12px, 1.8vw, 22px);
  padding: clamp(12px, 1.6vw, 18px) clamp(14px, 2vw, 24px);
  background: #eb7b1e;
  border-radius: 2px 2px 0 0;
  color: #211206;
}
.score-heading-title {
  flex: 1 1 220px;
  min-width: 0;
  font-family: var(--serif);
  font-size: clamp(20px, 2.2vw, 29px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.score-heading-right {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(10px, 1.6vw, 20px);
}
.score-heading-meta {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(12px, 1.8vw, 26px);
}
.score-actions { display: flex; align-items: center; gap: 5px; }
.score-action {
  height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(33, 18, 6, 0.3);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
  color: #211206;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
}
.score-action:hover { background: rgba(255, 255, 255, 0.32); }
.score-action:focus-visible { outline: 2px solid rgba(33, 18, 6, 0.55); outline-offset: 1px; }
.score-action.is-active { border-color: #211206; background: #211206; color: #ffb36a; }
.score-action:disabled { opacity: 0.38; cursor: default; }
.score-kita-input,
.score-bpm-input {
  height: 25px;
  padding: 0 4px;
  border: 1px solid rgba(33, 18, 6, 0.28);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
  color: #211206;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.score-kita-input { width: 34px; }
.score-bpm-input { width: 46px; }
.score-kita-input::placeholder,
.score-bpm-input::placeholder { color: rgba(33, 18, 6, 0.55); }
.score-kita-input:focus,
.score-bpm-input:focus {
  outline: 2px solid rgba(33, 18, 6, 0.38);
  outline-offset: 1px;
}
.score-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.score-meta-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  line-height: 1.2;
  text-transform: uppercase;
  opacity: 0.66;
}
.score-meta-label.tone-label {
  text-transform: none;
  letter-spacing: 0.06em;
}
.score-meta-value {
  font-family: var(--sans);
  font-size: clamp(13px, 1.35vw, 16px);
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.song-section.is-active .paper {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), var(--shadow);
}
.score { width: 100%; min-height: 160px; }
.score svg { display: block; max-width: 100%; }
.song-error {
  padding: 40px 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  text-align: center;
}
.song-error strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
}
.repeat-highlight {
  filter: drop-shadow(0 0 3px rgba(234, 255, 0, 0.8));
}
.song-section.is-editing .section-label-bg {
  pointer-events: all;
  cursor: grab;
}
.song-section.is-editing .section-label-bg:active { cursor: grabbing; }
.song-section.is-editing .section-label-text {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.song-section.is-editing .section-label-text:active { cursor: grabbing; }
.section-label-text.is-dragging-section { opacity: 0.68; }
.section-label-bg.is-dragging-section { opacity: 0.55; }
.section-editor {
  position: fixed;
  z-index: 1200;
  height: 27px;
  padding: 0 7px;
  border: 1.5px solid #b3261e;
  border-radius: 5px;
  background: #fffdf8;
  color: #14110c;
  font-family: "Times New Roman", serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  outline: none;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.24);
  caret-color: #b3261e;
}
.editable-text {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.editable-text:active { cursor: grabbing; }
.editable-text.is-dragging-text { opacity: 0.68; }
.text-editor {
  position: fixed;
  z-index: 1200;
  height: 27px;
  padding: 0 7px;
  border: 1.5px solid var(--accent);
  border-radius: 5px;
  background: #fffdf8;
  color: #14110c;
  font-family: "Times New Roman", serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1;
  outline: none;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.24);
  caret-color: #b3261e;
}
.osmd-chord-symbol text { font-weight: 700 !important; }
.editable-chord {
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.editable-chord:active { cursor: ew-resize; }
.editable-chord text { cursor: inherit; }
.editable-chord.is-dragging-chord { opacity: 0.65; }
.editable-chord:hover text { fill: #b3261e; }
.editable-chord.is-editing-chord text { fill: #b3261e; }
.chord-editor {
  position: fixed;
  z-index: 1200;
  height: 27px;
  padding: 0 7px;
  border: 1.5px solid var(--accent);
  border-radius: 5px;
  background: #fffdf8;
  color: #14110c;
  font-family: "Times New Roman", serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  outline: none;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.24);
  caret-color: #b3261e;
}

.viewer-empty {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}
.viewer-empty .empty-icon {
  width: 46px;
  height: 46px;
  margin-bottom: 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--accent);
}

.viewer-loading {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 210px;
  max-width: 300px;
  padding: 23px 28px 21px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-pop);
  text-align: center;
}
.spinner {
  width: 24px;
  height: 24px;
  margin-bottom: 3px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}
.loading-title { font-size: 12.5px; font-weight: 600; }
.loading-detail {
  max-width: 240px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.loading-detail:empty { display: none; }

.scrim {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(18, 15, 10, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ============================================================
   Toast / no-JS
   ============================================================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  max-width: min(92vw, 540px);
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: #1f1d18;
  color: #f5efe4;
  box-shadow: 0 18px 50px -16px rgba(0, 0, 0, 0.6);
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .icon { width: 16px; height: 16px; margin-top: 1px; flex: none; color: #efb083; }
.toast[data-tone="success"] .icon { color: #9ecb9c; }

.noscript {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 32px;
  background: var(--bg);
  color: var(--ink);
  text-align: center;
}
.noscript strong { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.noscript span { max-width: 420px; color: var(--muted); font-size: 13px; }

/* ============================================================
   Rename dialog
   ============================================================ */

.rename-dialog {
  width: min(410px, 92vw);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
.rename-dialog::backdrop {
  background: rgba(12, 10, 7, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.rename-dialog[open] { animation: dialog-in 0.18s ease both; }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(5px) scale(0.995); }
  to { opacity: 1; transform: none; }
}
.rename-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 22px 22px 18px;
}
.rename-form h2 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.rename-label {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.rename-input {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  outline: none;
}
.rename-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
}
.rename-hint {
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.rename-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 5px;
}
.dialog-btn {
  height: 33px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.dialog-btn:hover { background: var(--surface-2); }
.dialog-btn.danger {
  border-color: rgba(198, 40, 40, 0.6);
  background: rgba(198, 40, 40, 0.2);
  color: #ff8a7a;
}
.dialog-btn.danger:hover { background: rgba(198, 40, 40, 0.35); }
.dialog-btn.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}
html[data-theme="dark"] .dialog-btn.danger {
  border-color: rgba(198, 40, 40, 0.6);
  background: rgba(198, 40, 40, 0.2);
  color: #ff8a7a;
}
.dialog-btn.danger:hover { background: rgba(198, 40, 40, 0.35); }
.dialog-btn.primary { color: #191713; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1220px) {
  .control-bar { align-items: center; flex-wrap: wrap; gap: 8px 14px; }
  .control-left { flex: 1 1 auto; }
  .control-right { flex: 0 0 auto; justify-content: flex-end; flex-wrap: nowrap; }
  .crumb { max-width: none; flex: 1; }
}

@media (max-width: 900px) {
  .song-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 25;
    width: min(320px, 86vw);
    flex: none;
    transform: translateX(0);
    box-shadow: var(--shadow-pop);
    transition: transform 0.26s cubic-bezier(0.2, 0.7, 0.25, 1);
  }
  .setlist-view.songs-closed .song-panel {
    width: min(320px, 86vw);
    transform: translateX(-102%);
    border-right-color: var(--line);
  }
  .song-panel-head,
  .song-list { width: 100%; }
  .setlist-view:not(.songs-closed) .scrim { display: block; }
}

@media (max-width: 720px) {
  .app-header { flex-basis: auto; padding: 8px 12px; row-gap: 8px; }
  .app-header.is-viewer .header-left { flex: 1 1 100%; }
  .app-header.is-viewer .header-actions { flex: 1 1 100%; justify-content: flex-end; }
  .app-header.is-viewer .viewer-tools { flex: 1 1 auto; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-name { font-size: 17px; }
  .brand-by { font-size: 8.5px; }
  .library-view { padding: 30px 16px 28px; }
  .library-head h1 { font-size: 44px; }
  .library-load-btn { height: 38px; min-width: 88px; padding: 0 14px; font-size: 12px; }
  .library-head-actions { flex-wrap: wrap; }
  .library-secondary-btn { height: 38px; padding: 0 11px; font-size: 11px; }
  .selected-setlist-bar { flex-direction: column; align-items: stretch; gap: 6px; }
  .selected-setlist-count { text-align: right; }
  .library-subhead { align-items: stretch; flex-direction: column; gap: 9px; }
  .library-search { width: 100%; }
  .library-song-title { white-space: normal; }
  .setlist-grid { grid-template-columns: 1fr; margin-top: 24px; }
  .setlist-card { min-height: 200px; padding: 18px; }
  .setlist-card-title { font-size: 28px; }
  .control-bar { padding: 8px 12px; }
  .control-left { gap: 9px; }
  .crumb-setlist { font-size: 18px; }
  .songs-toggle { padding: 0 7px; }
  .back-btn span { display: none; }
  .app-header .back-btn { padding: 0 6px; width: 30px; justify-content: center; }
  .viewer-scroll { padding: 14px 10px 34px; }
  .paper { --paper-pad: 10px; padding: 10px; }
  .score-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
  .score-heading-title { flex: 0 0 auto; width: 100%; }
  .score-heading-right { width: 100%; justify-content: flex-start; }
  .score-heading-meta { justify-content: flex-start; }
  .score-actions { margin-left: auto; }
}

@media (max-width: 900px) {
  .edit-toolbar { gap: 6px 9px; padding: 6px 12px; }
  .measure-status { flex: 1 1 100%; margin-left: 0; order: 8; }
  .edit-tool-btn.undo-btn { order: 9; margin-left: auto; }
}

@media (max-width: 540px) {
  .header-crumb { max-width: 120px; }
  .header-crumb .crumb-song { display: none; }
  .control-right { gap: 6px; }
  .edit-toolbar { padding: 6px 9px; gap: 5px 7px; }
  .edit-tools-group { gap: 2px; }
  .edit-tool-btn { height: 26px; padding: 0 6px; font-size: 10.5px; }
  .edit-tool-btn.narrow { min-width: 21px; padding: 0 4px; }
  .kita-group { padding: 4px 6px; gap: 5px; }
  .ton-group { width: auto; flex: 1 1 auto; justify-content: flex-start; }
  .select-wrap { flex: 0 0 auto; }
  .select-wrap select { width: 72px; }
  .select-wrap.narrow { flex: 0 0 50px; }
  .select-wrap.narrow select { width: 50px; }
  .meter-group { flex: 0 0 auto; }
  .zoom-group { margin-left: 0; }
  .chord-size-group { padding: 4px 6px; }
  .chord-size-wrap select { width: 58px; }
  .tool-btn { padding: 0 8px; }
  .library-head h1 { font-size: 40px; }
  .setlist-card-title { font-size: 26px; }
}

@media (max-width: 380px) {
  .app-header { padding: 0 10px; }
  .control-right { gap: 4px; }
  .chord-size-group { padding: 4px; }
  .chord-size-wrap select { width: 50px; }
  .brand-name { font-size: 16px; }
  .brand-by { font-size: 8px; }
  .control-bar { padding: 7px 9px; }
  .ton-group { padding: 4px 6px; gap: 4px; }
  .meter-group { padding: 1px; }
  .bpm-chip, .time-chip { padding: 0 7px; gap: 5px; }
  .bpm-input { font-size: 14px; width: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Setlists as a compact selectable list */
.setlist-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 320px;
  overflow-y: auto;
  margin-top: 24px;
  padding-right: 5px;
  scrollbar-gutter: stable;
}
.setlist-card {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  padding: 11px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  transform: none !important;
  box-shadow: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
html[data-theme="dark"] .setlist-card { background: var(--surface-2); }
.setlist-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-solid);
  box-shadow: none;
}
.setlist-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}
.setlist-card-top {
  grid-column: 1 / 3;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.setlist-folder { font-size: 8.5px; }
.setlist-folder .icon { width: 12px; height: 12px; }
.setlist-card-title {
  grid-column: 1 / 3;
  grid-row: 2;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-wrap: nowrap;
}
.setlist-preview { display: none; }
.setlist-card .count-pill { font-size: 9px; }
@media (max-width: 720px) {
  .setlist-grid { max-height: none; }
  .setlist-card { min-height: 0; padding: 11px 12px 12px; }
  .setlist-card-title { font-size: 18px; }
}
