/* App pages: the conductor's dashboard, the choir space for singers and the admin page. */
body { padding-bottom: 40px; }
.bar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.bar-inner { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.bar .crumb { color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bar-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.bar select { min-height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 10px; max-width: 140px; }
.icon { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; color: var(--ink); padding: 0; }
.icon svg { width: 20px; height: 20px; }
.theme .i-sun { display: none; }
:root[data-theme="dark"] .theme .i-sun { display: block; }
:root[data-theme="dark"] .theme .i-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme .i-sun { display: block; } :root:not([data-theme="light"]) .theme .i-moon { display: none; } }

main { padding-top: 28px; }
.page-title { font-size: clamp(28px, 4vw, 40px); margin: 6px 0 4px; }
.sub { color: var(--ink-2); margin: 0 0 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin: 0 0 20px; }
.card > h2 { font-size: 22px; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
.card > p.hint { color: var(--ink-2); margin: 0 0 16px; font-size: 15.5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.hidden, [hidden] { display: none !important; }

/* auth */
.auth { max-width: 460px; margin: 24px auto; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--paper-2); border-radius: 14px; padding: 4px; margin-bottom: 20px; }
.tabs button { border: 0; background: transparent; min-height: 44px; border-radius: 10px; font-weight: 600; color: var(--ink-2); }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.auth .btn { width: 100%; }
.check-line { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; margin: 6px 0 14px; }
.check-line input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand-2); flex: none; }
.linkish { background: none; border: 0; color: var(--brand-2); text-decoration: underline; padding: 0; font-size: 15px; }

/* status banner */
.status { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; border-radius: var(--radius); padding: 18px 22px; margin-bottom: 20px; }
.status.trial { background: var(--brand-soft); }
.status.active { background: var(--ok-soft); }
.status.paused { background: var(--rose-soft); }
.status b { font-size: 17px; }
.status .row { margin-left: auto; }

/* share */
.share-grid { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: start; }
.copy { display: flex; gap: 8px; align-items: stretch; }
.copy input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; }
.code-big { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; font-weight: 700; letter-spacing: .02em; background: var(--paper-2); border-radius: 12px; padding: 8px 14px; display: inline-block; }
.qr { width: 148px; height: 148px; background: #fff; border-radius: 12px; padding: 8px; border: 1px solid var(--line); }
.qr svg, .qr img { width: 100%; height: 100%; display: block; }

/* songs */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; background: var(--paper); transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--brand-2); background: var(--brand-soft); }
.drop b { display: block; font-size: 18px; margin-bottom: 4px; }
.drop .formats { color: var(--ink-2); font-size: 14.5px; margin: 0 0 12px; }
.upload-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin-top: 16px; text-align: left; }
.upload-form .full { grid-column: 1 / -1; }
.songs { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; }
.song { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: var(--card); }
.song h3 { font-family: var(--font); font-size: 17px; margin: 0; letter-spacing: 0; }
.song .meta { color: var(--ink-2); font-size: 14px; }
.song-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; margin-left: 8px; vertical-align: 2px; }
.chip.ready { background: var(--ok-soft); color: var(--ok); }
.chip.preparing { background: var(--warn-soft); color: var(--warn); }
.chip.failed { background: var(--rose-soft); color: var(--rose); }
.empty { color: var(--ink-2); text-align: center; padding: 18px; }
.quota { font-size: 14px; color: var(--ink-2); margin-top: 10px; }
.progress { height: 6px; border-radius: 3px; background: var(--paper-2); overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; background: var(--brand-2); width: 0; transition: width .2s; }

/* plans in the dashboard */
.plan-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.plan-pick button { text-align: left; border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 14px 16px; display: grid; gap: 2px; }
.plan-pick button:hover { border-color: var(--brand-2); }
.plan-pick b { font-size: 22px; font-family: var(--serif); }
.plan-pick span { color: var(--ink-2); font-size: 14px; }
.plan-pick .save { color: var(--ok); font-weight: 600; }

/* modal */
dialog { border: 0; border-radius: 20px; padding: 0; width: min(640px, calc(100vw - 24px)); background: var(--card); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10, 8, 20, .5); }
.dlg { padding: 24px; max-height: 85vh; overflow: auto; }
.dlg h2 { font-size: 22px; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.parts-edit { display: grid; gap: 8px; }
.parts-edit .row > * { flex: 1; }
.parts-edit select, .parts-edit input, .sections-edit input { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); padding: 0 10px; }
.sections-edit { display: grid; gap: 8px; }
.sections-edit .row input[type=number] { width: 90px; flex: none; }
.sections-edit .row input[type=text] { flex: 1; }

