:root{
  --bg:#101216;--panel:#171a21;--panel2:#1e222b;--text:#f5f7fb;--muted:#aeb6c4;
  --accent:#7c5cff;--accent2:#9c87ff;--border:#2b3140;--ok:#33c58e;
}
*{box-sizing:border-box}
body{margin:0;font-family:Segoe UI,Tahoma,Arial,sans-serif;background:linear-gradient(135deg,#0d0f13,#151925);color:var(--text)}
header{position:sticky;top:0;z-index:5;background:rgba(16,18,22,.94);backdrop-filter:blur(10px);border-bottom:1px solid var(--border);padding:16px 22px}
.header-row{display:flex;gap:12px;align-items:center;justify-content:space-between;max-width:1400px;margin:auto}
h1{font-size:22px;margin:0}.sub{color:var(--muted);font-size:13px;margin-top:4px}
.container{max-width:1400px;margin:20px auto;padding:0 18px 40px;display:grid;grid-template-columns:minmax(0,1.4fr) minmax(340px,.8fr);gap:18px}
@media(max-width:980px){.container{grid-template-columns:1fr}.output{position:static!important}}
.card{background:var(--panel);border:1px solid var(--border);border-radius:16px;padding:18px;margin-bottom:16px;box-shadow:0 12px 30px rgba(0,0,0,.18)}
.card h2{font-size:17px;margin:0 0 14px}.section-note{font-size:12px;color:var(--muted);margin:-6px 0 14px}
.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.grid3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
@media(max-width:650px){.grid,.grid3{grid-template-columns:1fr}}
label{display:block;font-size:13px;color:#dfe4ee;margin-bottom:6px}
input,select,textarea{width:100%;background:var(--panel2);color:var(--text);border:1px solid var(--border);border-radius:10px;padding:10px 11px;font:inherit;outline:none}
input:focus,select:focus,textarea:focus{border-color:var(--accent)}
textarea{min-height:82px;resize:vertical}
.pills{display:flex;flex-wrap:wrap;gap:8px}
.pill{display:inline-flex;align-items:center;gap:7px;padding:8px 10px;background:var(--panel2);border:1px solid var(--border);border-radius:999px;font-size:13px;cursor:pointer}
.pill input{width:auto}
.btns{display:flex;gap:8px;flex-wrap:wrap}
button{border:0;border-radius:10px;padding:10px 14px;font-weight:600;cursor:pointer}
.primary{background:var(--accent);color:white}.secondary{background:#242a36;color:white;border:1px solid var(--border)}.danger{background:#3a2024;color:#ffd8dd}
.output{position:sticky;top:92px;align-self:start}
.outbox{background:#0f1116;border:1px solid var(--border);padding:12px;border-radius:10px;white-space:pre-wrap;min-height:120px;font-family:Consolas,monospace;font-size:13px;line-height:1.65}
.small{font-size:12px;color:var(--muted)}
.badge{display:inline-block;background:#26213d;color:#cfc3ff;padding:4px 8px;border-radius:999px;font-size:11px}
.section-block{background:var(--panel2);border:1px solid var(--border);border-radius:14px;padding:14px;margin-bottom:14px}
.section-top{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:end}
.section-title{font-size:14px;font-weight:700;margin:0 0 8px}
.section-tools{display:flex;gap:8px;align-items:center}
.section-tools button{padding:8px 10px}
.section-instruments,.section-restrictions{display:flex;flex-wrap:wrap;gap:7px;margin-top:10px}
.section-instruments .pill{padding:7px 9px}
.section-desc{margin-top:10px}
.section-order{font-size:11px;color:var(--muted);margin-bottom:6px}
@media(max-width:650px){}
hr{border:0;border-top:1px solid var(--border);margin:16px 0}
.toast{position:fixed;bottom:20px;left:20px;background:#1d6f54;color:white;padding:10px 14px;border-radius:10px;opacity:0;transform:translateY(10px);transition:.2s}
.toast.show{opacity:1;transform:none}
.langbtn{font-size:12px}

.lyrics-section{background:var(--panel2);border:1px solid var(--border);border-radius:14px;padding:14px;margin-bottom:14px}
.lyrics-completed{opacity:.92;border-style:dashed}
.lyrics-completed .lyrics-section-header{margin-bottom:0}
.lyrics-section-header{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:end}
.lyric-line{background:#151922;border:1px solid var(--border);border-radius:12px;padding:12px;margin-top:12px}
.lyric-line-header{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px}
.segment-row{display:grid;grid-template-columns:140px 1fr auto;gap:8px;align-items:end;margin-top:8px}
@media(max-width:700px){.segment-row{grid-template-columns:1fr}}
.segment-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:10px}
.chord-input{text-transform:none}


/* v17: independent scrolling for the two desktop columns */
@media (min-width:981px){
  html,body{
    height:100%;
    overflow:hidden;
  }

  body{
    display:flex;
    flex-direction:column;
  }

  header{
    flex:0 0 auto;
  }

  .container{
    flex:1 1 auto;
    min-height:0;
    width:100%;
    margin:0 auto;
    padding:20px 18px 20px;
    overflow:hidden;
    align-items:stretch;
  }

  .container > main,
  .container > aside{
    min-height:0;
    height:100%;
    overflow-y:auto;
    overflow-x:hidden;
    overscroll-behavior:contain;
    scrollbar-gutter:stable;
    padding-inline-end:6px;
  }

  .output{
    position:static;
    top:auto;
    align-self:stretch;
  }
}

/* On tablets/phones keep normal single-page scrolling */
@media (max-width:980px){
  html,body{
    height:auto;
    overflow:auto;
  }

  .container > main,
  .container > aside{
    height:auto;
    overflow:visible;
    padding-inline-end:0;
  }
}


.mode-hidden{display:none!important}

/* ===== v19 SaaS prototype ===== */
.app-screen{display:none}.app-screen.active{display:block}.hidden{display:none!important}
.auth-shell{min-height:100vh;display:grid;place-items:center;padding:24px;background:linear-gradient(135deg,#0d0f13,#171b28)}
.auth-card{width:min(520px,100%);background:var(--panel);border:1px solid var(--border);border-radius:20px;padding:24px;box-shadow:0 24px 60px rgba(0,0,0,.35)}
.brand{font-size:28px;font-weight:800}.auth-tabs{display:flex;gap:8px;margin:18px 0}.auth-tabs button{flex:1}.auth-pane{display:none}.auth-pane.active{display:block}.form-stack{display:grid;gap:12px}
.app-topbar{position:sticky;top:0;z-index:30;background:rgba(16,18,22,.97);border-bottom:1px solid var(--border);padding:12px 18px}.topbar-row{max-width:1500px;margin:auto;display:flex;align-items:center;justify-content:space-between;gap:12px}.nav-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.dashboard-wrap{max-width:1250px;margin:auto;padding:26px 18px 48px}.stat-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.stat-card{background:var(--panel);border:1px solid var(--border);border-radius:16px;padding:18px}.stat-value{font-size:28px;font-weight:800;margin-top:6px}.plan-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin-top:16px}.plan-card{background:var(--panel);border:1px solid var(--border);border-radius:16px;padding:20px}.plan-card.featured{border-color:var(--accent)}.price{font-size:30px;font-weight:800;margin:10px 0}.price small{font-size:13px;color:var(--muted);font-weight:400}.profile-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.notice{padding:12px 14px;border:1px solid var(--border);background:#141922;border-radius:12px;color:var(--muted);font-size:13px}.mini-badge{font-size:11px;padding:4px 8px;border-radius:999px;background:#272d3b;color:#dfe4ee}.lang-select{min-width:150px}.nav-btn.active{background:var(--accent);color:white}.builder-shell>header{display:none}
@media(max-width:900px){.stat-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.plan-grid{grid-template-columns:1fr}}@media(max-width:650px){.stat-grid,.profile-grid{grid-template-columns:1fr}}

/* ===== v19.2 page-aware scrolling ===== */
html, body{
  min-height:100%;
}

body{
  display:block !important;
  height:auto !important;
  overflow-y:auto !important;
  overflow-x:hidden !important;
}

#authScreen,
#appScreen{
  min-height:100vh;
}

#appScreen{
  overflow:visible;
}

.dashboard-wrap{
  min-height:calc(100vh - 72px);
}

/* Only the desktop Builder uses locked-body + independent column scrolling. */
@media (min-width:981px){
  body.builder-mode{
    height:100vh !important;
    overflow:hidden !important;
  }

  body.builder-mode #appScreen{
    height:100vh;
    overflow:hidden;
  }

  body.builder-mode #builderPage{
    height:calc(100vh - 64px);
    overflow:hidden;
  }

  body.builder-mode #builderMount{
    height:100%;
    overflow:hidden;
  }

  body.builder-mode #builderMount .container{
    height:100%;
    min-height:0;
    overflow:hidden;
    align-items:stretch;
  }

  body.builder-mode #builderMount .container > main,
  body.builder-mode #builderMount .container > aside{
    height:100%;
    min-height:0;
    overflow-y:auto;
    overflow-x:hidden;
    overscroll-behavior:contain;
    scrollbar-gutter:stable;
    padding-inline-end:6px;
  }

  body.builder-mode #builderMount .output{
    position:static;
    top:auto;
    align-self:stretch;
  }
}

/* Phones/tablets always scroll as a normal page. */
@media (max-width:980px){
  body,
  body.builder-mode{
    height:auto !important;
    overflow-y:auto !important;
    overflow-x:hidden !important;
  }

  #appScreen,
  #builderPage,
  #builderMount,
  #builderMount .container,
  #builderMount .container > main,
  #builderMount .container > aside{
    height:auto !important;
    overflow:visible !important;
  }
}


