:root {
  color-scheme: dark;
  --bg: #071b29;
  --bg-2: #09283b;
  --bg-3: #071f31;
  --mid: #174765;
  --mid-2: #256080;
  --blue: #1687ff;
  --blue-2: #0b4f8a;
  --blue-light: #38bdf8;
  --text: #e7f7ff;
  --muted: #9fc3d5;
  --dim: #5a8aa3;
  --green: #20dba9;
  --amber: #f2b544;
  --danger: #ff8d8d;
  --on-accent: #fff;
  --head-grad: linear-gradient(180deg, #0e3a57 0%, var(--bg) 100%);
  --topbar-grad: linear-gradient(180deg, #103b57 0%, var(--bg) 100%);
  --brand-grad: linear-gradient(180deg, #a5f0ff 0%, var(--blue-light) 45%, var(--blue) 100%);
  --hover: rgba(23, 71, 101, .55);
  --hover-strong: rgba(23, 71, 101, .68);
  --chord-hover-bg: rgba(56, 189, 248, .18);
  --chord-hover: #8fe3ff;
  /* Diagramas de acorde */
  --dg-grid: #4a7f9c;
  --dg-ink: #e7f7ff;
  --dg-muted: #b7d6e6;
  --dg-dot: #38bdf8;
  --dg-dot-text: #04202e;
  --dg-dot-ring: rgba(2, 16, 24, .4);
  --dg-barre: #38bdf8;
  --dg-barre-edge: rgba(2, 16, 24, .5);
  --dg-barre-text: #04202e;
  --overlay: rgba(2, 10, 16, .72);
  --switch-knob: #fff;
  --shadow-popover: 0 14px 40px rgba(0, 0, 0, .55);
  --shadow-modal: 0 30px 80px rgba(0, 0, 0, .6);
  --shadow-toast: 0 10px 30px rgba(0, 0, 0, .5);
  --fs: 16px;
  --mono: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
}

/* ----------------------------- Modo claro ------------------------------- */

body.light {
  color-scheme: light;
  --bg: #eef6fb;
  --bg-2: #ffffff;
  --bg-3: #e6f1f8;
  --mid: #cfe3ef;
  --mid-2: #9fc4d9;
  --blue: #0d7be0;
  --blue-2: #0a5db0;
  --blue-light: #0a6cbf;
  --text: #0a2a3e;
  --muted: #3a5f76;
  --dim: #4a6f86;
  --green: #0a9d7a;
  --amber: #b4770a;
  --danger: #c73a3a;
  --on-accent: #fff;
  --head-grad: linear-gradient(180deg, #dcecf8 0%, var(--bg) 100%);
  --topbar-grad: linear-gradient(180deg, #e2f0fa 0%, var(--bg) 100%);
  --brand-grad: linear-gradient(180deg, #1274b8 0%, #0a6cbf 55%, #0a4e93 100%);
  --hover: rgba(13, 123, 224, .08);
  --hover-strong: rgba(13, 123, 224, .13);
  --chord-hover-bg: rgba(13, 123, 224, .12);
  --chord-hover: #075a9e;
  /* Diagramas de acorde */
  --dg-grid: #9dbccd;
  --dg-ink: #0a2a3e;
  --dg-muted: #33596f;
  --dg-dot: #0a6cbf;
  --dg-dot-text: #ffffff;
  --dg-dot-ring: rgba(10, 42, 62, .35);
  --dg-barre: #0a6cbf;
  --dg-barre-edge: rgba(10, 42, 62, .35);
  --dg-barre-text: #ffffff;
  --overlay: rgba(10, 42, 62, .38);
  --switch-knob: #fff;
  --shadow-popover: 0 14px 40px rgba(10, 42, 62, .18);
  --shadow-modal: 0 30px 80px rgba(10, 42, 62, .25);
  --shadow-toast: 0 10px 30px rgba(10, 42, 62, .18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 700px 420px at 8% -5%, rgba(56, 189, 248, 0.16), transparent 62%),
    radial-gradient(ellipse 520px 360px at 88% 12%, rgba(22, 135, 255, 0.10), transparent 62%),
    radial-gradient(ellipse 500px 420px at 50% 110%, rgba(32, 219, 169, 0.05), transparent 65%);
}
body.light::before {
  background:
    radial-gradient(ellipse 700px 420px at 8% -5%, rgba(13, 123, 224, 0.10), transparent 62%),
    radial-gradient(ellipse 520px 360px at 88% 12%, rgba(56, 189, 248, 0.10), transparent 62%),
    radial-gradient(ellipse 500px 420px at 50% 110%, rgba(10, 157, 122, 0.04), transparent 65%);
}
.app { position: relative; z-index: 1; }

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app { display: flex; height: 100vh; }

.auth-screen {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 700px 420px at 15% 10%, rgba(56,189,248,.20), transparent 62%),
    radial-gradient(ellipse 700px 420px at 85% 90%, rgba(22,135,255,.14), transparent 62%),
    linear-gradient(180deg, #0a2c42 0%, #071b29 100%);
}
body.light .auth-screen {
  background:
    radial-gradient(ellipse 700px 420px at 15% 10%, rgba(13,123,224,.14), transparent 62%),
    linear-gradient(180deg, #eaf4fb 0%, #dcecf8 100%);
}
.auth-screen.hidden { display: none; }
.auth-card {
  width: min(480px, 100%);
  padding: 34px 28px;
  border-radius: 22px;
  background: color-mix(in srgb, var(--bg-2) 88%, #000 12%);
  border: 1px solid rgba(56,189,248,.16);
  box-shadow: 0 30px 90px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.03);
}
.auth-brand { display:flex; align-items:baseline; gap:10px; justify-content:center; margin-bottom: 10px; }
.auth-brand.brand-stack { align-items:center; }
.auth-sub { text-align:center; color: var(--muted); margin-bottom: 22px; }
.auth-block { display:flex; flex-direction:column; gap: 12px; }
.auth-block.hidden { display:none; }
.auth-btn { width:100%; justify-content:center; }
.auth-actions { display:flex; gap:10px; }
.auth-actions.hidden { display:none !important; }
.auth-actions .auth-btn { width:auto; flex:1; }
.auth-divider { height:1px; background: var(--mid); margin: 4px 0; }
.auth-skip { align-self:center; margin-top:4px; }
.auth-status { margin-top: 14px; min-height: 18px; font-size: 12px; color: var(--muted); text-align:center; white-space: pre-wrap; }

.auth-card { position: relative; overflow: hidden; }
.auth-decor { position:absolute; inset:0; pointer-events:none; }
.auth-note { position:absolute; width:34px; height:34px; stroke: rgba(56,189,248,.22); fill: none; stroke-width:1.6; }
.auth-note.n1 { top: 10%; left: 10%; transform: rotate(-12deg) scale(1.3); }
.auth-note.n2 { top: 18%; right: 14%; transform: rotate(10deg) scale(1.1); }
.auth-note.n3 { bottom: 14%; left: 16%; transform: rotate(8deg) scale(1.0); }
.auth-chord {
  position:absolute; font-weight:800; color: rgba(56,189,248,.10);
  font-family: var(--mono); letter-spacing: -1px;
}
.auth-chord.c1 { top: 12%; left: 22%; font-size: 54px; }
.auth-chord.c2 { bottom: 18%; right: 12%; font-size: 64px; }
.auth-chord.c3 { top: 48%; right: 18%; font-size: 40px; }
.auth-chord.c4 { bottom: 24%; left: 10%; font-size: 42px; }
body.light .auth-note { stroke: rgba(10,108,191,.18); }
body.light .auth-chord { color: rgba(10,108,191,.08); }



/* ------------------------------- Sidebar ------------------------------- */

.sidebar {
  width: 300px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  background: var(--bg-3);
  border-right: 1px solid var(--mid);
}

.sidebar-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px;
  background: var(--head-grad);
  overflow: hidden;
}
.sidebar-head::before {
  content: "";
  position: absolute;
  top: -50px;
  left: -30px;
  width: 220px;
  height: 140px;
  background: radial-gradient(closest-side, rgba(56, 189, 248, 0.28), transparent 72%);
  pointer-events: none;
}
.sidebar-head::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: 0;
  width: 160px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56,189,248,.55), transparent);
  pointer-events: none;
}

.sidebar-head > * { position: relative; z-index: 1; }
.head-actions { display: flex; align-items: center; gap: 6px; }

.brand { display: flex; align-items: baseline; gap: 8px; user-select: none; }
.brand-stack { flex-direction: column; align-items: flex-start; gap: 2px; }
.brand-main { display:flex; align-items: baseline; gap: 6px; }
.brand-ft {
  font-size: 36px;
  font-style: italic;
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 0.95;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(56, 189, 248, 0.22)) drop-shadow(0 8px 24px rgba(22, 135, 255, 0.18));
}
.brand-lab {
  font-size: 36px;
  font-style: italic;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 0.95;
  color: var(--text);
  opacity: .96;
}
.brand-word {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 5px;
  color: var(--muted);
  transform: none;
  opacity: .95;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 9px;
  background: var(--mid);
  color: var(--text);
  transition: filter .15s, transform .1s;
}
.icon-btn svg { width: 16px; height: 16px; stroke-width: 2.2; }
.icon-btn.primary {
  padding: 0;
  background: linear-gradient(180deg, var(--blue) 0%, var(--blue-2) 100%);
  box-shadow: 0 8px 20px rgba(22, 135, 255, 0.28), inset 0 1px 0 rgba(255,255,255,.25);
}
.icon-btn:hover { filter: brightness(1.15); }
.icon-btn:active { transform: scale(.96); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px 14px;
  padding: 9px 11px;
  background: var(--bg-2);
  border: 1px solid var(--mid);
  border-radius: 9px;
}
.search svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
.search input::placeholder { color: var(--dim); }

/* --------------------------- Abas da sidebar ---------------------------- */

.side-tabs {
  display: flex;
  gap: 4px;
  margin: 0 16px 10px;
  padding: 3px;
  background: var(--bg-2);
  border: 1px solid var(--mid);
  border-radius: 9px;
}
.side-tab {
  flex: 1;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  padding: 7px 0;
  transition: background .15s, color .15s;
}
.side-tab.on { background: linear-gradient(180deg, var(--blue) 0%, var(--blue-2) 100%); color: var(--on-accent); }
.side-tab:hover:not(.on) { color: var(--text); }

.new-setlist {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 6px;
  padding: 10px 10px;
  border: 1px dashed var(--mid-2);
  border-radius: 9px;
  background: transparent;
  color: var(--blue-light);
  font-size: 12px;
  font-weight: 700;
}
.new-setlist svg { width: 15px; height: 15px; }
.new-setlist:hover { background: var(--hover); }

.setlist-icon { width: 17px; height: 17px; color: var(--mid-2); flex: none; }
.setlist-icon svg { width: 17px; height: 17px; }
.song-item.active .setlist-icon { color: var(--blue-light); }
.setlist-item .chev { width: 14px; height: 14px; color: var(--dim); flex: none; }
.setlist-item .chev svg { width: 14px; height: 14px; }

.song-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}
.song-list::-webkit-scrollbar { width: 8px; }
.song-list::-webkit-scrollbar-thumb { background: var(--mid); border-radius: 4px; }

.song-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  margin-bottom: 2px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
}
.song-item:hover { background: var(--hover); }
.song-item.active {
  background: var(--hover-strong);
  box-shadow: inset 3px 0 0 var(--blue-light);
}
.song-item .meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.song-item .name {
  display: block;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-item .artist {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-item .star { width: 13px; height: 13px; color: var(--amber); fill: var(--amber); stroke: none; flex: none; }
.pad-badge {
  flex: none;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .6px;
  padding: 3px 6px;
  border-radius: 999px;
  color: #7dd3fc;
  background: rgba(56,189,248,.12);
  border: 1px solid rgba(56,189,248,.22);
}

.empty-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--dim);
  text-align: center;
  font-size: 13px;
}
.empty-side svg { width: 34px; height: 34px; color: var(--mid-2); stroke-width: 1.4; }
.empty-hint { font-size: 11px; color: var(--dim); max-width: 210px; }

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  border-top: 1px solid var(--mid);
  font-size: 11px;
  color: var(--dim);
}
.ftlab { font-weight: 800; letter-spacing: 1.2px; color: var(--mid-2); }

