:root {
  --bg: #faf7f2;
  --panel: #ffffff;
  --text: #2b2f36;
  --muted: #6b7280;
  --border: #e8e2d8;
  --primary: #2f8f9d;
  --primary-dark: #226b76;
  --amber: #e0a53d;
  --amber-bg: #fdf3e0;
  --red: #d9463c;
  --red-bg: #fbe8e6;
  --green: #3f9d64;
  --green-bg: #e7f5eb;
  --sidebar-width: 270px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

h1, h2, h3 {
  line-height: 1.25;
  font-weight: 700;
}

a {
  color: var(--primary-dark);
}

#app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: block;
  text-decoration: none;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-title {
  display: block;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.sidebar-brand-subtitle {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-title {
  margin-top: 16px;
  margin-bottom: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0 12px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
}

.sidebar-link:hover {
  background: var(--bg);
}

.sidebar-link.active {
  background: var(--primary);
  color: white;
}

.sidebar-link.highlight:not(.active) {
  color: var(--amber);
  font-weight: 600;
}

.sidebar-link-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--border);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-link.active .sidebar-link-number {
  background: rgba(255, 255, 255, 0.3);
}

.sidebar-link-checker {
  border: 1px solid var(--primary);
  margin: 6px 0;
}

.sidebar-category {
  margin-bottom: 4px;
}

.sidebar-category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.sidebar-category-header:hover {
  background: var(--bg);
}

.sidebar-category-header.active {
  background: var(--primary);
  color: white;
}

.sidebar-category-header.coming-soon {
  color: var(--muted);
  font-weight: 500;
}

.sidebar-category-icon {
  font-size: 15px;
}

.sidebar-category-caret {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

.sidebar-category-header.active .sidebar-category-caret {
  color: rgba(255, 255, 255, 0.8);
}

.sidebar-sublink {
  margin-left: 14px;
  font-weight: 400;
  font-size: 13px;
}

.sidebar-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--amber);
  background: var(--amber-bg);
  padding: 2px 8px;
  border-radius: 999px;
}

.menu-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 50;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
}

/* Content */

.content {
  flex: 1;
  min-width: 0;
  padding: 48px 24px 80px;
  display: flex;
  justify-content: center;
}

.content > section {
  width: 100%;
  max-width: 720px;
}

/* Hero */

.hero-kicker {
  color: var(--primary-dark);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.hero h1 {
  font-size: 40px;
  margin: 8px 0 12px;
}

.hero-subtitle {
  font-size: 18px;
  color: var(--muted);
  margin: 0 0 12px;
}

.hero-tagline {
  font-weight: 600;
  color: var(--primary-dark);
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}

.presentation {
  margin-top: 48px;
}

.author-byline {
  color: var(--muted);
  font-size: 14px;
}

/* Pullquote */

.pullquote {
  margin: 28px 0;
  padding: 18px 22px;
  border-left: 4px solid var(--primary);
  background: rgba(47, 143, 157, 0.06);
  font-size: 17px;
  font-style: italic;
  color: var(--primary-dark);
}

/* Chapters grid on home */

.chapters-grid {
  margin-top: 56px;
}

.chapter-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
}

.chapter-card:hover {
  border-color: var(--primary);
}

.chapter-card.highlight {
  border-color: var(--amber);
  background: var(--amber-bg);
}

.chapter-card-number {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.chapter-card-body h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.chapter-card-body p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

/* Category cards (home) */

.category-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.category-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  position: relative;
}

.category-card:hover {
  border-color: var(--primary);
}

.category-card.coming-soon {
  opacity: 0.65;
}

.category-card-icon {
  font-size: 26px;
  flex-shrink: 0;
}

.category-card-body {
  padding-right: 64px;
}

.category-card-body h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.category-card-body p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.category-card .sidebar-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  margin-left: 0;
}

/* Category page */

.category-page .chapter-card-list {
  margin: 28px 0;
}

.category-checker-link {
  margin-top: 8px;
}

.coming-soon-box {
  margin: 28px 0;
  padding: 24px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px dashed var(--border);
  color: var(--muted);
  text-align: center;
}

.draft-banner {
  margin-bottom: 24px;
  padding: 14px 18px;
  border-radius: 10px;
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  color: #96691d;
  font-weight: 600;
  font-size: 14px;
}

/* Chapter page */

.chapter-kicker {
  color: var(--primary-dark);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
  margin: 0;
}

.chapter-page h1 {
  margin: 6px 0 16px;
  font-size: 32px;
}

.chapter-intro {
  font-size: 18px;
  color: var(--muted);
}

.chapter-section {
  margin: 32px 0;
}

.chapter-section h3 {
  font-size: 19px;
  margin-bottom: 8px;
}

.critical-section {
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--red-bg);
  border-left: 4px solid var(--red);
}

.highlight-page h1 {
  color: var(--amber);
}

/* Summary / alert boxes */

.summary-box, .alert-box, .disclaimer-box {
  border-radius: 12px;
  padding: 20px 22px;
  margin: 28px 0;
}

.summary-box {
  background: var(--green-bg);
  border: 1px solid rgba(63, 157, 100, 0.3);
}

.summary-box h3 {
  color: var(--green);
  margin-top: 0;
}

.alert-box {
  background: var(--red-bg);
  border: 1px solid rgba(217, 70, 60, 0.3);
}

.alert-box h3 {
  color: var(--red);
  margin-top: 0;
}

