:root {
  --fundo: #030504;
  --superficie: #0e110f;
  --superficie-2: #171b18;
  --borda: #262b27;
  --texto: #f5f5f2;
  --texto-2: #bfc1bc;
  --texto-3: #8b8e88;
  --ouro: #e0b64e;
  --ouro-base: #cf9d2e;
  --ouro-escuro: #c18b21;
  --sobre-ouro: #1a1305;
  --verde: #008342;
  --acorde: #e0b64e;
  --dedo: #e0b64e;
  --sombra: 0 12px 40px rgba(0, 0, 0, 0.55);

  --serifa: Georgia, "Times New Roman", serif;
  --sans: "Century Gothic", "Avenir Next", "Avenir", "Segoe UI", Arial, sans-serif;
  --mono: Consolas, "SF Mono", Menlo, "Roboto Mono", "Courier New", monospace;

  --tam-cifra: 16px;
  --barra-altura: 64px;
  color-scheme: dark;
}

:root[data-tema="claro"] {
  --fundo: #f7f4ec;
  --superficie: #ffffff;
  --superficie-2: #efe9db;
  --borda: #ddd5c2;
  --texto: #1a1a17;
  --texto-2: #4a4a44;
  --texto-3: #6f6e66;
  --ouro: #8a6410;
  --acorde: #8a5a00;
  --dedo: #1a1a17;
  --sobre-ouro: #1a1305;
  --sombra: 0 12px 40px rgba(60, 45, 10, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--fundo);
  color: var(--texto);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--ouro); }

:focus-visible { outline: 2px solid var(--ouro); outline-offset: 2px; border-radius: 6px; }

/* Foto da marca ao fundo: aparece no topo e se funde no fundo. Na música, vira marca d'água. */
.fundo-foto {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--fundo) 30%, transparent) 0%, color-mix(in srgb, var(--fundo) 70%, transparent) 38%, var(--fundo) 72%),
    url("fundo.jpg") center 22% / cover no-repeat;
  opacity: 0.85;
  transition: opacity 0.4s ease;
}
:root[data-tela="musica"] .fundo-foto, :root[data-tela="professor"] .fundo-foto { opacity: 0.16; }
:root[data-tema="claro"] .fundo-foto { opacity: 0.45; }
:root[data-tema="claro"][data-tela="musica"] .fundo-foto, :root[data-tema="claro"][data-tela="professor"] .fundo-foto { opacity: 0.1; }

.faixa {
  position: fixed; inset: 0 0 auto 0; height: 4px; z-index: 30;
  background: linear-gradient(90deg, #008342, #cf9d2e 60%, #edcb6b);
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* ---------- Cabeçalho e início ---------- */

.marca {
  font-size: 12px; font-weight: 700; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ouro);
}

.topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; }

.titulo-app {
  font-family: var(--serifa); font-weight: normal;
  font-size: clamp(34px, 9vw, 48px); line-height: 1.05; letter-spacing: -0.02em;
  margin: 18px 0 6px;
}
.titulo-app em, .destaque { font-style: italic; color: var(--ouro); }

.subtitulo { color: var(--texto-2); max-width: 34em; }

.botao-icone {
  width: 44px; height: 44px; border-radius: 12px;
  display: inline-grid; place-items: center; flex: none;
  color: var(--texto-2); border: 1px solid var(--borda); background: var(--superficie);
}
.botao-icone:hover { color: var(--texto); }
.botao-icone svg { width: 20px; height: 20px; }
.botao-icone[aria-pressed="true"] { color: var(--ouro); border-color: var(--ouro); }

.busca {
  position: relative; margin: 24px 0 14px;
}
.busca svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--texto-3); pointer-events: none; }
.busca input {
  width: 100%; height: 52px; padding: 0 16px 0 44px;
  border-radius: 14px; border: 1px solid var(--borda);
  background: var(--superficie); font-size: 17px;
}
.busca input::placeholder { color: var(--texto-3); }
.busca input:focus { outline: none; border-color: var(--ouro); }

.filtros { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--borda); background: var(--superficie);
  color: var(--texto-2); font-size: 14px; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ouro); border-color: var(--ouro); color: var(--sobre-ouro); font-weight: 700; }

.contagem { color: var(--texto-3); font-size: 13px; margin: 18px 0 6px; }