/* -------------------------------- Main --------------------------------- */

.main { flex: 1; min-width: 0; display: flex; }
.detail { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--topbar-grad);
  border-bottom: 1px solid var(--mid);
  overflow: hidden;
}
.topbar::before {
  content: "";
  position: absolute;
  top: -60px;
  right: 10%;
  width: 260px;
  height: 160px;
  background: radial-gradient(closest-side, rgba(56,189,248,.14), transparent 72%);
  pointer-events: none;
}
.topbar > * { position: relative; z-index: 1; }
.song-info { min-width: 0; }
.song-info h1 {
  font-size: 25px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-info .artist { font-size: 13px; color: var(--muted); margin-top: 2px; }

.actions { margin-left: auto; display: flex; gap: 6px; }
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 58px;
  padding: 6px 0;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}
.tool svg { width: 17px; height: 17px; }
.tool:hover { background: var(--hover-strong); color: var(--text); }
.tool.fav {
  color: #f6c453;
  background: rgba(242, 181, 68, 0.10);
  border-color: rgba(242, 181, 68, 0.28);
}
.tool.fav svg { fill: #f6c453; stroke: #f6c453; }
body.light .tool.fav {
  color: #b86a00;
  background: rgba(242, 181, 68, 0.14);
  border-color: rgba(184, 106, 0, 0.25);
}
body.light .tool.fav svg { fill: #e09a00; stroke: #b86a00; }
.tool.danger { color: var(--danger); }
.tool.danger svg { color: var(--danger); }

.back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  max-width: 210px;
  padding: 7px 10px;
  border: 1px solid var(--mid);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.back-link svg { width: 14px; height: 14px; flex: none; }
.back-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-link:hover { background: var(--mid); color: var(--text); }
.topbar.has-back .tool { width: 48px; }

/* ----------------------------- Repertórios ------------------------------ */

.setlist-body {
  flex: 1;
  overflow-y: auto;
  padding: 26px 34px 80px;
}
.setlist-body::-webkit-scrollbar { width: 10px; }
.setlist-body::-webkit-scrollbar-thumb { background: var(--mid); border-radius: 5px; }

.setlist-songs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 820px;
}
.setlist-song {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--mid);
  border-radius: 11px;
  background: var(--bg-2);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.setlist-song:hover { background: var(--hover-strong); border-color: var(--mid-2); }
.drag-handle { color: var(--dim); font-size: 14px; line-height: 1; cursor: grab; user-select: none; padding: 2px 2px; flex: none; }
.setlist-song.dragging { opacity: .45; }
.setlist-song.drag-over { border-color: var(--blue-light); box-shadow: inset 0 0 0 1px rgba(56,189,248,.35); }
.setlist-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--mid);
  color: var(--blue-light);
  font-size: 13px;
  font-weight: 800;
}
.setlist-song .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.setlist-song .name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.setlist-song .artist {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-actions { display: flex; gap: 4px; opacity: .5; transition: opacity .12s; }
.setlist-song:hover .row-actions { opacity: 1; }
.mini {
  width: 27px;
  height: 27px;
  border: none;
  border-radius: 7px;
  background: var(--mid);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.mini:hover { background: var(--mid-2); }
.mini.danger { color: var(--danger); }

/* --------------------- Seleção de músicas / listas ---------------------- */

.modal-card.small { width: 480px; }
.inline-search { margin: 0; }

.pick-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg-2);
  border: 1px solid var(--mid);
  border-radius: 10px;
}
.pick-list::-webkit-scrollbar { width: 8px; }
.pick-list::-webkit-scrollbar-thumb { background: var(--mid); border-radius: 4px; }
.pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.pick-row:hover { background: var(--mid); }
.pick-row input { width: 16px; height: 16px; accent-color: var(--blue); flex: none; }
.pick-meta { display: flex; flex-direction: column; min-width: 0; }
.pick-name {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pick-artist { font-size: 11px; color: var(--muted); }
.pick-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }

.workbench { flex: 1; display: flex; min-height: 0; }

.cifra-scroll {
  flex: 1;
  overflow: auto;
  padding: 26px 34px 120px;
  user-select: text;
}
.cifra-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.cifra-scroll::-webkit-scrollbar-thumb { background: var(--mid); border-radius: 5px; }

.cifra {
  font-family: var(--mono);
  font-size: var(--fs);
  line-height: var(--lh, 1.5);
  color: var(--text);
  white-space: pre;
  -webkit-font-variant-ligatures: none;
  font-variant-ligatures: none;
}
.cifra-cols { display: flex; gap: 48px; align-items: flex-start; }
.cifra-col { flex: 1; min-width: 0; }

.row { position: relative; }
.chord-line { position: relative; height: calc(1em * var(--lh, 1.5)); }
.lyric { white-space: pre; min-height: calc(1em * var(--lh, 1.5)); }

.chord {
  position: absolute;
  top: 0;
  display: inline-block;
  color: var(--blue-light);
  font-weight: 700;
  white-space: pre;
  cursor: pointer;
  padding: 0 1px;
  border-radius: 3px;
  transition: background .12s, color .12s;
}
.chord:hover { background: var(--chord-hover-bg); color: var(--chord-hover); }

.inline-chord {
  position: static;
  display: inline;
  white-space: pre;
}

