/* ==========================================================================
   REVISTA CIRCUITO+ — Folha de Estilos v2.0 (Moderna, Interactiva e Atractiva)
   "Electrónica que se calcula, simula e constrói"
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Modo Claro (Padrão) */
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.86);
  --bg-code: #0f172a;
  --bg-hero: linear-gradient(135deg, #0f172a 0%, #1e1b4b 52%, #2e1065 100%);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  /* Acentos CIRCUITO+ */
  --accent-primary: #dc2626;
  --accent-primary-hover: #b91c1c;
  --accent-primary-soft: rgba(220, 38, 38, 0.1);
  --accent-amber: #f59e0b;
  --accent-amber-soft: rgba(245, 158, 11, 0.12);
  --accent-tech: #2563eb;
  --accent-emerald: #059669;

  /* Cores de Categorias */
  --cat-capa: #d97706;
  --cat-capa-bg: #fef3c7;
  --cat-radar: #2563eb;
  --cat-radar-bg: #dbeafe;
  --cat-teoria: #7c3aed;
  --cat-teoria-bg: #ede9fe;
  --cat-kit: #059669;
  --cat-kit-bg: #d1fae5;
  --cat-pratica: #e11d48;
  --cat-pratica-bg: #ffe4e6;
  --cat-editorial: #475569;
  --cat-editorial-bg: #e2e8f0;

  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Newsreader', Georgia, "Times New Roman", serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --reading-font-size: 1.14rem;
  --container-max: 1220px;
  --reading-max: 760px;
  --figure-max: 960px;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-xs: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 16px 40px rgba(15, 23, 42, 0.1);
  --shadow-glow: 0 0 28px rgba(220, 38, 38, 0.28);
}

/* Modo Escuro de Bancada */
[data-theme="dark"] {
  --bg-page: #0b0f19;
  --bg-surface: #111827;
  --bg-subtle: #1e293b;
  --bg-glass: rgba(17, 24, 39, 0.88);
  --bg-code: #090d16;

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --accent-primary: #ef4444;
  --accent-primary-hover: #f87171;
  --accent-primary-soft: rgba(239, 68, 68, 0.16);

  --cat-capa-bg: rgba(217, 119, 6, 0.2);
  --cat-radar-bg: rgba(37, 99, 235, 0.2);
  --cat-teoria-bg: rgba(124, 58, 237, 0.2);
  --cat-kit-bg: rgba(5, 150, 105, 0.2);
  --cat-pratica-bg: rgba(225, 29, 72, 0.2);
  --cat-editorial-bg: rgba(148, 163, 184, 0.2);

  --border-light: #1e293b;
  --border-medium: #334155;
  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.5);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* REGRA GLOBAL: Todos os parágrafos de texto de conteúdo justificados */
p,
.article-prose p,
.article-prose li,
.card-excerpt,
.issue-lead,
.toc-desc,
.callout p,
.callout li,
.glossary-desc,
.justified-text {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* Exceções onde centralização é necessária (cabeçalhos centrados, badges) */
.hero-masthead p,
.newsletter-inner p,
.center-text {
  text-align: center !important;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
  transition: all 0.2s ease;
}

/* Barra de Progresso de Leitura */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3.5px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-amber));
  z-index: 2000;
  transition: width 0.08s linear;
}

/* ==========================================================================
   Cabeçalho Moderno com Glassmorphism, Seletor de Edição e Tema
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-light);
}

.header-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #dc2626, #991b1b);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.05rem;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-logo {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text-primary);
}

.brand-logo .plus {
  color: var(--accent-amber);
  margin-left: 1px;
}

.brand-slogan {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.nav-link.active {
  color: var(--accent-primary);
  background: var(--accent-primary-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.edition-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 0.38rem 0.7rem;
  border-radius: 99px;
}

.mobile-menu-btn {
  display: none;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ==========================================================================
   Contentores e Secções
   ========================================================================== */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

.section {
  padding: 4.5rem 0;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: 1rem;
}

.section-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  display: block;
  margin-bottom: 0.35rem;
}

