/* MasterCifra — tema com a identidade da Casa de Cultura Viola ao Vento. */

:root {
  --escala: 1;
  --fundo: #0D1216;
  --superficie: #161E24;
  --superficie2: #1F2A32;
  --borda: #2C3A44;
  --texto: #EEF2F4;
  --texto2: #9DAAB3;
  --dourado: #D5963C;
  --dourado-suave: rgba(213, 150, 60, .18);
  --turquesa: #03B3BB;
  --turquesa-suave: rgba(3, 179, 187, .16);
  --acorde: #FF5A4E;
  --erro: #FF6B6B;
  --ok: #3DD68C;
  --sombra: 0 6px 24px rgba(0, 0, 0, .35);
  --raio: 12px;
  --fonte: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --topo-seguro: env(safe-area-inset-top, 0px);
  --base-segura: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

[data-tema="claro"] {
  --fundo: #F6F3EE;
  --superficie: #FFFFFF;
  --superficie2: #EFEAE2;
  --borda: #DDD5C8;
  --texto: #1A2126;
  --texto2: #5C6770;
  --dourado: #B07420;
  --dourado-suave: rgba(176, 116, 32, .14);
  --turquesa: #02858B;
  --turquesa-suave: rgba(2, 133, 139, .12);
  --acorde: #D9281C;
  --sombra: 0 6px 24px rgba(40, 30, 10, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--escala)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--texto);
  font-family: var(--fonte); line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--turquesa); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .6rem; }
.suave { color: var(--texto2); }
.pequeno { font-size: .85rem; }
.centro { text-align: center; }
.oculto { display: none !important; }
.ico { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.item > .ico { color: var(--texto2); }

/* ---------- Abertura ---------- */
.abertura { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; }
.abertura img { width: 64px; height: auto; opacity: .9; animation: pulso 1.4s ease-in-out infinite; }
.abertura p { color: var(--dourado); letter-spacing: .12em; font-weight: 600; }
@keyframes pulso { 50% { opacity: .45; } }

/* ---------- Casca (menu + conteúdo) ---------- */
.casca { min-height: 100vh; display: flex; }
.menu {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--superficie); border-top: 1px solid var(--borda);
  padding: 4px 4px calc(4px + var(--base-segura));
}
.menu .marca { display: none; }
.menu a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; color: var(--texto2); text-decoration: none; font-size: .7rem;
  border-radius: 10px; position: relative; min-width: 0;
}
.menu a svg { width: 22px; height: 22px; }
.menu a.ativo { color: var(--dourado); }
.menu a .badge { position: absolute; top: 2px; left: calc(50% + 6px); }
.conteudo {
  flex: 1; min-width: 0; padding: calc(12px + var(--topo-seguro)) 16px calc(84px + var(--base-segura));
  max-width: 1100px; margin: 0 auto;
}
.topo { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; min-height: 40px; }
.topo h1 { margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 900px) {
  .menu {
    position: sticky; top: 0; bottom: auto; right: auto; height: 100vh; width: 220px;
    flex-direction: column; justify-content: flex-start; gap: 2px;
    border-top: 0; border-right: 1px solid var(--borda); padding: 16px 10px;
  }
  .menu .marca { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--dourado); font-weight: 700; letter-spacing: .04em; }
  .menu .marca img { width: 22px; }
  .menu a { flex: none; flex-direction: row; gap: 12px; padding: 10px 12px; font-size: .95rem; }
  .menu a.ativo { background: var(--dourado-suave); }
  .menu a .badge { position: static; margin-left: auto; }
  .conteudo { padding: 24px 32px 40px; }
}

/* ---------- Status de sincronização ---------- */
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--texto2); white-space: nowrap; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.sync.pendente::before { background: var(--dourado); }
.sync.offline::before { background: var(--texto2); }

/* ---------- Controles ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--borda);
  background: var(--superficie2); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--texto);
}
.btn:hover { border-color: var(--texto2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.prim { background: var(--dourado); border-color: var(--dourado); color: #1A1206; }
.btn.sec { background: transparent; border-color: var(--turquesa); color: var(--turquesa); }
.btn.perigo { background: transparent; border-color: var(--erro); color: var(--erro); }
.btn.bloco { width: 100%; }
.btn.peq { min-height: 34px; padding: 0 12px; font-size: .88rem; }
.btn svg { width: 18px; height: 18px; }
.icone-btn {
  width: 40px; height: 40px; flex: none; display: inline-grid; place-items: center;
  border-radius: 10px; border: 0; background: transparent; cursor: pointer; color: var(--texto2);
}
.icone-btn:hover { background: var(--superficie2); color: var(--texto); }
.icone-btn svg { width: 22px; height: 22px; }
.icone-btn.ativo { color: var(--dourado); }

.campo { display: grid; gap: 4px; margin-bottom: 12px; }
.campo > span { font-size: .85rem; color: var(--texto2); }
.campo input, .campo select, .campo textarea, input.entrada, select.entrada, textarea.entrada {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--borda); background: var(--superficie); outline: none;
}
.campo textarea, textarea.entrada { min-height: 120px; resize: vertical; line-height: 1.5; }
.campo input:focus, .campo select:focus, .campo textarea:focus, .entrada:focus { border-color: var(--turquesa); }
.linha-campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--dourado); }

.erro-msg { color: var(--erro); font-size: .9rem; margin: 6px 0; }
.ok-msg { color: var(--ok); font-size: .9rem; margin: 6px 0; }

/* ---------- Blocos ---------- */
.cartao { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px; margin-bottom: 12px; }
.grade { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-bottom: 14px; }
.kpi { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 12px 14px; }
.kpi b { display: block; font-size: 1.5rem; color: var(--dourado); }
.kpi span { font-size: .8rem; color: var(--texto2); }

