/* BioSphere · plataforma · estilos do shell e das camadas (W1).
   Carrega depois de ds/tokens.css, ds/bundle.css e ui/composites.css. Toda cor, raio, espaço, sombra e desfoque vem de token.
   Prefixo ap- (aplicação). Construtores de módulo não editam este arquivo: usam os blocos ui/ciencia.css, execucao.css, decisao.css e organizacao.css. */

/* ================= Base ================= */
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; background: var(--bg); }
html.ap-locked { overflow: hidden; }
body.ap-body { margin: 0; min-height: 100vh; overflow-x: hidden; background: var(--bg); color: var(--ink); font-family: var(--font-sans); }
body.ap-body::before {
  content: ""; position: fixed; inset: -20vh -10vw auto auto; width: 70vw; height: 80vh; z-index: -1; pointer-events: none; filter: blur(40px);
  background:
    radial-gradient(40% 45% at 70% 30%, color-mix(in srgb, var(--purple-300) 22%, transparent), transparent 70%),
    radial-gradient(35% 40% at 30% 60%, color-mix(in srgb, var(--orange) 18%, transparent), transparent 70%),
    radial-gradient(30% 35% at 85% 75%, color-mix(in srgb, var(--mint) 22%, transparent), transparent 70%);
}
[data-theme=dark] body.ap-body::before { opacity: .55; }
a { color: inherit; }
.ap-body :where(a.bs-row, a.bs-btn, a.bs-mini, a.bs-menu-it, a.bs-module, a.bs-rail__btn, a.bs-mnav__btn, a.bs-cta, a.bs-mc__fact, a.bs-mc-group__cell, a.bs-bucket) { text-decoration: none; color: inherit; }
.ap-body :where(a.bs-btn--ink, a.bs-mini--ink) { color: var(--on-ink); }
.ap-skip { position: absolute; left: -999px; top: 8px; z-index: var(--z-tip); padding: 10px 16px; border-radius: var(--radius-pill); background: var(--ink); color: var(--on-ink); }
.ap-skip:focus { left: 12px; }

/* ================= Shell (MOD-00) ================= */
.ap-app { display: grid; grid-template-columns: var(--size-rail) minmax(0, 1fr); min-height: 100vh; }
.ap-rail { position: sticky; top: 0; height: 100vh; box-sizing: border-box; padding: 20px 0 16px; gap: 0; }
.ap-rail__home { display: grid; place-items: center; border-radius: var(--radius-sm); flex: none; }
.ap-rail__list { flex: 1; min-height: 0; width: 100%; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0 12px; scrollbar-width: none; }
.ap-rail__list::-webkit-scrollbar { display: none; }
.ap-rail__btn { flex: none; }
.ap-rail__sep { flex: none; width: 20px; height: 1px; margin: 4px 0; background: var(--line-strong); }
.ap-rail__fase { position: absolute; right: -7px; bottom: -3px; padding: 0 4px; border-radius: var(--radius-pill); font: 500 9px/14px var(--font-mono); background: var(--purple-soft); color: var(--purple-ink); }
.ap-rail__btn.is-active .ap-rail__fase { background: var(--mint); color: var(--on-mint); }
.ap-me { flex: none; border-radius: 50%; }
.ap-me .bs-avatar { width: 48px; height: 48px; }
.ap-rail .ap-me { margin-top: 8px; }
.ap-main { min-width: 0; padding: 22px 32px 40px 8px; display: flex; flex-direction: column; gap: var(--space-5); }
.ap-top { gap: 12px; }
.ap-top__logo { display: none; width: 36px; height: 36px; border-radius: var(--radius-sm); flex: none; }
.ap-ctx { min-width: 0; max-width: 100%; }
.ap-ctx b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ap-only-m, .ap-top .ap-me { display: none; }
.ap-top .ap-me .bs-avatar { width: 40px; height: 40px; }
.ap-badge[hidden] { display: none; }
.ap-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 8px 8px 18px; border-radius: var(--radius-pill); background: var(--purple-tint); color: var(--purple-ink); font-size: 13px; }
.ap-banner[hidden] { display: none; }
.ap-banner__txt { flex: 1; min-width: 0; }
.ap-banner b { font-weight: 500; }
.ap-view { min-width: 0; outline: none; }
.ap-foot { display: flex; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding: 8px 4px 0; font-size: 12px; color: var(--ink-muted); }