.section-title {
  font-size: clamp(1.45rem, 2.5vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.section-link {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.section-link:hover {
  gap: 0.55rem;
}

/* ==========================================================================
   Hero Tecnológico Moderno com Ondas de Osciloscópio Animadas
   ========================================================================== */
.hero-modern {
  position: relative;
  background: var(--bg-hero);
  color: #ffffff;
  padding: 4.5rem 0 4rem;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.hero-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.hero-wave-svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 110px;
  opacity: 0.22;
  pointer-events: none;
}

.featured-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  align-items: center;
}

@media (min-width: 900px) {
  .featured-grid {
    grid-template-columns: 370px 1fr;
    gap: 4.5rem;
  }
}

.issue-cover-wrap {
  position: relative;
  max-width: 370px;
  margin: 0 auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.15);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease;
}

.issue-cover-wrap:hover {
  transform: translateY(-6px) rotate(-1deg) scale(1.015);
  box-shadow: 0 30px 60px -12px rgba(220, 38, 38, 0.4), 0 0 0 1px rgba(245, 158, 11, 0.5);
}

.issue-info {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.issue-badge-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.issue-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fef08a;
  background: rgba(245, 158, 11, 0.22);
  border: 1px solid rgba(250, 204, 21, 0.4);
  padding: 0.35rem 0.85rem;
  border-radius: 99px;
}

.issue-date {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #cbd5e1;
}

.issue-headline {
  font-size: clamp(2rem, 3.8vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: #ffffff;
}

.issue-headline span {
  background: linear-gradient(90deg, #f87171, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-modern .issue-lead {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: #e2e8f0;
  line-height: 1.65;
}

/* Métricas / Destaques Rápidos no Hero */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.85rem;
  margin: 0.5rem 0;
}

.stat-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  backdrop-filter: blur(8px);
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  color: #fbbf24;
  display: block;
}

.stat-lbl {
  font-size: 0.76rem;
  color: #cbd5e1;
}

/* Botões Modernos */
.btn-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 0.8rem 1.45rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(220, 38, 38, 0.45);
}

.btn-download {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
}

.btn-download:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.btn-glass {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

/* ==========================================================================
   Banner Dedicado de Download do Pacote Digital (.ZIP)
   ========================================================================== */
.digital-pack-banner {
  background: linear-gradient(135deg, #111827 0%, #1e293b 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 2.25rem 2.5rem;
  border: 1px solid rgba(245, 158, 11, 0.35);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  margin: 2.5rem 0;
}

.pack-info {
  flex: 1;
  min-width: 280px;
}

.pack-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.16);
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  margin-bottom: 0.6rem;
}

.pack-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.45rem;
  color: #ffffff;
}

.pack-desc {
  font-size: 0.92rem;
  color: #cbd5e1;
  line-height: 1.6;
}

/* ==========================================================================
   Grelha de Artigos Interactiva (Cards)
   ========================================================================== */
.articles-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.85rem;
}

@media (min-width: 660px) {
  .articles-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1020px) {
  .articles-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.article-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease, border-color 0.28s ease;
  position: relative;
}

.article-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-primary);
}

.card-thumb {
  aspect-ratio: 16 / 10;
  background-color: #ffffff;
  overflow: hidden;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem;
  position: relative;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.35s ease;
}