.lista { display: grid; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio);
  text-decoration: none; color: inherit; cursor: pointer; min-width: 0;
}
.item:hover { border-color: var(--texto2); }
.item .principal { flex: 1; min-width: 0; }
.item .principal b, .item .principal .sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--texto2); font-size: .85rem; }
.item.inativo { opacity: .55; }

.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--acorde); color: #fff; font-size: .7rem; font-weight: 700; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: var(--superficie2); font-size: .8rem; color: var(--texto2); }
.chip.dourado { background: var(--dourado-suave); color: var(--dourado); }
.chip.turquesa { background: var(--turquesa-suave); color: var(--turquesa); }
.vazio { text-align: center; color: var(--texto2); padding: 40px 16px; }
.barra-ferr { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.barra-ferr .cresce { flex: 1; min-width: 180px; }

.abas { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 14px; border-bottom: 1px solid var(--borda); scrollbar-width: none; }
.abas button { flex: none; padding: 10px 14px; border: 0; background: none; color: var(--texto2); cursor: pointer; border-bottom: 2px solid transparent; font-weight: 600; }
.abas button.ativo { color: var(--dourado); border-bottom-color: var(--dourado); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login .caixa { width: 100%; max-width: 360px; }
.login .logo { display: block; margin: 0 auto 10px; width: 56px; }
.login h1 { text-align: center; color: var(--dourado); letter-spacing: .05em; margin-bottom: 2px; }
.login .sub { text-align: center; color: var(--texto2); margin-bottom: 24px; font-size: .9rem; }

/* ---------- Modal ---------- */
.modal-fundo { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: grid; place-items: end center; }
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  background: var(--superficie); border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + var(--base-segura));
  box-shadow: var(--sombra);
}
.modal .acoes { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
@media (min-width: 640px) {
  .modal-fundo { place-items: center; }
  .modal { border-radius: 18px; padding: 22px; }
}
.aviso-flutuante {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--base-segura)); z-index: 60;
  background: var(--superficie2); border: 1px solid var(--borda); padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--sombra); max-width: calc(100% - 32px);
}
@media (min-width: 900px) { .aviso-flutuante { bottom: 24px; } }

/* ---------- Cifra ---------- */
.cifra { font-family: var(--mono); font-size: calc(1rem * var(--zoom-cifra, 1)); }
.cifra .linha { display: flex; flex-wrap: wrap; align-items: flex-end; min-height: 1.5em; margin-bottom: .55em; }
.cifra .linha.vazia { min-height: .9em; }
.cifra .tk { display: inline-flex; flex-direction: column; border-radius: 4px; }
.cifra .tk.esp { margin-right: 1ch; }
.cifra .ac { min-height: 1.35em; display: flex; gap: .6ch; color: var(--acorde); font-weight: 700; white-space: nowrap; }
.cifra .ac.meio { justify-content: center; }
.cifra .ac.depois { justify-content: flex-end; }
.cifra .ac sup { font-size: .62em; color: var(--dourado); font-weight: 700; margin-left: 1px; }
.cifra .tx { white-space: pre; }
.cifra .tk.clicavel { cursor: pointer; }
.cifra .tk.clicavel:hover { background: var(--superficie2); }
.cifra .tk.sel { outline: 2px solid var(--turquesa); outline-offset: 1px; background: var(--turquesa-suave); }
.cifra .tk.atual { background: var(--dourado-suave); }
.cifra .tk.atual .ac .agora { color: var(--dourado); text-decoration: underline; text-underline-offset: 3px; }
.cifra .tk.com-duvida .tx { text-decoration: underline dotted var(--turquesa); text-underline-offset: 4px; }
.cifra .tk.sem-letra .tx { color: var(--texto2); opacity: .7; }
.cifra .tk.sem-letra .ac { justify-content: flex-start; }
.cifra .rotulo-interludio { font-family: var(--fonte); font-size: .72rem; font-style: italic; color: var(--texto2); align-self: center; margin-right: 1ch; }
.cifra .linha .num { font-family: var(--fonte); font-size: .7rem; color: var(--texto2); width: 2.2em; align-self: center; flex: none; }

