:root {
  --resource-ink: #1f2933;
  --resource-muted: #5f6f6b;
  --resource-brand: #1fa37a;
  --resource-brand-dark: #157a5c;
  --resource-soft: #f4faf7;
  --resource-border: #e2ece7;
  --resource-page-width: 1120px;
  --resource-reading-width: 900px;
}

body.public-resource-page {
  background: #fff !important;
  color: var(--resource-ink) !important;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
  font-size: 1rem !important;
  line-height: 1.6 !important;
  overflow-x: hidden;
}

.public-resource-page *,
.public-resource-page *::before,
.public-resource-page *::after {
  box-sizing: border-box;
}

.resource-hub,
.module-index,
.resource-page {
  margin: 0 auto;
  min-width: 0;
  padding: clamp(1.25rem, 3vw, 2.25rem) clamp(1rem, 4vw, 2rem) clamp(2.5rem, 5vw, 4rem);
  width: 100%;
}

.resource-hub { max-width: var(--resource-page-width); }
.module-index,
.resource-page { max-width: var(--resource-reading-width); }

.resource-hub__header,
.module-index__header {
  max-width: 48rem;
}

.resource-hub h1,
.module-index h1 {
  color: var(--resource-ink);
  font-size: 2.25rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 .65rem;
  overflow-wrap: anywhere;
}

.resource-hub .intro,
.module-intro {
  color: var(--resource-muted);
  font-size: 1.05rem;
  line-height: 1.65;
  margin: 0 0 1rem;
  max-width: 46rem;
}

.resource-hub a,
.module-index a,
.resource-page > :not(.resource-content) a {
  text-underline-offset: .18em;
}

.board-selector {
  background: var(--resource-soft);
  border: 1px solid var(--resource-border);
  border-radius: 999px;
  display: inline-flex;
  gap: .25rem;
  margin-bottom: 1.25rem;
  max-width: 100%;
  padding: .25rem;
}