.card-thumb.cover-crop {
  padding: 1.25rem;
  background: linear-gradient(145deg, #0f172a, #1e293b);
  aspect-ratio: auto;
  max-height: none;
}

.card-thumb.cover-crop img {
  width: auto;
  max-width: 100%;
  max-height: 480px;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.article-card:hover .card-thumb img {
  transform: scale(1.02);
}

.article-card:hover .card-thumb.cover-crop img {
  transform: none;
}

.card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.7rem;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.category-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  display: inline-block;
}

.cat-capa { color: var(--cat-capa); background: var(--cat-capa-bg); }
.cat-radar { color: var(--cat-radar); background: var(--cat-radar-bg); }
.cat-teoria { color: var(--cat-teoria); background: var(--cat-teoria-bg); }
.cat-kit { color: var(--cat-kit); background: var(--cat-kit-bg); }
.cat-pratica { color: var(--cat-pratica); background: var(--cat-pratica-bg); }
.cat-editorial { color: var(--cat-editorial); background: var(--cat-editorial-bg); }

.card-readtime {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.article-card:hover .card-title {
  color: var(--accent-primary);
}

.card-excerpt {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
}

.card-footer {
  padding-top: 0.9rem;
  margin-top: 0.4rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-footer .arrow {
  color: var(--accent-primary);
  font-family: var(--font-mono);
  transition: transform 0.2s ease;
}

.article-card:hover .card-footer .arrow {
  transform: translateX(5px);
}

/* ==========================================================================
   Sumário da Edição (TOC)
   ========================================================================== */
.toc-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.toc-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 1.35rem;
  padding: 1.35rem 1.6rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all 0.22s ease;
}

.toc-item:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
  transform: translateX(5px);
}

.toc-num {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent-primary-soft);
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toc-content {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.toc-title {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--text-primary);
}

.toc-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.toc-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

@media (max-width: 680px) {
  .toc-item {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
}

/* ==========================================================================
   Layout de Página de Artigo com Índice Lateral Flutuante (Sticky Sidebar)
   ========================================================================== */
.article-header {
  padding: 3.5rem 0 2.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface);
}

.article-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.article-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1.2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.article-breadcrumb a:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

.article-title {
  font-size: clamp(1.9rem, 4vw, 2.75rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.article-standfirst {
  font-family: var(--font-serif);
  font-size: clamp(1.15rem, 2vw, 1.32rem);
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  text-align: justify;
}

.article-byline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.reading-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tool-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 0.28rem 0.6rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.tool-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Grelha de Leitura (Sidebar + Conteúdo) */
.article-layout {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  align-items: start;
}

@media (min-width: 1080px) {
  .article-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }
}

.article-sidebar {
  display: none;
}

@media (min-width: 1080px) {
  .article-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: 90px;
  }
}

.sidebar-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  box-shadow: var(--shadow-xs);
}

.sidebar-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.sidebar-toc {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.sidebar-toc a {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: block;
  padding: 0.3rem 0.5rem;
  border-left: 2px solid var(--border-light);
  border-radius: 0 4px 4px 0;
}

.sidebar-toc a:hover,
.sidebar-toc a.active {
  color: var(--accent-primary);
  border-left-color: var(--accent-primary);
  background: var(--accent-primary-soft);
  font-weight: 600;
}

.sidebar-toc .toc-sub a {
  padding-left: 1.15rem;
  font-size: 0.79rem;
  color: var(--text-muted);
}

.sidebar-toc .toc-sub a.active {
  color: var(--accent-primary);
}

.article-body {
  min-width: 0;
}

.article-prose {
  max-width: var(--reading-max);
  margin: 0 auto;
}

.article-prose p {
  font-family: var(--font-serif);
  font-size: var(--reading-font-size);
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 1.35rem;
  text-align: justify;
}

.article-prose h2 {
  font-family: var(--font-sans);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 2.75rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-light);
  scroll-margin-top: 90px;
}

.article-prose h3 {
  font-family: var(--font-sans);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 2rem 0 0.7rem;
  scroll-margin-top: 90px;
}

.article-prose ul, .article-prose ol {
  font-family: var(--font-serif);
  font-size: var(--reading-font-size);
  line-height: 1.75;
  margin: 0 0 1.5rem 1.5rem;
  color: var(--text-primary);
}

.article-prose li {
  margin-bottom: 0.45rem;
  text-align: justify;
}

.article-prose a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}

/* Fórmulas e Cálculos */
.formula-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.3rem;
  margin: 1.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.7;
  overflow-x: auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-xs);
}