/* choir space (singers) */
.space-hero { text-align: center; padding: 20px 0 10px; }
.space-hero h1 { font-size: clamp(30px, 5vw, 46px); }
.gate { max-width: 420px; margin: 20px auto; text-align: center; }
.gate input { text-align: center; font-size: 20px; letter-spacing: .03em; }
.song-list { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 12px; }
.song-list a { display: flex; align-items: center; gap: 16px; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; box-shadow: var(--shadow); min-height: 76px; }
.song-list a:hover { border-color: var(--brand-2); }
.song-list .play-dot { width: 48px; height: 48px; border-radius: 50%; background: var(--rose); color: var(--rose-ink); display: grid; place-items: center; flex: none; }
.song-list .play-dot svg { width: 22px; height: 22px; fill: currentColor; margin-left: 3px; }
.song-list b { display: block; font-size: 19px; color: var(--ink); }
.song-list a { transition: transform .15s, box-shadow .15s, border-color .15s; }
.song-list a:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.song-list span { color: var(--ink-2); font-size: 15px; }
.powered { text-align: center; color: var(--ink-3); font-size: 14px; margin-top: 30px; }
.powered a { color: inherit; }

/* admin */
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stats b { display: block; font-size: 28px; font-family: var(--serif); }
.table-wrap { overflow-x: auto; }

@media (max-width: 760px) {
  .grid2, .share-grid, .upload-form, .plan-pick { grid-template-columns: 1fr; }
  .song { grid-template-columns: 1fr; }
  .song-actions { justify-content: flex-start; }
  .stats { grid-template-columns: 1fr 1fr; }
  .card { padding: 18px; }
  .bar select { max-width: 96px; }
  .status .row { margin-left: 0; width: 100%; }
  .status .row .btn { flex: 1; }
}
@media (max-width: 520px) {
  .bar .logo .word { display: none; }
  .bar-inner { gap: 8px; }
  .bar .btn-small { padding: 0 10px; }
}

/* language select with the current flag drawn inside it (I18N.picker) */

/* choir page while the space is paused: songs are listed but do not open */
#songs.off a { opacity: .55; pointer-events: none; }
.linkish { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* demo choir: invitation to start a trial */
.demo-cta { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin: 20px 0; padding: 16px 18px; border-radius: 16px; background: var(--rose-soft); border: 1px solid var(--line); }
.demo-cta p { margin: 0; font-weight: 600; flex: 1 1 240px; }
.demo-cta .btn { flex: none; }
#planPick .suggested { outline: 3px solid var(--rose); outline-offset: 2px; }
/* empty choir: the songs card moves up, right under the status */
#dashView:not([hidden]) { display: flex; flex-direction: column; }
#dashView > * { min-width: 0; }
#songsCard.first { order: -1; }
#dashView > .page-title { order: -4; } #dashView > .sub { order: -3; } #dashView > .status { order: -2; }

/* QA round 2 (layout): edit dialog rows on phones, sticky Save, share card at 320, 44 px touch targets, notch insets */
.parts-edit .row, .sections-edit .row { flex-wrap: nowrap; }
.parts-edit .row > * { flex: 1 1 0; min-width: 0; width: 0; }
.parts-edit select { flex: 0 0 auto; width: auto; max-width: 46%; -webkit-appearance: none; appearance: none;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2357526b' stroke-width='1.8'/%3E%3C/svg%3E") no-repeat right 10px center / 12px; padding-right: 30px; }
.sections-edit .row input.bar { flex: 0 0 72px; width: 72px; }
.sections-edit .row input[type=text]:not(.bar) { flex: 1 1 0; min-width: 0; width: 0; }
.sections-edit .row .btn { width: 44px; min-height: 44px; padding: 0; flex: none; }
/* keep Save in reach */
.dlg { padding-bottom: 0; }
.dlg-actions { position: sticky; bottom: 0; background: var(--card); margin: 16px -24px 0; padding: 12px 24px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex-wrap: nowrap; }
@media (max-width: 520px) { .dlg { padding: 18px 18px 0; max-height: 90dvh; } .dlg-actions { margin-inline: -18px; padding-inline: 18px; } .dlg-actions .btn { flex: 1; padding: 0 12px; } }
dialog[open] { overscroll-behavior: contain; }
html:has(dialog[open]) { overflow: hidden; }
.file-btn:has(input:focus-visible) { outline: 3px solid var(--brand-2); outline-offset: 2px; }
.share-grid > * { min-width: 0; }
#shareCard .row .btn { white-space: normal; text-align: center; line-height: 1.25; padding-block: 8px; }
@media (max-width: 520px) { #shareCard .row .btn { flex: 1 1 100%; } .copy .btn { flex: none; } }
@media (pointer: coarse) { .btn-small { min-height: 44px; } .icon, .lp-btn, .theme-btn { width: 44px; height: 44px; } .lp-btn { width: auto; } .linkish { padding: 10px 0; } }
.bar .logo, .bar .logo img { flex: none; }
.song-actions [data-act=up] { min-width: 44px; }
.wrap { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
@media (max-width: 520px) { .song > * { min-width: 0; } .song-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; } .song-actions > * { flex: 1 1 auto; } .song-actions [data-act=up], .song-actions [data-act=delete] { flex: 0 0 44px; } .chip { margin-left: 0; margin-top: 4px; } .song h3 { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; } }
html { scroll-padding-top: 80px; }
