/* Mestre — tokens, identidade e componentes compartilhados.
   Sem CDN, sem fonte remota, sem framework: só o que o FastAPI serve. */

:root {
  color-scheme: light;
  --nav: #082D45;
  --nav-text: #FFFFFF;
  --nav-muted: #A9C2D6;
  --nav-hover: #11405F;
  --bg: #F5F7F9;
  --surface: #FFFFFF;
  --surface-alt: #E9EEF3;
  --text: #142536;
  --muted: #4D6071;
  --border: #CDD6DF;
  --primary: #14314D;
  --link: #17558B;
  --accent: #C2731A;
  --action: #99550D;
  --action-text: #FFFFFF;
  --warning-bg: #FFF1D9;
  --warning-border: #E6C68A;
  --warning-text: #704000;
  --danger-bg: #FCE8E8;
  --danger-border: #E8B4B4;
  --danger-text: #8B2020;
  --ok-text: #1C5E3F;
  --focus: #17558B;
  --mark: #FFF1D9;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fs-xs: 12px; --fs-sm: 14px; --fs-base: 16px; --fs-lg: 20px; --fs-xl: 28px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px;
  --shadow: 0 2px 8px rgb(20 49 77 / 8%);
  --touch: 44px;
}

/* Escuro automático, a menos que o leitor tenha fixado o tema claro. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --nav: #0C2335; --nav-text: #F1F5F9; --nav-muted: #9FB3C4; --nav-hover: #16354B;
    --bg: #111820; --surface: #1B2631; --surface-alt: #263544;
    --text: #EDF2F6; --muted: #B6C4D1; --border: #435567;
    --primary: #C1D9ED; --link: #A9D5FF; --accent: #E5AC59;
    --action: #E5AC59; --action-text: #17212A;
    --warning-bg: #3B2D1B; --warning-border: #6B5126; --warning-text: #FFD38D;
    --danger-bg: #42262B; --danger-border: #7A4046; --danger-text: #FFBFC4;
    --ok-text: #86E0B4;
    --focus: #A9D5FF; --mark: #3B2D1B; --shadow: none;
  }
}

/* Tema escuro fixado pelo leitor. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --nav: #0C2335; --nav-text: #F1F5F9; --nav-muted: #9FB3C4; --nav-hover: #16354B;
  --bg: #111820; --surface: #1B2631; --surface-alt: #263544;
  --text: #EDF2F6; --muted: #B6C4D1; --border: #435567;
  --primary: #C1D9ED; --link: #A9D5FF; --accent: #E5AC59;
  --action: #E5AC59; --action-text: #17212A;
  --warning-bg: #3B2D1B; --warning-border: #6B5126; --warning-text: #FFD38D;
  --danger-bg: #42262B; --danger-border: #7A4046; --danger-text: #FFBFC4;
  --ok-text: #86E0B4;
  --focus: #A9D5FF; --mark: #3B2D1B; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-base)/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
svg { flex: none; }
[hidden] { display: none !important; }

/* ---------- marca ---------- */
/* Três livros empilhados e o marcador âmbar: procedência e página exata. */
.mark-logo { display: block; }
.mark-logo .books { fill: currentColor; }
.mark-logo .ribbon { fill: var(--accent); }

.brand { display: flex; align-items: center; gap: var(--s3); text-decoration: none; color: inherit; min-width: 0; }
.brand-name { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-name strong { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.02em; }
.brand-name span {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--nav-muted); white-space: nowrap;
}

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--touch); padding: 0 var(--s4); border-radius: var(--radius);
  font-size: var(--fs-base); font-weight: 600; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--action); color: var(--action-text); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-quiet { background: var(--surface); color: var(--link); border-color: var(--border); }
.btn-quiet:hover { border-color: var(--link); }
.btn-small { min-height: 36px; font-size: var(--fs-sm); padding: 0 var(--s3); border-radius: var(--radius-sm); }

.icon-btn {
  width: var(--touch); height: var(--touch); border-radius: var(--radius); flex: none;
  display: grid; place-items: center; background: transparent; border: 0;
  color: inherit; cursor: pointer; text-decoration: none; transition: background .15s;
}
.icon-btn:hover { background: rgb(255 255 255 / 12%); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.muted { color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- cabeçalho do aplicativo ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--s4);
  height: calc(76px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--s5) 0;
  background: var(--nav); color: var(--nav-text);
}
.appbar .tagline { color: var(--nav-muted); font-size: var(--fs-sm); flex: 1; min-width: 0; }
.appbar .tools { display: flex; align-items: center; gap: var(--s1); margin-left: auto; }
.pill {
  display: inline-flex; align-items: center; gap: var(--s2); height: 38px; padding: 0 var(--s3);
  border-radius: 999px; background: var(--nav-hover); color: var(--nav-text);
  font-size: var(--fs-sm); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.pill b {
  background: var(--accent); color: #17212A; border-radius: 999px;
  padding: 1px 8px; font-variant-numeric: tabular-nums;
}

/* ---------- avisos ---------- */
.notice {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4); border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-alt); color: var(--text);
}
.notice .notice-text { min-width: 0; }
.notice strong { display: block; }
.notice p { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--muted); }
.notice-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.notice-warning p { color: inherit; }
.notice-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.notice-danger p { color: inherit; }

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