.formula-lines {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.formula-num {
  color: var(--accent-primary);
  background: var(--accent-primary-soft);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Figuras, Esquemas e Capturas — Sticky Image durante a rolagem */
.sticky-figure-group {
  position: relative;
  margin-bottom: 1.5rem;
}

.article-figure {
  max-width: var(--figure-max);
  margin: 1.75rem auto;
  position: sticky;
  top: 66px;
  z-index: 45;
  transition: all 0.25s ease;
}

.figure-frame {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.15rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: padding 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.article-figure.is-stuck .figure-frame {
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-color: var(--accent-primary);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
  padding: 0.65rem 1rem;
}

.sticky-fig-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.55rem;
  margin-bottom: 0.55rem;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.sticky-fig-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  color: var(--accent-primary);
  flex-wrap: wrap;
}

.sticky-tab-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sticky-tab-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.sticky-fig-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.sticky-fig-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 0.22rem 0.55rem;
  border-radius: 5px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sticky-fig-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.figure-img-box {
  background: #ffffff;
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: max-height 0.28s ease;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.figure-frame img {
  margin: 0 auto;
  cursor: zoom-in;
  max-height: 480px;
  width: 100%;
  object-fit: contain;
  transition: max-height 0.28s ease, filter 0.2s ease;
  filter: contrast(1.04);
}

/* Quando a imagem está fixa no topo durante a leitura, mantém excelente visibilidade e nitidez */
.article-figure.is-stuck .figure-frame img {
  max-height: 340px;
}

/* Modo expandido quando o utilizador clica em "Expandir" na imagem */
.article-figure.sticky-expanded .figure-frame img,
.article-figure.is-stuck.sticky-expanded .figure-frame img {
  max-height: 720px;
}

/* Modo minimizado se o utilizador quiser recolher temporariamente a imagem fixa */
.article-figure.sticky-minimized .figure-img-box {
  display: none;
}

.article-figure.sticky-minimized .figure-caption {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.figure-caption {
  margin-top: 0.65rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-light);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-secondary);
  text-align: justify;
}

.article-figure.is-stuck .figure-caption {
  font-size: 0.79rem;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
}

@media (max-width: 768px) {
  .article-figure {
    top: 58px;
  }
  .article-figure.is-stuck .figure-frame img {
    max-height: 185px;
  }
}

/* Barra Interactiva de Simulador Falstad (Link Direto + Simulador Integrado) */
.sim-links-bar {
  background: linear-gradient(135deg, var(--bg-subtle), var(--bg-surface));
  border: 1px solid var(--border-medium);
  border-left: 4px solid var(--cat-kit);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.35rem;
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: var(--shadow-xs);
}

.sim-links-bar .sim-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sim-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.sim-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff !important;
  background: var(--cat-kit);
  border: 1px solid var(--cat-kit);
  padding: 0.48rem 0.9rem;
  border-radius: 6px;
  text-decoration: none !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sim-btn:hover {
  background: #047857;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.sim-btn-embed {
  background: var(--bg-surface);
  color: var(--text-primary) !important;
  border: 1px solid var(--border-medium);
}

.sim-btn-embed:hover {
  background: var(--accent-primary);
  color: #ffffff !important;
  border-color: var(--accent-primary);
}

/* Tabelas Técnicas */
.table-wrap {
  max-width: var(--figure-max);
  margin: 2rem auto;
  overflow-x: auto;
}

.table-title {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.65rem;
}

.tech-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  line-height: 1.5;
  box-shadow: var(--shadow-xs);
}

.tech-table th {
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-weight: 700;
  text-align: left;
  padding: 0.75rem 0.95rem;
  border-bottom: 2px solid var(--border-medium);
}

.tech-table td {
  padding: 0.7rem 0.95rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: top;
}

.tech-table tr:hover td {
  background: var(--bg-subtle);
}

/* Caixas de Destaque */
.callout {
  border-radius: var(--radius-md);
  padding: 1.4rem 1.6rem;
  margin: 2rem 0;
  font-family: var(--font-sans);
  box-shadow: var(--shadow-xs);
}

.callout-title {
  font-size: 0.92rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.callout p, .callout ul {
  font-family: var(--font-sans) !important;
  font-size: 0.94rem !important;
  line-height: 1.65 !important;
  margin-bottom: 0.5rem !important;
  text-align: justify;
}

.callout ul {
  margin-left: 1.25rem !important;
}

.callout-summary {
  background: var(--accent-amber-soft);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-left: 4px solid var(--accent-amber);
}

.callout-summary .callout-title {
  color: var(--cat-capa);
}

.callout-safety {
  background: var(--accent-primary-soft);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-left: 4px solid var(--accent-primary);
}

.callout-safety .callout-title {
  color: var(--accent-primary);
}

.callout-note {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--cat-radar);
}

.callout-note .callout-title {
  color: var(--cat-radar);
}

/* Código Arduino */
.code-block-wrap {
  margin: 1.75rem 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-medium);
  background: var(--bg-code);
  box-shadow: var(--shadow-sm);
}

