/* Sing Along room chrome — uses shared parchment tokens from css/sangeet-theme.css.
   Pitch-feedback greens/magentas stay intentional (colorblind-safe). */

:root {
  --panel2: #f3e6cf;
  --good: #22d17c;
  --good2: #0ea862;
  --bad: #ff2d9b;
  --warn: #b5451d;
  --accent: var(--terra);
  --accent2: var(--terra-soft);
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 20px 120px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
body.sangeet-has-practice-bar #app {
  padding-bottom: 130px;
}
@media (max-width: 820px) {
  body.sangeet-has-practice-bar #app {
    padding-bottom: 150px;
  }
}
.pt-topnav {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.pt-topnav a { color: var(--terra); text-decoration: none; font-weight: 600; }
.pt-topnav a:hover { color: var(--terra-soft); }
.pt-brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  color: var(--terra);
  line-height: 1.1;
}
.pt-desc {
  margin: 0;
  max-width: 40rem;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--ink);
}

header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.title h1,
.title h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 600;
  color: var(--ink);
}
.title .sub { color: var(--muted); font-size: 13px; }
#scoreboard { display: flex; gap: 10px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 14px;
  min-width: 92px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat .num { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
#onPitch { color: var(--good2); }

#library { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
#library .grow { min-width: 220px; }
#library .grow2 { flex: 1; min-width: 260px; }
#library input[type=text],
#libraryAdd input[type=text] {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 14px;
  width: 100%;
}
#library select { width: 100%; }
#libraryAdd {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
#libraryAdd.hidden,
#delBtn.hidden,
#cleanup.hidden,
#liveLibraryNote.hidden,
#song-save-disclaimer.hidden,
#singLocalUI.hidden { display: none; }
.sing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.sing-actions .btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.sing-actions .btn:hover,
a.btn:hover { border-color: var(--terra); }
.sing-actions .btn.primary,
a.btn.primary {
  background: var(--terra);
  border-color: var(--terra);
  color: #fff;
}
.sing-steps {
  margin: 8px 0 0;
  padding-left: 1.25rem;
}
.sing-steps li { margin: 0.35rem 0; }
#libraryAdd .grow { min-width: 220px; }
#libraryAdd .grow2 { flex: 1; min-width: 260px; }
#addBtn {
  background: var(--terra);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  height: 38px;
  padding: 0 16px;
  cursor: pointer;
}
#addBtn:hover { background: var(--terra-soft); }
.opt { color: var(--muted); font-weight: 400; font-size: 10px; }
.jobstatus { color: var(--warn); font-size: 13px; min-height: 18px; align-self: center; }
.jobstatus.ok { color: var(--good2); }
.jobstatus.err { color: var(--bad); }
.job-progress {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 0 0 10px;
}
.job-progress.hidden { display: none !important; }
.job-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--terra);
  transition: width .25s ease;
}
.rhythm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#rhythmTaal { min-width: 140px; }
#rhythmMeta { white-space: nowrap; }

/* Pitch stage stays dark for contrast against the highway */
#stage {
  position: relative;
  background: linear-gradient(180deg, #1e463b, #122820);
  border: 1px solid var(--leaf-deep);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
#hud { display: block; width: 100%; height: 460px; }
#overlay { position: absolute; top: 12px; right: 16px; display: flex; gap: 10px; pointer-events: none; }
#bignote, #yournote {
  background: rgba(30, 70, 59, 0.82);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(240, 217, 168, 0.25);
  border-radius: 14px;
  padding: 8px 14px;
  text-align: center;
  min-width: 78px;
  color: var(--mist);
}
#bignote span, #yournote span { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; }
#bignote em, #yournote em { display: block; font-style: normal; font-size: 14px; font-weight: 700; line-height: 1.2; }
#bignote small, #yournote small { color: var(--sand); font-size: 10px; text-transform: uppercase; letter-spacing: .6px; }
#targetNote { color: var(--glow); }
#targetSa { color: #9fc0ff; }
#userNote { color: var(--good); }
#userSa { color: #7fe6b4; }

#countdown {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 120px; font-weight: 800; color: #fff;
  text-shadow: 0 8px 40px rgba(47, 107, 90, 0.6);
  background: rgba(18, 40, 32, 0.35);
}
#micWarn {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(181, 69, 29, 0.14);
  border: 1px solid var(--terra);
  color: var(--terra);
  padding: 6px 12px; border-radius: 10px; font-size: 13px;
}
.hidden { display: none !important; }