.lista { list-style: none; }
.item a {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 14px 4px; border-bottom: 1px solid var(--borda);
  text-decoration: none; color: inherit;
}
.item a:hover .item-titulo { color: var(--ouro); }
.item-titulo { font-family: var(--serifa); font-size: 20px; line-height: 1.25; }
.item-info { grid-column: 1; color: var(--texto-3); font-size: 14px; }
.item-tom {
  grid-row: 1 / span 2; grid-column: 2;
  min-width: 44px; height: 44px; padding: 0 8px; border-radius: 10px;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; color: var(--acorde);
  background: var(--superficie-2);
}
.estrela { color: var(--ouro); margin-left: 6px; font-size: 14px; }

.vazio { text-align: center; color: var(--texto-2); padding: 48px 8px; }
.vazio strong { display: block; font-family: var(--serifa); font-weight: normal; font-size: 22px; color: var(--texto); margin-bottom: 6px; }

.rodape { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--borda); color: var(--texto-3); font-size: 13px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.rodape a { color: var(--texto-2); }

/* ---------- Página da música ---------- */

.pagina-musica { padding-bottom: calc(var(--barra-altura) + 180px); }

.voltar { display: inline-flex; align-items: center; gap: 6px; color: var(--texto-2); text-decoration: none; height: 44px; font-size: 15px; }
.voltar svg { width: 18px; height: 18px; }

.musica-titulo { font-family: var(--serifa); font-weight: normal; font-size: clamp(28px, 7.5vw, 40px); line-height: 1.1; letter-spacing: -0.015em; margin-top: 8px; }
.musica-artista { color: var(--texto-2); margin-top: 4px; }

.etiquetas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.etiqueta { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--superficie-2); color: var(--texto-2); }
.etiqueta b { color: var(--acorde); font-family: var(--mono); }

.levada {
  margin-top: 18px; padding: 14px 16px; border-radius: 14px;
  border-left: 3px solid var(--ouro); background: var(--superficie);
  color: var(--texto-2); font-size: 15px;
}
.levada strong { display: block; color: var(--ouro); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 4px; }

.botao-video {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px;
  height: 44px; padding: 0 18px; border-radius: 12px; text-decoration: none; font-weight: 700;
  background: linear-gradient(180deg, #e0b64e, #c18b21); color: var(--sobre-ouro);
}
.botao-video svg { width: 18px; height: 18px; }

.acoes-musica { display: flex; gap: 8px; }

.faixa-acordes {
  display: flex; gap: 6px; overflow-x: auto; margin: 22px -16px 0; padding: 4px 16px 10px;
  scrollbar-width: thin;
}
.cartao-acorde {
  flex: none; width: 82px; padding: 8px 4px 4px; border-radius: 12px;
  background: var(--superficie); border: 1px solid var(--borda); text-align: center;
}
.cartao-acorde:hover { border-color: var(--ouro); }
.cartao-acorde .nome { font-family: var(--mono); font-weight: 700; color: var(--acorde); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.cartao-acorde .diagrama { width: 74px; height: auto; display: block; margin: 0 auto; }
.sem-diagrama { font-size: 11px; color: var(--texto-3); padding: 24px 0; display: block; }

.diagrama { color: var(--texto-2); }
.diagrama .d-corda, .diagrama .d-traste { stroke: currentColor; stroke-width: 1; opacity: 0.7; }
.diagrama .d-pestana { fill: currentColor; }
.diagrama .d-dedo { fill: var(--dedo); }
.diagrama .d-solta { fill: none; stroke: currentColor; stroke-width: 1.4; }
.diagrama .d-casa { fill: currentColor; font-size: 10px; font-family: var(--sans); }
.diagrama .d-num { fill: var(--fundo); font-size: 9.5px; font-weight: 700; font-family: var(--sans); }

.cifra {
  margin-top: 18px;
  font-family: var(--mono); font-size: var(--tam-cifra); line-height: 1.45;
  white-space: pre; overflow-x: auto; padding-bottom: 8px;
}
.cifra.quebrar { white-space: pre-wrap; }
.cifra .l-acordes { color: var(--acorde); font-weight: 700; }
.cifra .l-acordes .sinal { color: var(--texto-3); font-weight: normal; }
.cifra .ac { color: var(--acorde); cursor: pointer; border-radius: 4px; }
.cifra .ac:hover { background: var(--superficie-2); }
.cifra .l-secao { display: inline-block; font-family: var(--sans); font-size: 0.8em; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--texto-3); margin-top: 0.8em; }
.cifra .l-letra { color: var(--texto); }

/* ---------- Barra de ferramentas ---------- */

.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--fundo) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--borda);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.barra-dentro { max-width: 760px; margin: 0 auto; }
.painel { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 4px 0 10px; }
.painel[hidden] { display: none; }
.painel-rotulo { font-size: 13px; color: var(--texto-3); min-width: 64px; text-align: right; }
.painel-valor { min-width: 64px; text-align: center; font-family: var(--mono); font-weight: 700; font-size: 18px; color: var(--acorde); }
.redondo {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--borda); background: var(--superficie); font-size: 20px; line-height: 1;
}
.redondo:hover { border-color: var(--ouro); }
.texto-pequeno { font-size: 13px; color: var(--texto-2); text-decoration: underline; padding: 8px; }