.code-header {
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.65rem 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.copy-code-btn {
  background: #334155;
  color: #f8fafc;
  border: none;
  border-radius: 5px;
  padding: 0.3rem 0.7rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.copy-code-btn:hover {
  background: var(--accent-primary);
}

.code-block {
  padding: 1.2rem 1.35rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.65;
  color: #f1f5f9;
}

/* Navegação Anterior / Seguinte */
.article-pager {
  max-width: var(--reading-max);
  margin: 3.5rem auto 0;
  padding-top: 2rem;
  border-top: 1px solid var(--border-light);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.25rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  transition: all 0.22s ease;
}

.pager-link:hover {
  border-color: var(--accent-primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
}

.pager-link.next {
  text-align: right;
}

.pager-dir {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
}

.pager-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* ==========================================================================
   Modal de Simulador Falstad Integrado & Lightbox
   ========================================================================== */
.sim-modal-overlay,
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.88);
  backdrop-filter: blur(6px);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.sim-modal-overlay.open,
.lightbox-overlay.open {
  display: flex;
}

.sim-modal-box {
  width: 96vw;
  max-width: 1280px;
  height: 86vh;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}

.sim-modal-header {
  padding: 0.75rem 1.25rem;
  background: #0f172a;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.sim-modal-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #000000;
}

.lightbox-img {
  max-width: 95vw;
  max-height: 90vh;
  background: #ffffff;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

/* Secção Comercial WhatsApp e Rodapé */
.newsletter-box {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  padding: 3.75rem 0;
}

.whatsapp-commercial-section {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.98) 0%, rgba(17, 34, 51, 0.96) 100%);
  border-top: 2px solid rgba(16, 185, 129, 0.45);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.newsletter-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
}

.whatsapp-promo-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.32rem 0.9rem;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #34d399;
  margin-bottom: 1rem;
}

.newsletter-title {
  font-size: 1.65rem;
  font-weight: 800;
  margin-bottom: 0.7rem;
  color: #ffffff;
}

.newsletter-desc {
  font-size: 0.98rem;
  color: #cbd5e1;
  line-height: 1.65;
  margin-bottom: 1.25rem;
  text-align: center !important;
}

.whatsapp-price-highlight {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.6rem 1.35rem;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.55);
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.whatsapp-price-highlight .price-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fde68a;
}

.whatsapp-price-highlight .price-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: 0.02em;
}

.whatsapp-contact-text {
  font-size: 0.96rem;
  color: #e2e8f0;
  line-height: 1.6;
  margin-bottom: 1.35rem;
  text-align: center !important;
}

.whatsapp-number-link {
  color: #34d399 !important;
  font-family: var(--font-mono);
  font-weight: 800;
  text-decoration: underline !important;
  text-underline-offset: 3px;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.14);
  transition: all 0.2s ease;
}

.whatsapp-number-link:hover {
  background: #10b981;
  color: #ffffff !important;
}

.whatsapp-cta-actions {
  display: flex;
  justify-content: center;
}

.btn-whatsapp-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.88rem 1.75rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff !important;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 800;
  text-decoration: none !important;
  border: 1px solid rgba(52, 211, 153, 0.6);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
  transition: all 0.22s ease;
}