#seekrow { display: flex; align-items: center; gap: 12px; }
#seekrow span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; min-width: 38px; text-align: center; }
#seek { flex: 1; accent-color: var(--terra); height: 6px; cursor: pointer; }

#lyrics {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  text-align: center;
}
.lyr { transition: .2s; }
.lyr.prev { color: var(--muted); font-size: 14px; opacity: .6; }
.lyr.cur { color: var(--ink); font-size: 24px; font-weight: 700; line-height: 1.25; }
.lyr.cur .w { opacity: .45; transition: .12s; }
.lyr.cur .w.on { opacity: 1; color: var(--terra); }
.lyr.next { color: var(--muted); font-size: 15px; opacity: .8; }
#lyrics.empty { display: none; }

#sargamLine {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  overflow: hidden;
}
#sargamLine.empty { display: none; }
.sargam-scroll {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding: 2px 0;
  -webkit-overflow-scrolling: touch;
}
.sargam-scroll .tok {
  flex: 0 0 auto;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  opacity: 0.4;
  padding: 2px 4px;
  border-radius: 6px;
  transition: .12s;
}
.sargam-scroll .tok.on {
  opacity: 1;
  background: color-mix(in srgb, var(--ochre) 35%, transparent);
  font-weight: 700;
}
.sargam-scroll .tok.name-komal {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.sargam-scroll .tok.name-tivra {
  position: relative;
}
.sargam-scroll .tok.name-tivra::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 1.5px;
  height: 0.45em;
  background: var(--ink);
  transform: translate(-50%, -15%);
}
#bignote em.name-komal, #yournote em.name-komal {
  text-decoration: underline;
  text-underline-offset: 2px;
}
#bignote em.name-tivra, #yournote em.name-tivra {
  position: relative;
}
#bignote em.name-tivra::before, #yournote em.name-tivra::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 1.5px;
  height: 0.4em;
  background: currentColor;
  transform: translate(-50%, -20%);
}