.player { padding: 2px 0 6px; margin-bottom: 6px; border-bottom: 1px solid var(--borda); }
.player-linha { display: flex; align-items: center; gap: 8px; }
.faixa-escolha { flex: 1; min-width: 0; }
.faixa-escolha select {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--borda); background: var(--superficie); color: var(--texto); font-size: 15px;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.play-audio { flex: none; background: linear-gradient(180deg, #e0b64e, #c18b21); border: 0; color: var(--sobre-ouro); }
.play-audio svg { width: 20px; height: 20px; }
.play-audio:disabled { opacity: 0.4; cursor: not-allowed; }
.tempo { flex: none; min-width: 36px; font-family: var(--mono); font-size: 12px; color: var(--texto-3); text-align: center; }
.player input[type="range"] { flex: 1; min-width: 0; height: 32px; accent-color: var(--ouro-base); }
.chip-vel { flex: none; height: 32px; min-width: 52px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--borda); background: var(--superficie); font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--acorde); }

.ferramentas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ferramenta {
  height: 48px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--texto-2); font-size: 12px;
}
.ferramenta svg { width: 20px; height: 20px; }
.ferramenta[aria-pressed="true"], .ferramenta.ativa { color: var(--ouro); background: var(--superficie); }
.ferramenta .valor { font-family: var(--mono); font-weight: 700; }

/* ---------- Folha (detalhe do acorde) ---------- */

