/* Option F presentation for curriculum collections, guides and reviews.
   All rules stay inside the original academic content wrapper. Subject,
   section, term and review-state colours remain meaningful and unchanged. */
.portal-f-academic .portal-f-page {
  color: var(--f-ink, #1b2735);
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  line-height: 1.65;
  min-width: 0;
}
.portal-f-academic .portal-f-page :is(input, select, textarea) {
  color: var(--f-ink, #1b2735);
  background: #fff;
  border-color: #aeb8b9;
  accent-color: var(--f-navy, #0b2a4d);
}
.portal-f-academic .portal-f-page :is(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--f-focus, #b8852a);
  outline-offset: 3px;
}

/* Collections, assessment maps and review dashboards share the plain desk. */
.portal-f-collection .portal-f-page {
  max-width: 1420px;
  margin-inline: auto;
  background: var(--f-paper, #f6f4ee);
}
.portal-f-collection .portal-f-page > header,
.portal-f-collection .portal-f-page > main > header {
  max-width: none;
  color: var(--f-ink, #1b2735);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--f-ink, #1b2735);
  padding: 26px 0 22px;
  margin: 0 32px;
}
.portal-f-collection .portal-f-page > main > header {
  margin-inline: 0;
  padding-top: 8px;
}
.portal-f-collection .portal-f-page > header :is(h1, h2),
.portal-f-collection .portal-f-page > main > header :is(h1, h2) {
  color: var(--f-navy, #0b2a4d);
  font-family: var(--f-serif, Georgia, serif);
  font-weight: 400;
  font-size: clamp(1.8rem, 3.2vw, 2.35rem);
  line-height: 1.2;
  margin: 8px 0 12px;
}
.portal-f-collection .portal-f-page > header p,
.portal-f-collection .portal-f-page > main > header p {
  color: var(--f-muted, #5c6774);
  font-size: .88rem;
  line-height: 1.6;
}
.portal-f-collection .portal-f-page > header a,
.portal-f-collection .portal-f-page > main > header a {
  color: var(--f-link, #17496f);
  border-bottom-color: #c4a76c;
}
.portal-f-collection .portal-f-page > header nav,
.portal-f-collection .portal-f-page > main > header nav {
  margin-top: 16px;
  gap: 12px 20px;
  font-size: .83rem;
}
.portal-f-collection .portal-f-page > main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 24px 32px 42px;
  background: transparent;
  min-width: 0;
}
.portal-f-collection .portal-f-page :is(.panel, .map-section, .cr-department) {
  background: #fff;
  border-color: var(--f-line, #dedad0);
  border-radius: 8px;
  box-shadow: none;
}
.portal-f-collection .portal-f-page :is(.notice, .cr-how, .map-notes) {
  color: #4c402a;
  background: var(--f-sand, #f2eadb);
  border-color: var(--f-sand-line, #e0d3b4);
  border-left-color: #b3914a;
  border-radius: 5px;
}
.portal-f-collection .portal-f-page :is(.notice, .cr-how, .map-notes) :is(h2, h3) {
  color: #4c402a;
}
.portal-f-collection .portal-f-page :is(.stat, .cr-summary article) {
  border-radius: 7px;
  box-shadow: none;
}
.portal-f-collection .portal-f-page :is(.map-section h3, .panel h2, .cr-how h2) {
  font-family: var(--f-serif, Georgia, serif);
  font-weight: 400;
  line-height: 1.35;
}
.portal-f-collection .portal-f-page :is(.table-wrap, .matrix-wrap, .map-table-wrap) {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border-color: var(--f-line, #dedad0);
}
.portal-f-collection .portal-f-page :is(th, td) {
  border-bottom-color: var(--f-line, #dedad0);
}
/* Source URLs and grade-boundary references must fit their grid cells. */
.portal-f-collection .portal-f-page .map-boundaries,
.portal-f-collection .portal-f-page .map-boundaries > :is(dt, dd) {
  min-width: 0;
  max-width: 100%;
}
.portal-f-collection .portal-f-page :is(.map-source, .map-boundaries dt, .map-boundaries dd) {
  overflow-wrap: anywhere;
}
.portal-f-collection .portal-f-page :is(.small, .intro, .cr-note, .cr-evidence) {
  color: #53616c;
}
.portal-f-collection .portal-f-page > footer {
  max-width: none;
  margin: 0 32px;
  padding: 18px 0 28px;
  color: var(--f-muted, #5c6774);
  border-color: var(--f-line, #dedad0);
}

/* A guide's contents navigation starts below the shared portal chrome.
   Fixed sidebars from the original guide no longer cover the launch band. */
.portal-f-guide .portal-f-page {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  max-width: 1440px;
  margin-inline: auto;
  padding: 26px 28px 44px;
  background: var(--f-paper, #f6f4ee);
}
.portal-f-guide.cg-nav-collapsed .portal-f-page {
  grid-template-columns: 56px minmax(0, 1fr);
}
.portal-f-guide .portal-f-page > #sidebar {
  grid-column: 1;
  grid-row: 1;
  position: sticky;
  top: 16px;
  bottom: auto;
  left: auto;
  width: auto;
  height: auto;
  min-height: 66px;
  max-height: calc(100dvh - 32px);
  transform: none;
  overflow-y: auto;
  background: var(--f-navy, #0b2a4d);
  border: 1px solid #203e5c;
  border-radius: 8px;
  box-shadow: none;
  padding: 0 0 20px;
  z-index: 20;
}
.portal-f-guide .portal-f-page > #sidebar .sidebar-header {
  padding: 62px 20px 19px;
  border-bottom-color: #ffffff26;
}
.portal-f-guide .portal-f-page > #sidebar .sidebar-title {
  font-family: var(--f-serif, Georgia, serif);
  font-size: 1.35rem;
  font-weight: 400;
  color: #fff;
}
.portal-f-guide .portal-f-page > #sidebar .sidebar-eyebrow {
  color: #c0cfe0;
  font-size: .64rem;
}
.portal-f-guide .portal-f-page > #sidebar .sidebar-subtitle {
  color: #c0cfe0;
  font-size: .76rem;
  line-height: 1.5;
}
.portal-f-guide .portal-f-page > #sidebar .nav-link {
  padding: 12px 20px;
  font-size: .86rem;
}
.portal-f-guide .portal-f-page > #sidebar .nav-sublink {
  padding: 7px 20px 7px 29px;
  font-size: .77rem;
  line-height: 1.5;
}
.portal-f-guide .portal-f-page > main.content {
  grid-column: 2;
  grid-row: 1;
  margin: 0 !important;
  padding: 0;
  max-width: none;
  width: auto;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--f-line, #dedad0);
  border-radius: 8px;
}
.portal-f-guide .portal-f-page .hero {
  padding: 26px 30px 24px;
  background: #fff;
  color: var(--f-ink, #1b2735);
  border: 0;
  border-bottom: 2px solid var(--f-ink, #1b2735);
  border-radius: 8px 8px 0 0;
}
.portal-f-guide .portal-f-page .hero :is(h1, h2) {
  color: var(--f-navy, #0b2a4d);
  font-family: var(--f-serif, Georgia, serif);
  font-weight: 400;
  font-size: clamp(1.8rem, 3vw, 2.25rem);
  line-height: 1.25;
}
.portal-f-guide .portal-f-page .hero p {
  color: var(--f-muted, #5c6774);
  font-size: .88rem;
  line-height: 1.6;
}
.portal-f-guide .portal-f-page .hero a {
  color: var(--f-link, #17496f);
}
.portal-f-guide .portal-f-page .hero .draft-badge,
.portal-f-guide .portal-f-page .hero .draft-notice {
  color: #76561e;
  background: #fff3dc;
  border-color: #d6bd88;
}
.portal-f-guide .portal-f-page .grade-banner,
.portal-f-guide .portal-f-page .grade-header {
  color: var(--f-ink, #1b2735);
  background: var(--f-sand, #f2eadb);
  border-block-color: var(--f-sand-line, #e0d3b4);
}
.portal-f-guide .portal-f-page .grade-banner :is(h2, .grade-eyebrow, .grade-title-cn),
.portal-f-guide .portal-f-page .grade-header :is(h2, .grade-eyebrow, .grade-title-cn) {
  color: var(--f-navy, #0b2a4d);
}
.portal-f-guide .portal-f-page .grade-banner::after {
  color: #6b573115;
}
.portal-f-guide .portal-f-page .grade-banner .chip {
  color: #405061;
  background: #fff9;
  border-color: #c8b890;
}
.portal-f-guide .portal-f-page .subsection {
  max-width: none;
  padding: 28px 30px;
  background: #fff;
  border-top-color: var(--f-line, #dedad0);
}
.portal-f-guide .portal-f-page .subsection :is(p, li) {
  color: #273743;
  font-size: .94rem;
  line-height: 1.8;
}
.portal-f-guide .portal-f-page :is(.unit-card, .cg-table-scroll) {
  border-radius: 5px;
  box-shadow: none;
}
.portal-f-guide .portal-f-page .data-table :is(th, td) {
  border-bottom-color: var(--f-line, #dedad0);
}
.portal-f-guide .portal-f-page .site-footer {
  max-width: none;
  color: var(--f-muted, #5c6774);
  background: #fff;
  border-color: var(--f-line, #dedad0);
  padding: 24px 30px;
}
.portal-f-guide .portal-f-page > footer {
  grid-column: 1 / -1;
}
.portal-f-guide .portal-f-page > .menu-toggle {
  display: none !important;
}
.portal-f-guide .portal-f-page > #sidebar .cg-nav-toggle {
  top: 14px;
  right: 14px;
  color: #f3f0e5;
  background: #163d61;
  border-color: #627995;
}
.portal-f-guide.cg-nav-collapsed .portal-f-page > #sidebar .cg-nav-toggle {
  right: 9px;
}
/* The existing cg-nav-toggle controller remains authoritative. Its overlay
   is unnecessary because the contents list now expands in document flow. */
.portal-f-guide .portal-f-page > .sidebar-overlay {
  display: none !important;
}

/* Review state remains labelled; green answered cards keep their existing state. */
.portal-f-academic .portal-f-page .cr-inline-toolbar {
  color: #34424e;
  background: #f2eadb;
  border-color: #dbcdaf;
  box-shadow: 0 3px 8px #30250c0a;
}
.portal-f-academic .portal-f-page .cr-inline-request:not(.cr-answered):not(.cr-legacy-request):not(.cr-required-request):not(.cr-optional-request),
.portal-f-academic .portal-f-page .cr-edit-rail {
  color: #34424e;
  background: #fbf6e9;
  border-color: #ddccaa;
  border-left-color: #a77f37;
}
.portal-f-academic .portal-f-page :is(.cr-source-excerpt, .cr-audit-note) {
  color: #34424e;
  background: #f4f5f1;
  border-color: #d1dad3;
  border-left-color: #54756c;
}
.portal-f-academic .portal-f-page .cr-source-text {
  color: #2b3d46;
}
.portal-f-academic .portal-f-page .cr-question-status {
  color: #356444;
}

@media (max-width: 1100px) {
  .portal-f-guide .portal-f-page {
    display: block;
    padding: 20px 24px 36px;
  }
  /* Without JS, the contents list stays accessible in the document. */
  .portal-f-guide .portal-f-page > #sidebar {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    max-height: 360px;
    margin: 0 0 18px;
    transform: none !important;
  }
  .portal-f-guide.cg-nav-collapsed .portal-f-page > #sidebar {
    width: 100%;
    max-height: 66px;
    overflow: hidden;
  }
  .portal-f-guide .portal-f-page > #sidebar .cg-nav-toggle,
  .portal-f-guide.cg-nav-collapsed .portal-f-page > #sidebar .cg-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    top: 12px;
    left: 12px;
    right: 12px;
    width: calc(100% - 24px);
    height: 40px;
    padding: 8px 14px;
    font-size: 1.15rem;
  }
  .portal-f-guide .portal-f-page > #sidebar .cg-nav-toggle::before {
    content: "Contents";
    font: 600 .86rem/1.4 system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  }
  html[lang|="zh"] .portal-f-guide .portal-f-page > #sidebar .cg-nav-toggle::before {
    content: "目录";
  }
  .portal-f-guide .portal-f-page > main.content {
    margin: 0 !important;
  }
}
@media (max-width: 700px) {
  .portal-f-collection .portal-f-page > header,
  .portal-f-collection .portal-f-page > main > header {
    margin-inline: 18px;
    padding-block: 20px;
  }
  .portal-f-collection .portal-f-page > main > header {
    margin-inline: 0;
  }
  .portal-f-collection .portal-f-page > main {
    padding: 20px 18px 32px;
  }
  .portal-f-collection .portal-f-page > footer {
    margin-inline: 18px;
  }
  .portal-f-collection .portal-f-page :is(.cr-filters, .matrix-tools, .tools) {
    gap: 12px;
  }
  .portal-f-collection .portal-f-page :is(.cr-filters, .matrix-tools, .tools) > * {
    min-width: 0;
    max-width: 100%;
  }
  .portal-f-collection .portal-f-page :is(.cr-filters input, .tools input, .tools select) {
    max-width: 100%;
  }
  .portal-f-guide .portal-f-page {
    padding: 18px 14px 30px;
  }
  .portal-f-guide .portal-f-page :is(.hero, .subsection, .site-footer) {
    padding-inline: 20px;
  }
  .portal-f-guide .portal-f-page :is(.grade-banner, .grade-header) {
    padding-inline: 20px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .portal-f-guide .portal-f-page > #sidebar {
    transition: none;
  }
}
@media print {
  .portal-f-academic .portal-f-page,
  .portal-f-guide .portal-f-page,
  .portal-f-collection .portal-f-page {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
    background: #fff;
  }
  .portal-f-guide .portal-f-page > #sidebar,
  .portal-f-guide .portal-f-page > .menu-toggle,
  .portal-f-guide .portal-f-page > .sidebar-overlay {
    display: none !important;
  }
  .portal-f-guide .portal-f-page > main.content {
    border: 0;
    margin: 0;
  }
  .portal-f-academic .portal-f-page :is(.cr-inline-toolbar, .cr-inline-request, .cr-edit-rail) {
    display: none !important;
  }
  .portal-f-collection .portal-f-page :is(.table-wrap, .matrix-wrap, .map-table-wrap),
  .portal-f-guide .portal-f-page .cg-table-scroll {
    overflow: visible;
    border: 0;
  }
  .portal-f-guide .portal-f-page :is(.hero, .subsection, .site-footer),
  .portal-f-collection .portal-f-page > main {
    padding-inline: 0;
  }
}

/* State colours must outrank the academic theme and remain visible in old responses. */
.portal-f-academic .portal-f-page .cr-inline-request.cr-required-request{background:#eaf3ff;border-color:#8cb2dc;border-left-color:#205d9e;color:#183452}
.portal-f-academic .portal-f-page .cr-inline-request.cr-optional-request{background:#edf7ef;border-color:#9cc4a6;border-left-color:#287044;color:#183d28}
.portal-f-academic .portal-f-page .cr-active-rail{background:transparent;border-color:transparent}

/* Collection header links must retain button contrast after theme overrides. */
.portal-f-academic .portal-f-page a.button:not(.secondary){color:#fff;background:#142e52;border-color:#142e52}
.portal-f-academic .portal-f-page a.button.secondary{color:#17496f;background:#fff;border-color:#8ba0b5}
.portal-f-academic .portal-f-page a.button:not(.secondary):hover{color:#fff;background:#214873}
