/* Layout: uma coluna para celular; cabeçalho fixo e compacto (voltar, título, cargo, ajustes) com abas no capítulo
   (Ritual, Índice, Preparação); listas em cartões com linhas; no ritual, texto corrido sem caixas, com as falas e os atos
   do cargo escolhido em destaque; barra inferior "Minha vez". */
:root {
  --bg: #F2F4EF;
  --surface: #FFFFFF;
  --ink: #1C2620;
  --muted: #5B675F;
  --line: #D6DDD6;
  --edge: #7C8A80;          /* contorno de controles (3:1 sobre o fundo) */
  --accent: #2E6A4D;
  --accent-ink: #FFFFFF;
  --accent-soft: #E1EDE5;
  --rubric: #A3271F;        /* rubricas: vermelho e itálico, como no livro */
  --warn-bg: #FFF0A3;
  --warn-ink: #4F4100;
  --warn-bar: #C99700;
  --font-display: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --top-h: 57px;            /* altura do cabeçalho, atualizada por script */
  --safe-top: env(safe-area-inset-top, 0px);   /* faixa do alto que o aplicativo do Claude no iPhone cobre */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111713; --surface: #18201B; --ink: #E4ECE6; --muted: #9AA79F; --line: #2B3730; --edge: #6B7C71;
    --accent: #72C29A; --accent-ink: #0E1A13; --accent-soft: #1F3328; --rubric: #F0907F;
    --warn-bg: #4B4212; --warn-ink: #FFE58A; --warn-bar: #E3BD52;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111713; --surface: #18201B; --ink: #E4ECE6; --muted: #9AA79F; --line: #2B3730; --edge: #6B7C71;
  --accent: #72C29A; --accent-ink: #0E1A13; --accent-soft: #1F3328; --rubric: #F0907F;
  --warn-bg: #4B4212; --warn-ink: #FFE58A; --warn-bar: #E3BD52;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
html[data-text="large"] { font-size: 19px; }
html[data-text="larger"] { font-size: 22px; }
html[data-text="max"] { font-size: 25px; }
body { margin: 0; padding-top: var(--safe-top); background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 1rem; line-height: 1.5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 42rem; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Cabeçalho (medidas em px: não cresce com o tamanho do texto) */
header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); transition: transform .25s ease; }
header.top.hide { transform: translateY(calc(-100% - env(safe-area-inset-top, 0px))); }
.title-row { display: flex; align-items: center; gap: 6px; padding-block: 6px; }
.top-title { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { flex: none; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--bg); }
.icon-btn svg { width: 22px; height: 22px; }
#bt-back { margin-left: -10px; color: var(--ink); }
/* chip do cargo: a bolinha fica verde quando o cargo tem fala, ato ou preparação no capítulo aberto */
.cargo-chip { flex: none; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--edge); background: var(--bg); border-radius: 999px; padding: 8px 14px 8px 12px; font-size: 15px; color: var(--ink); cursor: pointer; min-height: 44px; max-width: 50%; }
.cargo-chip b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cargo-chip::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--edge); }
.cargo-chip[data-on="1"]::before { background: var(--accent); }
.cargo-chip.unset { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); padding-left: 14px; }
.cargo-chip.unset::before { display: none; }
nav.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
nav.tabs button { font-weight: 600; font-size: 15px; background: none; border: 0; color: var(--muted); padding: 4px 2px 8px; border-bottom: 3px solid transparent; cursor: pointer; min-height: 44px; white-space: nowrap; }
nav.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
nav.tabs .n { font-family: var(--font-mono); font-size: 13px; font-weight: 500; margin-left: 4px; }

