:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-side: #f6f8fa;
  --bg-hdr: #ffffff;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  --hover: #eef2f7;
  --active-bg: #dbeafe;
  --active-bdr: #0969da;
  --cal-has: #dbeafe;
  --cal-has-t: #0550ae;
  --cal-wknd: #f3f4f6;
  --cal-ring: #0969da;
  --cal-sel: #0969da;
  --shadow: 0 1px 4px rgba(0, 0, 0, .08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .15);
  --md-h2-bg: #f0f6ff;
  --md-bq: #f6f8fa;
  --chip-bg: #f0f6ff;
  --chip-active: #0969da;
  --chip-at: #dbeafe;
  --backdrop: rgba(0, 0, 0, .35);
  --article-glass-bg: rgba(255, 255, 255, .72);
  --article-glass-border: rgba(91, 74, 58, .18);
  --article-glass-border-hover: rgba(9, 105, 218, .42);
  --article-glass-marker: rgba(101, 109, 118, .42);
  --article-glass-shadow: 0 16px 36px rgba(31, 35, 40, .08), inset 0 1px rgba(255, 255, 255, .96), inset 0 -1px rgba(125, 96, 68, .12);
  --article-glass-shadow-hover: 0 22px 48px rgba(31, 35, 40, .13), inset 0 1px rgba(255, 255, 255, 1), inset 0 -1px rgba(125, 96, 68, .16);
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --bg-side: #161b22;
  --bg-hdr: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --hover: #1c2128;
  --active-bg: #1f2d3d;
  --active-bdr: #58a6ff;
  --cal-has: #1f2d3d;
  --cal-has-t: #58a6ff;
  --cal-wknd: #161b22;
  --cal-ring: #58a6ff;
  --cal-sel: #1f6feb;
  --shadow: 0 1px 4px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .6);
  --md-h2-bg: #1c2d3f;
  --md-bq: #161b22;
  --chip-bg: #1c2128;
  --chip-active: #1f6feb;
  --chip-at: #1f2d3d;
  --backdrop: rgba(0, 0, 0, .6);
  --article-glass-bg: rgba(29, 34, 41, .66);
  --article-glass-border: rgba(210, 217, 226, .18);
  --article-glass-border-hover: rgba(88, 166, 255, .5);
  --article-glass-marker: rgba(210, 217, 226, .38);
  --article-glass-shadow: 0 18px 42px rgba(0, 0, 0, .28), inset 0 1px rgba(255, 255, 255, .16), inset 0 -1px rgba(190, 153, 119, .14);
  --article-glass-shadow-hover: 0 24px 58px rgba(0, 0, 0, .4), inset 0 1px rgba(255, 255, 255, .22), inset 0 -1px rgba(190, 153, 119, .2);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  height: 100dvh;
}

/* Sem isso o navegador do celular (Chrome Android "font boosting", Safari
   iOS) aumenta a fonte de cada bloco conforme o tamanho do texto: notícias
   de resumo longo saíam com letra maior que as de resumo curto. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── HEADER ─── */
header {
  background: var(--bg-hdr);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  z-index: 30;
  padding-top: max(6px, env(safe-area-inset-top));
  flex-wrap: wrap;
}

header h1 .logo {
  border-radius: 5px;
  vertical-align: middle;
  margin-right: 2px;
}

header h1 {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

#file-count {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.hbtn {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  background: var(--bg-hdr);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  min-height: 30px;
}

.hbtn:hover { background: var(--hover); }

.hbtn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.hbtn.primary:hover { opacity: .88; }

.hbtn.warning {
  background: #f59e0b;
  color: #fff;
  border-color: transparent;
  animation: pulse-warn 2.4s ease-in-out infinite;
}
.hbtn.warning:hover { opacity: .88; animation: none; }

.app-version {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

.app-version.header-version {
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-side);
}

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: .65; }
}

/* Botao icon-only (hamburguer / close) */
.hbtn.icon {
  padding: 5px 8px;
  font-size: 15px;
  line-height: 1;
}

.search-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 30px;
  width: 240px;
  padding-right: 4px;
  transition: border-color .15s;
}
.search-wrap:focus-within { border-color: var(--accent); }

