:root {
  --navy: #0a2769;
  --navy-deep: #061a4a;
  --navy-soft: #143580;
  --gold: #b28d34;
  --gold-ink: #6b5420;
  --ink: #1f2937;
  --ink-soft: #5b6678;
  --mist: #eef1f6;
  --line: #d9dee8;
  --paper: #f7f8fb;
  --white: #fff;
  --red: #c2410c;
  --green: #15803d;
  --radius: 10px;
  --font: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-weight: 300;
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.error { color: var(--red); font-size: 14px; }

/* Wordmark */
.wordmark { font-weight: 700; font-size: 22px; letter-spacing: -0.02em; color: var(--white); }
.wordmark .k { color: var(--gold); }
.wordmark small { font-weight: 300; font-size: 14px; opacity: .75; margin-left: 6px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--navy); padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--navy-deep); padding: 32px; border-radius: 16px; color: var(--white); }
.login-card .muted { color: rgba(255,255,255,.65); margin: 6px 0 22px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: rgba(255,255,255,.8); }
.login-card input { margin-top: 6px; width: 100%; background: var(--navy-soft); border: 1px solid transparent; color: var(--white); }
.login-card input:focus { border-color: var(--gold); }
.login-card .btn { width: 100%; margin-top: 8px; }

/* App frame */
.app { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.side {
  background: var(--navy);
  color: var(--white);
  padding: 24px 18px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
}
.main { padding: 36px 44px 80px; max-width: 1100px; }

/* On-air panel */
.onair { display: grid; grid-template-columns: 64px minmax(0, 1fr); overflow: hidden; gap: 12px; background: var(--navy-deep); border-radius: 12px; padding: 12px; align-items: center; }
.onair-art { width: 64px; height: 64px; border-radius: 8px; overflow: hidden; background: var(--navy-soft); }
.onair-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.onair-label { font-size: 11px; color: var(--gold); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.onair-label .dot { width: 7px; height: 7px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.25); }
.onair-title { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.onair-artist, .onair-listeners { font-size: 12px; color: rgba(255,255,255,.65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Nav */
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: rgba(255,255,255,.78); text-decoration: none; padding: 9px 12px; border-radius: 8px; font-weight: 400; display: flex; justify-content: space-between; align-items: center; }
.nav a:hover { background: var(--navy-soft); color: var(--white); }
.nav a.active { background: var(--gold); color: var(--navy-deep); font-weight: 500; }
.badge { background: var(--red); color: var(--white); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.nav a.active .badge { background: var(--navy-deep); color: var(--gold); }
.side-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.side-foot .muted { color: rgba(255,255,255,.55); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { background: none; border: 0; color: var(--gold); cursor: pointer; font: inherit; font-size: 13px; padding: 0; }

/* Page headers */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 10px; }
.page-head p { margin: 4px 0 0; color: var(--ink-soft); max-width: 60ch; }

/* Buttons */
.btn { font: inherit; font-weight: 500; font-size: 14px; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--white); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--ink-soft); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--navy-deep); }
.btn.primary:hover { background: #c49d3e; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .nav a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Forms */
input, textarea, select { font: inherit; font-weight: 300; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--white); color: var(--ink); width: 100%; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.tall { min-height: 260px; }
.field { display: block; margin-bottom: 16px; font-size: 13px; font-weight: 500; color: var(--ink); }
.field > input, .field > textarea, .field > select { margin-top: 6px; }
.field .help { display: block; font-weight: 300; color: var(--ink-soft); margin-top: 5px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; margin-bottom: 16px; }
.check input { width: auto; }
input[type=radio], input[type=checkbox] { width: auto; padding: 0; flex: none; margin: 0; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.actions .spacer { flex: 1; }

/* Layout: list + editor */
.split { display: grid; grid-template-columns: 340px 1fr; gap: 28px; align-items: start; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.list { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; gap: 2px; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--mist); }
.list-item.active { background: var(--mist); box-shadow: inset 3px 0 0 var(--gold); }
.list-item .t { font-weight: 500; font-size: 14px; }
.list-item .m { font-size: 12px; color: var(--ink-soft); display: flex; gap: 8px; }
.pill { font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 999px; background: var(--mist); color: var(--ink-soft); }
.pill.live { background: #dcfce7; color: var(--green); }
.pill.draft { background: #fef3c7; color: var(--gold-ink); }
.pill.new { background: #fee2e2; color: var(--red); }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-soft); }

/* Overview cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .n { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.recent-list { display: grid; gap: 8px; }
.recent-list .r { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.recent-list img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--mist); }
.recent-list .time { color: var(--ink-soft); font-size: 12px; }

/* Prayer */
.prayer-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; }
.prayer-card .who { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.prayer-card .req { white-space: pre-wrap; font-size: 15px; }
.prayer-card .actions { margin-top: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.filters .btn.on { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* Upload */
.upload { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.upload img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--mist); }
.upload input[type=file] { width: auto; padding: 6px; }
.progress { height: 4px; background: var(--mist); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--gold); width: 0; transition: width .2s; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy-deep); color: var(--white); padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 30px rgba(18,24,38,.3); }

.side-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.menu-btn { display: none; font: inherit; font-size: 14px; font-weight: 500; color: var(--navy-deep); background: var(--gold); border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; }

/* Phones and small tablets: a slim top bar; the menu opens on tap. */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; max-height: 100vh; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; gap: 12px; }
  .menu-btn { display: inline-block; }
  .side .onair { display: none; }
  .side .nav, .side .side-foot { display: none; }
  .side.open { overflow-y: auto; }
  .side.open .nav, .side.open .side-foot { display: flex; }
  .side.open .onair { display: grid; }
  .main { padding: 18px 16px 80px; max-width: none; }
  .split, .row { grid-template-columns: 1fr; }
  .split { gap: 16px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .page-head h1 { font-size: 24px; }
  .panel { padding: 16px; }
  table { display: block; overflow-x: auto; }
  input, textarea, select { font-size: 16px; } /* stops iPhone zooming into fields */
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Song likes */
.likes-table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.likes-table th, .likes-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.likes-table th { font-weight: 500; color: var(--ink-soft); font-size: 12px; }
.likes-table td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.likes-table img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--mist); display: block; }
.bar { height: 6px; background: var(--mist); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); }

/* Verse backgrounds gallery */
.bg-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.bg-item { width: 90px; display: grid; gap: 4px; }
.bg-item img { width: 90px; height: 160px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--mist); }
.prayer-card.muted { opacity: .6; color: inherit; }

.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.roles div { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--line, #e3e6ee); border-radius: 10px; }
.btn.link { background: none; border: 0; color: rgba(255,255,255,.75); text-decoration: underline; padding: 0; }
.nav a.hidden { display: none; }
code { background: rgba(0,0,0,.06); padding: 2px 6px; border-radius: 6px; font-size: 13px; }

/* Covers */
.toggle { margin: 0; white-space: nowrap; font-weight: 500; }
.help-line { color: var(--ink-soft); margin: -12px 0 16px; font-size: 13px; }
.filters { flex-wrap: wrap; }
.filters .count { opacity: .6; margin-left: 4px; font-variant-numeric: tabular-nums; }
.cover-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.cover-main { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: start; }
.cover-art { width: 120px; height: 120px; border-radius: 10px; overflow: hidden; background: var(--navy); }
.cover-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-blank { width: 100%; height: 100%; display: grid; place-items: center; color: #fff; font-weight: 700; letter-spacing: .04em; }
.cover-info .t { font-weight: 600; font-size: 16px; }
.cover-info .m, .cover-tools .m { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.cover-tools { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.cand-row { display: flex; gap: 10px; overflow-x: auto; padding: 8px 2px 10px; }
.cand { flex: 0 0 110px; border: 2px solid transparent; border-radius: 10px; background: var(--mist); padding: 6px; text-align: left; cursor: pointer; font: inherit; display: grid; gap: 2px; }
.cand.on { border-color: var(--gold); background: #fff8e6; }
.cand img { width: 94px; height: 94px; border-radius: 6px; object-fit: cover; display: block; }
.cand span { font-size: 11px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand .sub { color: var(--ink-soft); }
.cover-search { display: flex; gap: 8px; margin: 4px 0 10px; max-width: 560px; }
.upload-btn { display: inline-flex; align-items: center; }
.progress.inline { display: inline-block; margin: 0 0 0 6px; vertical-align: middle; width: 120px; height: 4px; background: var(--mist); border-radius: 2px; overflow: hidden; }
.progress.inline span { display: block; height: 100%; width: 0; background: var(--gold); }
@media (max-width: 900px) { .cover-main { grid-template-columns: 90px 1fr; } .cover-art { width: 90px; height: 90px; } }

/* Artists */
.bio-preview { white-space: pre-line; line-height: 1.45; }
.artist-form h2 { margin-bottom: 14px; }

.onair > div { min-width: 0; } /* lets long song titles end in … instead of spilling out */
/* The sidebar scrolls; never squeeze its blocks to fit the window height. */
.side > * { flex-shrink: 0; }

/* Listeners */
.listen-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.map-panel { padding: 0; overflow: hidden; }
#listenMap { height: 520px; background: var(--mist); }
.big-num { font-size: 40px; font-weight: 600; letter-spacing: -0.02em; }
.city-list { margin-top: 14px; max-height: 420px; overflow-y: auto; }
.city-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
@media (max-width: 900px) { .listen-grid { grid-template-columns: 1fr; } #listenMap { height: 360px; } }

.day-row { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; }
.day-row .check { margin-bottom: 0; }

.notsong-box { margin-bottom: 16px; padding: 14px 18px; }
.notsong-box .field { margin-bottom: 8px; }

/* Theme page */
.tp-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.tp-choice { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; }
.tp-choice:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(178,141,52,.25); }
.tp-choice small { display: block; font-size: 12px; }
.tp-choice > span:last-child { min-width: 0; }
.tp-season select { width: auto; }
.tp-dates input { width: auto; flex: 1 1 140px; min-width: 0; }
.tp-sw { display: inline-flex; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); flex-shrink: 0; }
.tp-sw i { width: 14px; height: 28px; display: block; }
.tp-custom { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; margin-top: 16px; }
.tp-custom .help { grid-column: 1 / -1; }
.tp-color { display: flex; gap: 8px; margin-top: 6px; }
.tp-color input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.tp-color input:not([type]) { flex: 1; }
.tp-season { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.tp-season b { min-width: 110px; font-weight: 500; }
.tp-dates { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; max-width: 100%; }
.tp-previews { display: flex; flex-wrap: wrap; gap: 20px; }
.tp { text-align: center; }
.tp-label { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.tp-phone { width: 190px; border-radius: 26px; overflow: hidden; border: 6px solid #1f2937; font-size: 11px; text-align: left; }
.tp-hero { padding: 10px 10px 0; }
.tp-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.tp-live { background: #ef4444; color: #fff; font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 999px; }
.tp-cover { height: 130px; border-radius: 12px; background: linear-gradient(160deg, #6b7a99, #2b3550); position: relative; margin-bottom: -40px; }
.tp-ttl { position: absolute; left: 10px; bottom: 10px; color: #fff; font-weight: 600; }
.tp-ttl small { display: block; font-weight: 300; opacity: .85; }
.tp-play { position: absolute; right: 8px; bottom: -12px; width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 3px solid; }
.tp-body { padding: 52px 10px 10px; }
.tp-row { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; }
.tp-row i { width: 22px; height: 22px; border-radius: 50%; display: block; }
.tp-row b { margin-left: auto; border: 1px solid; border-radius: 999px; padding: 2px 8px; font-weight: 600; font-size: 10px; }
.tp-h { font-weight: 700; margin-bottom: 6px; }
.tp-cards { display: flex; gap: 6px; margin-bottom: 10px; }
.tp-cards div { flex: 1; border-radius: 8px; padding: 6px; }
.tp-cards span { display: block; font-weight: 600; }
.tp-cards small { font-size: 10px; }
.tp-btn { text-align: center; border-radius: 8px; padding: 6px; font-weight: 600; }
.tp-nav { display: flex; justify-content: space-around; padding: 8px 0 10px; font-weight: 600; }

/* App usage */
.ubar { display: grid; grid-template-columns: minmax(140px, 260px) 1fr 70px; gap: 12px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.ubar:first-of-type { border-top: 0; }
.ubar .ut { background: var(--mist); border-radius: 999px; height: 10px; overflow: hidden; }
.ubar .ut i { display: block; height: 100%; background: var(--gold); border-radius: 999px; }
.ubar b { text-align: right; font-weight: 500; }
.udays { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.udays > div { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.udays i { display: block; width: 100%; background: var(--navy); border-radius: 4px 4px 0 0; }
.udays span { font-size: 10px; color: var(--ink-soft); margin-top: 4px; white-space: nowrap; }
@media (max-width: 900px) {
  .ubar { grid-template-columns: 1fr 60px; }
  .ubar .ut { grid-column: 1 / -1; grid-row: 2; }
}

/* Staff → page access checkboxes */
.access { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 10px; }
.access .check { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.access-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 16px; }
.access-grid .presets { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.access-grid fieldset { border: 1px solid var(--line, #e3e6ee); border-radius: 10px; padding: 8px 12px 10px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.access-grid legend { font-weight: 700; font-size: 13px; padding: 0 4px; }