.btn-whatsapp-cta:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(16, 185, 129, 0.48);
  color: #ffffff !important;
}

.newsletter-form {
  display: flex;
  gap: 0.65rem;
  max-width: 460px;
  margin: 0 auto;
}

.newsletter-input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
}

.site-footer {
  margin-top: auto;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  padding: 2.5rem 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.footer-links {
  display: flex;
  gap: 1.35rem;
  flex-wrap: wrap;
  font-weight: 600;
}

.footer-links a:hover {
  color: var(--accent-primary);
}

@media (max-width: 820px) {
  .mobile-menu-btn {
    display: inline-flex;
  }
  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    padding: 0.85rem 1.5rem;
    flex-direction: column;
    align-items: stretch;
    box-shadow: var(--shadow-md);
  }
  .main-nav.open {
    display: flex;
  }
  .article-pager {
    grid-template-columns: 1fr;
  }
  .pager-link.next {
    text-align: left;
  }
}

/* ==========================================================================
   Botão & Modal de Leitura em Formato Flipbook
   ========================================================================== */
.btn-flipbook {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.72rem 1.35rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border: 1px solid rgba(245, 158, 11, 0.55);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.22s ease;
}

.btn-flipbook:hover {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  border-color: #fbbf24;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(217, 119, 6, 0.32);
}

.btn-flipbook .flipbook-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.btn-flipbook:hover .flipbook-badge {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.5);
}

.flipbook-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(9, 13, 22, 0.88);
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  padding: 0.85rem;
}

.flipbook-modal-backdrop.open {
  display: flex;
}

.flipbook-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #0f172a;
  color: #f8fafc;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: none;
}

.flipbook-modal-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 700;
}

.flipbook-modal-note {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
}

.flipbook-modal-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flipbook-modal-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0.38rem 0.8rem;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.flipbook-modal-btn:hover {
  background: #d97706;
  border-color: #fbbf24;
  color: #ffffff;
}

.flipbook-modal-frame-wrap {
  flex: 1;
  background: #1e293b;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  position: relative;
}

.flipbook-modal-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ==========================================================================
   Controlo de Acesso por Código do Administrador (1 Utilizador / Sessão Única)
   ========================================================================== */
.access-status-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  transition: all 0.2s ease;
  white-space: nowrap;
}

[data-theme="light"] .access-status-btn {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.45);
}

.access-status-btn.unlocked {
  border-color: rgba(16, 185, 129, 0.55);
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

[data-theme="light"] .access-status-btn.unlocked {
  color: #047857;
  background: rgba(16, 185, 129, 0.12);
}

.access-status-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.access-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.access-badge-tag.free-sample {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

[data-theme="light"] .access-badge-tag.free-sample {
  color: #047857;
}

.access-badge-tag.locked-item {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

[data-theme="light"] .access-badge-tag.locked-item {
  color: #b45309;
}

/* Painel de Bloqueio nos Artigos Restritos */
.article-paywall-gate {
  margin: 2rem 0 3rem;
  padding: 2.4rem 2rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.96));
  border: 2px solid rgba(245, 158, 11, 0.55);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.42);
  color: #f8fafc;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.article-paywall-gate h3 {
  font-family: var(--font-sans);
  font-size: 1.45rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 0.65rem;
}

.article-paywall-gate p {
  font-size: 0.96rem;
  line-height: 1.65;
  color: #cbd5e1;
  max-width: 640px;
  margin: 0 auto 1.35rem;
  text-align: center !important;
}

.paywall-form-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  max-width: 480px;
  margin: 0 auto 1rem;
  flex-wrap: wrap;
}

.paywall-code-input {
  flex: 1;
  min-width: 220px;
  padding: 0.78rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(9, 13, 22, 0.85);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}

.paywall-code-input:focus {
  outline: none;
  border-color: #fbbf24;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

.paywall-feedback {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  display: none;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.paywall-feedback.error {
  display: block;
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.6);
  color: #fca5a5;
}

.paywall-feedback.success {
  display: block;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.6);
  color: #6ee7b7;
}