.header-audio-slot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  min-width: 30px;
  margin-left: 0;
}
.header-audio-slot:empty { display: none; }
.header-audio-slot .md-audio {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}
.header-audio-slot .md-audio svg {
  width: 16px;
  height: 16px;
}
/* Player aberto: controles na mesma linha do botão de narração. */
.header-audio-slot.aberto {
  flex: 1 1 440px;
  min-width: 0;
  gap: 6px;
}
/* Sem espaço pro player inline, a narração desce pra segunda linha levando o
   botão junto: botão e controles de som sempre na mesma linha, e os demais
   botões do topo ficam onde estavam. */
@media (max-width: 1100px) {
  .header-audio-slot.aberto { order: 2; flex: 1 0 100%; }
}
.header-audio-slot .md-player {
  flex: 1 1 auto;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}
.header-audio-slot .mdp-tabs { flex: 0 0 auto; gap: 3px; }
.header-audio-slot .mdp-tab {
  width: 30px;
  padding: 0;
  justify-content: center;
}
#header-audio-slot .mdp-tab-label { display: none; }
.header-audio-slot .mdp-tab-nota {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-audio-slot .mdp-tab-nota:empty { display: none; }
.header-audio-slot .mdp-controls { flex: 1 1 auto; min-width: 0; gap: 6px; }

#search {
  background: none;
  border: none;
  flex: 1;
  min-width: 0;
  padding: 6px 4px 6px 10px;
  color: var(--text);
  font-size: 12px;
  outline: none;
}
#search::placeholder { color: var(--muted); }

#search-nav:not([hidden]) {
  display: inline-flex;
}
#search-nav {
  align-items: center;
  gap: 1px;
  white-space: nowrap;
  border-right: 1px solid var(--border);
  padding-right: 4px;
  margin-right: 2px;
}
#search-count {
  font-size: 11px;
  color: var(--muted);
  min-width: 30px;
  text-align: center;
}
.snav {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 10px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 3px;
}
.snav:hover { background: var(--border); color: var(--text); }

#search-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 3px;
}
#search-clear:hover { color: var(--text); }

mark { background: #ffe066; color: #000; border-radius: 2px; }
mark.ativo { background: #ff9800; outline: 2px solid #e65c00; }

/* ─── LAYOUT ─── */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ─── SIDEBAR ─── */
aside {
  width: 262px;
  flex-shrink: 0;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .25s ease, transform .25s ease, margin-left .25s ease;
}

/* Sidebar colapsada no desktop: some lateralmente */
aside.collapsed {
  width: 0;
  border-right-width: 0;
}

/* Backdrop para mobile (escurece o conteudo quando drawer aberto) */
.backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  z-index: 20;
  opacity: 0;
  transition: opacity .2s ease;
}

/* ─── CALENDAR ─── */
.cal-wrap {
  padding: 12px 11px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cal-nbtn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-nbtn:hover { background: var(--hover); }

.cal-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-dow {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  padding-bottom: 2px;
}

.cal-day {
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border-radius: 4px;
  color: var(--muted);
  user-select: none;
}

.cal-day.other { opacity: .3; }
.cal-day.wknd { background: var(--cal-wknd); }
.cal-day.today {
  outline: 2px solid var(--cal-ring);
  outline-offset: -2px;
}
.cal-day.has {
  background: var(--cal-has);
  color: var(--cal-has-t);
  font-weight: 700;
  cursor: pointer;
}
.cal-day.has:hover { opacity: .7; }
.cal-day.sel {
  background: var(--cal-sel) !important;
  color: #fff !important;
  outline: none;
}

/* ─── FONTE FILTROS ─── */
.fontes-wrap {
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fontes-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 5px;
}

.fontes-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px 5px 20px;
  border-radius: 20px;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
  background: color-mix(in srgb, var(--bg) 38%, transparent);
  color: var(--text);
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 2px 8px rgba(31, 35, 40, .05);
  -webkit-backdrop-filter: blur(12px) saturate(145%);
  backdrop-filter: blur(12px) saturate(145%);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .15s;
  position: relative;
}
.chip[data-id]:not([data-id=""])::before {
  content: '';
  position: absolute;
  left: 6px; top: 50%;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--chip-color, var(--muted));
  transform: translateY(-50%);
}
.chip[data-id=""] { padding-left: 10px; }