.disclaimer-box {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.disclaimer-box.small {
  margin-top: 24px;
}

.summary-box ul, .alert-box ul {
  margin: 0;
  padding-left: 20px;
}

.summary-box li, .alert-box li {
  margin-bottom: 8px;
}

/* Video slots */

.video-slot {
  margin: 20px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.video-slot-placeholder {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: var(--bg);
  border-style: dashed;
}

.video-slot-icon {
  font-size: 28px;
}

.video-slot-label {
  font-weight: 600;
  font-size: 14px;
}

.video-slot-hint {
  font-size: 12px;
  color: var(--muted);
}

.video-slot-embed .video-slot-label {
  padding: 12px 16px 0;
}

.video-frame-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
}

.video-frame-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-slot-embed video {
  width: 100%;
  display: block;
  padding: 12px 16px 16px;
}

/* Illustrations */

.illustration-slot {
  margin: 20px 0;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  overflow: hidden;
}

.illustration-canvas {
  padding: 18px 20px 4px;
}

.illustration-canvas svg {
  width: 100%;
  height: auto;
  display: block;
  max-height: 220px;
}

.illustration-label {
  padding: 10px 20px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.illus-caption {
  font-size: 13px;
  fill: var(--muted);
  font-weight: 600;
  font-family: inherit;
}

.illus-caption-small {
  font-size: 11px;
  fill: var(--muted);
  font-family: inherit;
}

.illus-caption-critical {
  fill: var(--red);
}

/* Breathing rate comparison */

.illus-chest-normal {
  animation: illusBreatheSlow 3s ease-in-out infinite;
  transform-origin: 0px 150px;
}

.illus-chest-fast {
  animation: illusBreatheFast 0.9s ease-in-out infinite;
  transform-origin: 240px 150px;
}

@keyframes illusBreatheSlow {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.1); }
}

@keyframes illusBreatheFast {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.22); }
}

/* Tiragem */

.illus-tiragem-spot {
  animation: illusRetract 2.2s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.illus-delay-1 { animation-delay: 0.15s; }
.illus-delay-2 { animation-delay: 0.3s; }

@keyframes illusRetract {
  0%, 100% { transform: scale(1) translateY(0); opacity: 0.55; }
  50% { transform: scale(0.6) translateY(4px); opacity: 1; }
}

/* Batimento de asa nasal */

.illus-nostril {
  animation: illusFlare 1.6s ease-in-out infinite;
  transform-box: fill-box;
}

.illus-nostril-left {
  transform-origin: right center;
}

.illus-nostril-right {
  transform-origin: left center;
}

@keyframes illusFlare {
  0%, 100% { transform: scaleX(1); }
  50% { transform: scaleX(1.45); }
}

/* Gemencia e cabeceio */

.illus-head-bob {
  animation: illusHeadBob 1.4s ease-in-out infinite;
}

@keyframes illusHeadBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(10px) rotate(4deg); }
}

.illus-sound-wave {
  animation: illusSoundWave 1.8s ease-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.illus-delay-0 { animation-delay: 0s; }

@keyframes illusSoundWave {
  0% { transform: scale(0.4); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Cianose */

.illus-alert-ring {
  animation: illusAlertPulse 1.6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes illusAlertPulse {
  0%, 100% { opacity: 0.25; transform: scale(0.95); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

/* Asma: crise vs controlada */

.illus-asthma-muscle, .illus-asthma-airway {
  animation: illusAsthmaSqueeze 2.4s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes illusAsthmaSqueeze {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.82); }
}

/* Chapter nav */

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.chapter-nav-link {
  text-decoration: none;
  font-weight: 600;
  color: var(--primary-dark);
  font-size: 14px;
  max-width: 45%;
}

/* Symptom checker */

.checker-result {
  border-radius: 12px;
  padding: 20px 22px;
  margin: 24px 0;
  border: 2px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}

.checker-result h3 {
  margin-top: 0;
}

.checker-result-action {
  font-weight: 700;
  margin-bottom: 0;
}

.checker-result.level-green {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
}

.checker-result.level-yellow {
  background: var(--amber-bg);
  border-color: var(--amber);
  color: #96691d;
}

.checker-result.level-red {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}

.checker-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.checker-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.checker-group legend {
  font-weight: 700;
  padding: 0 6px;
}

.checker-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
  font-size: 14px;
}

.checker-item input {
  margin-top: 3px;
}

#checkerReset {
  margin-top: 20px;
}

/* AI search */

.search-form {
  display: flex;
  gap: 10px;
  margin: 24px 0;
  flex-wrap: wrap;
}

.search-form input {
  flex: 1;
  min-width: 220px;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: inherit;
}

.search-form input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.search-status {
  color: var(--muted);
  font-size: 14px;
  margin: 12px 0;
}

.search-answer {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  padding: 20px 22px;
  margin: 12px 0 24px;
  white-space: pre-wrap;
  line-height: 1.6;
}

/* Responsive */

@media (max-width: 900px) {
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    padding: 72px 16px 60px;
  }

  .hero h1 {
    font-size: 28px;
  }

  .hero-subtitle {
    font-size: 16px;
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-actions .btn {
    text-align: center;
  }

  .presentation {
    margin-top: 32px;
  }

  .chapters-grid {
    margin-top: 36px;
  }

  .category-card {
    flex-direction: column;
    padding: 14px;
  }

  .category-card-body {
    padding-right: 0;
  }

  .category-card .sidebar-badge {
    position: static;
    display: inline-block;
    margin-top: 8px;
  }
}
