:root {
  --bg:#0f1115;
  --panel:#171a20;
  --panel2:#1f232b;
  --panel3:#252a34;
  --text:#f5f7fb;
  --muted:#9ca4b4;
  --line:#2a303a;
  --accent:#4f8cff;
  --ok:#75d59a;
  --warning:#f0bb62;
  --danger:#ff6b6b;
}

* { box-sizing:border-box; }
html, body { width:100%; max-width:100%; overflow-x:hidden; }
html { scroll-behavior:smooth; }

body {
  margin:0;
  min-height:100vh;
  background:var(--bg);
  color:var(--text);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
body.menu-open { overflow:hidden; }

button,input,select,textarea { font:inherit; }
button { color:inherit; }
button,a { -webkit-tap-highlight-color:transparent; }

.hidden { display:none !important; }
.muted { color:var(--muted); }
.spacer { flex:1; }
.row { display:flex; gap:12px; align-items:center; }
.row.wrap { flex-wrap:wrap; }

.sidebar {
  position:fixed;
  inset:0 auto 0 0;
  width:min(310px,86vw);
  background:#0b0d11;
  border-right:1px solid var(--line);
  padding:max(22px,env(safe-area-inset-top)) 18px max(22px,env(safe-area-inset-bottom));
  z-index:1000;
  transform:translateX(-105%);
  transition:transform .2s ease;
  display:flex;
  flex-direction:column;
}
.sidebar.open { transform:translateX(0); }

.sidebar-backdrop {
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.62);
  backdrop-filter:blur(3px);
  z-index:999;
  opacity:0;
  pointer-events:none;
  transition:opacity .18s ease;
}
.sidebar-backdrop.visible { opacity:1; pointer-events:auto; }

.sidebar-header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}
.brand { font-weight:900; letter-spacing:.08em; font-size:20px; }
.brand span { color:var(--accent); }

.menu-close {
  width:42px;
  height:42px;
  border:1px solid var(--line);
  border-radius:50%;
  background:var(--panel2);
  font-size:26px;
  line-height:1;
  cursor:pointer;
}

.sidebar nav { display:grid; gap:7px; margin-top:32px; }
.sidebar nav a {
  display:flex;
  align-items:center;
  gap:12px;
  min-height:50px;
  padding:11px 13px;
  border-radius:10px;
  color:var(--muted);
  text-decoration:none;
  font-weight:650;
}
.sidebar nav a:hover,
.sidebar nav a.active { background:var(--panel2); color:var(--text); }
.nav-icon { width:26px; color:var(--accent); text-align:center; font-size:19px; }
.sidebar-footer { margin-top:auto; color:var(--muted); font-size:12px; }

.app,
.view,
.player-shell,
.player-shell > *,
.card,
.transport-card,
.sections-block,
.section-markers,
.mixer,
.lyrics-card,
.table-wrap {
  min-width:0;
  max-width:100%;
}

.app {
  width:min(1420px,100%);
  min-height:100vh;
  margin:0 auto;
  padding:24px clamp(18px,3vw,42px) 70px;
}

.topbar {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  margin-bottom:24px;
}
.topbar-left { display:flex; align-items:center; gap:15px; min-width:0; }
.title-wrap { min-width:0; }

.hamburger {
  width:46px;
  height:46px;
  flex:0 0 46px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  gap:5px;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--panel);
  cursor:pointer;
}
.hamburger span { width:20px; height:2px; border-radius:999px; background:var(--text); }