/* ===== v19.3 definitive root scroll fix ===== */
html{
  height:auto !important;
  min-height:100% !important;
  overflow-y:auto !important;
  overflow-x:hidden !important;
}

body{
  height:auto !important;
  min-height:100% !important;
  overflow-y:auto !important;
  overflow-x:hidden !important;
  display:block !important;
}

/* Desktop Builder: body is locked, but the two Builder columns scroll independently. */
@media (min-width:981px){
  body.builder-mode{
    height:100vh !important;
    min-height:100vh !important;
    overflow:hidden !important;
  }

  body.builder-mode #appScreen{
    height:100vh !important;
    overflow:hidden !important;
  }

  body.builder-mode #builderPage{
    height:calc(100vh - 64px) !important;
    overflow:hidden !important;
  }

  body.builder-mode #builderMount{
    height:100% !important;
    overflow:hidden !important;
  }

  body.builder-mode #builderMount .container{
    height:100% !important;
    min-height:0 !important;
    overflow:hidden !important;
  }

  body.builder-mode #builderMount .container > main,
  body.builder-mode #builderMount .container > aside{
    height:100% !important;
    min-height:0 !important;
    overflow-y:auto !important;
    overflow-x:hidden !important;
  }
}

/* Mobile/tablet: never lock either root element. */
@media (max-width:980px){
  html,
  body,
  body.builder-mode{
    height:auto !important;
    min-height:100% !important;
    overflow-y:auto !important;
    overflow-x:hidden !important;
  }
}