/* ================= Telas ================= */
.ap-page { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.ap-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding: 6px 0 4px; }
.ap-head__txt { min-width: 0; flex: 1 1 420px; }
.ap-head__eyebrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; font-size: 12px; color: var(--ink-muted); }
.ap-head h1 { margin: 0; font-weight: 400; font-size: 44px; line-height: 1.06; letter-spacing: -.035em; outline: none; }
.ap-head h1 span { display: block; color: var(--ink-muted); }
.ap-head__acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-previa { display: flex; align-items: center; gap: 10px; }
.ap-fase { vertical-align: 2px; }
.ap-card { animation: ap-up .7s cubic-bezier(.625, .05, 0, 1) both; }
@keyframes ap-up { from { opacity: 0; transform: translateY(16px); } }
.ap-count { margin-left: auto; padding: 6px 8px; border-radius: var(--radius-md); line-height: 0; transition: background .3s; }
.ap-count:hover { background: var(--surface-sunken); }
.ap-state .bs-card { max-width: 560px; margin: 8vh auto 0; }
.ap-state__lock { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-sunken); color: var(--ink); }
.ap-state__acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 8px; }
.ap-build { justify-content: center; }
.ap-build__q { margin: 0; font-size: 12px; color: var(--ink-muted); text-align: center; }
.ap-p { margin: 0; font-size: 14px; line-height: 1.5; }
.ap-link { font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.ap-entity__ico { display: grid; place-items: center; width: 100%; height: 100%; }

/* ================= Início (MOD-01, W1) ================= */
.ini .ap-head { align-items: center; }
.ini-papel { gap: 8px; padding: 0 14px; font-size: 13px; }
.ini-papel b { font-weight: 500; }
.ini-aviso { align-items: center; flex-wrap: wrap; }
.ini-aviso > span { flex: 1; min-width: 200px; }
.ini-strip { padding-left: 18px; }
.ini-strip__legend { margin-top: -8px; padding-left: 18px; }
.ini-foco { min-height: 380px; }
.ini-foco .bs-card__h { font-size: 30px; margin-bottom: 14px; }
.ini-foco .bs-mc__facts { margin-top: auto; padding-top: var(--space-5); }
.ini-chip { cursor: pointer; }
.ini-q .bs-row { padding: 10px 12px; }
.ini-q .bs-row__main b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ini-brief p { font-size: 16px; }
.ini-orbs { height: 140px; margin: -4px 0 8px; }
.ini-ag { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--ink-muted); }
.ini-ag span { display: inline-flex; align-items: center; gap: 6px; }
.ini-ag i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint-strong); }
.ini-ag i.busy { background: var(--purple); animation: bs-pulse 1.4s infinite; }
.ini-ag i.warn { background: var(--alert); }
.ini-diverge { display: flex; gap: 10px; align-items: flex-start; margin-top: auto; padding: 12px 14px; border-radius: var(--radius-md); background: var(--surface-raised); font-size: 12.5px; line-height: 1.45; text-align: left; color: var(--ink); }
.ini-diverge b { font-weight: 500; }
.bs-card--mint .ini-diverge { margin-top: 14px; }
.ini-radar { position: relative; max-width: 330px; width: 100%; margin: 0 auto; }
.ini-radar__callout { position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%); width: min(270px, 92%); padding: 10px 14px; border-radius: var(--radius-md); background: rgba(255, 255, 255, .14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .24); backdrop-filter: blur(var(--blur-glass)); -webkit-backdrop-filter: blur(var(--blur-glass)); color: var(--on-media); font-size: 12px; line-height: 1.4; text-align: left; }
.ini-radar__callout b { display: block; font: 500 12px var(--font-mono); margin-bottom: 2px; }
.ini-radar__foot { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--on-media); opacity: .86; }
.ini-radar__foot b { font-weight: 500; }
.ini-radar .rdot { cursor: pointer; }
.ini-sim__mol { display: grid; place-items: center; margin: -8px 0 4px; min-height: 120px; }
.ini-sim__hint { margin: 12px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-muted); }
.ini-sim__hint b { color: var(--ink); font-weight: 500; }
.ini-line { position: relative; cursor: pointer; }
.ini-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; font-size: 11.5px; opacity: .9; }
.ini-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ini-meses .bs-month { cursor: pointer; }
.ini-rows .bs-dotrow { width: 100%; text-align: left; }
.ini-funil { margin-top: 4px; }
.ini-dwmetric { display: flex; align-items: flex-end; gap: 14px; margin-top: 6px; font-size: 13px; line-height: 1.4; }
.ini-dwmetric span { opacity: .85; padding-bottom: 4px; }
.ini-dwmetric--ink span { color: var(--ink-muted); opacity: 1; }
.ini-rowtags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.ini-hyp { display: flex; align-items: center; gap: 10px; width: 100%; }
.ini-hyp__id { font-size: 12px; color: var(--ink-muted); width: 40px; flex: none; }
.ini-afr { font-weight: 400; font-size: 14px; line-height: 1.5; margin-top: 6px; display: block; }
.ini-radrow { display: flex; gap: 12px; align-items: center; }
.ini-ladbox { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.ini-log { font-size: 11.5px; line-height: 1.7; }
.ini-pauta__who { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12px; opacity: .9; }
.ini-pauta__it { display: flex; gap: 12px; align-items: flex-start; }
.ini-pauta__n { font-size: 20px; width: 22px; flex: none; }
.ini-kv-on { box-shadow: inset 0 0 0 1.5px var(--ink); }
@media (max-width: 900px) {
  .ini-foco { min-height: 340px; }
  .ini-foco .bs-card__h { font-size: 26px; }
  .ini .ap-head__acts { width: 100%; }
}

/* ================= Camadas ================= */
.ap-layer { position: fixed; inset: 0; z-index: var(--z-drawer); }
.ap-layer--modal { z-index: var(--z-modal); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.ap-layer > .bs-backdrop { animation: ap-fade .3s ease both; }
@keyframes ap-fade { from { opacity: 0; } }
.ap-drawer { width: min(560px, calc(100vw - 24px)); outline: none; }
.ap-drawer--narrow { width: min(480px, calc(100vw - 24px)); }
.ap-drawer .bs-drawer__head, .ap-drawer .bs-drawer__tabs, .ap-drawer .bs-drawer__foot { flex: none; }
.ap-drawer .bs-drawer__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.ap-drawer .bs-drawer__ttl h2 { outline: none; }
.ap-modal { position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; outline: none; animation: ap-pop .35s cubic-bezier(.625, .05, 0, 1) both; }
.ap-modal.bs-palette { align-self: start; margin-top: 11vh; width: min(640px, 100%); }
@keyframes ap-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.ap-pal__list { max-height: min(52vh, 460px); overflow-y: auto; }
.ap-pal__lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-pop { position: fixed; z-index: var(--z-pop); outline: none; max-height: calc(100vh - 24px); overflow-y: auto; animation: ap-pop .3s cubic-bezier(.625, .05, 0, 1) both; }
.ap-pop__scroll { max-height: 50vh; overflow-y: auto; }
.ap-pop__search { margin: 0 4px 8px; }
.ap-pop__chips { padding: 0 4px 10px; }
.ap-pop__foot { display: flex; justify-content: flex-end; padding: 10px 4px 2px; }
.ap-pop .bs-rows { gap: 6px; }
.ap-toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: var(--z-toast); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(600px, calc(100vw - 32px)); pointer-events: none; }
.ap-toast { pointer-events: auto; animation: ap-up .4s cubic-bezier(.625, .05, 0, 1) both; transition: opacity .3s, transform .3s; }
.ap-toast.is-out { opacity: 0; transform: translateY(8px); }
.ap-tip { position: fixed; z-index: var(--z-tip); pointer-events: none; }
.ap-tip[hidden] { display: none; }
.ap-mailbox { display: flex; align-items: center; gap: 10px; }
.ap-code { letter-spacing: .4em; font-size: 20px; text-align: center; }
.ap-quote { margin: 0; }
.ap-tab-fase { font: 500 9px var(--font-mono); opacity: .7; margin-left: 2px; }
.ap-chain { display: flex; flex-direction: column; gap: 14px; }
.ap-chain__step { display: flex; gap: 12px; align-items: flex-start; }
.ap-chain__txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ap-chain__txt > b { font-weight: 500; font-size: 13px; }

/* Copiloto (drawer global) */
.ap-cp .bs-drawer__body { gap: 12px; }
.ap-cp__sugg { margin-top: 4px; }
.ap-cp__bar { flex: none; padding: 12px 16px 16px; box-shadow: inset 0 1px 0 var(--line); background: var(--surface); }

/* ================= Navegação móvel e folha "Mais" ================= */
.ap-mnav { display: none; position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: var(--z-nav); width: calc(100vw - 24px); }
.ap-mnav .bs-mnav__btn { text-decoration: none; }
.ap-sheet { position: fixed; inset: 0; z-index: var(--z-sheet); display: flex; align-items: flex-end; justify-content: center; }
.ap-sheet[hidden] { display: none; }
.ap-sheet__panel { position: relative; max-height: 82vh; overflow-y: auto; animation: ap-sheet .45s cubic-bezier(.625, .05, 0, 1) both; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
@keyframes ap-sheet { from { transform: translateY(100%); } }
.ap-sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ap-sheet__head b { font-weight: 400; font-size: 17px; }
.ap-sheet .bs-module .bs-tag { margin-top: -4px; }

/* ================= Modos de exibição (SH-03) ================= */
[data-modo=apresentacao] .ap-app { grid-template-columns: minmax(0, 1fr); }
[data-modo=apresentacao] .ap-rail { display: none; }
[data-modo=apresentacao] .ap-main { padding-left: 32px; }
[data-modo=leitura] .ap-body { font-size: 15px; }
[data-modo=leitura] .ap-view .bs-bento { max-width: 1080px; }

/* ================= Celular e tablet (≤ 900px) ================= */
@media (max-width: 900px) {
  .ap-app { grid-template-columns: minmax(0, 1fr); }
  .ap-rail { display: none; }
  .ap-main { padding: 14px 16px calc(112px + env(safe-area-inset-bottom)); gap: 18px; }
  .ap-mnav { display: flex; }
  .ap-top { gap: 8px; flex-wrap: nowrap; }
  .ap-top__logo { display: block; }
  .ap-ctx { flex: 1 1 auto; padding: 0 14px; }
  .ap-ctx .ap-crumb { display: none; }
  .ap-search, .ap-copilot { display: none; }
  .ap-only-m { display: inline-grid; }
  .ap-top .ap-me { display: inline-grid; }
  .ap-top .bs-top__spacer { display: none; }
  .ap-head h1 { font-size: 30px; }
  .ap-head__txt { flex-basis: 100%; }
  .ap-toasts { bottom: calc(96px + env(safe-area-inset-bottom)); }
  /* camadas viram folha inferior */
  .ap-drawer.bs-drawer--fixed { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 92vh; border-radius: 30px 30px 0 0; animation: ap-sheet .45s cubic-bezier(.625, .05, 0, 1); }
  .ap-layer--modal { place-items: end center; padding: 0; }
  .ap-modal, .ap-modal.bs-palette { width: 100%; max-height: 92vh; margin: 0; border-radius: 30px 30px 0 0; align-self: end; animation: ap-sheet .45s cubic-bezier(.625, .05, 0, 1); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .ap-pop { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100% !important; max-height: 80vh; border-radius: 30px 30px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); animation: ap-sheet .45s cubic-bezier(.625, .05, 0, 1); }
  .ap-pop__scroll { max-height: 56vh; }
}
@media (max-width: 420px) {
  .ap-top .ap-capturar { display: none; }
  .ap-head h1 { font-size: 27px; }
  .ap-banner { border-radius: var(--radius-lg); }
}

@media (prefers-reduced-motion: reduce) {
  .ap-card, .ap-toast, .ap-modal, .ap-pop, .ap-drawer.bs-drawer--fixed, .ap-sheet__panel, .ap-layer > .bs-backdrop { animation: none !important; }
}