.chip:hover {
  background: color-mix(in srgb, var(--bg) 58%, transparent);
  border-color: color-mix(in srgb, var(--text) 24%, transparent);
  transform: translateY(-1px);
}

.chip.on {
  background: color-mix(in srgb, var(--chip-color, var(--text)) 14%, transparent);
  border-color: color-mix(in srgb, var(--chip-color, var(--text)) 42%, transparent);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .38), 0 3px 12px color-mix(in srgb, var(--chip-color, var(--text)) 12%, transparent);
}
.chip.on::before { background: var(--chip-color, var(--text)); }
.chip[data-id=""].on {
  background: color-mix(in srgb, var(--text) 9%, transparent);
  border-color: color-mix(in srgb, var(--text) 30%, transparent);
}

/* ─── LIST ─── */
/* Envolve calendario + filtro + lista num scroll unico; o rodape
   (.sidebar-footer) fica fora, sempre fixo embaixo. */
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.list-area {
  padding: 5px 0;
}

.list-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  padding: 6px 12px 3px;
}

.mgroup { border-bottom: 1px solid var(--border); }
.mhead {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  background: var(--bg-side);
}
.mhead:hover { color: var(--text); }
.mhead .mcaret { transition: transform .15s; font-size: 9px; }
.mgroup.open .mhead .mcaret { transform: rotate(90deg); }
.mcount { margin-left: auto; font-size: 10px; opacity: .7; }
.mbody { display: none; }
.mgroup.open .mbody { display: block; }

.entry {
  display: block;
  padding: 8px 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.entry:hover { background: var(--hover); }

.entry.active {
  background: var(--active-bg);
  border-left-color: var(--active-bdr);
}

.entry .erow {
  display: flex;
  align-items: center;
  gap: 6px;
}

.entry .edate {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.entry .edow {
  font-size: 11px;
  color: var(--muted);
}

.entry .etags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}

.etag {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border: 1px solid color-mix(in srgb, var(--tag-color, var(--text)) 34%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--tag-color, var(--bg)) 12%, transparent);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .32), 0 2px 8px rgba(31, 35, 40, .05);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  white-space: nowrap;
}

.etag-IA { --tag-color: #2563eb; }

.entry.hidden { display: none; }

/* ─── SEARCH HIGHLIGHT ─── */
mark {
  background: #fff3a3;
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .05);
}
[data-theme="dark"] mark {
  background: #bb8800;
  color: #0d1117;
}

/* ─── FAB "Tendências" ─── */
.fab {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  right: 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 15;
  display: none;
  align-items: center;
  gap: 6px;
}
.fab.show { display: inline-flex; }
.fab:hover { opacity: .9; }
#btn-tend { right: 102px; }
#btn-topo { right: 20px; }
.fab-secondary {
  background: var(--bg-hdr);
  color: var(--text);
  border: 1px solid var(--border);
}
@media (max-width: 768px) {
  .fab { padding: 9px 12px; font-size: 12px; bottom: 14px; }
  #btn-tend { right: 86px; }
  #btn-topo { right: 14px; }
}

/* ─── CONTENT ─── */
#content {
  flex: 1;
  width: 100%;
  min-width: 0;
  overflow-y: auto;
  padding: 0 0 32px;
  max-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

#ph {
  text-align: center;
  padding-top: 90px;
  color: var(--muted);
}

#ph .icon {
  font-size: 48px;
  margin-bottom: 14px;
}

/* Ícone do app na tela inicial (antes de abrir uma edição). */
#ph .ph-logo {
  width: 96px;
  height: 96px;
  border-radius: 22%;
  box-shadow: var(--shadow-lg);
}

#ph p {
  font-size: 14px;
  line-height: 1.8;
}

/* ─── MARKDOWN ─── */
#md { display: none; }

#md h1 img.logo-h1 {
  width: 1.15em;
  height: 1.15em;
  margin: 0;
  border-radius: 22%;
  flex: 0 0 auto;
}

#md h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 14px;
  line-height: 1.25;
}

#md h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin: 20px 0 8px;
  padding: 6px 10px;
  background: var(--md-h2-bg);
  border-radius: 6px;
}

#md h3 {
  font-size: 18px;
  font-weight: 650;
  line-height: 1.38;
  color: var(--text);
  margin: 0 0 12px;
}