.board-selector a {
  align-items: center;
  border-radius: 999px;
  color: var(--resource-ink);
  display: inline-flex;
  font-size: .9rem;
  font-weight: 700;
  gap: .4rem;
  justify-content: center;
  min-height: 44px;
  padding: .45rem .9rem;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.board-selector a:hover { background: var(--resource-border); }
.board-selector a:focus-visible {
  outline: 3px solid rgba(31, 163, 122, .28);
  outline-offset: 2px;
}
.board-selector a.active {
  background: var(--resource-brand);
  color: #fff;
}
.board-selector .board-badge {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  opacity: .9;
  text-transform: uppercase;
}

.trust-strip {
  color: var(--resource-ink);
  display: flex;
  flex-wrap: wrap;
  font-size: .875rem;
  gap: .5rem 1rem;
  margin: 0 0 clamp(1.5rem, 3vw, 2rem);
}
.trust-strip span {
  align-items: flex-start;
  display: inline-flex;
  gap: .4rem;
}
.trust-strip span::before {
  color: var(--resource-brand);
  content: "\2713";
  font-weight: 800;
}

.paper-hub-banner,
.tools-banner {
  background: var(--resource-soft);
  border: 1px solid var(--resource-border);
  border-radius: 14px;
  padding: clamp(1rem, 2.5vw, 1.4rem);
}
.paper-hub-banner { margin: 1.5rem 0 2rem; }
.tools-banner { margin-top: 2rem; }
.paper-hub-banner h2,
.tools-banner h2 {
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 0 0 .55rem;
}
.paper-hub-banner p,
.tools-banner p {
  color: var(--resource-muted);
  font-size: .95rem;
  margin: 0 0 .75rem;
}
.paper-hub-banner ul {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.paper-hub-banner a {
  background: #fff;
  border: 1px solid var(--resource-border);
  border-radius: 8px;
  color: var(--resource-brand-dark);
  display: inline-flex;
  font-size: .9rem;
  font-weight: 700;
  min-height: 42px;
  padding: .5rem .8rem;
  text-decoration: none;
}
.paper-hub-banner a:hover {
  background: var(--resource-brand);
  border-color: var(--resource-brand);
  color: #fff;
}

.module-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.module-section {
  border: 1px solid var(--resource-border);
  border-radius: 14px;
  min-width: 0;
  padding: 1rem;
}
.module-section h2 {
  border-bottom: 2px solid var(--resource-brand);
  display: inline-block;
  font-size: 1.08rem;
  line-height: 1.35;
  margin: 0 0 .75rem;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding-bottom: .3rem;
}
.module-section h2 a { color: inherit; text-decoration: none; }
.module-section h2 a:hover { color: var(--resource-brand-dark); }

.resource-list {
  display: grid;
  gap: .5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.resource-list li {
  background: var(--resource-soft);
  border: 1px solid var(--resource-border);
  border-radius: 9px;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.resource-list li:hover {
  border-color: #b8d8c8;
  box-shadow: 0 5px 14px rgba(31, 163, 122, .1);
  transform: translateY(-1px);
}
.resource-list a {
  align-items: center;
  color: var(--resource-ink);
  display: flex;
  font-size: .95rem;
  font-weight: 650;
  gap: .65rem;
  justify-content: space-between;
  line-height: 1.4;
  min-height: 48px;
  min-width: 0;
  padding: .7rem .8rem;
  text-decoration: none;
}
.resource-list a:hover { color: var(--resource-brand-dark); }
.resource-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.resource-type,
.resource-type-badge {
  background: var(--resource-brand);
  border-radius: 999px;
  color: #fff;
  flex: 0 0 auto;
  font-size: .7rem;
  font-weight: 750;
  line-height: 1.2;
  max-width: 12rem;
  overflow: hidden;
  padding: .25rem .55rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tools-banner a,
.resource-hub__footer a,
.module-index .breadcrumb a,
.module-index .back-link {
  color: var(--resource-brand-dark);
  font-weight: 700;
}
.resource-hub__footer {
  color: var(--resource-muted);
  font-size: .92rem;
  margin: 1.75rem 0 0;
}

.module-index .breadcrumb,
.resource-breadcrumb {
  color: var(--resource-muted);
  font-size: .875rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
  overflow-wrap: anywhere;
}
.module-index .breadcrumb a,
.resource-breadcrumb a { color: var(--resource-brand-dark); }
.topic-heading {
  font-size: 1rem;
  margin: 0 0 .55rem;
}
.topic-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}
.topic-list li {
  background: var(--resource-soft);
  border: 1px solid var(--resource-border);
  border-radius: 999px;
  color: #374151;
  font-size: .85rem;
  line-height: 1.35;
  padding: .4rem .75rem;
}
.resource-meta {
  align-items: center;
  color: var(--resource-muted);
  display: flex;
  flex: 0 1 auto;
  font-size: .8rem;
  font-weight: 400;
  gap: .5rem;
  min-width: 0;
}
.resource-topic {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty-state {
  background: var(--resource-soft);
  border: 1px solid var(--resource-border);
  border-radius: 12px;
  color: var(--resource-muted);
  padding: 2rem 1rem;
  text-align: center;
}
.back-link { display: inline-block; margin-top: 1.5rem; text-decoration: none; }
.module-index__footer {
  color: var(--resource-muted);
  font-size: .9rem;
  margin: .75rem 0 0;
}

.resource-home-logo {
  display: inline-block;
  margin-bottom: .75rem;
}
.resource-home-logo img {
  height: 36px;
  max-width: 100%;
  opacity: .85;
  width: auto;
}
.resource-content {
  line-height: 1.65;
  min-width: 0;
  overflow-wrap: break-word;
}

/* Stored resources are legacy full HTML documents. These high-specificity,
   important guardrails stop their unscoped viewport CSS escaping the article. */
.public-resource-detail .resource-content h1 {
  font-size: 2.5rem !important;
  letter-spacing: -.025em !important;
  line-height: 1.08 !important;
  max-width: 52rem !important;
  overflow-wrap: anywhere;
}
.public-resource-detail .resource-content h2 {
  font-size: 1.65rem !important;
  line-height: 1.2 !important;
}
.public-resource-detail .resource-content h3 {
  font-size: 1.2rem !important;
  line-height: 1.3 !important;
}
.public-resource-detail .resource-content .hero {
  min-height: 0 !important;
  padding-block: clamp(1.5rem, 5vw, 3rem) !important;
}
.public-resource-detail .resource-content img,
.public-resource-detail .resource-content svg,
.public-resource-detail .resource-content video,
.public-resource-detail .resource-content canvas,
.public-resource-detail .resource-content iframe {
  height: auto;
  max-width: 100% !important;
}
.public-resource-detail .resource-content iframe {
  aspect-ratio: 16 / 9;
  border: 0;
  width: 100%;
}
.public-resource-detail .resource-content pre,
.public-resource-detail .resource-content .equation,
.public-resource-detail .resource-content .answer-line,
.public-resource-detail .resource-content .table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}
.public-resource-detail .resource-content table { min-width: 34rem; }
.public-resource-detail .resource-content button,
.public-resource-detail .resource-content input,
.public-resource-detail .resource-content select,
.public-resource-detail .resource-content textarea { max-width: 100%; }
.public-resource-detail .resource-content button,
.public-resource-detail .resource-content [role="button"] { min-height: 44px; }

.author-review-box {
  background: var(--resource-soft) !important;
  border: 1px solid var(--resource-border) !important;
  border-radius: 12px !important;
  color: #374151 !important;
  font-family: inherit !important;
  font-size: .9rem !important;
  margin: 1.75rem 0 !important;
  padding: 1rem 1.25rem !important;
}
.author-review-box p { margin: .35rem 0 !important; }
.related-resources {
  border-top: 1px solid var(--resource-border);
  margin-top: 2rem;
  padding-top: 1.5rem;
}
.related-resources h2 {
  font-family: inherit !important;
  font-size: 1.35rem !important;
  line-height: 1.3 !important;
  margin: 0 0 1rem !important;
}
.related-resources h3 {
  font-family: inherit !important;
  font-size: 1rem !important;
  line-height: 1.4 !important;
  margin: 1rem 0 .5rem !important;
}
.related-resources ul {
  display: grid;
  gap: .55rem;
  list-style: none;
  margin: 0 0 1rem !important;
  padding: 0 !important;
}
.related-resources li { margin: 0 !important; }
.related-resources a { color: var(--resource-brand-dark) !important; font-weight: 650; }
.resource-footer {
  border-top: 1px solid var(--resource-border);
  color: var(--resource-muted) !important;
  font-family: inherit !important;
  font-size: .85rem !important;
  margin-top: 2rem;
  padding-top: 1rem;
}
.resource-footer p { margin: 0 0 .75rem !important; }
.resource-footer a { color: var(--resource-brand-dark) !important; }

@media (max-width: 760px) {
  .resource-hub h1,
  .module-index h1 { font-size: 1.75rem; }
  .resource-hub .intro,
  .module-intro { font-size: 1rem; }
  .module-grid { grid-template-columns: 1fr; }
  .module-section { padding: .85rem; }
  .resource-list a { align-items: flex-start; }
  .resource-meta { flex-direction: column; align-items: flex-end; }
  .resource-topic { display: none; }
  .public-resource-detail .resource-content h1 { font-size: 2rem !important; }
  .public-resource-detail .resource-content h2 { font-size: 1.4rem !important; }
  .public-resource-detail .resource-content h3 { font-size: 1.1rem !important; }
  .public-resource-detail .resource-content .grid,
  .public-resource-detail .resource-content .practice-grid,
  .public-resource-detail .resource-content .learning-route,
  .public-resource-detail .resource-content .equation-options {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 420px) {
  .board-selector { display: flex; width: 100%; }
  .board-selector a { flex: 1 1 0; padding-inline: .55rem; }
  .trust-strip { display: grid; }
  .resource-type,
  .resource-type-badge { max-width: 8.5rem; }
  .paper-hub-banner a { flex: 1 1 auto; }
  .resource-page { padding-inline: .85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .resource-list li { transition: none; }
  .resource-list li:hover { transform: none; }
}