/* ---------- Editor ---------- */
.editor { display: grid; gap: 16px; }
.editor .painel-topo { display: flex; align-items: center; gap: 4px; margin: -6px -6px 8px; }
.editor .painel-topo .icone-btn { flex: none; }
/* Painel de edição sempre à vista: janela flutuante presa embaixo da tela
   (celular, tablet e notebook), para cifrar sem rolar a página a cada acorde. */
.editor .painel {
  position: fixed; z-index: 15; left: 8px; right: 8px; bottom: calc(70px + var(--base-segura));
  max-height: 46vh; overflow-y: auto; margin: 0; padding: 12px;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .45); border-color: var(--dourado);
}
.editor .painel.recolhido { max-height: 30vh; }
.editor { padding-bottom: calc(46vh + 40px); }
@media (min-width: 900px) {
  .editor .painel { left: 236px; right: 16px; bottom: 12px; max-width: 900px; }
}
/* Tela larga: painel ao lado da letra, acompanhando a rolagem. */
@media (min-width: 1100px) {
  .editor { grid-template-columns: 1fr 320px; align-items: start; padding-bottom: 0; }
  .editor .painel { position: sticky; top: 16px; left: auto; right: auto; bottom: auto; max-height: calc(100vh - 32px);
    box-shadow: none; border-color: var(--borda); }
  .editor .painel.recolhido { max-height: calc(100vh - 32px); }
  .editor .so-flutuante { display: none; }
}
.editor .cifra { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px; min-height: 200px; }
.editor .painel .item { gap: 6px; flex-wrap: wrap; }
.editor .painel .item .entrada { min-height: 34px; padding: 4px 6px; }
.acorde-lista { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.acorde-lista .chip { font-family: var(--mono); color: var(--acorde); font-weight: 700; }
.teclas { font-size: .8rem; color: var(--texto2); }
.teclas kbd { font-family: var(--mono); background: var(--superficie2); border: 1px solid var(--borda); border-radius: 4px; padding: 0 4px; }

/* ---------- Prática ---------- */
.pratica-barra {
  position: sticky; bottom: calc(70px + var(--base-segura)); z-index: 10; margin-top: 12px;
  background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 10px 12px; box-shadow: var(--sombra);
}
@media (min-width: 900px) { .pratica-barra { bottom: 12px; } }
.agora-prox { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.agora-prox .grande { font-family: var(--mono); font-size: 2rem; font-weight: 800; color: var(--acorde); min-width: 3ch; }
.agora-prox .prox { color: var(--texto2); font-family: var(--mono); }
.batidas { display: flex; gap: 6px; }
.batidas i { width: 12px; height: 12px; border-radius: 50%; background: var(--superficie2); border: 1px solid var(--borda); }
.batidas i.on { background: var(--dourado); border-color: var(--dourado); }
.batidas i.on.forte { background: var(--turquesa); border-color: var(--turquesa); }
.controles { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.controles input[type=range] { accent-color: var(--dourado); width: 140px; }
.diagramas { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; }
.diagrama { flex: none; display: grid; justify-items: center; gap: 2px; font-family: var(--mono); font-weight: 700; color: var(--acorde); }
.diagrama svg { width: 84px; height: 100px; }
.diagrama small { font-family: var(--fonte); font-weight: 400; color: var(--texto2); font-size: .65rem; }

/* ---------- Afinador ---------- */
.afinador { display: grid; justify-items: center; gap: 12px; padding: 12px 0; }
.afinador .nota { font-size: 4.5rem; font-weight: 800; line-height: 1; color: var(--texto2); }
.afinador .nota.afinado { color: var(--ok); }
.afinador .freq { font-family: var(--mono); color: var(--texto2); }
.afinador svg { width: min(100%, 360px); height: auto; }
.cordas { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.cordas .chip.ativo { background: var(--turquesa-suave); color: var(--turquesa); }

/* ---------- Chat (recados) ---------- */
.chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.bolha { max-width: 82%; padding: 8px 12px; border-radius: 14px; background: var(--superficie2); white-space: pre-wrap; overflow-wrap: anywhere; }
.bolha.minha { align-self: flex-end; background: var(--dourado-suave); }
.bolha small { display: block; color: var(--texto2); font-size: .7rem; margin-top: 2px; }
.envio { display: flex; gap: 8px; }
.envio textarea { min-height: 44px !important; height: 44px; flex: 1; }

/* ---------- Tabelas ---------- */
.tabela { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabela th, .tabela td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--borda); }
.tabela th { color: var(--texto2); font-weight: 600; font-size: .8rem; }
.rolagem-x { overflow-x: auto; }

.barras { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin: 8px 0 4px; }
.barras div { flex: 1; background: var(--dourado); border-radius: 3px 3px 0 0; min-height: 2px; }
.barras-rotulos { display: flex; gap: 4px; font-size: .65rem; color: var(--texto2); }
.barras-rotulos span { flex: 1; text-align: center; }
