:root {
  --bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #b91c1c;
  --primary-dark: #991b1b;
  --primary-soft: #fef2f2;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.page {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 8px 10px 14px;
}

.hero {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.hero-cover {
  flex-shrink: 0;
  width: 88px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.hero-cover img {
  display: block;
  width: 100%;
  height: auto;
}

.hero-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 8px;
}

.hero-icon--materials {
  width: 48px;
  height: 48px;
  border-radius: 10px;
}

.hero-icon--materials svg {
  width: 26px;
  height: 26px;
}

.hero-text {
  min-width: 0;
  flex: 1;
}

.hero-kicker {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.hero h1 {
  margin: 2px 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  color: #111827;
}

.hero-course {
  margin: 4px 0 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.3;
}

.hero-disclaimer {
  margin: 6px 0 0;
  max-width: none;
  font-size: 0.625rem;
  font-weight: 400;
  line-height: 1.4;
  color: #9ca3af;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .hero-disclaimer {
    white-space: normal;
    max-width: 42rem;
  }
}

.info-panel {
  margin-bottom: 10px;
}

.meta-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.meta-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.meta-chips li {
  font-size: 0.75rem;
  color: var(--text);
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
}

.meta-chips strong {
  color: var(--primary-dark);
}

.panel-title {
  margin: 0 0 6px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
}

.channels-panel {
  margin-bottom: 10px;
}

.channels-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.channel-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.channel-card:hover {
  border-color: #fca5a5;
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.08);
}

.channel-card-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #111827;
}

.channel-card-hint {
  font-size: 0.6875rem;
  color: var(--muted);
  line-height: 1.3;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn-quick {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-quick:hover {
  background: var(--primary-dark);
  color: #fff;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.social-link:hover {
  border-color: #fca5a5;
  color: var(--primary);
}

.social-link svg {
  width: 16px;
  height: 16px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.tab[data-category="all"] {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.tab[data-category="libros"] {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.tab[data-category="audios"] {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.tab[data-category="videos"] {
  background: #faf5ff;
  border-color: #e9d5ff;
  color: #7e22ce;
}

.tab[data-category="diapositivas"] {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
}

.tab[data-category="evaluaciones"] {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #0369a1;
}

.tab[data-category="complementos"] {
  background: #fdf4ff;
  border-color: #f5d0fe;
  color: #a21caf;
}

.tab[data-category="frases"] {
  background: #fefce8;
  border-color: #fef08a;
  color: #a16207;
}

.tab svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.tab:hover {
  filter: brightness(0.97);
}

.tab.is-active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  filter: none;
}

.tab.is-active svg {
  stroke: #fff;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  margin-bottom: 8px;
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

#searchMaterial {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px 7px 30px;
  font: inherit;
  font-size: 0.8125rem;
  color: inherit;
  background: #fff;
}

#searchMaterial:focus {
  outline: none;
  border-color: #fca5a5;
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.1);
}

.btn-tool {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

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

.materiales-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.material {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.material:hover {
  border-color: #d1d5db;
}

.material[open] {
  border-color: #fecaca;
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.06);
}

.material.is-hidden {
  display: none;
}

.material > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  user-select: none;
}

.material > summary::-webkit-details-marker {
  display: none;
}

.summary-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.summary-chevron {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform 0.2s;
}

.material[open] .summary-chevron {
  transform: rotate(90deg);
  color: var(--primary);
}

.summary-title {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  color: #111827;
}

.badge-count {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.material-body {
  padding: 0 10px 10px;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #374151;
}

.material-intro {
  margin: 8px 0 0;
  font-style: italic;
  color: var(--muted);
}

.link-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.link-list--bulleted {
  list-style: disc;
  padding-left: 1.35rem;
}

.link-list--bulleted li::marker {
  color: var(--primary);
}

.link-list li {
  margin-bottom: 6px;
  line-height: 1.45;
}

.link-list a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  word-break: break-word;
}

.link-list a:hover {
  text-decoration: underline;
  color: var(--primary-dark);
}

.link-list li.is-plain {
  color: #374151;
  font-weight: 500;
}

.material-download {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.material-body a.btn-quick {
  color: #fff;
  text-decoration: none;
}

.material-body a.btn-quick:hover {
  color: #fff;
}

.complemento-block:first-child {
  padding-top: 10px;
}

.complemento-block + .complemento-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.complemento-block > h4 {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #111827;
}

.complemento-section + .complemento-section {
  margin-top: 8px;
}

.complemento-section h5 {
  margin: 0 0 4px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #374151;
}

.complemento-note {
  margin: 0 0 4px;
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--muted);
}

.frases-table-wrap {
  margin-top: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.frases-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.frases-table th,
.frases-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.frases-table thead th {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700;
}

.frases-table .group-header td {
  background: #f9fafb;
  font-weight: 700;
  color: #111827;
  text-align: center;
}

.frases-table em {
  font-style: italic;
}

.frases-cards {
  display: none;
  margin-top: 8px;
  gap: 6px;
}

.frase-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.75rem;
}

.frase-card dt {
  font-weight: 700;
  color: var(--muted);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.frase-card dd {
  margin: 2px 0 6px;
}

.frase-card dd:last-child {
  margin-bottom: 0;
}

.frase-group-title {
  margin: 10px 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary-dark);
}

.empty-state {
  display: none;
  text-align: center;
  padding: 20px 12px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.empty-state.is-visible {
  display: block;
}

.empty-state svg {
  width: 32px;
  height: 32px;
  margin-bottom: 6px;
  opacity: 0.5;
}

@media (max-width: 720px) {
  .hero {
    flex-wrap: wrap;
  }

  .channels-grid {
    grid-template-columns: 1fr;
  }

  .meta-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .meta-actions {
    margin-left: 0;
    justify-content: space-between;
  }

  .social-links {
    justify-content: flex-start;
  }

  .frases-table-wrap {
    display: none;
  }

  .frases-cards {
    display: flex;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 700px) {
  .page {
    padding: 6px 8px 10px;
  }

  .material > summary {
    padding: 6px 8px;
  }

  .material-body {
    padding: 0 8px 8px;
  }
}