#md .article-card {
  background: var(--article-glass-bg);
  border: 1px solid var(--article-glass-border);
  border-radius: 22px;
  corner-shape: squircle;
  box-shadow: var(--article-glass-shadow);
  margin: 5px 0 5px;
  padding: 5px;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  backdrop-filter: blur(18px) saturate(135%);
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), border-color .28s ease, box-shadow .28s ease, background-color .28s ease;
}
#md .article-card h3 {
  border-inline-start: 3px solid var(--article-glass-marker);
  padding-inline-start: 14px;
  transition: border-color .24s ease, color .24s ease;
}
#md .article-card h3 a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--article-glass-marker);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: color .2s ease, text-decoration-color .2s ease;
}
#md .article-card h3 a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
#md .article-card h3 a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
  border-radius: 4px;
}
#md .article-card:focus-within {
  border-color: var(--article-glass-border-hover);
  box-shadow: var(--article-glass-shadow-hover);
  transform: translateY(-2px);
}
#md .article-card:focus-within h3 { border-inline-start-color: var(--accent); }
#md .article-card > p {
  width: 100%;
  max-width: none;
  font-size: 16.5px;
  line-height: 1.78;
}
#md .article-card > p.card-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: .01em;
  margin-bottom: 14px;
}
#md .article-card > :last-child { margin-bottom: 0; }

/* ─── DIA COMPLETO: FAIXA DE TEMAS FIXA + SEÇÕES DE TEMA ─── */
/* Uma faixa só, fixa no topo da leitura: o tema corrente fica destacado e
   tocar em outro pula pra ele (js/busca-render.js). */
.dia-tags {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin: 0 0 6px;
  padding: 4px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 64%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  backdrop-filter: blur(12px) saturate(130%);
}
.dia-tags::-webkit-scrollbar { display: none; }
#md .dia-tags .etag {
  flex: 0 0 auto;
  font-size: 12px;
  padding: 4px 12px;
  color: var(--muted);
  text-decoration: none;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
#md .dia-tags .etag:hover {
  color: var(--text);
  text-decoration: none;
  background: color-mix(in srgb, var(--tag-color, var(--bg)) 20%, transparent);
  border-color: color-mix(in srgb, var(--tag-color, var(--text)) 48%, transparent);
}
#md .dia-tags .etag.atual {
  color: #fff;
  background: var(--tag-color);
  border-color: var(--tag-color);
  box-shadow: 0 4px 10px color-mix(in srgb, var(--tag-color) 30%, transparent);
}

.tema-audio-slot { margin-left: auto; display: flex; align-items: center; }

.tema-divisor { border: none; border-top: 1px solid var(--border); margin: 24px 0; }


.voice-reader-strip {
  display: none;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-hdr) 86%, transparent);
  box-shadow: var(--shadow);
}

.voice-reader-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tema-audio-slot.audio-principal {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
  margin-left: 0;
}

.voice-reader-strip .md-player {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0;
}

@media (hover: hover) and (pointer: fine) {
  #md .article-card:hover {
    border-color: var(--article-glass-border-hover);
    box-shadow: var(--article-glass-shadow-hover);
    transform: translateY(-2px);
  }
  #md .article-card:hover h3 { border-inline-start-color: var(--accent); }
}

#md p {
  font-size: 18px;
  line-height: 1.85;
  color: var(--text);
  margin-bottom: 12px;
}

#md ul, #md ol {
  padding-left: 22px;
  margin-bottom: 12px;
}

#md li {
  font-size: 18px;
  line-height: 1.85;
  color: var(--text);
  margin-bottom: 5px;
}

#md blockquote {
  border-left: 3px solid var(--accent);
  padding: 6px 14px;
  color: var(--muted);
  font-size: 17px;
  margin: 8px 0;
  background: var(--md-bq);
  border-radius: 0 6px 6px 0;
}

#md a {
  color: var(--accent);
  text-decoration: none;
}

#md a:hover { text-decoration: underline; }
#md strong { font-weight: 600; }

#md hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

#md code {
  background: var(--md-bq);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 12px;
  font-family: 'Menlo', 'Consolas', monospace;
}