.folha { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.folha[hidden] { display: none; }
.folha-fundo { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.folha-caixa {
  position: relative; width: 100%; max-width: 520px;
  background: var(--superficie); border: 1px solid var(--borda); border-bottom: 0;
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--sombra);
}
.folha-topo { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.folha-titulo { font-family: var(--mono); font-size: 28px; color: var(--acorde); }
.folha-posicoes { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.folha-posicoes figure { text-align: center; }
.folha-posicoes .diagrama { width: 120px; height: auto; }
.folha-posicoes figcaption { font-size: 12px; color: var(--texto-3); font-family: var(--mono); }
.folha-nota { margin-top: 12px; font-size: 13px; color: var(--texto-3); text-align: center; }

/* ---------- Repertórios ---------- */

.atalho-rep {
  display: flex; align-items: center; gap: 14px; margin-top: 20px; padding: 14px 16px;
  border-radius: 14px; border: 1px solid var(--borda); background: var(--superficie);
  color: var(--texto); text-decoration: none;
}
.atalho-rep:hover { border-color: var(--ouro); }
.atalho-rep > svg:first-child { width: 26px; height: 26px; color: var(--ouro); flex: none; }
.atalho-rep > svg:last-child { width: 18px; height: 18px; color: var(--texto-3); flex: none; margin-left: auto; }
.atalho-rep strong { display: block; font-weight: 700; }
.atalho-rep small { display: block; color: var(--texto-3); font-size: 13px; }

.criar-rep { display: flex; gap: 8px; margin: 22px 0 8px; }
.criar-rep input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--borda); background: var(--superficie);
}
.criar-rep input:focus { outline: none; border-color: var(--ouro); }
.folha .criar-rep { margin: 14px 0 10px; }

.acoes-rep { margin: 18px 0 8px; }
.botao-link { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.botao-link svg { width: 18px; height: 18px; }

.lista-rep { list-style: none; margin-top: 8px; }
.item-rep { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--borda); }
.rep-num { flex: none; width: 28px; text-align: center; font-family: var(--mono); font-weight: 700; color: var(--ouro); }
.rep-musica { flex: 1; min-width: 0; display: grid; text-decoration: none; color: inherit; }
.rep-musica .item-titulo { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.rep-musica:hover .item-titulo { color: var(--ouro); }
.rep-controles { display: flex; gap: 4px; flex: none; }
.botao-icone.pequeno { width: 36px; height: 36px; border-radius: 10px; }
.botao-icone.pequeno svg { width: 18px; height: 18px; }
.botao-icone:disabled { opacity: 0.3; cursor: default; }
.rodape-rep { margin-top: 24px; }
.perigo { color: #e07a6a; }

.nav-rep {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  margin-top: 10px; padding: 6px; border-radius: 14px; background: var(--superficie); border: 1px solid var(--borda);
}
.nav-rep a { display: flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 8px; color: var(--texto-2); text-decoration: none; font-size: 14px; border-radius: 10px; }
.nav-rep a:hover { color: var(--ouro); }
.nav-rep svg { width: 18px; height: 18px; }
.nav-rep .nav-rep-prox { justify-content: flex-end; color: var(--ouro); font-weight: 700; }
.nav-rep .nav-rep-meio { flex-direction: column; justify-content: center; gap: 0; text-align: center; line-height: 1.2; }
.nav-rep-meio b { color: var(--texto); font-size: 14px; }
.nav-rep-meio small { color: var(--texto-3); font-size: 12px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.folha-titulo-texto { font-family: var(--serifa); font-weight: normal; font-size: 24px; color: var(--texto); }
.folha-rolagem { max-height: 50vh; overflow-y: auto; margin: 0 -4px; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--borda); cursor: pointer; }
.check-item input { width: 22px; height: 22px; accent-color: var(--ouro-base); flex: none; }
.check-item b { display: block; font-weight: 700; }
.check-item small { display: block; color: var(--texto-3); font-size: 13px; }
.largo { width: 100%; margin-top: 12px; }

/* ---------- Senha ---------- */

.tela-senha { max-width: 460px; margin: 12vh auto 0; }
.tela-senha .criar-rep { margin-top: 28px; }
.mostrar-senha { display: inline-flex; align-items: center; gap: 8px; color: var(--texto-2); font-size: 14px; cursor: pointer; }
.mostrar-senha input { width: 18px; height: 18px; accent-color: var(--ouro-base); }
.erro-senha { margin-top: 12px; min-height: 1.5em; color: #e07a6a; font-size: 15px; }
.rodape .texto-pequeno { padding: 0; font-size: 13px; }

/* ---------- Área do professor ---------- */

.form { display: grid; gap: 14px; margin-top: 20px; }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.campo { display: grid; gap: 4px; }
.campo span { font-size: 13px; color: var(--texto-2); }
.campo input, .campo textarea {
  width: 100%; border-radius: 10px; border: 1px solid var(--borda); background: var(--superficie);
  padding: 10px 12px; min-height: 44px;
}
.campo textarea { font-family: var(--mono); font-size: 14px; line-height: 1.45; min-height: 260px; resize: vertical; white-space: pre; }
.campo input:focus, .campo textarea:focus { outline: none; border-color: var(--ouro); }
.campo-largo { grid-column: 1 / -1; }

.botao {
  height: 48px; padding: 0 20px; border-radius: 12px; font-weight: 700;
  background: linear-gradient(180deg, #e0b64e, #c18b21); color: var(--sobre-ouro);
}
.botao-secundario { height: 48px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--borda); background: var(--superficie); }
.linha-botoes { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.aviso { font-size: 14px; color: var(--texto-2); background: var(--superficie); border: 1px solid var(--borda); border-radius: 12px; padding: 12px 14px; }
.aviso ol { margin: 6px 0 0 20px; }
.secao-titulo { font-family: var(--serifa); font-weight: normal; font-size: 24px; margin-top: 28px; }
.previa { border: 1px dashed var(--borda); border-radius: 14px; padding: 4px 14px 14px; }
.previa .faixa-acordes { margin: 14px 0 0; padding: 4px 0 10px; }

@media (min-width: 700px) {
  .app { padding-top: 36px; }
  .item a { padding: 16px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
