:root{
  --bg:#0b0f16;
  --panel:#121821;
  --card:#1d2633;
  --blue:#2563eb;
  --text:#f8fafc;
  --muted:#94a3b8;
  --paper:#fffdf7;
  --ink:#111827;
  --chord:#0057d9;
}

*{box-sizing:border-box}

body{
  margin:0;
  height:100vh;
  background:var(--bg);
  color:var(--text);
  font-family:Inter,Segoe UI,Arial,sans-serif;
  overflow:hidden;
}

.app{
  height:100vh;
  display:grid;
  grid-template-columns:310px 1fr;
}

.sidebar{
  background:linear-gradient(180deg,#141b26,#0f141c);
  border-right:1px solid #263244;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.brand{padding:18px}
.logo{font-size:21px;font-weight:900}
.tagline{color:var(--muted);font-size:12px;margin-top:4px}

.search{
  margin:0 14px 12px;
  padding:13px;
  border-radius:12px;
  border:1px solid #334155;
  background:#0b0f16;
  color:white;
  outline:none;
}

.tabs{
  display:flex;
  padding:0 14px 12px;
  gap:8px;
}

.tabs button{
  flex:1;
  background:transparent;
  border:none;
  color:var(--muted);
  padding:8px;
  border-bottom:2px solid transparent;
}

.tabs .active{
  color:white;
  border-color:var(--blue);
}

.sectionHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-size:12px;
  text-transform:uppercase;
  color:#cbd5e1;
  padding:10px 14px;
  font-weight:800;
}

.sectionHeader button{
  background:#3b1f24;
  color:white;
  border:none;
  border-radius:8px;
  padding:5px 9px;
}

.setlist{
  display:none;
  border-top:1px solid #263244;
  border-bottom:1px solid #263244;
  max-height:330px;
  overflow:auto;
}

#setListBox{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding:0 10px 10px;
}

.setItem{
  background:#1e293b;
  border:1px solid #3b82f6;
  border-radius:12px;
  padding:9px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  cursor:pointer;
}

.setItem button{
  width:24px;
  height:24px;
  min-width:24px;
  min-height:24px;
  padding:0;
  border-radius:50%;
  background:#0f172a;
  color:white;
  border:none;
  display:flex;
  align-items:center;
  justify-content:center;
  line-height:1;
  font-size:14px;
}

.library{
  flex:1;
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

#songList{
  overflow:auto;
  padding:8px;
}

.song{
  padding:13px;
  border-radius:14px;
  margin-bottom:8px;
  cursor:pointer;
  border:1px solid transparent;
}

.song:hover,
.song.active{
  background:#1e293b;
  border-color:#3b82f6;
}

.songTitle{font-weight:850}

.songArtist{
  color:var(--muted);
  font-size:12px;
  margin-top:4px;
}

.songActions{
  display:flex;
  gap:8px;
  margin-top:8px;
}

.badge,
.addSet{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height:26px;
  padding:0 10px;
  border-radius:999px;
  font-size:12px;
  line-height:1;
}

.badge{
  background:#0f172a;
  color:#bfdbfe;
  border:1px solid #334155;
}

.addSet{
  background:#2563eb;
  color:white;
  border:none;
}

.main{
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.topbar{
  min-height:86px;
  padding:14px 20px;
  background:#0d1118;
  border-bottom:1px solid #263244;
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:center;
}

h1{
  margin:0;
  font-size:24px;
}

#songMeta,
#flowMeta{
  margin:4px 0 0;
  color:var(--muted);
  font-size:13px;
}

#flowMeta{color:#93c5fd}

.controls{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:flex-end;
}

button,
select{
  height:40px;
  border:none;
  border-radius:12px;
  background:#1e293b;
  color:white;
  padding:0 13px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
  font-family:inherit;
  font-weight:700;
}