/* ===== v19.5: flexible Builder height + reliable full scrolling ===== */
@media (min-width:981px){
  html.builder-mode-root{
    height:100vh !important;
    min-height:100vh !important;
    overflow:hidden !important;
  }

  body.builder-mode{
    height:100vh !important;
    min-height:100vh !important;
    overflow:hidden !important;
  }

  body.builder-mode #appScreen.active{
    display:flex !important;
    flex-direction:column !important;
    height:100vh !important;
    min-height:0 !important;
    overflow:hidden !important;
  }

  body.builder-mode .app-topbar{
    position:relative !important;
    top:auto !important;
    flex:0 0 auto !important;
  }

  body.builder-mode #builderPage{
    display:block !important;
    flex:1 1 0 !important;
    min-height:0 !important;
    height:auto !important;
    overflow:hidden !important;
  }

  body.builder-mode #builderMount{
    height:100% !important;
    min-height:0 !important;
    overflow:hidden !important;
  }

  body.builder-mode #builderMount > header{
    display:none !important;
  }

  body.builder-mode #builderMount .container{
    height:100% !important;
    min-height:0 !important;
    max-height:none !important;
    overflow:hidden !important;
    box-sizing:border-box !important;
  }

  body.builder-mode #builderMount .container > main,
  body.builder-mode #builderMount .container > aside{
    height:100% !important;
    min-height:0 !important;
    max-height:none !important;
    overflow-y:auto !important;
    overflow-x:hidden !important;
    box-sizing:border-box !important;
    padding-bottom:64px !important;
    scroll-padding-bottom:64px !important;
  }
}