.paywall-sample-links {
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.84rem;
  color: #94a3b8;
}

.paywall-sample-links a {
  color: #fbbf24;
  font-weight: 700;
  text-decoration: underline;
  margin: 0 0.35rem;
}

/* Modal Global de Inserção/Gestão de Código de Acesso */
.cp-code-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10005;
  background: rgba(9, 13, 22, 0.84);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.cp-code-modal-backdrop.open {
  display: flex;
}

.cp-code-modal {
  width: 100%;
  max-width: 520px;
  background: #0f172a;
  color: #f8fafc;
  border: 2px solid rgba(245, 158, 11, 0.55);
  border-radius: var(--radius-lg);
  padding: 2rem 1.85rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  position: relative;
}

.cp-code-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-weight: 700;
}

.cp-code-modal h3 {
  font-size: 1.3rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 0.5rem;
}

.cp-code-modal p {
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.6;
  margin-bottom: 1.15rem;
  text-align: left !important;
}

.modal-whatsapp-promo {
  margin-top: 1.15rem;
  padding: 1.1rem 1.15rem;
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.11), rgba(15, 23, 42, 0.75));
  border: 1px solid rgba(16, 185, 129, 0.42);
  text-align: center;
}

.modal-whatsapp-title {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 800;
  color: #34d399;
  margin-bottom: 0.45rem;
}

.modal-whatsapp-text {
  font-size: 0.85rem !important;
  line-height: 1.55 !important;
  color: #e2e8f0 !important;
  margin-bottom: 0.85rem !important;
  text-align: center !important;
}

.modal-price-tag {
  color: #fbbf24;
  font-weight: 800;
}

.btn-whatsapp-modal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.72rem 1rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff !important;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none !important;
  border: 1px solid rgba(52, 211, 153, 0.55);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.28);
  transition: all 0.2s ease;
}

.btn-whatsapp-modal:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.42);
  color: #ffffff !important;
}

/* ==========================================================================
   Responsividade Completa: Computador, Portátil, Tablet e Telemóvel
   ========================================================================== */

/* 1. Monitores Grandes / Computador Desktop (>= 1360px) */
@media (min-width: 1360px) {
  :root {
    --container-max: 1320px;
  }
  .figure-frame img {
    max-height: 500px;
  }
  .article-figure.is-stuck .figure-frame img {
    max-height: 360px;
  }
}