#md img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 8px 0;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVO - MOBILE / TABLET
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  header {
    padding: 6px 10px;
    gap: 6px;
    flex-wrap: wrap;
  }
  /* Topo numa linha só: ☰ · Hoje · busca · narração · tema · ajustes.
     O título já está na aba do navegador e cede o espaço pra busca. */
  /* O nome cede o espaço pra busca; o ícone do app fica, como marca. */
  header h1 { display: flex; flex: 0 0 auto; }
  header h1 .h1-txt { display: none; }
  header h1 .logo { width: 30px; height: 30px; border-radius: 7px; margin: 0; }
  #file-count { display: none; }
  .app-version.header-version { display: none; }
  header .hbtn { min-height: 36px; }
  header .hbtn.icon { min-width: 36px; justify-content: center; }

  .search-wrap {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    min-height: 36px;
    margin-left: 0;
  }
  .header-audio-slot .md-audio { width: 36px; height: 36px; }
  /* Navegando entre resultados, a busca ganha a linha inteira pra caber
     contador e setas sem espremer o texto digitado. */
  header:has(#search-nav:not([hidden])) .search-wrap { order: 1; flex: 1 0 100%; }
  #search {
    padding: 7px 6px 7px 10px;
    font-size: 16px;
  }
  #search-nav {
    gap: 4px;
    padding: 3px 6px 3px 2px;
    margin-right: 3px;
  }
  #search-count {
    min-width: 40px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
  }
  .snav {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
    border-radius: 9px;
    background: color-mix(in srgb, var(--bg) 45%, transparent);
    font-size: 14px;
  }
  #search-clear {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    font-size: 18px;
  }

  /* Sidebar vira drawer - absoluta, sai de fora */
  aside {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 85vw;
    max-width: 320px;
    z-index: 25;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  aside.collapsed { transform: translateX(-100%); width: 85vw; border-right-width: 1px; }
  aside.open      { transform: translateX(0); }

  .backdrop.show {
    display: block;
    opacity: 1;
  }

  /* Conteudo usa 100% */
  #content {
    padding: 0 0 32px;
    max-width: 100%;
  }
  #md h1 { font-size: 24px; }
  #md h2 { font-size: 18px; padding: 6px 10px; }
  #md h3 { font-size: 16px; }
  #md p, #md li { font-size: 16px; line-height: 1.7; }
  #md blockquote { font-size: 15px; }
  #md .article-card {
    border-radius: 18px;
    margin: 10px 0 14px;
    padding: 5px;
    -webkit-backdrop-filter: blur(14px) saturate(125%);
    backdrop-filter: blur(14px) saturate(125%);
  }
  #md .article-card h3 { padding-inline-start: 11px; }
  #md .article-card > p { font-size: 15.5px; line-height: 1.72; }
  #md .article-card > p.card-meta { font-size: 12px; }

  .dia-tags { gap: 5px; }

  .voice-reader-strip {
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 8px;
  }

  .tema-audio-slot.audio-principal {
    grid-template-columns: auto 1fr;
  }

  .voice-reader-strip .md-player {
    width: 100%;
  }

  #ph { padding-top: 50px; }
  #ph .icon { font-size: 42px; }
}

@media (max-width: 400px) {
  .hbtn { padding: 6px 8px; font-size: 11px; }
  header { gap: 5px; }
}

/* Botao toggle sempre visivel (desktop + mobile) */
#toggle-sidebar {
  /* usa .hbtn.icon do header */
}

/* ─── SIDEBAR LEGAL FOOTER ─── */
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
}
.sidebar-footer a {
  font-size: 10px;
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
}
.sidebar-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.sidebar-footer .sep {
  font-size: 10px;
  color: var(--border);
  user-select: none;
}
.sidebar-footer .app-version { margin-left: 1px; }