#results {
  position: fixed; inset: 0;
  background: rgba(61, 43, 31, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 24px;
}
.results-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px 26px;
  width: min(760px, 96%);
  max-height: 96%;
  overflow: auto;
  box-shadow: var(--shadow);
}
.res-close { position: absolute; top: 12px; right: 12px; background: transparent; border: none; color: var(--muted); font-size: 18px; padding: 4px 8px; cursor: pointer; }
.grade {
  font-size: 64px; font-weight: 900; text-align: center; line-height: 1;
  background: linear-gradient(90deg, var(--good2), var(--terra));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.results-card h2 { text-align: center; margin: 6px 0 14px; font-weight: 700; font-family: var(--font-display); }
.res-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.rs { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.rs span { display: block; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rs small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
#resCanvas {
  display: block; width: 100%; height: 160px;
  background: #122820;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 14px;
}
.res-phrases h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.res-phrases ul { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.res-phrases li {
  display: flex; justify-content: space-between; gap: 12px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 14px;
}
.res-phrases li .pct { font-weight: 800; font-variant-numeric: tabular-nums; }
.res-phrases li .lo { color: var(--bad); }
.res-phrases li .mid { color: var(--warn); }
.res-actions { display: flex; gap: 10px; justify-content: center; }

#pt-transport { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
#settings { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
button {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: .15s;
  font-family: var(--font-sans);
}
button:hover { border-color: var(--terra); transform: translateY(-1px); }
button.primary { background: var(--terra); color: #fff; border-color: var(--terra); font-weight: 700; }
button.primary:hover { background: var(--terra-soft); }
button.live { background: var(--green); color: #fff; border-color: var(--green); }
.ctl {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px 12px;
}
.ctl select, .ctl input[type=range] { accent-color: var(--terra); }
.ctl select {
  background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px;
}
.ctl span { color: var(--ink); font-weight: 700; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.rec-toggle {
  display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 12px; cursor: pointer;
}
.rec-toggle input { accent-color: var(--terra); width: 16px; height: 16px; cursor: pointer; }
.rec-toggle .opt { color: var(--muted); font-size: 11px; }
#recbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 14px;
}
#recbar .rec-label { color: var(--ink); font-weight: 700; font-size: 13px; white-space: nowrap; }
#recbar audio { flex: 1; height: 34px; }
#recbar a { color: var(--terra); text-decoration: none; font-size: 13px; white-space: nowrap; }
#recbar a:hover { text-decoration: underline; }
#cleanup { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; }
#cleanup summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink); list-style: none; }
#cleanup summary::-webkit-details-marker { display: none; }
#cleanup summary .opt { font-weight: 400; color: var(--muted); font-size: 12px; }
.cleanup-body { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 12px; }
.cleanup-body .ctl { min-width: 170px; }
.cleanup-body .ctl small { color: var(--muted); font-size: 10px; font-weight: 400; }
.cleanup-actions { display: flex; align-items: center; gap: 10px; }
#delBtn:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
#delBtn:disabled { opacity: .4; cursor: not-allowed; }

#app.riyaz-mode #scoreboard { display: none; }
#riyazControls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
#riyazControls .ctl { min-width: 130px; }

#rzStage {
  position: relative;
  background: linear-gradient(180deg, #1e463b, #122820);
  border: 1px solid var(--leaf-deep);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
#rzHud { display: block; width: 100%; height: 360px; }
#rzOverlay {
  position: absolute; top: 12px; right: 16px;
  display: flex; gap: 10px; pointer-events: none;
}
.rz-bignote, .rz-yournote {
  background: rgba(30, 70, 59, 0.82);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(240, 217, 168, 0.25);
  border-radius: 14px;
  padding: 8px 14px;
  text-align: center;
  min-width: 78px;
  color: var(--mist);
}
.rz-bignote span, .rz-yournote span { display: block; font-size: 22px; font-weight: 800; line-height: 1.1; }
.rz-bignote em, .rz-yournote em { display: block; font-style: normal; font-size: 13px; font-weight: 700; line-height: 1.2; }
.rz-bignote small, .rz-yournote small { color: var(--sand); font-size: 10px; text-transform: uppercase; letter-spacing: .6px; }
#rzTargetNote { color: var(--glow); }
#rzTargetSa { color: #9fc0ff; }
#rzUserNote { color: var(--good); }
#rzUserSa { color: #7fe6b4; }
#rzMicWarn {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  background: rgba(181, 69, 29, 0.14);
  border: 1px solid var(--terra);
  color: var(--terra);
  padding: 6px 12px; border-radius: 10px; font-size: 13px;
  white-space: nowrap;
}

#rzSheet {
  display: flex; flex-wrap: wrap; gap: 6px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; min-height: 52px;
}
.swar-chip {
  min-width: 34px; text-align: center; padding: 6px 8px; border-radius: 8px;
  font-size: 16px; font-weight: 700; background: var(--panel2);
  border: 1px solid var(--line); color: var(--ink); font-variant-numeric: tabular-nums;
}
.swar-chip.rest { color: var(--muted); font-weight: 400; }
.swar-chip.bad { border-color: var(--bad); color: var(--bad); }
.swar-chip.cur { background: var(--green); color: #fff; border-color: var(--green); }
#rzEditor { display: flex; flex-direction: column; gap: 6px; }
#rzEditor .ed-label { font-size: 13px; color: var(--ink); font-weight: 600; }
#rzEditor .ed-label .opt { color: var(--muted); font-weight: 400; font-size: 11px; }
#rzText {
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
  font: 15px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 1px; resize: vertical;
}
.rz-warn { color: var(--bad); font-size: 12px; min-height: 14px; }
.custom-save-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 4px 0 2px;
}
.custom-save-row input[type="text"] {
  flex: 1 1 160px;
  min-width: 140px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}
.custom-save-row button {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.custom-save-row button:hover { border-color: var(--terra); }
.custom-save-row button.primary {
  background: var(--terra);
  color: #fff;
  border-color: var(--terra);
}
.save-note {
  margin: 4px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--ochre);
  background: #fbf1da;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #5a4a34;
}
.save-note code {
  font-size: 0.9em;
  color: var(--ink);
}
#rzSavedList {
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.custom-saved-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.custom-saved-item.active {
  border-color: var(--ochre);
  background: #faf3e0;
}
.custom-saved-item .name {
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.custom-saved-item .name:hover { color: var(--terra); }
.custom-saved-item .meta { color: var(--muted); font-size: 0.8rem; }
.custom-saved-item .actions { display: flex; gap: 6px; }
.custom-saved-item .actions button {
  padding: 4px 8px;
  font-size: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--ink);
  cursor: pointer;
}
.custom-saved-item .actions button:hover { border-color: var(--terra); }
.custom-saved-item .actions button.danger:hover { border-color: #a33; color: #a33; }
.rz-save-status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.88rem;
  color: var(--muted);
}
#rzTransport { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
#rzTransport button.on { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }

@media (max-width: 720px) {
  header { flex-direction: column; align-items: flex-start; }
  #hud { height: 360px; }
  #rzHud { height: 280px; }
  .res-stats { grid-template-columns: repeat(2, 1fr); }
}