/* 2. Portátil / Laptop (992px a 1279px — ecrãs 13" a 15.6") */
@media (min-width: 992px) and (max-width: 1279px) {
  .container,
  .header-inner,
  .footer-inner {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
  .featured-grid {
    grid-template-columns: 280px 1fr;
    gap: 2rem;
  }
  .issue-headline {
    font-size: 2.2rem;
  }
  .article-layout {
    grid-template-columns: 235px minmax(0, 1fr);
    gap: 1.75rem;
  }
  .figure-frame img {
    max-height: 390px;
  }
  .article-figure.is-stuck .figure-frame img {
    max-height: 270px;
  }
}

/* 3. Tablet (768px a 991px — iPad / Tablets Android em retrato e paisagem) */
@media (max-width: 991px) {
  .header-inner {
    padding: 0.7rem 1.1rem;
    gap: 0.65rem;
  }
  .brand-slogan {
    display: none;
  }
  .featured-grid {
    grid-template-columns: 1fr;
    gap: 1.85rem;
    text-align: center;
  }
  .issue-cover-wrap {
    max-width: 280px;
    margin: 0 auto;
  }
  .issue-badge-row,
  .hero-stats,
  .featured-grid .btn-group {
    justify-content: center;
  }
  .issue-lead {
    margin-left: auto;
    margin-right: auto;
  }
  .article-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .article-sidebar {
    position: static;
    max-height: none;
    margin-bottom: 0.5rem;
  }
  .download-pkg-banner {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 1.75rem 1.35rem;
  }
  .pkg-files-list {
    justify-content: center;
  }
  .pkg-action {
    align-items: center;
  }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* 4. Telemóvel / Smartphone (<= 767px) */
@media (max-width: 767px) {
  html {
    font-size: 15px;
  }
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .header-inner {
    padding: 0.6rem 0.9rem;
    flex-wrap: wrap;
  }
  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
  }
  .brand-logo {
    font-size: 1.12rem;
  }
  .header-actions {
    gap: 0.35rem;
    margin-left: auto;
  }
  .access-status-btn,
  .icon-btn.theme-toggle-btn {
    padding: 0.34rem 0.62rem;
    font-size: 0.72rem;
  }
  .mobile-menu-btn {
    padding: 0.34rem 0.6rem;
    font-size: 0.78rem;
    order: 3;
  }
  .hero-modern {
    padding: 2rem 0 2.4rem;
  }
  .issue-cover-wrap {
    max-width: 230px;
  }
  .issue-headline {
    font-size: clamp(1.55rem, 6vw, 2rem) !important;
  }
  .issue-lead {
    font-size: 0.94rem;
    text-align: justify;
  }
  .hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    width: 100%;
  }
  .stat-card {
    padding: 0.6rem 0.4rem;
    text-align: center;
  }
  .stat-val {
    font-size: 1.25rem;
  }
  .stat-lbl {
    font-size: 0.68rem;
  }
  .btn-group {
    flex-direction: column;
    width: 100%;
    gap: 0.6rem;
  }
  .btn-group .btn,
  .btn-group .btn-flipbook {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
  .section {
    padding: 2.2rem 0;
  }
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
  }
  .articles-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
  .toc-item {
    grid-template-columns: 1fr;
    gap: 0.45rem;
    padding: 1rem;
  }
  .toc-pages {
    justify-self: start;
  }
  /* Artigos e Sticky Image no Telemóvel */
  .article-header {
    padding: 1.75rem 0 1.35rem;
  }
  .article-title {
    font-size: 1.5rem;
  }
  .article-figure {
    top: 54px;
    margin: 1.1rem 0;
  }
  .figure-frame {
    padding: 0.55rem;
  }
  .figure-frame img {
    max-height: 260px;
  }
  .article-figure.is-stuck .figure-frame img {
    max-height: 175px;
  }
  .article-figure.sticky-expanded .figure-frame img,
  .article-figure.is-stuck.sticky-expanded .figure-frame img {
    max-height: 380px;
  }
  .sticky-fig-toolbar {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .sticky-fig-btn {
    padding: 0.2rem 0.45rem;
    font-size: 0.68rem;
  }
  .figure-caption {
    font-size: 0.78rem;
  }
  .sim-links-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem;
  }
  .sim-links-actions {
    width: 100%;
    flex-direction: column;
  }
  .sim-links-actions .btn {
    width: 100%;
    justify-content: center;
  }
  /* Modal Flipbook em Ecrã Total no Telemóvel */
  .flipbook-modal-backdrop {
    padding: 0;
  }
  .flipbook-modal-header {
    border-radius: 0;
    padding: 0.55rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  .flipbook-modal-title {
    font-size: 0.8rem;
  }
  .flipbook-modal-note {
    display: none;
  }
  .flipbook-modal-frame-wrap {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  /* Painel de Código e Modais no Telemóvel */
  .article-paywall-gate {
    padding: 1.5rem 1.1rem;
  }
  .article-paywall-gate h3 {
    font-size: 1.2rem;
  }
  .paywall-form-row {
    flex-direction: column;
    align-items: stretch;
  }
  .paywall-code-input,
  .paywall-form-row .btn {
    width: 100%;
  }
  .cp-code-modal {
    padding: 1.4rem 1.15rem;
  }
  .footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 0.85rem;
  }
  .footer-links {
    justify-content: center;
  }
}

/* 5. Telemóveis Compactos (<= 420px) */
@media (max-width: 420px) {
  .brand-logo {
    font-size: 1rem;
  }
  .access-status-btn {
    font-size: 0.68rem;
    padding: 0.3rem 0.5rem;
  }
  .hero-stats {
    grid-template-columns: 1fr;
  }
}