main .wrap { padding-block: 16px calc(40px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px; }
body.has-mybar main .wrap { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
.view { display: grid; gap: 14px; }
.note { color: var(--muted); font-size: 0.86rem; margin: 0; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; }
.page-title { font-size: 1.45rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
.sub { color: var(--muted); font-size: 0.86rem; margin: 4px 0 0; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Cartões e listas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li { border-top: 1px solid var(--line); }
.row-btn { display: grid; width: 100%; text-align: left; background: none; border: 0; cursor: pointer; padding: 12px 14px; min-height: 48px; align-items: center; }
.row-btn:hover { background: var(--bg); }
.doc-btn { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding-block: 14px; }
.doc-btn .nome { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.doc-btn .det { grid-column: 1; color: var(--muted); font-size: 0.86rem; }
.doc-btn svg, .cap-btn svg { grid-row: 1 / span 2; grid-column: 2; width: 18px; height: 18px; color: var(--muted); }
.doc-btn[disabled] { cursor: default; opacity: .6; }
.cap-btn { grid-template-columns: 3.4rem minmax(0, 1fr) auto; gap: 0 8px; align-items: baseline; }
.cap-btn .p { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cap-btn .v { color: var(--accent); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.cap-btn svg { grid-row: auto; grid-column: auto; align-self: center; }
.tag-ok { color: var(--accent); font-weight: 600; }

/* Leitura do ritual */
.legend { font-size: 0.86rem; color: var(--muted); }
.legend summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 6px; }
.legend p { margin: 0 0 8px; }
.legend .rb { color: var(--rubric); font-style: italic; }
.legend .mn { background: var(--accent-soft); color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); padding: 1px 6px 1px 8px; }
.ritual { display: flex; flex-direction: column; gap: 12px; }
.pg { display: flex; align-items: center; gap: 10px; margin-block: 8px 0; scroll-margin-top: calc(var(--top-h) + var(--safe-top) + 12px); color: var(--muted); font-family: var(--font-mono); font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.pg::before, .pg::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.tit { font-size: 1.12rem; font-weight: 700; line-height: 1.25; padding-top: 18px; margin-top: 6px; border-top: 1px solid var(--line); scroll-margin-top: calc(var(--top-h) + var(--safe-top) + 8px); }
.tit.sub2 { font-size: 1rem; border-top: 0; padding-top: 6px; }
.nota { margin: 0; }
.fala, .rub { scroll-margin-top: calc(var(--top-h) + var(--safe-top) + 12px); }
.fala .quem { font-family: var(--font-display); font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 1px; }
.rub, .red { color: var(--rubric); font-style: italic; }
.inf { font-family: var(--font-body); font-weight: 400; font-style: italic; color: var(--muted); }
.lacuna { color: var(--accent); font-weight: 600; }
.corte { text-decoration: underline dotted var(--rubric); text-underline-offset: 3px; }
.img-nota { color: var(--muted); font-size: 0.86rem; font-style: italic; margin: 0; }
/* destaque do cargo escolhido */
.fala.mine, .rub.mine { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); border-radius: 0 8px 8px 0; padding: 10px 12px 10px 16px; }
.fala.mine .quem { color: var(--accent); }
.fala.mine .txt { font-weight: 600; }
.rub.mine::before { content: "Seu ato"; display: block; font-family: var(--font-display); font-style: normal; font-weight: 600; font-size: 0.8rem; color: var(--accent); margin-bottom: 1px; }
.red.ato.mine { font-weight: 600; border-bottom: 2px solid var(--accent); }
.vizinhos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.viz { text-align: left; background: var(--surface); border: 1px solid var(--edge); border-radius: 10px; padding: 10px 12px; min-height: 56px; cursor: pointer; font-size: 0.86rem; line-height: 1.3; min-width: 0; }
.viz small { display: block; color: var(--muted); font-size: 0.78rem; }
.viz.next { text-align: right; }

/* Barra "Minha vez" */
.mybar { position: fixed; z-index: 4; inset: auto 0 0; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.mybar .wrap { display: flex; gap: 8px; padding-block: 8px; }
.btn { font-weight: 600; font-size: 16px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); padding: 8px 16px; min-height: 48px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.ghost { background: var(--bg); color: var(--ink); border-color: var(--edge); }
.btn svg { width: 18px; height: 18px; }
.mybar .btn.go { flex: 1; }

/* Índice */
.idx h2 { font-size: 1rem; font-weight: 700; }
.prep .sessao { margin-top: 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.prep .sessao h2 { font-size: 1.12rem; font-weight: 700; }
.linkbtn { font-weight: 600; color: var(--accent); background: none; border: 0; padding: 10px 0; cursor: pointer; min-height: 44px; font-size: 0.92rem; }
.pgs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.pgs-grid button { min-height: 44px; background: var(--surface); border: 1px solid var(--edge); border-radius: 10px; font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; cursor: pointer; }

/* Preparação (checklists por cargo) */
.banner { border-radius: 8px; padding: 10px 12px; font-size: 0.92rem; background: var(--warn-bg); color: var(--warn-ink); margin: 0; }
button.banner { border: 0; width: 100%; text-align: left; cursor: pointer; min-height: 44px; box-shadow: inset 3px 0 0 var(--warn-bar); }
button.banner u { font-weight: 600; }
details.sec { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
details.sec > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; min-height: 48px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary svg { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
details.sec[open] > summary svg { transform: rotate(90deg); }
.sec-name { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.sec-count { font-family: var(--font-mono); color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sec-count.full { color: var(--accent); font-weight: 500; }
.meter { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.sec-body { border-top: 1px solid var(--line); }
.sec-body > .note, .sec-body > .banner { margin: 12px 14px; }
h3.grp { font-family: var(--font-display); font-weight: 600; font-size: 0.86rem; color: var(--muted); padding: 14px 14px 6px; border-top: 1px solid var(--line); margin: 0; }
ul.items { list-style: none; margin: 0; padding: 0; }
li.item { border-top: 1px solid var(--line); }
li.item label { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: start; cursor: pointer; padding: 12px 14px 12px 6px; min-height: 48px; }
li.item input { width: 24px; height: 24px; margin: 0 auto; accent-color: var(--accent); cursor: pointer; }
li.item .meta { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
li.item.done .what { color: var(--muted); text-decoration: line-through; }

/* Janelas (cargo e ajustes) */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 0; width: min(30rem, calc(100vw - 32px)); max-height: calc(100dvh - 48px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
dialog::backdrop { background: rgba(8, 14, 10, 0.55); }
.dg { display: grid; gap: 12px; padding: 16px; }
.dg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dg-head h2 { font-size: 1.15rem; font-weight: 700; }
.dg-head .icon-btn { margin: -8px -8px -8px 0; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 0.86rem; color: var(--muted); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.seg button { min-height: 44px; border: 1px solid var(--edge); background: var(--bg); border-radius: 10px; font-size: 15px; cursor: pointer; padding: 6px 4px; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent); }
.cargos { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cargos li + li { border-top: 1px solid var(--line); }
.cargos button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; align-items: baseline; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; min-height: 48px; cursor: pointer; }
.cargos button[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); font-weight: 600; }
.cargos .conta { color: var(--muted); font-size: 0.8rem; font-weight: 400; white-space: nowrap; }
.cargos button.vazio { color: var(--muted); }
.cargos-sep { font-family: var(--font-display); font-size: 0.8rem; font-weight: 600; color: var(--muted); background: var(--bg); padding: 6px 12px; }

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

/* ---- Acréscimos do app: fontes próprias, telas de entrada, avisos, formulários e administração ---- */
.sprite { position: absolute; width: 0; height: 0; }
.gate { min-height: calc(100dvh - var(--safe-top)); display: grid; align-content: center; padding-block: 32px calc(32px + env(safe-area-inset-bottom, 0px)); }
.gate .wrap { display: grid; gap: 18px; width: 100%; max-width: 26rem; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand svg { width: 40px; height: 40px; color: var(--accent); flex: none; }
.brand h1 { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }
.gate h2 { font-size: 1.2rem; font-weight: 700; }
.gate p { margin: 0; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 0.92rem; font-weight: 600; }
.form input[type="email"], .form input[type="password"], .form input[type="text"], .form input[type="date"], .form select {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--surface); border: 1px solid var(--edge); border-radius: 10px;
  padding: 10px 12px; min-height: 48px; width: 100%; }
.form .hint { font-weight: 400; color: var(--muted); font-size: 0.86rem; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .6; cursor: default; }
.btn.danger { background: var(--surface); color: var(--rubric); border-color: var(--rubric); }
.msg { border-radius: 8px; padding: 10px 12px; font-size: 0.92rem; background: var(--warn-bg); color: var(--warn-ink); box-shadow: inset 3px 0 0 var(--warn-bar); margin: 0; }
.consent { background: var(--surface); border: 2px solid var(--accent); border-radius: 12px; padding: 16px; display: grid; gap: 12px; }
.consent ul { margin: 0; padding-left: 1.2rem; display: grid; gap: 4px; }
.check { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: start; cursor: pointer; font-weight: 600; min-height: 48px; padding-block: 6px; }
.check input { width: 24px; height: 24px; margin: 2px auto 0; accent-color: var(--accent); }
.stack { display: grid; gap: 10px; }
.acct { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.loading { color: var(--muted); text-align: center; padding: 32px 0; margin: 0; }
.tag-warn { color: var(--warn-ink); background: var(--warn-bg); border-radius: 6px; padding: 1px 8px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.cap-btn .tag-warn { align-self: center; }
/* Administração */
.adm-row { display: grid; gap: 4px; padding: 12px 14px; }
.adm-row .mail { font-weight: 600; overflow-wrap: anywhere; }
.adm-row .meta { color: var(--muted); font-size: 0.86rem; }
.adm-row .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.btn.small { min-height: 44px; font-size: 15px; padding: 6px 12px; }
.qr { width: 200px; height: 200px; background: #fff; border-radius: 8px; padding: 8px; justify-self: center; }
.secret { font-family: var(--font-mono); font-size: 0.86rem; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.log li { padding: 10px 14px; font-size: 0.9rem; display: grid; gap: 2px; }
.log .when { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.viz.vazio { visibility: hidden; }
a.btn { text-decoration: none; }
#tela-admin h2 { font-size: 1.05rem; font-weight: 700; margin-top: 8px; }
#tela-admin .form.card { gap: 12px; }