.primary{background:#2563eb}
.activeBtn{background:#16a34a !important}

.mobileSongsBtn,
.mobileCloseBtn{
  display:none;
}

.sectionTabs{
  display:flex;
  gap:8px;
  padding:10px 18px;
  background:#0d1118;
  border-bottom:1px solid #263244;
  overflow-x:auto;
}

.sectionTabs button{
  height:34px;
  background:#1e293b;
  white-space:nowrap;
}

.contentArea{
  flex:1;
  min-height:0;
  display:grid;
  grid-template-columns:1fr 330px;
  overflow:hidden;
}

.chart{
  overflow:auto;
  background:var(--paper);
  color:var(--ink);
  padding:20px;
}

pre{
  margin:0;
  white-space:pre;
  font-family:Consolas,"Courier New",monospace;
  font-size:15px;
  line-height:1.45;
}

.chord{
  color:var(--chord);
  font-weight:900;
  cursor:pointer;
}

.sectionLabel{
  display:block;
  margin:16px 0 8px;
  padding:5px 10px;
  border-radius:6px;
  font-weight:900;
  width:min(520px, 100%);
}

.sectionLabel.intro{background:#e8f7e8;color:#1f7a34}
.sectionLabel.verse{background:#e9efff;color:#1d4ed8}
.sectionLabel.chorus{background:#f3e8ff;color:#7e22ce}
.sectionLabel.bridge{background:#fff1df;color:#b45309}
.sectionLabel.ending,
.sectionLabel.outro,
.sectionLabel.tag{background:#f1f5f9;color:#334155}

.loopBanner{
  background:#dcfce7;
  color:#166534;
  border:1px solid #86efac;
  padding:8px 12px;
  border-radius:10px;
  font-weight:900;
  margin-bottom:12px;
}

.flowPanel{
  background:#0d1118;
  border-left:1px solid #263244;
  padding:12px;
  overflow:auto;
}

.panelCard{
  background:#141b26;
  border:1px solid #263244;
  border-radius:14px;
  padding:14px;
  margin-bottom:12px;
}

.panelCard h3{
  margin:0 0 12px;
  font-size:13px;
  text-transform:uppercase;
}

.flowSong{margin-bottom:12px}

.flowSong small{
  display:block;
  color:var(--muted);
  margin-bottom:3px;
}

.flowButtons,
.quickTools,
.loopButtons{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.flowButtons button{flex:1}

.loopControls{margin-bottom:10px}

.clearLoopBtn{
  background:#3b1f24;
  color:#fecaca;
}

.loopButtons button{background:#1e293b}

.loopButtons button.activeLoop{
  background:#16a34a;
  color:white;
}

.scrollSpeed,
.topScrollSpeed{
  width:100%;
  margin-top:10px;
}

.helperText{
  color:var(--muted);
  font-size:12px;
  line-height:1.4;
  margin:0 0 10px;
}

#capoHelper{
  background:#0f172a;
  border:1px solid #334155;
  border-radius:12px;
  padding:10px;
  color:#dbeafe;
  font-size:13px;
  line-height:1.45;
}

/* PERFORMANCE MODE */
body.performance .sidebar{
  display:none;
}

body.performance .app{
  grid-template-columns:1fr;
}

body.performance .topbar{
  background:#000;
}

body.performance .chart{
  background:#000;
  color:white;
  padding:28px;
}

body.performance pre{
  font-size:24px;
  line-height:1.55;
}

body.performance .chord{
  color:#60a5fa;
}

body.performance .contentArea{
  grid-template-columns:1fr 330px;
}

/* MOBILE */
@media(max-width:900px){
  .app{
    grid-template-columns:1fr;
  }

  .sidebar{
    position:fixed;
    inset:0;
    z-index:999;
    width:100vw;
    height:100vh;
    transform:translateX(-100%);
    transition:.25s ease;
  }

  .sidebar.open{
    transform:translateX(0);
  }

  .mobileSongsBtn{
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    height:40px !important;
    min-width:78px !important;
    padding:0 14px !important;
    line-height:1 !important;
    background:#7c3aed !important;
    color:white !important;
    font-weight:800 !important;
  }

  .mobileCloseBtn{
    display:flex;
    margin:10px 14px 0;
    background:#3b1f24;
    color:#fecaca;
    justify-content:center;
    align-items:center;
  }

  .main{
    width:100vw;
    height:100vh;
  }

  .topbar{
    display:block;
    padding:14px;
  }

  .controls{
    margin-top:10px;
    justify-content:flex-start;
    display:flex;
    flex-wrap:wrap;
    gap:8px;
  }

  .controls button,
  .controls select{
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    height:40px !important;
    line-height:1 !important;
    padding:0 13px !important;
    text-align:center !important;
  }

  .contentArea{
    grid-template-columns:1fr;
  }

  .flowPanel{
    display:none !important;
  }

  .sectionTabs{
    padding:10px 8px;
  }

  .chart{
    padding:14px;
  }

  pre{
    white-space:pre-wrap;
    overflow-wrap:break-word;
    font-size:clamp(10px,3vw,14px);
  }

  body.performance .app{
    grid-template-columns:1fr !important;
  }

  body.performance .contentArea{
    display:block !important;
    grid-template-columns:none !important;
    width:100vw !important;
    height:calc(100vh - 150px) !important;
    overflow:hidden !important;
  }

  body.performance .flowPanel{
    display:none !important;
  }

  body.performance .chart{
    width:100vw !important;
    height:100% !important;
    overflow:auto !important;
    padding:14px !important;
    padding-bottom:70px !important;
    background:#000 !important;
    color:white !important;
  }

  body.performance pre{
    white-space:pre-wrap !important;
    overflow-wrap:normal !important;
    word-break:normal !important;
    font-size:16px !important;
    line-height:1.45 !important;
  }

  body.performance .sectionTabs{
    display:flex !important;
    overflow-x:auto !important;
  }
}

/* FINAL mobile top button fix */
@media(max-width:900px){

  .controls{
    align-items:center !important;
  }

  .controls button,
  .controls select{
    height:40px !important;
    min-height:40px !important;
    padding:0 14px !important;
    margin:0 !important;

    display:grid !important;
    place-items:center !important;

    line-height:1 !important;
    text-align:center !important;
    vertical-align:middle !important;

    font-family:Inter, Segoe UI, Arial, sans-serif !important;
    font-size:14px !important;
    font-weight:800 !important;

    appearance:none !important;
    -webkit-appearance:none !important;
  }

  .controls .mobileSongsBtn{
    min-width:78px !important;
    background:#7c3aed !important;
    color:white !important;
  }
}
/* Allow Songs menu to open during performance mode on mobile */
@media(max-width:900px){

  body.performance .sidebar{
    display:flex !important;
  }

  body.performance .sidebar:not(.open){
    transform:translateX(-100%) !important;
  }

  body.performance .sidebar.open{
    transform:translateX(0) !important;
  }
}
.mobileAutoTop{
  display:none;
}

@media(max-width:900px){
  .mobileAutoTop{
    display:inline-flex;
    align-items:center;
    gap:8px;
    height:40px;
    padding:0 10px;
    border-radius:12px;
    background:#1e293b;
  }

  .mobileAutoTop button{
    height:32px !important;
    padding:0 10px !important;
    background:#16a34a !important;
  }

  .mobileAutoTop input{
    width:78px;
  }
}

.songRow{
  display:flex;
  gap:12px;
  align-items:flex-start;
}

.songCover{
  width:56px;
  height:56px;
  min-width:56px;
  border-radius:12px;
  object-fit:cover;

  background:#0f172a;
  border:1px solid #334155;

  box-shadow:
    0 2px 10px rgba(0,0,0,.25);
}

.songInfo{
  flex:1;
  min-width:0;
}

.songTitle{
  font-size:17px;
  font-weight:850;
  line-height:1.15;
  margin-bottom:4px;
}

.songArtist{
  color:var(--muted);
  font-size:12px;
  line-height:1.35;
  margin-bottom:10px;
}

.songActions{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}

.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;

  height:28px;
  padding:0 12px;

  border-radius:999px;

  background:#0f172a;
  border:1px solid #334155;

  color:#bfdbfe;
  font-size:12px;
  font-weight:700;
}

.addSet{
  display:inline-flex;
  align-items:center;
  justify-content:center;

  height:28px;
  padding:0 12px;

  border:none;
  border-radius:999px;

  background:#2563eb;
  color:white;

  font-size:12px;
  font-weight:800;

  cursor:pointer;

  transition:.15s ease;
}

.addSet:hover{
  transform:translateY(-1px);
  background:#3b82f6;
}

.setIndicator{
  display:inline-block;
  width:9px;
  height:9px;
  margin-left:7px;
  border-radius:50%;
  background:#22c55e;
  box-shadow:0 0 0 3px rgba(34,197,94,.18);
  vertical-align:middle;
}