/* ------------------------------- Panel --------------------------------- */

.panel {
  width: 268px;
  min-width: 268px;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-3);
  border-left: 1px solid var(--mid);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: var(--mid); border-radius: 4px; }

.panel-section {
  background: var(--bg-2);
  border: 1px solid var(--mid);
  border-radius: 11px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.panel-section h3 {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.3px;
  color: var(--dim);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.switch-row input { display: none; }
.switch {
  position: relative;
  width: 34px;
  height: 19px;
  border-radius: 10px;
  background: var(--mid);
  transition: background .18s;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .18s, background .18s;
}
.switch-row input:checked + .switch { background: var(--blue); }
.switch-row input:checked + .switch::after { transform: translateX(15px); background: var(--switch-knob); }

.range-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--mid);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blue-light);
  cursor: pointer;
}

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 34px;
  height: 30px;
  border: none;
  border-radius: 7px;
  background: var(--mid);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}
.stepper button:hover { background: var(--mid-2); }
.stepper .value {
  flex: 1;
  text-align: center;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.link {
  border: none;
  background: transparent;
  color: var(--blue-light);
  font-size: 11px;
  font-weight: 700;
  padding: 0;
  text-align: left;
}
.link:hover { text-decoration: underline; }

.seg { display: flex; background: var(--mid); border-radius: 8px; padding: 2px; }
.seg button {
  flex: 1;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 0;
}
.seg button.on { background: var(--blue); color: var(--on-accent); }

.font-row { display: flex; gap: 8px; }
.font-row button {
  flex: 1;
  height: 31px;
  border: none;
  border-radius: 7px;
  background: var(--mid);
  color: var(--text);
  font-weight: 700;
  font-size: 12px;
}
.font-row button:hover { background: var(--mid-2); }

.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  padding: 5px 0;
  text-align: left;
}
.action-row svg { width: 15px; height: 15px; color: var(--muted); }
.action-row:hover svg { color: var(--text); }
.action-row.danger { color: var(--danger); }
.action-row.danger svg { color: var(--danger); }
.pad-row { display:flex; flex-direction:column; gap:4px; margin-bottom:10px; }
.pad-name { font-size:12px; color: var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pad-status { font-size:11px; color: var(--muted); }
.pad-actions { display:flex; gap:8px; margin-bottom:10px; flex-wrap:wrap; }
.pad-actions .tool { padding:8px 10px; }

/* ------------------------------ Popover -------------------------------- */

.chord-popover {
  position: fixed;
  z-index: 60;
  padding: 8px;
  background: var(--bg-2);
  border: 1px solid var(--mid);
  border-radius: 12px;
  box-shadow: var(--shadow-popover);
  pointer-events: none;
}
.chord-popover.hidden { display: none; }
.diagram { display: flex; flex-direction: column; align-items: center; }
.diagram-name { font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 2px; }
.diagram svg { display: block; }
.dg-grid { stroke: var(--dg-grid); stroke-width: 1; }
.dg-nut { stroke: var(--dg-ink); stroke-width: 3.2; }
.dg-barre-edge { stroke: var(--dg-barre-edge); stroke-width: 16; stroke-linecap: round; fill: none; }
.dg-barre { stroke: var(--dg-barre); stroke-width: 13; stroke-linecap: round; fill: none; }
.dg-barre-text { fill: var(--dg-barre-text); font-size: 11px; font-weight: 800; stroke: none; paint-order: normal; }
.dg-open { fill: none; stroke: var(--dg-ink); stroke-width: 1.6; }
.dg-mute { fill: var(--dg-muted); font-size: 12px; font-weight: 700; stroke: none; }
.dg-dot { fill: var(--dg-dot); stroke: var(--dg-dot-ring); stroke-width: 0.8; }
.dg-finger { fill: var(--dg-dot-text); font-size: 11px; font-weight: 800; stroke: none; paint-order: normal; }
.dg-fret { fill: var(--dg-muted); font-size: 11px; font-weight: 700; stroke: none; }
.no-diagram { padding: 16px; font-size: 12px; color: var(--muted); }

/* -------------------------------- Modal -------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
  backdrop-filter: blur(3px);
}
.modal.hidden { display: none; }

.modal-card {
  width: 760px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
  border: 1px solid var(--mid);
  border-radius: 16px;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-card h2 { font-size: 22px; font-weight: 800; color: var(--text); }
.hint { font-size: 13px; color: var(--muted); }

.field-row { display: flex; gap: 12px; }
.field { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.field span, .field-head label { font-size: 12px; font-weight: 700; color: var(--muted); }
.field input {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--mid);
  background: var(--bg-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.field input:focus, textarea:focus { border-color: var(--blue); }

.field-head { display: flex; align-items: center; justify-content: space-between; }

#mRaw {
  min-height: 300px;
  resize: vertical;
  padding: 12px;
  border-radius: 9px;
  border: 1px solid var(--mid);
  background: var(--bg-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  outline: none;
  white-space: pre;
  overflow: auto;
}

.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.ghost {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 9px;
}
.ghost:hover { background: var(--hover-strong); color: var(--text); }
.primary {
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  background: linear-gradient(180deg, var(--blue) 0%, var(--blue-2) 100%);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 700;
}
.primary:hover { filter: brightness(1.12); }
.primary:disabled { opacity: .45; cursor: default; }

/* -------------------------------- Empty -------------------------------- */

.empty-main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  text-align: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, rgba(56, 189, 248, 0.06), transparent 70%),
    var(--bg-1);
}
.empty-main h2 { font-size: 20px; font-weight: 700; color: var(--text); }
.empty-main p { font-size: 13px; color: var(--muted); max-width: 360px; }
.empty-brand { display:flex; align-items:baseline; gap:10px; opacity:.9; }
.empty-brand.brand-stack { align-items:center; gap: 6px; }
.empty-brand .brand-ft { font-size: 72px; }
.empty-brand .brand-lab { font-size: 72px; }
.empty-brand .brand-word { font-size: 14px; letter-spacing: 8px; }
.empty-sub { margin-top: 4px; color: var(--dim) !important; position:relative; z-index:1; }
.empty-decor { position:absolute; inset:0; pointer-events:none; }
.empty-decor .auth-note { opacity: .55; }
.empty-decor .auth-chord { opacity: .35; }