@media (max-width:980px){
  html,
  html.builder-mode-root,
  body,
  body.builder-mode{
    height:auto !important;
    min-height:100% !important;
    overflow-y:auto !important;
    overflow-x:hidden !important;
  }

  body.builder-mode #appScreen.active{
    display:block !important;
    height:auto !important;
    overflow:visible !important;
  }

  body.builder-mode #builderPage,
  body.builder-mode #builderMount,
  body.builder-mode #builderMount .container,
  body.builder-mode #builderMount .container > main,
  body.builder-mode #builderMount .container > aside{
    height:auto !important;
    min-height:0 !important;
    max-height:none !important;
    overflow:visible !important;
  }
}


/* ===== v19.9 compact language selector ===== */
#appLanguage{
  width:auto !important;
  min-width:108px !important;
  max-width:132px !important;
  height:34px !important;
  padding:5px 28px 5px 9px !important;
  font-size:12px !important;
  border-radius:9px !important;
  margin-inline-start:10px !important;
  margin-inline-end:2px !important;
}

.lang-divider{
  width:1px;
  height:24px;
  background:var(--border);
  opacity:.9;
  flex:0 0 auto;
  margin-inline-start:5px;
}

@media(max-width:760px){
  #appLanguage{
    min-width:100px !important;
    max-width:116px !important;
    font-size:11px !important;
    margin-inline-start:5px !important;
  }
  .lang-divider{display:none}
}


/* v19.31 Wallet & UX */
#authLanguage{
  width:250px;
  min-width:250px;
  max-width:290px;
  padding:9px 36px 9px 12px;
  font-size:13px;
}
.wallet-balance-chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-width:112px;
  min-height:38px;
  padding:9px 15px;
  border:2px solid var(--border);
  border-radius:999px;
  background:var(--panel);
  font-size:16px;
  font-weight:800;
  line-height:1;
  white-space:nowrap;
  box-shadow:0 2px 8px rgba(0,0,0,.08);
}
.wallet-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
  margin:16px 0;
}
.wallet-card{
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--panel);
  padding:16px;
}
.wallet-card .wallet-label{
  font-size:12px;
  opacity:.72;
  margin-bottom:6px;
}
.wallet-card .wallet-value{
  font-size:26px;
  font-weight:800;
}
.topup-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:10px;
  margin-top:12px;
}
.topup-grid button{width:100%}
.wallet-custom-row{
  display:flex;
  gap:10px;
  align-items:end;
  margin-top:14px;
}
.wallet-custom-row > div{flex:1}
.wallet-history{
  margin-top:16px;
  border-top:1px solid var(--border);
  padding-top:12px;
}
.wallet-history-row{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:9px 0;
  border-bottom:1px dashed var(--border);
  font-size:13px;
}
.wallet-history-row:last-child{border-bottom:none}
.wallet-positive{font-weight:700}
.wallet-negative{font-weight:700}
.wallet-warning{
  margin-top:12px;
  padding:11px 12px;
  border:1px solid var(--border);
  border-radius:10px;
  font-size:12px;
}
@media(max-width:900px){
  #appLanguage,#authLanguage{width:190px;min-width:190px}
  .wallet-grid{grid-template-columns:1fr}
  .topup-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:620px){
  #appLanguage,#authLanguage{width:100%;min-width:0;max-width:none}
  .wallet-custom-row{flex-direction:column;align-items:stretch}
}


/* v19.33 Security UX */
.password-wrap{position:relative}
.password-wrap input{padding-inline-end:68px}
.password-toggle{
  position:absolute;
  inset-inline-end:7px;
  top:50%;
  transform:translateY(-50%);
  border:0;
  background:transparent;
  padding:5px 7px;
  font-size:11px;
  cursor:pointer;
  opacity:.75;
}
.password-meter{
  height:6px;
  border-radius:999px;
  background:var(--border);
  overflow:hidden;
  margin-top:7px;
}
.password-meter > span{
  display:block;
  height:100%;
  width:0%;
  background:currentColor;
  transition:width .18s ease;
}
.security-hint{
  margin-top:6px;
  font-size:11px;
  line-height:1.45;
  opacity:.75;
}
.security-status-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
  margin-top:12px;
}
.security-status{
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
}
.security-status strong{display:block;margin-bottom:4px}
.security-badge{
  display:inline-flex;
  margin-top:6px;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  font-size:11px;
  font-weight:700;
}
@media(max-width:700px){
  .security-status-grid{grid-template-columns:1fr}
  .wallet-balance-chip{min-width:96px;font-size:15px;padding:8px 12px}
}
