/* Conjoin · Layout do app: palco, aparelho, tela, cabeçalhos, rodapé fixo, barra de abas, bento */

/* Palco: no desktop o app aparece num aparelho centralizado */
.stage {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s-6);
}

.device {
  position: relative;
  width: 390px;
  height: min(844px, calc(100dvh - 48px));
  background: var(--bg);
  border-radius: 44px;
  box-shadow: 0 0 0 10px var(--noite), 0 0 0 11px var(--porto), 0 24px 64px rgba(16, 28, 38, 0.28);
  overflow: hidden;
  isolation: isolate;
}

.app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.screen-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#tab-host { flex: none; }

/* Barra de status simulada (só no aparelho do desktop) */
.statusbar {
  flex: none;
  height: 44px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--noite);
  background: var(--bg);
}
.statusbar svg { width: 18px; height: 18px; }
.statusbar .sb-icons { display: flex; gap: 6px; align-items: center; }
.app[data-tone="azul"] .statusbar { background: var(--azul); color: var(--alva); }
.app[data-tone="alva"] .statusbar { background: var(--alva); }

/* Tela */
.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.screen[data-tone="alva"] { background: var(--alva); }
.screen[data-tone="azul"] { background: var(--azul); color: var(--alva); }

.screen-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-2) var(--gutter) var(--s-8);
  scroll-padding-bottom: 96px;
}
.screen-body.is-flush { padding: 0; }
.screen-body.is-centered {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Cabeçalho grande (telas de aba) */
.tab-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--gutter) var(--s-3);
}
.tab-header .th-text { flex: 1; min-width: 0; }
.tab-header h1 { font-size: var(--fs-headline); line-height: var(--lh-headline); font-weight: 700; letter-spacing: -0.015em; color: var(--azul); }
.tab-header .th-kicker { color: var(--ink-soft); font-size: var(--fs-body); }

/* Cabeçalho compacto (telas internas) */
.topbar {
  flex: none;
  display: grid;
  grid-template-columns: var(--touch) 1fr auto;
  align-items: center;
  gap: var(--s-2);
  min-height: 56px;
  padding: var(--s-1) var(--s-2) var(--s-1) var(--s-2);
  background: var(--bg);
}
.topbar h1 {
  font-size: var(--fs-title);
  line-height: var(--lh-title);
  font-weight: 600;
  color: var(--noite);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .tb-end { display: flex; gap: var(--s-1); justify-content: flex-end; min-width: var(--touch); }
.screen[data-tone="alva"] .topbar { background: var(--alva); }
.screen[data-tone="azul"] .topbar { background: var(--azul); }
.screen[data-tone="azul"] .topbar h1 { color: var(--alva); }

/* Barra de progresso do cadastro sob o cabeçalho */
.topbar-progress { flex: none; padding: 0 var(--gutter) var(--s-3); }

/* Rodapé fixo com a ação principal */
.screen-footer {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3) var(--gutter) calc(var(--s-4) + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.screen[data-tone="alva"] .screen-footer { background: var(--alva); }
.screen[data-tone="azul"] .screen-footer { background: var(--azul); border-top: 0; }
.screen-footer.is-plain { border-top: 0; }
.screen-footer .footer-note { text-align: center; font-size: var(--fs-label); color: var(--ink-soft); }

/* Barra de abas */
.tabbar {
  flex: none;
  position: relative;
  z-index: var(--z-tabbar);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  min-height: var(--tabbar-h);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--alva);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow-float);
}

/* Pilhas e agrupamentos */
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-xs { display: flex; flex-direction: column; gap: var(--s-1); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.stack-md { display: flex; flex-direction: column; gap: var(--s-3); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-6); }
.stack-xl { display: flex; flex-direction: column; gap: var(--s-8); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row-sm { display: flex; align-items: center; gap: var(--s-2); }
.row-wrap { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.grow { flex: 1; min-width: 0; }
.mt-2 { margin-top: var(--s-2); }
.mt-4 { margin-top: var(--s-4); }
.mt-6 { margin-top: var(--s-6); }

/* Seção com título */
.section { display: flex; flex-direction: column; gap: var(--s-3); }
.section + .section { margin-top: var(--s-6); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.section-head h2 { font-size: var(--fs-title); line-height: var(--lh-title); font-weight: 600; color: var(--noite); }
.section-head .section-link { font-weight: 600; color: var(--azul); text-decoration: none; font-size: var(--fs-label); padding: var(--s-2) 0; }

/* Bento: grade de 2 colunas com blocos de tamanhos diferentes */
.bento {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}
.bento > .span-2 { grid-column: span 2; }

/* Pergunta por tela (cadastros) */
.question { display: flex; flex-direction: column; gap: var(--s-6); padding-top: var(--s-2); }
.question-head { display: flex; flex-direction: column; gap: var(--s-2); }
.question-head h2 { font-size: var(--fs-title-lg); line-height: var(--lh-title-lg); font-weight: 600; color: var(--azul); letter-spacing: -0.01em; }
.question-head p { color: var(--ink-soft); }

/* Hero centralizado (estados, confirmações) */
.hero-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-4);
  padding: var(--s-8) var(--s-2) var(--s-6);
}
.hero-state h1, .hero-state h2 { font-size: var(--fs-title-lg); line-height: var(--lh-title-lg); font-weight: 700; color: var(--azul); }
.hero-state p { color: var(--ink-soft); max-width: 32ch; }