/* -------------------------------- Toast --------------------------------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--mid);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow-toast);
}
.toast.hidden { display: none; }

/* ----------------------------- Modo palco ------------------------------- */

.fit-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 9px 20px;
  background: var(--head-grad);
  border-bottom: 1px solid var(--mid);
}
.fit-song { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.fit-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fit-artist {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fit-controls { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.fit-setlist {
  max-width: 260px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fit-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--dim);
}
.fit-btn {
  border: 1px solid var(--mid);
  background: var(--bg-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 15px;
  border-radius: 8px;
}
.fit-btn:hover { background: var(--mid); }
.fit-btn:disabled { opacity: .35; cursor: default; }
.fit-btn:disabled:hover { background: var(--bg-2); }
.fit-btn.pad-fit-btn.on { border-color: rgba(56,189,248,.45); color: #7dd3fc; background: rgba(56,189,248,.10); }

.fit-stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 20px;
}
.fit-stage::-webkit-scrollbar { width: 10px; height: 10px; }
.fit-stage::-webkit-scrollbar-thumb { background: var(--mid); border-radius: 5px; }

.cifra.fit { white-space: pre; }

/* No modo palco, a cifra usa a tela inteira */
body.fit-active .sidebar { display: none; }

.fit-cols {
  display: flex;
  gap: 34px;
  align-items: flex-start;
  width: max-content;
}
.fit-col { flex: none; }

.fit-empty {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--muted);
  font-size: 13px;
  white-space: normal;
}


/* ----------------------------- Context menu ----------------------------- */
.context-menu {
  position: fixed;
  z-index: 200;
  min-width: 220px;
  padding: 6px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-2) 92%, #000 8%);
  border: 1px solid var(--mid);
  box-shadow: 0 18px 40px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.03);
  backdrop-filter: blur(10px);
}
.context-menu.hidden { display: none; }
.ctx-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
}
.ctx-item:hover { background: var(--hover); }
.ctx-item svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.ctx-item.fav { color: #f6c453; }
.ctx-item.fav svg { color: #f6c453; fill: #f6c453; stroke: #f6c453; }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger svg { color: var(--danger); }
/* ----------------------------- Mobile / PWA ----------------------------- */

.menu-btn { display: none; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 80;
}
.sidebar-backdrop.show { display: block; }

.mobile-only { display: none; }

@media (max-width: 980px) {
  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--mid);
    border-radius: 9px;
    background: var(--bg-2);
    color: var(--text);
    margin-right: 10px;
    flex: 0 0 auto;
  }
  .menu-btn svg { width: 18px; height: 18px; }
  .mobile-only { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 320px);
    min-width: 0;
    z-index: 90;
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: 0 20px 50px rgba(0,0,0,.35);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }

  .topbar { padding: 14px 14px; gap: 10px; align-items: flex-start; }
  .song-info { display: flex; align-items: flex-start; gap: 2px; }
  .song-info .title-row { display: flex; align-items: flex-start; gap: 10px; }
  .song-info h1 { font-size: 28px; line-height: 1.1; }
  .actions { width: 100%; margin-left: 0; justify-content: flex-start; }
  .tool span { display: none; }
  .tool { padding: 9px 10px; }

  .workbench { flex-direction: column; }
  .panel {
    width: auto;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--mid);
    max-height: 42vh;
  }

  .cifra-scroll { padding: 14px 14px 28px; }
  .cifra-cols { gap: 20px; }
  .setlist-view { padding: 18px 14px 28px; }

  .fit-topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .fit-controls { width: 100%; margin-left: 0; flex-wrap: wrap; }
  .fit-stage { padding: 10px 12px; }

  .modal-card { width: min(96vw, 860px); padding: 18px 16px; }
  .field-row { flex-direction: column; gap: 10px; }
}