/* ─── APARÊNCIA ─── */
.ap-wrap { position: relative; }
#ap-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-hdr);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  min-width: 220px;
  z-index: 1000;
  display: none;
}
#ap-panel.open { display: block; }
.ap-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ap-row:last-child { margin-bottom: 0; }
.ap-label { font-size: 12px; color: var(--muted); min-width: 38px; }
/* Seletor segmentado Claro | Escuro: mostra qual tema está ativo. */
.ap-seg {
  display: inline-flex;
  flex: 1;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.ap-seg-btn {
  flex: 1;
  border: 0;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  background: none;
  color: var(--muted);
  white-space: nowrap;
  transition: background .2s ease, color .2s ease;
}
.ap-seg-btn:hover { color: var(--text); background: var(--hover); }
.ap-seg-btn.active { background: var(--active-bg); color: var(--accent); font-weight: 700; }
.ap-seg-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--active-bg); }
.ap-fbtn {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.ap-fbtn:hover { background: var(--hover); }
#ap-fval { font-size: 12px; min-width: 36px; text-align: center; color: var(--text); }
.ap-colors { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.ap-color {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
}
.ap-color.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.ap-color.reset { background: linear-gradient(135deg,#fff 0 50%,#0d1117 50% 100%); }
#ap-picker { width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; background: none; padding: 0; }

/* Voz do boletim diario */
.ap-sep { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }

/* Glossario de termos */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 60;
  align-items: flex-start; justify-content: center;
  overflow-y: auto;
  padding: 5vh 0 5vh;
}
.modal-backdrop.open { display: flex; }
.glossario-modal {
  background: var(--bg, #fff);
  border-radius: 14px;
  width: min(720px, 92vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border, #ddd);
}
.modal-body { padding: 14px 16px; overflow-y: auto; }
.gl-busca-wrap { position: relative; }
.gl-busca-wrap #gl-busca { width: 100%; box-sizing: border-box; padding: 8px 32px 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.gl-busca-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 13px; width: 22px; height: 22px; border-radius: 50%;
}
.gl-busca-clear:hover { background: var(--hover); color: var(--text); }
.gl-novo { display: grid; grid-template-columns: 1fr 1fr 140px auto; gap: 8px; margin: 10px 0 14px; }
.gl-novo input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); width: 100%; box-sizing: border-box; }
.gl-combo { position: relative; }
.gl-combo input { width: 100%; box-sizing: border-box; }
.gl-combo-drop {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 180px; overflow-y: auto; z-index: 5;
  background: var(--bg, #fff); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 4px;
}
.gl-combo-item { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.gl-combo-item:hover { background: var(--hover); }
.gl-combo-item.gl-combo-empty { opacity: .6; cursor: default; }
.gl-combo-item.gl-combo-empty:hover { background: none; }
.gl-lista { display: flex; flex-direction: column; gap: 6px; }
.gl-item { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border, #ddd); border-radius: 8px; }
.gl-item .gl-termo { font-weight: 600; min-width: 120px; }
.gl-item .gl-falada { flex: 1; opacity: .85; }
.gl-item .gl-categoria { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--hover, #eee); }
.gl-item .gl-origem-minerado { font-size: 10px; opacity: .6; }
.gl-item-edit { display: grid; grid-template-columns: 1fr 1fr 120px auto auto; gap: 6px; align-items: center; }
.gl-item-edit input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 12px; }
@media (max-width: 600px) { .gl-item-edit { grid-template-columns: 1fr; } }
.gl-nota {
  font-size: 12px; margin: 0; padding: 8px 16px;
  background: var(--active-bg); border-bottom: 1px solid var(--border);
  color: var(--text);
}
.gl-nota:empty { display: none; padding: 0; border: 0; }
@media (max-width: 600px) { .gl-novo { grid-template-columns: 1fr; } }
.ap-vozes { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ap-voz {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  width: 100%;
}
.ap-voz:hover { background: var(--hover); }
.ap-voz.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.ap-voz-nome { flex: 1; display: flex; flex-direction: column; }
.ap-voz-nome small { color: var(--muted); font-size: 10px; margin-top: 1px; }
.ap-voz-play {
  border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 13px; padding: 0 2px; line-height: 1;
}
.ap-voz-play:hover { color: var(--accent); }
.ap-nota { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.35; }
.ap-auth { display: none; gap: 5px; margin-top: 8px; }
.ap-auth.show { display: grid; grid-template-columns: 1fr 1fr auto; }
.ap-auth input {
  min-width: 0; width: 100%; border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg); color: var(--text); font-size: 11px; padding: 6px;
}
.ap-auth button {
  border: 1px solid var(--accent); border-radius: 5px; background: var(--accent);
  color: #fff; cursor: pointer; font-size: 11px; padding: 5px 8px;
}

/* Botao de ouvir o boletim, a direita do titulo da edicao.
   So icone (ondas sonoras); clicar abre o player logo abaixo do titulo. */
.md-audio {
  margin-left: auto;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--bg-hdr);
  color: var(--muted);
  border-radius: 50%;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background .2s ease, transform .15s ease;
}
.md-audio:hover { color: var(--accent); border-color: var(--accent); background: var(--hover); transform: translateY(-1px); }
.md-audio:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--active-bg); }
.md-audio.tocando { color: var(--accent); border-color: var(--accent); background: var(--active-bg); }
.md-audio[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.md-audio svg { width: 18px; height: 18px; }
/* Barrinhas do icone dancam enquanto o boletim toca (so transform: sem reflow) */
.oa-b { transform-box: fill-box; transform-origin: center; }
.md-audio.tocando .oa-b { animation: oa-eq 1.1s ease-in-out infinite; }
.md-audio.tocando .oa-b:nth-child(2n) { animation-delay: .18s; }
.md-audio.tocando .oa-b:nth-child(3n) { animation-delay: .36s; }
@keyframes oa-eq { 0%, 100% { transform: scaleY(.5); } 50% { transform: scaleY(1); } }

/* Player do boletim (seek, volume, velocidade) */
.md-player {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin: 2px 0 20px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--bg-hdr);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.md-player[hidden] { display: none !important; }
.md-player.aberto { display: flex; animation: mdp-in .25s cubic-bezier(.4, 0, .2, 1); }
.mdp-controls { display: flex; align-items: center; gap: 10px; }
.mdp-tabs { display: flex; gap: 6px; }
.mdp-tab {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); border-radius: 999px; cursor: pointer;
  padding: 6px 10px; font-size: 12px; height: 30px;
}
.mdp-tab svg { width: 14px; height: 14px; flex-shrink: 0; }
.mdp-tab .mdp-tab-label { display: none; }
.mdp-tab.active { border-color: var(--accent); background: var(--active-bg); color: var(--accent); }
.mdp-tab.active .mdp-tab-label { display: inline; }
.mdp-tab:disabled { opacity: .4; cursor: not-allowed; }
.mdp-tab-nota { font-size: 11px; opacity: .7; margin: 0; }
@keyframes mdp-in { from { opacity: 0; transform: translateY(-4px); } }
.mdp-play {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter .2s ease, transform .15s ease;
}
.mdp-play:hover { filter: brightness(1.12); transform: translateY(-1px); }
.mdp-play:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--active-bg); }
.mdp-play svg { width: 15px; height: 15px; }
.mdp-t { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mdp-range {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 3px;
  cursor: pointer;
  background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--border) var(--fill, 0%));
}
.mdp-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-hdr);
  box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.mdp-range::-webkit-slider-thumb:hover { transform: scale(1.2); }
