:root {
  --bg: #f6f4ef; --card: #fff; --ink: #1f1d1a; --muted: #6b665e; --line: #ddd8cc;
  --accent: #7a1f2b; --accent-ink: #fff; --chord: #c2410c;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
header#nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); }
header#nav a { color: inherit; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
header#nav a:hover, header#nav a.on { background: rgba(255,255,255,.18); }
header#nav .brand { font-weight: 700; margin-right: 8px; color: inherit; text-decoration: none; }
main { max-width: 900px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: .2em 0 .6em; }
h2 { font-size: 1.15rem; margin: 1.2em 0 .5em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 8px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 200px; }
.muted { color: var(--muted); font-size: .9em; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 12px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: #b91c1c; }
button.sm { padding: 4px 8px; font-size: .9em; }
input, textarea, select { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 260px; font-family: ui-monospace, Menlo, monospace; font-size: .95em; }
label { display: block; font-size: .85em; color: var(--muted); margin: 10px 0 4px; }
.tabs { display: flex; gap: 6px; margin: 8px 0; }
.tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pill { font-size: .75em; padding: 2px 8px; border-radius: 99px; background: #eee7d6; color: #5b4a1b; margin-right: 6px; }
.pill.today { background: #fde68a; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
.preview { background: #fff; border: 1px dashed var(--line); border-radius: 8px; padding: 10px; }

/* Chords */
.ln { margin: 0 0 .35em; }
.ln.chords { display: flex; flex-wrap: wrap; align-items: flex-end; row-gap: .15em; }
.seg { display: inline-flex; flex-direction: column; }
.ch { color: var(--chord); font-weight: 700; font-size: .85em; line-height: 1.1; margin-right: .5em; min-height: 1.1em; }
.tx { white-space: pre; }
.tx::after { content: '\200b'; } /* segmento sem sílaba (acorde no fim da linha) mantém a altura: o acorde fica na linha das cifras */

/* Live */
body.live { background: #0d0d0f; color: #f4f1ea; overflow: hidden; }
body.live header#nav { display: none; }
body.live main { max-width: none; padding: 0; height: 100dvh; }
.stage { display: flex; flex-direction: column; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #1a1a1f; font-size: .9em; }
.topbar .fsz { display: flex; gap: 6px; }
.topbar .fsz button { background: #2a2a31; border: 1px solid #3a3a42; color: #f4f1ea; font-weight: 700; min-width: 44px; padding: 8px 10px; }
.topbar .title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; display: inline-block; }
.dot.ok { background: #22c55e; }
.slide-wrap { flex: 1; overflow: auto; padding: 16px 18px; }
.slide-label { color: #a8a29e; font-size: .85em; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.slide-title { font-weight: 700; margin-bottom: 10px; color: #fbbf24; }
.slide .ln, .slide-body .ln { font-size: var(--fs, 1.5rem); }
body.live .ch { color: #fb923c; }
.next { margin-top: 24px; padding-top: 12px; border-top: 1px solid #333; opacity: .55; font-size: .8em; }
.controls { display: flex; gap: 8px; padding: 10px; background: #1a1a1f; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.controls button { background: #2a2a31; border-color: #3a3a42; color: #f4f1ea; padding: 14px 0; font-size: 1.1em; }
.controls .nav { flex: 1 1 0; min-width: 0; font-size: .85em; line-height: 1.2; padding: 8px 4px; }
.controls .nav::first-line { font-size: 1.5em; }
.controls .nav.next-btn { background: var(--accent); border-color: var(--accent); }
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; z-index: 10; }
.drawer.open { display: block; }
.drawer .panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(380px, 90vw); background: #17171b; overflow: auto; padding: 12px; }
.drawer .item { display: block; width: 100%; text-align: left; margin: 4px 0; background: #23232a; border-color: #33333b; color: #f4f1ea; }
.drawer .item.on { background: var(--accent); border-color: var(--accent); }

/* Projector */
body.projector .slide-wrap { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; overflow: hidden; padding: 4vh 6vw; }
body.projector .slide-title { font-size: 3vh; color: #fbbf24; }
body.projector .slide-body { width: 100%; }
body.projector .controls, body.projector .topbar { display: none; }
body.projector .hint { position: fixed; right: 10px; bottom: 6px; font-size: 12px; opacity: .25; }
body.projector .ln { margin: 0 0 .2em; }
header#nav .who { opacity: .85; font-size: .9em; padding: 0 6px; }

/* Compartilhamento, avisos e controle */
.sharebox { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.sharebox .qr { width: 132px; height: 132px; background: #fff; padding: 4px; border-radius: 8px; }
.sharebox .qr svg { width: 100%; height: 100%; display: block; }
.sharebox input { margin-bottom: 6px; font-size: .85em; }
.slot:empty { display: none; }
.banner { background: #fde68a; color: #422006; padding: 8px 12px; border-radius: 8px; margin: 8px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
body.live .banner { border-radius: 0; margin: 0; justify-content: center; }
.toast { background: #1f2937; color: #fff; text-align: center; padding: 6px 10px; font-size: .9em; }
.chip { background: #2a2a31; border-radius: 99px; padding: 2px 10px; font-size: .85em; white-space: nowrap; }
.chip.warn { background: #7f1d1d; }
.controls button:disabled { opacity: .35; }
body.live .topbar { flex-wrap: wrap; }

/* Modos de apresentação */
.stage.blackout { background: #000; }
.blankslide { text-align: center; margin-top: 12vh; font-size: 1.6rem; opacity: .8; }
.controls button.on { background: #fbbf24; color: #1a1a1f; border-color: #fbbf24; }
.controls { align-items: stretch; }
.controls button.frozen:not(.nav) { flex: 1 1 0; background: #dc2626; border-color: #dc2626; color: #fff; font-weight: 700; animation: frozen-blink 1s steps(2, start) infinite; }
.controls button#peek.on { animation: peek-blink 1s steps(2, start) infinite; }
@keyframes peek-blink { 50% { background: #2a2a31; border-color: #fbbf24; color: #fbbf24; } }
@keyframes frozen-blink { 50% { background: #fbbf24; border-color: #fbbf24; color: #1a1a1f; } }
.controls button:not(.nav) { flex: 1 1 0; min-width: 0; font-size: .85em; line-height: 1.2; padding: 8px 4px; }
.controls button .lb { display: block; font-size: .78em; font-weight: 600; }
.peekbar { background: #bfdbfe; color: #1e3a8a; }
.live-edit { position: fixed; inset: 0; z-index: 30; overflow: auto; background: #0d0d0f; color: #f4f1ea; padding: 14px; }
.live-edit .card { background: #1a1a1f; border-color: #33333b; color: #f4f1ea; }
.live-edit input, .live-edit select { background: #23232a; border-color: #3a3a42; color: #f4f1ea; }
.live-edit button { background: #2a2a31; border-color: #3a3a42; color: #f4f1ea; }
.live-edit button.primary { background: #7a1f2b; border-color: #7a1f2b; }
.live-edit .tabs button.on { background: #7a1f2b; }
.live-edit .le-card { max-width: 1280px; margin: 0 auto; }
.le-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .le-grid { grid-template-columns: 1fr 1fr; align-items: start; } .le-prev { position: sticky; top: 0; max-height: calc(100vh - 60px); overflow: auto; } }
.le-prev .pj { margin-bottom: 10px; }
.live-edit .muted { color: #a8a29e; }
.drawer .panel label { color: #a8a29e; }
.drawer .panel input { background: #23232a; border-color: #3a3a42; color: #f4f1ea; }
.drawer .panel button:disabled { opacity: .35; }
.card.archived { opacity: .6; }
body.projector .hint a { color: inherit; pointer-events: auto; }

/* Editor de texto de músicas e orações */
.editor-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .editor-grid { grid-template-columns: 1fr; } }
.editor-side { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.editor-toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px; background: #efe9db; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; }
.editor-toolbar button { min-width: 38px; padding: 6px 10px; }
.editor-toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.rte { min-height: 62vh; max-height: 78vh; overflow: auto; padding: 18px 20px; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 0 0 10px 10px; font-size: 1.15rem; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word; outline: none; }
.rte:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122, 31, 43, .12); }
.ln b { font-weight: 800; }
.musicians-only { display: inline-block; background: #3b2f12; color: #fde68a; border-radius: 6px; padding: 3px 10px; font-size: .85em; margin-bottom: 8px; }
.musicians-card { border-style: dashed; opacity: .8; }
.count { display: inline-block; min-width: 1.6em; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: rgba(255,255,255,.22); font-size: .78em; text-align: center; line-height: 1.5; }
.count.big { background: var(--accent); color: #fff; font-size: .55em; vertical-align: middle; padding: 2px 10px; }

/* Leitura em folhas (membros): como um PDF, uma folha abaixo da outra */
.doc-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 4px 0 14px; }
.sheets { display: flex; flex-direction: column; gap: 18px; align-items: center; }
.sheet { width: min(100%, 794px); min-height: 520px; background: #fff; color: #1b1a17; border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 2px 10px rgba(60, 40, 20, .12); padding: 34px 40px 18px; display: flex; flex-direction: column; font-size: var(--rfs, 1.05rem); }
.sheet .ln { font-size: 1em; line-height: 1.5; margin: 0 0 .5em; }
.sheet .ch { color: #b4410b; font-size: .88em; }
.sheet-head h1 { margin: 0 0 4px; font-size: 1.7em; }
.sheet-meta { color: var(--muted); font-size: .92em; margin-bottom: 18px; border-bottom: 2px solid #1b1a17; padding-bottom: 8px; }
.stz { margin: 0 0 1.1em; break-inside: avoid; }
.stz-label { font-size: .78em; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.sheet-foot { margin-top: auto; padding-top: 18px; display: flex; justify-content: space-between; color: var(--muted); font-size: .78em; border-top: 1px solid var(--line); }
@media (max-width: 600px) { .sheet { padding: 20px 16px 12px; min-height: 0; } }
@media print {
  header#nav, .no-print, .doc-toolbar { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .sheets { gap: 0; }
  /* Folha = A4 exata (794px ≈ 210mm), mesmo layout da tela; sem margem do navegador */
  @page { size: A4; margin: 0; }
  .sheet { width: 210mm; height: 296mm; min-height: 0 !important; box-sizing: border-box; overflow: hidden; margin: 0; box-shadow: none; border: 0; border-radius: 0; break-inside: avoid; break-after: page; }
  .sheet:last-child { break-after: auto; }
}

/* Editor de texto em tela larga, com destaque colorido */
body.editing main { max-width: none; padding: 10px 18px 0; }
.meta { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0 10px; }
.meta > summary { cursor: pointer; font-weight: 600; }
.ed-shell { display: grid; grid-template-columns: auto minmax(300px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .ed-shell { grid-template-columns: 1fr; } }
.ed-left { min-width: 0; }
.ed-right { position: sticky; top: 8px; max-height: calc(100vh - 90px); overflow: auto; min-width: 0; }
.hl-wrap { position: relative; width: calc(var(--cols, 48) * 1ch + 40px); max-width: 100%; height: calc(100vh - 250px); min-height: 360px;
  background: #fffdf8; border: 1px solid var(--line); border-radius: 0 0 10px 10px; overflow: hidden; --efs: 1rem; }
.hl, .hl-ta { position: absolute; inset: 0; margin: 0; padding: 16px 20px; border: 0; width: 100%; height: 100%;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: var(--efs, 1rem); line-height: 1.75; letter-spacing: 0;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; tab-size: 4; overflow: auto; scrollbar-width: none; box-sizing: border-box; }
.hl::-webkit-scrollbar, .hl-ta::-webkit-scrollbar { display: none; }
.hl { pointer-events: none; color: #1b1a17; background: transparent; }
.hl-ta { background: transparent; color: transparent; caret-color: #1b1a17; resize: none; outline: none; }
.hl-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122, 31, 43, .12); }
.hl-ta::selection { background: rgba(37, 99, 235, .28); color: transparent; }
.h-chord { color: #c2410c; background: #ffedd5; border-radius: 3px; font-weight: 700; }
.h-slide { color: #fff; background: #2563eb; border-radius: 3px; font-weight: 700; }
.h-pipe { color: #fff; background: #16a34a; border-radius: 3px; font-weight: 700; }
.h-label { color: #7c3aed; font-weight: 700; background: #f3e8ff; }
.h-blank { color: #fff; background: #52525b; border-radius: 3px; }
.h-proj { color: #0f766e; background: #ccfbf1; border-radius: 3px; font-weight: 700; }
.h-fmt { color: #be185d; background: #fce7f3; border-radius: 3px; }
.h-b { font-weight: 800; } .h-i { font-style: italic; } .h-u { text-decoration: underline; }
.legend { font-size: .82em; color: var(--muted); margin-top: 8px; line-height: 2; }
.legend span { padding: 1px 5px; margin: 0 1px; font-family: ui-monospace, Menlo, monospace; }
.editor-toolbar code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; }
.ed-savebar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 35%); padding: 10px 0 12px; display: flex; gap: 12px; align-items: center; }
/* prévia do projetor: tela 16:9 escura, texto corrido */
.pv-list { display: flex; flex-direction: column; gap: 12px; }
.pj { margin: 0; }
.pj-screen { position: relative; aspect-ratio: 16 / 9; background: #0d0d0f; color: #f4f1ea; border-radius: 8px; overflow: hidden; border: 2px solid #1f1f23; }
/* tela virtual 1280x720, igual ao projetor real (padding 4vh 6vw, título 3vh), reduzida por transform */
.pj-virt { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: top left; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.pj-wrap { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; overflow: hidden; padding: 28.8px 76.8px; box-sizing: border-box; }
.pj-title { font-size: 21.6px; font-weight: 700; color: #fbbf24; margin-bottom: 10px; }
.pj-body { width: 100%; }
.pj-body .ln { font-size: var(--fs, 72px); margin: 0 0 .2em; }
.pj-off { color: #71717a; font-size: 28px; }
.pj figcaption { font-size: .82em; color: var(--muted); margin-top: 4px; }
.pj.off .pj-screen { border-style: dashed; }
.pj.over .pj-screen { border-color: #f59e0b; }
.pj-warn { color: #b45309; }

/* Missa completa em PDF */
.doc-bar { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--bg); padding: 8px 0 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.doc-bar select { width: auto; max-width: 56vw; }
.doc-kicker { text-transform: uppercase; letter-spacing: .1em; font-size: .72em; color: var(--accent); font-weight: 700; margin-bottom: 2px; }
.doc-tom { display: inline-flex; gap: 6px; align-items: center; }
.doc-cont { color: var(--muted); font-size: .8em; margin-bottom: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 4px; }
.toc { list-style: none; margin: 8px 0 0; padding: 0; }
.toc li a { display: flex; gap: 12px; align-items: baseline; padding: 7px 4px; border-bottom: 1px dotted var(--line); color: inherit; text-decoration: none; }
.toc li a:hover { background: #faf5ea; }
.toc-n { width: 2.2em; color: var(--muted); text-align: right; }
.toc-t { flex: 1; font-weight: 600; }
.toc-t small { display: block; font-weight: 400; color: var(--muted); }
.toc-p { color: var(--muted); font-variant-numeric: tabular-nums; }
.print-only { display: none; }
@media print { .print-only { display: inline; } .doc-bar { display: none !important; } }
.doc-live { flex-basis: 100%; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stz.leader-here { outline: 3px solid #f59e0b; outline-offset: 6px; border-radius: 6px; background: #fffbeb; }
.toc li.here a { background: #fef3c7; }
.toc li.here a::after { content: '👑 aqui'; margin-left: 6px; font-size: .8em; color: #b45309; }
.slide-wrap.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.slide-wrap.two .slide-next { border-left: 1px solid #333; padding-left: 18px; opacity: .85; }
.slide-wrap.two .slide-next .slide-title { color: #a8a29e; }
@media (max-width: 640px) { .slide-wrap.two { grid-template-columns: 1fr; } .slide-wrap.two .slide-next { border-left: 0; padding-left: 0; border-top: 1px solid #333; padding-top: 12px; } }

/* lista de adicionar / ordem da missa: título quebra dentro do cartão, botões nunca caem para a linha de baixo */
.card.pick { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.card.pick .t { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.card.pick > button, .card.pick .acts { flex: 0 0 auto; white-space: nowrap; }

/* missas ao vivo na lista da banda */
.card.is-live { border-color: #dc2626; box-shadow: 0 0 0 2px rgba(220,38,38,.18); }
.live-badge { display: inline-flex; align-items: center; gap: 6px; background: #dc2626; color: #fff; font-size: .72em; font-weight: 700; letter-spacing: .06em; padding: 2px 8px; border-radius: 99px; margin-right: 6px; vertical-align: middle; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: livepulse 1.2s ease-in-out infinite; }
@keyframes livepulse { 50% { opacity: .25; } }

.tip { margin: 4px 0 8px; }
.tip kbd { background: #eee7d6; border-radius: 4px; padding: 0 5px; font-size: .9em; }

/* ordem da missa: arrastar e soltar */
.ordrow { position: relative; }
.grip { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; padding: 4px 6px; font-size: 1.2em; color: var(--muted); flex: 0 0 auto; border-radius: 6px; }
.grip:hover { background: #eee7d6; color: var(--ink); }
.grip:active { cursor: grabbing; }
.grip-demo { font-size: 1.1em; }
.ordrow.dragging { opacity: .55; border-color: var(--accent); }
.ordrow.drop-before::before, .ordrow.drop-after::after { content: ''; position: absolute; left: 0; right: 0; height: 4px; background: var(--accent); border-radius: 2px; }
.ordrow.drop-before::before { top: -7px; }
.ordrow.drop-after::after { bottom: -7px; }
.ordrow.ins-here { box-shadow: 0 3px 0 0 var(--accent); }

.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; box-sizing: border-box; background: #fff; border: 1px solid var(--line); font-weight: 600; padding: 10px 14px; }
.google-btn:hover { background: #f8f6f0; }

/* menu do topo: lista completa em tela larga; sanduíche em tela estreita */
header#nav .navlinks { display: contents; }
header#nav #burger { display: none; background: transparent; border: 1px solid rgba(255,255,255,.45); color: inherit; font-size: 1.25em; line-height: 1; padding: 6px 12px; }
@media (max-width: 880px) {
  header#nav { flex-wrap: wrap; }
  header#nav #burger { display: inline-block; margin-left: auto; }
  header#nav .navlinks { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 2px; padding-top: 8px; }
  header#nav.open .navlinks { display: flex; }
  header#nav .navlinks a { padding: 12px 10px; font-size: 1.05em; }
  header#nav .navlinks > span[style] { display: none; }
  header#nav .navlinks .who { padding: 8px 10px; }
}

.drawer .itemrow { display: flex; gap: 6px; align-items: center; }
.drawer .itemrow .item { flex: 1 1 auto; min-width: 0; }
.drawer .itemrow .sm { flex: 0 0 auto; background: #2a2a31; border-color: #3a3a42; color: #f4f1ea; }
