:root {
  --grafite: #2b2b2b;
  --grafite-2: #4a4a48;
  --ouro: #b8964a;
  --ouro-claro: #c9a86a;
  --papel: #f7f4ee;
  --folha: #fffdf9;
  --linha: #e4ddd0;
  --tinta: #1e1e1e;
  --apagado: #7a756c;
  --titulo: "Fraunces", Georgia, serif;
  --corpo: "Roboto Condensed", system-ui, sans-serif;
  --baixo: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--papel); color: var(--tinta);
  font-family: var(--corpo); font-size: 17px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
#tela { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(96px + var(--baixo)); min-height: 100dvh; }
h1 { font-family: var(--titulo); font-weight: 600; font-size: 26px; line-height: 1.15; margin: 8px 0 4px; }
h2 { font-family: var(--titulo); font-weight: 600; font-size: 19px; margin: 24px 0 8px; }
p { margin: 0 0 10px; }
a { color: inherit; }
.sub { color: var(--apagado); font-size: 15px; margin: 0 0 14px; }
.topo { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.topo .acoes { display: flex; gap: 6px; flex-shrink: 0; padding-top: 6px; }

button, .botao {
  font: inherit; font-weight: 500; border: 1px solid var(--grafite); background: var(--grafite); color: #fff;
  padding: 11px 16px; border-radius: 10px; min-height: 44px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button.claro, .botao.claro { background: transparent; color: var(--grafite); border-color: var(--linha); }
button.ouro { background: var(--ouro); border-color: var(--ouro); color: #1e1e1e; }
button.fio { background: none; border: none; color: var(--grafite-2); padding: 8px 10px; min-height: 40px; text-decoration: underline; text-underline-offset: 3px; }
button.perigo { background: transparent; color: #7a3b2e; border-color: #d9c2ba; }
button:disabled { opacity: .5; }
button svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fila { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fila.fim { justify-content: flex-end; }
.cresce { flex: 1; }

input, textarea, select {
  font: inherit; width: 100%; padding: 11px 12px; border: 1px solid var(--linha); border-radius: 10px;
  background: var(--folha); color: var(--tinta); min-height: 44px;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
textarea.passagem { font-family: var(--titulo); font-size: 18px; min-height: 160px; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--ouro); outline-offset: 1px; }
label { display: block; font-size: 14px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--grafite-2); margin: 16px 0 6px; }
.dupla { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dupla label { margin-top: 10px; }

/* Anotação */
.cartao { background: var(--folha); border: 1px solid var(--linha); border-radius: 14px; padding: 14px 16px; margin: 0 0 12px; display: block; text-decoration: none; }
.cartao .passagem { font-family: var(--titulo); font-size: 18px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 8px; }
.cartao .passagem.curta { display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.cartao .reflexao { border-left: 3px solid var(--ouro); padding-left: 10px; margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--grafite-2); }
.cartao .fonte { font-size: 15px; color: var(--apagado); margin: 6px 0 8px; }
.cartao .fonte b { color: var(--grafite-2); font-weight: 500; }
.cartao .pe { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; color: var(--apagado); margin-top: 8px; }
.cartao audio { width: 100%; margin: 6px 0; height: 40px; }
.estado { font-size: 14px; color: var(--apagado); font-style: italic; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  --c: var(--grafite-2);
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; line-height: 1;
  padding: 7px 10px; border-radius: 999px; text-decoration: none; cursor: pointer; min-height: 30px;
  background: color-mix(in srgb, var(--c) 14%, #fff); border: 1px solid color-mix(in srgb, var(--c) 35%, #fff); color: var(--tinta);
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.chip.vazio { background: transparent; border-style: dashed; }
.chip.ligado { background: var(--c); border-color: var(--c); color: #fff; }
.chip.ligado::before { background: #fff; }

.faixa { background: var(--grafite); color: #fff; border-radius: 14px; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-decoration: none; margin: 0 0 14px; }
.faixa b { color: var(--ouro-claro); font-family: var(--titulo); font-size: 22px; }
.vazio-tela { text-align: center; color: var(--apagado); padding: 36px 12px; }
.vazio-tela .frase { font-family: var(--titulo); font-style: italic; font-size: 19px; color: var(--grafite-2); margin-bottom: 10px; }

/* Árvore de assuntos */
.arvore { list-style: none; margin: 0; padding: 0; }
.arvore ul { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 1px solid var(--linha); margin-left: 9px; }
.no { display: flex; align-items: center; gap: 4px; }
.no a { flex: 1; display: flex; align-items: center; gap: 10px; padding: 11px 6px; text-decoration: none; min-height: 46px; border-bottom: 1px solid var(--linha); }
.no .ponto { width: 14px; height: 14px; border-radius: 4px; background: var(--c); flex-shrink: 0; }
.no .nome { flex: 1; font-weight: 500; }
.arvore > li > .no .nome { font-family: var(--titulo); font-size: 19px; font-weight: 600; }
.no .conta { color: var(--apagado); font-size: 14px; }
.no button { background: none; border: none; color: var(--apagado); padding: 0; width: 36px; min-height: 44px; }
.no button svg { transition: transform .15s; }
.no button[aria-expanded="true"] svg { transform: rotate(90deg); }

.cabeca-assunto { border-left: 6px solid var(--c); padding-left: 12px; margin-bottom: 12px; }
.migalha { font-size: 14px; color: var(--apagado); }
.migalha a { text-decoration: none; }

.cores { display: flex; flex-wrap: wrap; gap: 8px; }
.cores button { width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; border: 3px solid transparent; background: var(--c); }
.cores button.herda { background: var(--folha); border: 1px dashed var(--apagado); color: var(--apagado); font-size: 12px; width: auto; padding: 0 12px; border-radius: 999px; }
.cores button[aria-pressed="true"] { border: 3px solid var(--tinta); }

dialog { border: none; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--baixo)); width: 100%; max-width: 640px; margin: auto auto 0; max-height: 88dvh; background: var(--papel); color: var(--tinta); }
dialog::backdrop { background: rgba(30, 30, 30, .45); }
dialog h2 { margin-top: 0; }
.lista-marca { max-height: 46dvh; overflow: auto; margin: 8px 0; }
.lista-marca label { display: flex; align-items: center; gap: 10px; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 17px; color: var(--tinta); margin: 0; padding: 9px 4px; border-bottom: 1px solid var(--linha); }
.lista-marca input { width: 22px; height: 22px; min-height: 0; accent-color: var(--grafite); flex-shrink: 0; }
.lista-marca .ponto { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex-shrink: 0; }

/* Gravação */
.gravando { background: var(--grafite); color: #fff; border-radius: 14px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.gravando .luz { width: 12px; height: 12px; border-radius: 50%; background: var(--ouro-claro); animation: pulsa 1s infinite; }
.gravando .tempo { font-family: var(--titulo); font-size: 22px; flex: 1; font-variant-numeric: tabular-nums; }
@keyframes pulsa { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .gravando .luz { animation: none; } }

/* Mapa */
#mapa { position: fixed; inset: 0 0 calc(72px + var(--baixo)) 0; background: var(--papel); touch-action: none; }
#mapa canvas { width: 100%; height: 100%; display: block; }
.sobre-mapa { position: fixed; top: 12px; left: 16px; right: 16px; pointer-events: none; }
.sobre-mapa h1 { margin: 0; }

/* Barra de baixo */
#barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--grafite);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  padding: 6px 6px calc(6px + var(--baixo));
}
#barra[hidden] { display: none; }
#barra a { color: #cfc9bd; text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; padding: 6px 0; min-height: 52px; justify-content: center; }
#barra a svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#barra a.aqui { color: var(--ouro-claro); }
#barra a.mais { background: var(--ouro); color: #1e1e1e; width: 54px; height: 54px; min-height: 54px; border-radius: 50%; margin: -18px auto 0; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }
#barra a.mais svg { width: 28px; height: 28px; stroke-width: 2.2; }

#aviso { position: fixed; left: 16px; right: 16px; bottom: calc(92px + var(--baixo)); z-index: 20; background: var(--grafite); color: #fff; padding: 12px 16px; border-radius: 12px; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 608px; margin: 0 auto; }
#aviso.visivel { opacity: 1; }

.entrada-login { max-width: 360px; margin: 18dvh auto 0; text-align: center; }
.entrada-login h1 { font-size: 32px; }
.entrada-login form { margin-top: 24px; display: grid; gap: 10px; }
.erro { color: #7a3b2e; font-size: 15px; min-height: 22px; }