.eyebrow {
  margin:0 0 3px;
  color:var(--muted);
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.12em;
}
h1,h2,h3,p { margin-top:0; }
.topbar h1 {
  margin:0;
  font-size:clamp(21px,3vw,28px);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.status-pill {
  padding:8px 12px;
  border:1px solid var(--line);
  border-radius:999px;
  color:var(--muted);
  font-size:12px;
  white-space:nowrap;
}
.status-pill.ok { color:var(--ok); border-color:#305740; }

.error-banner {
  background:#321b20;
  color:#ffb6c0;
  border:1px solid #6c303b;
  border-radius:10px;
  padding:12px 14px;
  margin-bottom:16px;
}

.card {
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:14px;
  padding:18px;
}

.btn {
  min-height:42px;
  border:0;
  border-radius:9px;
  padding:10px 14px;
  cursor:pointer;
  font-weight:650;
}
.btn.primary,.primary { background:var(--accent); color:#fff; }
.btn.secondary,.secondary { background:var(--panel2); color:var(--text); }
.btn:disabled { opacity:.45; cursor:not-allowed; }

.chip {
  display:inline-flex;
  align-items:center;
  font-size:12px;
  padding:5px 8px;
  border-radius:999px;
  background:var(--panel2);
  color:var(--muted);
}
.meta { display:flex; gap:7px; flex-wrap:wrap; }
.loading { color:var(--muted); padding:18px 0; }

/* Home */
.home-intro { margin-bottom:20px; color:var(--muted); max-width:680px; line-height:1.55; }
.home-menu { border-top:1px solid var(--line); }
.home-option {
  width:100%;
  display:grid;
  grid-template-columns:42px 1fr auto;
  gap:14px;
  align-items:center;
  padding:18px 4px;
  border:0;
  border-bottom:1px solid var(--line);
  background:transparent;
  text-align:left;
  cursor:pointer;
}
.home-option:hover { background:rgba(255,255,255,.025); }
.home-option-icon { font-size:22px; text-align:center; color:var(--accent); }
.home-option strong { display:block; margin-bottom:4px; }
.home-option small { color:var(--muted); line-height:1.45; }
.home-option-arrow { color:var(--muted); font-size:18px; }

/* Song library */
.grid {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(250px,1fr));
  gap:14px;
}
.song-card { cursor:pointer; transition:.14s ease; }
.song-card:hover { transform:translateY(-2px); border-color:#3b4655; }
.song-card h3 { margin-bottom:5px; }
.song-card p { margin-bottom:13px; }

/* Player */
.player-shell {
  display:grid;
  grid-template-columns:minmax(0,1.65fr) minmax(300px,.75fr);
  gap:18px;
  align-items:start;
}
.player-card,.lyrics-card { min-height:420px; }

.key-control {
  display:flex;
  justify-content:center;
  align-items:center;
  gap:18px;
  padding:20px 0;
}
.key-big {
  font-size:clamp(48px,7vw,64px);
  line-height:1;
  font-weight:900;
  min-width:110px;
  text-align:center;
}
.semitone-label { text-align:center; color:var(--muted); margin-top:8px; font-size:13px; }
.icon-btn {
  width:50px;
  height:50px;
  flex:0 0 50px;
  border-radius:50%;
  border:1px solid var(--line);
  background:var(--panel2);
  font-size:27px;
  cursor:pointer;
}

.transport-card { background:var(--panel2); margin-bottom:16px; }
.transport-top { display:flex; align-items:center; gap:12px; margin-bottom:10px; }
#play-button { min-width:96px; }
.time-display { color:var(--muted); font-size:13px; font-variant-numeric:tabular-nums; }
.seek-wrap { width:100%; min-width:0; overflow:hidden; }
#seek-bar { display:block; width:100%; max-width:100%; height:30px; margin:0; accent-color:var(--accent); }
.audio-status { margin-top:7px; color:var(--muted); font-size:12px; }

.sections-block { margin-top:15px; padding-top:13px; border-top:1px solid var(--line); overflow:hidden; }
.sections-heading { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:9px; }
.sections-heading strong { font-size:14px; }
.current-section { color:var(--accent); font-size:13px; font-weight:750; }
.section-markers { display:flex; flex-wrap:wrap; gap:7px; width:100%; overflow:hidden; }
.section-marker {
  min-height:35px;
  border:1px solid var(--line);
  background:#15191f;
  color:var(--muted);
  border-radius:999px;
  padding:7px 10px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:7px;
  font-size:12px;
  white-space:nowrap;
}
.section-marker.active { color:#fff; background:var(--accent); border-color:var(--accent); }
.marker-time { opacity:.72; font-variant-numeric:tabular-nums; }

.mixer-header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-top:20px;
  margin-bottom:8px;
}
.mixer-header h3 { margin:0; font-size:16px; }
.mixer-note { color:var(--muted); font-size:12px; margin-bottom:12px; }
.mixer { display:grid; gap:9px; }
.mix-row {
  display:grid;
  grid-template-columns:120px minmax(0,1fr) 56px;
  gap:10px;
  align-items:center;
  padding:10px 11px;
  background:var(--panel2);
  border-radius:10px;
}
.mix-label { font-size:13px; font-weight:650; }
.mix-row input[type="range"] { width:100%; max-width:100%; min-width:0; height:30px; accent-color:var(--accent); }
.mix-value { text-align:right; color:var(--muted); font-size:12px; font-variant-numeric:tabular-nums; }

.lyrics-card { position:sticky; top:20px; }
.lyrics { white-space:pre-wrap; line-height:1.75; color:#d9deea; max-height:calc(100vh - 150px); overflow:auto; }

/* Planning Center */
.pco-note {
  color:var(--muted);
  font-size:12px;
  margin-bottom:16px;
}
.plan-heading {
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:18px;
  margin-bottom:14px;
  padding-bottom:14px;
  border-bottom:1px solid var(--line);
}
.plan-heading h2 { margin-bottom:3px; }
.plan-heading p { margin:0; color:var(--muted); font-size:13px; }

.plan-table {
  width:100%;
  border-collapse:collapse;
}
.plan-table th,
.plan-table td {
  text-align:left;
  padding:12px 10px;
  border-bottom:1px solid var(--line);
  vertical-align:middle;
}
.plan-table th {
  color:var(--muted);
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.08em;
  font-weight:700;
}
.plan-row { cursor:pointer; }
.plan-row:hover { background:rgba(255,255,255,.025); }
.plan-row.unlinked {
  cursor:default;
  opacity:.42;
}
.plan-song-title { font-weight:700; }
.plan-subtle { color:var(--muted); font-size:12px; }
.plan-open { color:var(--accent); text-align:right; }
.empty-state { color:var(--muted); padding:22px 0; border-bottom:1px solid var(--line); }

/* Team key chart */
.table-wrap { overflow:auto; border:1px solid var(--line); border-radius:12px; -webkit-overflow-scrolling:touch; }
table { width:100%; border-collapse:collapse; min-width:720px; }
th,td { padding:12px 14px; border-bottom:1px solid var(--line); text-align:left; }
th { background:#12151a; color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.08em; }
td.editable { cursor:pointer; }
td.editable:hover { background:var(--panel2); }

/* Dialog */
dialog { border:0; border-radius:16px; padding:0; background:transparent; color:var(--text); }
dialog::backdrop { background:#000b; backdrop-filter:blur(3px); }
.dialog-card {
  width:min(420px,calc(100vw - 30px));
  background:var(--panel);
  border:1px solid var(--line);
  padding:20px;
  border-radius:16px;
}
.dialog-card label { display:grid; gap:6px; margin:14px 0; }
.dialog-card select {
  min-height:46px;
  width:100%;
  background:#11151a;
  color:var(--text);
  border:1px solid var(--line);
  border-radius:10px;
  padding:10px;
}
.dialog-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:18px; }

@media(max-width:960px) {
  .player-shell { grid-template-columns:1fr; }
  .lyrics-card { position:static; }
  .lyrics { max-height:520px; }
}

@media(max-width:640px) {
  .app {
    padding:max(14px,env(safe-area-inset-top)) 12px calc(48px + env(safe-area-inset-bottom));
  }

  .topbar { gap:8px; margin-bottom:16px; }
  .topbar-left { gap:10px; }
  .hamburger { width:42px; height:42px; flex-basis:42px; border-radius:10px; }
  .topbar h1 { font-size:19px; }
  .eyebrow { font-size:10px; }

  .status-pill {
    width:10px;
    height:10px;
    flex:0 0 10px;
    padding:0;
    border:0;
    border-radius:50%;
    background:var(--warning);
    font-size:0;
  }
  .status-pill.ok { background:var(--ok); }

  .grid { grid-template-columns:1fr; gap:10px; }
  .card { padding:14px; border-radius:12px; }
  .song-card:hover { transform:none; }

  .home-option {
    grid-template-columns:36px minmax(0,1fr) 18px;
    gap:10px;
    padding:16px 2px;
  }

  .player-shell { width:100%; gap:12px; overflow:hidden; }
  .player-card,.lyrics-card { width:100%; min-height:0; overflow:hidden; }
  .player-card h2 { font-size:22px; margin-bottom:5px; }

  .key-control { padding:15px 0 12px; gap:15px; }
  .key-big { min-width:88px; font-size:48px; }
  .icon-btn { width:46px; height:46px; flex-basis:46px; }

  .key-actions {
    display:grid !important;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    gap:8px !important;
    width:100%;
  }
  .key-actions .btn { width:100%; min-width:0; padding-left:8px; padding-right:8px; }

  .transport-card { padding:12px; width:100%; overflow:hidden; }
  .transport-top { justify-content:space-between; }
  #play-button { min-width:100px; min-height:45px; }
  .time-display { min-width:0; font-size:11px; }
  #seek-bar { width:100%; max-width:100%; height:38px; }

  .section-markers {
    width:100%;
    max-width:100%;
    flex-wrap:nowrap;
    overflow-x:auto;
    overflow-y:hidden;
    overscroll-behavior-x:contain;
    padding:2px 0 7px;
    -webkit-overflow-scrolling:touch;
  }
  .section-marker { flex:0 0 auto; min-height:39px; }

  .mixer-header { margin-top:18px; }
  .mixer-header .btn { min-height:35px; padding:7px 9px; font-size:12px; }
  .mix-row {
    width:100%;
    grid-template-columns:minmax(0,1fr) 48px;
    grid-template-areas:"label value" "slider slider";
    gap:2px 9px;
    padding:9px 10px;
  }
  .mix-label { grid-area:label; }
  .mix-row input[type="range"] { grid-area:slider; width:100%; height:38px; }
  .mix-value { grid-area:value; }

  .lyrics { max-height:none; overflow:visible; font-size:15px; line-height:1.8; }

  .plan-heading { display:block; }
  .plan-heading .plan-meta-right { margin-top:6px; }
  .plan-table { table-layout:fixed; }
  .plan-table th,
  .plan-table td { padding:11px 6px; }
  .plan-table th:nth-child(1),
  .plan-table td:nth-child(1) { width:48%; }
  .plan-table th:nth-child(2),
  .plan-table td:nth-child(2) { width:17%; }
  .plan-table th:nth-child(3),
  .plan-table td:nth-child(3) { width:27%; }
  .plan-table th:nth-child(4),
  .plan-table td:nth-child(4) { width:8%; }
  .plan-song-title,
  .plan-subtle {
    display:block;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }

  .dialog-actions { display:grid; grid-template-columns:1fr 1fr; }
  .dialog-actions .btn { width:100%; }
}

@media(max-width:390px) {
  .topbar h1 { font-size:17px; }
  .key-big { font-size:44px; }
}


/* ============================================================
   WORSHIP TEAM CHART - MOBILE FROZEN SONG COLUMN
============================================================ */

.team-key-table th:first-child,
.team-key-table td:first-child {
  min-width:180px;
}

@media(max-width:640px) {
  .table-wrap {
    max-width:100%;
    overflow-x:auto;
    overflow-y:visible;
    overscroll-behavior-x:contain;
    touch-action:pan-x pan-y;
  }

  .team-key-table {
    border-collapse:separate;
    border-spacing:0;
  }

  .team-key-table th:first-child,
  .team-key-table td:first-child {
    position:sticky;
    left:0;
    min-width:155px;
    max-width:155px;
  }

  .team-key-table th:first-child {
    z-index:4;
    background:#12151a;
  }

  .team-key-table td:first-child {
    z-index:3;
    background:var(--panel);
    box-shadow:10px 0 14px -14px rgba(0,0,0,.95);
  }
}