@media (max-width: 560px) {
  .song-info h1 { font-size: 24px; }
  .actions { gap: 6px; }
  .panel { max-height: 38vh; }
  .modal-actions { flex-wrap: wrap; }
}

@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar {
    padding-top: env(safe-area-inset-top);
  }
}

/* -------------------------------- Print --------------------------------- */

@media print {
  html, body { overflow: visible; height: auto; background: #fff; }
  .sidebar, .actions, .panel, .chord-popover, .toast, .modal { display: none !important; }
  .app, .main, .detail, .workbench { display: block; height: auto; }
  .topbar { background: #fff; border: none; padding: 0 0 12px; }
  .song-info h1 { color: #000; }
  .song-info .artist { color: #333; }
  .cifra-scroll { overflow: visible; padding: 0; height: auto; }
  .cifra, .lyric { color: #000; }
  .chord { color: #0b4f8a; }
  .cifra-cols { display: block; }
}

/* Auth team setup */
.auth-divider { display:flex; align-items:center; gap:10px; margin: 12px 0; color: var(--muted); font-size:12px; }
.auth-divider::before, .auth-divider::after { content:""; height:1px; background: var(--line); flex:1; }
#authTeam .auth-btn { width:100%; margin-top: 8px; }
#authTeam .field { margin-top: 8px; }
.pass-wrap { position: relative; display:flex; align-items:center; }
.pass-wrap input { width:100%; padding-right: 42px; }
.pass-toggle { position:absolute; right:8px; top:50%; transform:translateY(-50%); border:0; background:transparent; color:var(--muted); cursor:pointer; padding:4px; line-height:1; display:flex; align-items:center; justify-content:center; }
.pass-toggle:hover { color: var(--text); }
.pass-toggle .eye-icon { width:18px; height:18px; display:block; }

.account-box { padding: 10px 14px; border-top: 1px solid var(--line); display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%; background:transparent; }
.account-box.hidden { display:none; }
.account-email { font-size:12px; color: var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:600; background:transparent; border:0; padding:0; cursor:pointer; text-align:left; }
.account-email:hover { text-decoration: underline; }
.account-logout { font-size:11px; padding:0; color: var(--muted); }
.group-head { padding: 10px 12px 4px; font-size: 10px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.remember-row { display:flex; align-items:center; gap:8px; margin-top:10px; font-size:12px; color:var(--muted); cursor:pointer; }
.remember-row input { accent-color: var(--blue); }
.artist-head { width:100%; display:flex; align-items:center; gap:8px; background:transparent; border:0; text-align:left; cursor:pointer; }
.artist-head:hover { background: var(--bg-2); border-radius: 8px; }
.artist-caret { width:12px; color: var(--muted); flex:none; }
.artist-name { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.artist-count { font-size:10px; color:var(--dim); flex:none; }
.artist-group { padding-left: 6px; }
