/* shell.css — the app shell: sidebar (expanded 232 px / rail 64 px), top bar, mobile bottom bar and the "More" sheet.
   Approved design (01/10/2026): navy sidebar with the brand, light top bar on desktop, navy top bar on mobile.
   Buttons here use .sbtn / .ibtn so the global `button` rule (accent fill) never leaks in. */
/* author `display` rules (flex...) beat the UA [hidden] rule: inside the shell the attribute must always win */
.shell [hidden], .sheet-overlay[hidden], .pop[hidden] { display: none !important; }
.skip-link { position: absolute; left: 8px; top: -56px; z-index: 200; background: #fff; color: #021E35; padding: 8px 14px; border-radius: 8px; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 8px; }

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.shell-body { min-width: 0; display: flex; flex-direction: column; }
#main { min-width: 0; flex: 1; }
#main:focus { outline: none; }
.area { max-width: 1200px; margin: 0 auto; padding: 24px; }
.area[hidden] { display: none; }

/* ---------- sidebar ---------- */
.shell-nav {
  position: sticky; top: 0; align-self: start; height: 100vh; z-index: 30;
  background: var(--nav-bg); color: var(--nav-text); display: flex; flex-direction: column;
  padding: 12px 10px; border-right: 1px solid rgba(255,255,255,.10); overflow-y: auto; overflow-x: hidden;
}
.shell-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 12px; border-bottom: 2px solid var(--crimson); margin-bottom: 6px; min-height: 52px; }
.shell-brand b { display: block; color: #fff; font-size: 14px; letter-spacing: .08em; line-height: 1.1; }
.shell-brand span { display: block; font-size: 12px; letter-spacing: .04em; color: rgba(255,255,255,.65); }
.nav-group-label { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--nav-group); margin: 14px 10px 4px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px; min-height: 44px; padding: 0 10px; border-radius: 9px; position: relative;
  font-weight: 600; font-size: 14px; color: var(--nav-text); text-decoration: none; white-space: nowrap;
  background: none; border: none; width: 100%; text-align: left; cursor: pointer; font-family: inherit;
}
.nav-item:hover { background: var(--nav-hover); color: #fff; }
.nav-item[aria-current="page"] { background: var(--nav-active); color: #fff; }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 3px; border-radius: 2px; background: var(--crimson-lite); }
.nav-item:focus-visible, .sbtn:focus-visible, .ibtn:focus-visible, .shell-account:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.shell-top .ibtn:focus-visible { outline: 2px solid var(--crimson); outline-offset: 2px; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-badge { background: var(--crimson); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; min-width: 20px; text-align: center; }
.nav-badge[hidden], .nav-state[hidden] { display: none; }
.nav-state { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.nav-state[data-st="ready"] { background: #2ecc71; }
.nav-state[data-st="error"] { background: #ff8a9c; }
.nav-state[data-st="busy"] { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; background: none; animation: rh-spin .9s linear infinite; }
@keyframes rh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .nav-state[data-st="busy"] { animation: none; } }

.shell-nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 10px; }
.sbtn { background: none; border: none; color: inherit; font: inherit; padding: 0; cursor: pointer; border-radius: 9px; }
.shell-account { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px; border-radius: 10px; background: rgba(255,255,255,.08); color: #fff; text-align: left; border: none; cursor: pointer; font-family: inherit; }
.shell-account:hover { background: rgba(255,255,255,.14); }
.shell-av { position: relative; width: 28px; height: 28px; border-radius: 50%; background: var(--crimson); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.cloud-dot { position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--nav-bg); background: #8a99a6; }
.shell-account[data-s="signedout"] .cloud-dot { display: none; }
.shell-account[data-s="ok"] .cloud-dot { background: #2ecc71; }
.shell-account[data-s="saving"] .cloud-dot { background: #f5b301; }
.shell-account[data-s="problem"] .cloud-dot, .shell-account[data-s="update"] .cloud-dot, .shell-account[data-s="paused"] .cloud-dot, .shell-account[data-s="unreachable"] .cloud-dot { background: #ff4d4d; }
.shell-who { min-width: 0; line-height: 1.25; }
.shell-who b { display: block; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-who small { display: block; font-size: 11px; color: rgba(255,255,255,.65); }
.nav-toggle { align-self: flex-end; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; color: var(--nav-text); }
.nav-toggle:hover { background: var(--nav-hover); color: #fff; }

/* rail (icons only) */
:root[data-sidebar="rail"] .shell-nav { padding: 12px 8px; align-items: center; }
:root[data-sidebar="rail"] .shell-brand { justify-content: center; padding: 0 0 12px; width: 100%; }
:root[data-sidebar="rail"] .shell-brand > div, :root[data-sidebar="rail"] .nav-label, :root[data-sidebar="rail"] .shell-who { display: none; }
:root[data-sidebar="rail"] .nav-group-label { height: 1px; background: rgba(255,255,255,.14); margin: 10px 6px; font-size: 0; width: 32px; padding: 0; }
:root[data-sidebar="rail"] .nav-item { justify-content: center; padding: 0; width: 44px; }
:root[data-sidebar="rail"] .nav-item[aria-current="page"]::before { left: -8px; }
:root[data-sidebar="rail"] .nav-badge { position: absolute; top: 3px; right: 1px; padding: 0 5px; line-height: 16px; min-width: 16px; font-size: 10px; }
:root[data-sidebar="rail"] .nav-state { position: absolute; top: 7px; right: 7px; }
:root[data-sidebar="rail"] .shell-account { width: 44px; justify-content: center; padding: 8px 0; background: none; }
:root[data-sidebar="rail"] .shell-nav-foot { align-items: center; }
:root[data-sidebar="rail"] .nav-toggle { align-self: center; }

/* ---------- top bar ---------- */
.shell-top {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 0 20px;
}
.shell-top h1 { font-size: 19px; margin: 0; font-weight: 700; color: var(--text); outline: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.shell-top .sp { flex: 1; }
.shell-logo-m { display: none; flex: none; }
.top-actions { display: flex; align-items: center; gap: 8px; position: relative; }
.ibtn { position: relative; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; flex: none;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 9px; padding: 0; cursor: pointer; }
.ibtn:hover { border-color: var(--accent); }
.pop { position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; min-width: 190px; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 5px; box-shadow: 0 8px 28px rgba(2,30,53,.2); }
.pop[hidden] { display: none; }
.pop button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: transparent; color: var(--text); border: none; padding: 9px 12px; border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer; }
.pop button:hover { background: var(--panel-2); }
.pop button[aria-checked="true"] { font-weight: 700; }
.pop button[aria-checked="true"]::before { content: "✓"; color: var(--crimson); }
.pop button[aria-checked="false"]::before { content: ""; display: inline-block; width: 1em; }

/* ---------- mobile bottom bar + "More" sheet ---------- */
.shell-bottom { display: none; }
.sheet-overlay { position: fixed; inset: 0; background: rgba(2,30,53,.5); z-index: 70; display: flex; align-items: flex-end; }
.sheet-overlay[hidden] { display: none; }
.sheet { z-index: 71; background: var(--panel); color: var(--text); width: 100%; border-radius: 16px 16px 0 0; max-height: 85vh; overflow-y: auto; padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px)); }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--border); margin: 4px auto 10px; }
.sheet-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 6px 4px; background: none; border: none; border-bottom: 1px solid var(--border);
  color: var(--text); font-size: 15px; font-weight: 600; text-align: left; cursor: pointer; border-radius: 0; font-family: inherit; }
.sheet-row small { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 13px; }
.sheet-row .ic { color: var(--muted); }
.sheet-row .shell-av { width: 32px; height: 32px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .shell-nav { display: none; }
  .area { padding: 12px; }
  .shell-top { background: var(--nav-bg); border-bottom: 2px solid var(--crimson); padding: env(safe-area-inset-top, 0px) 12px 0; height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); }
  .shell-top { gap: 8px; }
  .top-actions { gap: 4px; }   /* the Escrever areas show 4 buttons (Histórico, Configurações, sino, tema): keep room for the title */
  .shell-top h1 { color: #fff; font-size: 17px; }
  .shell-top .ibtn { background: transparent; border-color: rgba(255,255,255,.3); color: #fff; }
  .shell-logo-m { display: block; }
  .shell-bottom {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: var(--bottom-offset); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--nav-bg); z-index: 30; border-top: 1px solid rgba(255,255,255,.10);
  }
  #main { padding-bottom: var(--bottom-offset); }
  .bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 64px; position: relative;
    color: var(--nav-text); font-size: 11px; font-weight: 600; text-decoration: none; background: none; border: none; padding: 6px 0 4px; cursor: pointer; font-family: inherit; border-radius: 0; }
  .bn-item[aria-current="page"] { color: #fff; }
  .bn-item[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 24%; right: 24%; height: 3px; border-radius: 0 0 3px 3px; background: var(--crimson-lite); }
  .bn-item .ic { width: 22px; height: 22px; }
  .bn-item .nav-badge { position: absolute; top: 3px; left: 54%; }
  .bn-item .nav-state { position: absolute; top: 6px; left: 56%; }
  .bn-item:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }
}