.mdp-range::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-hdr);
}
.mdp-range:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--active-bg); }
.mdp-seek { flex: 1 1 auto; min-width: 60px; }
.mdp-mute {
  flex: 0 0 auto;
  border: 0;
  background: none;
  color: var(--muted);
  display: inline-flex;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: color .2s ease;
}
.mdp-mute:hover { color: var(--accent); }
.mdp-mute:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--active-bg); }
.mdp-mute svg { width: 16px; height: 16px; }
.mdp-vol { width: 64px; flex: 0 0 auto; }
.mdp-rate {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background .2s ease;
}
.mdp-rate:hover { color: var(--accent); border-color: var(--accent); background: var(--hover); }
.mdp-rate:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--active-bg); }
@media (max-width: 640px) {
  .md-audio { width: 34px; height: 34px; }
  .md-player { gap: 8px; padding: 8px 10px; }
  /* Volume some no celular: la o controle e o botao fisico do aparelho */
  .mdp-mute, .mdp-vol { display: none; }
}
@media (max-width: 420px) {
  /* Linha do player apertada: o tempo decorrido sai, a barra mostra a posição. */
  .header-audio-slot .mdp-cur { display: none; }
  .header-audio-slot .mdp-tab { width: 28px; height: 28px; }
  .header-audio-slot .mdp-play { width: 30px; height: 30px; }
  .header-audio-slot .mdp-seek { min-width: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .md-audio.tocando .oa-b { animation: none; }
  .md-player.aberto { animation: none; }
  #md .article-card { transition: none; }
  #md .article-card:hover, #md .article-card:focus-within { transform: none; }
}
