/* THEME TOKENS — change these first to restyle the whole application. */
:root {
  color-scheme: dark;
  --bg: #202831; --surface: #293440; --card: #33414f; --border: #445361;
  --text: #eef2f5; --muted: #a7b4c0; --accent: #8ab8db; --accent-bg: #304c63;
  --gold: #e9bd59; --red: #ec777d; --green: #79b794; --rank-muted: #84909b;
  --danger: #ffadb0; --radius: 8px; --gap: 16px; --row-height: 44px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
/* BASE / ACCESSIBILITY */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.login-panel { max-width: 420px; margin: 6vh auto; }
.login-panel label { display: block; margin: 18px 0; }
.login-panel input { display: block; width: 100%; margin-top: 6px; }
.account { display: flex; gap: 12px; align-items: center; margin-left: auto; }
#login-error { color: var(--danger); }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
button, input, select, textarea { font: inherit; }
button, input, select, textarea { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 10px 12px; }
button, a, summary { cursor: pointer; }
button:hover, a:hover { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .5; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 30px; margin-bottom: 5px; letter-spacing: -.7px; }
h2 { font-size: 19px; } h3 { font-size: 16px; }
.muted, .eyebrow, small { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: 2px; font-size: 11px; margin-bottom: 8px; }
.primary { background: var(--accent-bg); border-color: var(--accent); }
.danger { color: var(--danger); }
.empty { color: var(--muted); padding: 20px 12px; }
/* APPLICATION CHROME / PAGE HEADINGS */
.app-header { display: flex; align-items: center; gap: 36px; padding: 18px 28px; border-bottom: 1px solid var(--border); }
.brand { font-size: 24px; font-weight: 750; letter-spacing: -1px; }
.brand span { font-size: 12px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
nav { display: flex; gap: 24px; } .mode { margin-left: auto; color: var(--muted); font-size: 12px; }
main { padding: 28px; max-width: 1800px; margin: auto; }
.section-heading, .actions, .toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-heading { justify-content: space-between; margin-bottom: 20px; }
.section-heading h2 { margin: 0; }
.toolbar { margin: 20px 0; } .toolbar input[type=search] { flex: 1; min-width: 190px; }
.toolbar label { display: flex; align-items: center; gap: 7px; }
#message { position: sticky; top: 0; z-index: 5; padding: 14px 28px; background: #633b40; color: white; }
/* DASHBOARD / SONG LIBRARY */
.gig-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); gap: var(--gap); margin-bottom: 30px; }
.gig-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.gig-card h3 { margin: 10px 0; font-size: 20px; } .gig-card footer { display: flex; justify-content: space-between; color: var(--muted); margin-top: 18px; font-size: 12px; }
.library { max-width: 900px; } .library .song-row { margin-bottom: 5px; }
/* BOARD — shared compact rows, rank dots and selected destination. */
.board { display: grid; grid-template-columns: minmax(0,1fr); gap: var(--gap); align-items: start; }
.board.has-library { grid-template-columns: 280px minmax(0,1fr); }
.board-main { min-width: 0; container: board-main / inline-size; }
.board-work, .board-sets { display: grid; gap: var(--gap); align-items: start; min-width: 0; }
.board-sets { grid-template-columns: repeat(auto-fit,minmax(min(100%,280px),1fr)); }
/* Keep overflow sets in their own area, never beneath Library. */
@container board-main (min-width: 576px) {
  .board-work.has-pool { grid-template-columns: 280px minmax(0,1fr); }
}
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-width: 0; }
.list.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.list-header { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.list-title { flex: 1; text-align: left; font-weight: 650; border-color: transparent; padding-left: 5px; }
.list-title small { margin-left: 8px; font-weight: 400; }
.icon { padding: 8px; min-width: 36px; min-height: 40px; background: transparent; }
.song-row { display: flex; align-items: center; gap: 7px; min-height: var(--row-height); background: var(--card); border-radius: 5px; padding: 3px 7px; margin: 4px 0; }
.song-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; border: 0; background: transparent; padding: 8px 0; }
.song-transfer { flex: 0 0 40px; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 24px; }
.rank { width: 12px; height: 12px; flex: 0 0 12px; margin-left: auto; border-radius: 50%; background: var(--rank-muted); }
.rank-1 { background: var(--gold); } .rank-2 { background: var(--red); } .rank-3 { background: var(--green); }
.played-control { display: grid; place-items: center; flex: 0 0 40px; min-height: 44px; cursor: pointer; }
.played-check { appearance: none; width: 21px; height: 21px; padding: 0; margin: 0; border: 2px solid var(--muted); border-radius: 50%; background: transparent; cursor: pointer; }
.played-check:checked { background: var(--green); border-color: var(--green); box-shadow: inset 0 0 0 3px var(--card); }
#board .song-row { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.song-row.moving { outline: 2px solid var(--accent); background: var(--accent-bg); touch-action: none; cursor: grab; }
.song-row.moving .song-title { cursor: grab; touch-action: none; }
.list.drop-target { outline: 2px dashed var(--accent); }
.song-row.drop-before { box-shadow: 0 -3px var(--accent); }
.list-hint { font-size: 12px; color: var(--muted); padding: 0 5px; }
/* FORMS / DIALOGS — explicit Save and Cancel. */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); width: min(520px,calc(100% - 24px)); max-height: 90dvh; padding: 24px; }
dialog::backdrop { background: rgb(0 0 0 / .6); }
.song-dialog { width: min(900px,calc(100% - 24px)); height: 92dvh; max-height: 92dvh; padding: 0; overflow: hidden; }
.song-dialog[open] { display: flex; flex-direction: column; }
.song-view-header { flex: 0 0 auto; padding: 16px 20px 0; border-bottom: 1px solid var(--border); }
.song-view-header .section-heading { flex-wrap: nowrap; margin-bottom: 12px; }
.song-view-header h2 { overflow-wrap: anywhere; }
.song-view-header [role=tablist] { display: flex; gap: 8px; padding-bottom: 10px; }
.song-view-header [aria-selected=true] { background: var(--accent-bg); border-color: var(--accent); }
.song-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px; -webkit-overflow-scrolling: touch; }
.song-scroll section { margin-bottom: 28px; }
.song-text { white-space: pre-wrap; overflow-wrap: anywhere; font: 18px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; margin: 0 0 24px; tab-size: 4; }
.song-notes { color: var(--muted); }
#lyrics-input { display: block; width: 100%; min-height: 50dvh; margin: 10px 0 16px; font: 16px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; resize: vertical; tab-size: 4; }
.song-fields label { display: block; margin: 12px 0; }
.song-fields input:not([type=checkbox]), .song-fields textarea, .song-fields select { display: block; width: 100%; margin-top: 5px; }
.song-fields textarea { min-height: 140px; }
.song-error { color: var(--danger); }
body:has(.song-dialog[open]) { overflow: hidden; }
#fields label { display: block; margin: 12px 0; color: var(--muted); }
#fields input:not([type=checkbox]), #fields textarea, #fields select { width: 100%; display: block; margin-top: 5px; }
#fields textarea { min-height: 110px; resize: vertical; } dialog .actions { justify-content: flex-end; margin-top: 22px; }
/* RESPONSIVE — full-width stacked lists on iPhone; multiple columns above. */
@media (max-width: 600px) {
  .app-header { flex-wrap: wrap; }
  .account { width: 100%; justify-content: space-between; }
  .song-dialog { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .song-view-header { padding: max(12px,env(safe-area-inset-top)) 16px 0; }
  .song-scroll { padding: 20px 16px max(24px,env(safe-area-inset-bottom)); }
  .app-header { padding: 12px 16px; gap: 24px; } .brand span, .mode { display: none; }
  nav { margin-left: auto; } main { padding: 20px 12px; } h1 { font-size: 26px; }
  .board, .board.has-library { grid-template-columns: minmax(0,1fr); } .toolbar { gap: 10px; } .toolbar input[type=search] { width: 100%; flex-basis: 100%; }
  .section-heading { align-items: flex-start; } .song-row { min-height: 48px; }
}
/* Compact account menu and responsive gig controls. */
.account { min-width: 0; }
.account details { position: relative; min-width: 0; }
.account summary { padding: 10px 8px; min-height: 44px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account summary::after { content: ' \25BE'; }
.account summary { list-style: none; }
.account summary::-webkit-details-marker { display: none; }
.account-panel { position: absolute; right: 0; top: 100%; z-index: 20; width: 240px; max-width: calc(100vw - 24px); padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px #0006; }
.account-panel span { display: block; overflow-wrap: anywhere; margin-bottom: 10px; }
.account-panel button { width: 100%; }
.gig-menu-toggle { display: none; }
#gig-controls { display: contents; }
#gig-controls .toolbar { width: 100%; margin: 0; }
@media (max-width: 600px) {
  .app-header { flex-wrap: nowrap; gap: 12px; padding: 6px 12px; }
  .brand { font-size: 22px; flex-shrink: 0; }
  .app-header nav { margin-left: 0; gap: 12px; flex-shrink: 0; }
  .app-header nav a { display: flex; align-items: center; min-height: 44px; }
  .account { width: auto; margin-left: auto; flex: 0 1 auto; }
  .account summary { max-width: 140px; }
  main:has(.gig-heading) { padding-top: 12px; }
  .gig-heading { position: relative; flex-wrap: nowrap; align-items: center; gap: 8px; margin-bottom: 10px; }
  .gig-title { min-width: 0; flex: 1; }
  .gig-title h1 { font-size: 23px; overflow-wrap: anywhere; margin-bottom: 0; }
  .gig-title .eyebrow { font-size: 10px; letter-spacing: 1px; margin-bottom: 2px; }
  .gig-details { display: block; font-size: 12px; }
  .gig-details:empty { display: none; }
  .gig-menu-toggle { display: block; flex: 0 0 44px; height: 44px; padding: 0; font-size: 26px; }
  #gig-controls { display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 10; width: min(340px, calc(100vw - 24px)); max-height: 65dvh; overflow-y: auto; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px #0006; }
  .gig-menu-toggle[aria-expanded=true] + #gig-controls { display: block; }
  #gig-controls .actions, #gig-controls .toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
  #gig-controls .toolbar { margin: 12px 0 0; }
  #gig-controls .toolbar input[type=search] { min-width: 0; flex-basis: auto; }
  #gig-controls .toolbar label { min-height: 44px; }
  #gig-controls #destination { margin: 12px 0 0; }
}

.list-heading-text { flex: 1; min-width: 0; }
.list-heading-text .list-title { width: 100%; overflow-wrap: anywhere; }
.list-transfer-hint { display: block; padding: 0 5px; color: var(--accent); font-size: 12px; overflow-wrap: anywhere; }
.library-toggle { order: 1; margin-left: auto; flex: 0 0 44px; display: grid; place-items: center; height: 44px; padding: 0; line-height: 1; }
.list.is-collapsed .list-header { margin-bottom: 0; }
#gig-controls #destination { width: 100%; font-size: 12px; margin-bottom: 0; }

.library-toggle .fas { width: 1em; font-size: 16px; line-height: 1; }

.library-search { display: block; width: 100%; min-width: 0; margin-bottom: 10px; font-size: 16px; }
