.site-header .masthead {
  min-height: 52px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand nav account";
  align-items: center;
  column-gap: 22px;
  padding-block: 7px;
}

.site-header .home-title,
.site-header .wordmark,
.site-header .lesson-brand {
  grid-area: brand;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-self: start;
}

.site-header .home-title strong,
.site-header .wordmark__main,
.site-header .lesson-brand strong {
  position: static;
  font-family: inherit;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.site-header .wordmark__main::after,
.site-header .home-title span,
.site-header .wordmark__sub,
.site-header .lesson-brand span,
.site-header .header-meta,
.site-header .account-tools__name {
  display: none;
}

.site-header .header-nav {
  grid-area: nav;
  width: auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: thin;
  border: 0;
}

.site-header .header-nav a {
  flex: 0 0 auto;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.site-header .header-nav a:hover,
.site-header .header-nav a:focus-visible {
  background: rgba(255, 255, 255, 0.8);
  color: var(--blue);
  outline: 1px solid rgba(17, 17, 17, 0.22);
  outline-offset: -1px;
}

.site-header .header-nav a[aria-current="page"] {
  background: var(--ink);
  color: #fff;
}

.site-header .header-nav a[aria-current="page"]:hover,
.site-header .header-nav a[aria-current="page"]:focus-visible {
  color: var(--lime);
}

.site-header .account-tools {
  grid-area: account;
  width: auto;
  margin-left: 0;
  justify-self: end;
  flex-wrap: nowrap;
  gap: 5px;
}

.site-header .account-tools a,
.site-header .account-tools button,
.site-header .account-tools__status {
  min-height: 30px;
  padding-inline: 9px;
  font-size: 11px;
}

.site-header .account-tools button:disabled { opacity: 0.55; cursor: wait; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Keep account actions out of the primary navigation. */
.site-header .account-menu { position: relative; display: block; }
.site-header .account-menu > summary {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--ink);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
  list-style: none;
}
.site-header .account-menu > summary::-webkit-details-marker { display: none; }
.site-header .account-menu[open] > summary { background: var(--ink); color: #fff; }
.site-header .account-menu__panel {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 6px);
  right: 0;
  width: 176px;
  padding: 5px;
  border: 1px solid var(--ink);
  background: #fff;
  box-shadow: 5px 5px 0 rgba(17, 17, 17, 0.12);
}
.site-header .account-menu__panel > * {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 9px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 760;
  text-align: left;
}
.site-header .account-menu__panel a:hover,
.site-header .account-menu__panel button:hover,
.site-header .account-menu__panel a:focus-visible,
.site-header .account-menu__panel button:focus-visible { background: var(--paper); color: var(--blue); }
.site-header .account-menu__name { color: var(--muted); font-size: 11px; font-weight: 650; }

/* Page headings: one line, then the work itself. */
.page-intro,
.quiz-heading,
.learning-heading,
.tool-heading,
.guide-heading {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-block: 20px 15px;
  border-bottom: 1px solid var(--ink);
}

.page-intro h1,
.quiz-heading h1,
.learning-heading h1,
.tool-heading h1,
.guide-heading h1 {
  margin: 0;
  font-size: clamp(27px, 3vw, 36px);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.page-intro > p,
.quiz-heading > div > p,
.learning-heading > p,
.tool-heading > p,
.guide-heading > p {
  display: none;
}

/* Home: short menu rows instead of explanatory cards. */
.home-page .function-menu {
  grid-template-columns: 142px minmax(0, 1fr);
  gap: 18px;
  padding-block: 20px;
}

.home-page .function-menu h2 {
  padding-top: 10px;
  font-size: 14px;
}

.home-page .function-list a {
  min-height: 48px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 9px 10px;
}

.home-page .function-list strong { font-size: 15px; }
.home-page .function-list > a > span { display: none; }
.home-page .feature-access-label { min-width: 92px; padding: 4px 7px; font-size: 11px; }
.home-page .member-access { gap: 18px; padding-block: 15px; }
.home-page .member-access p { margin-top: 3px; font-size: 12px; line-height: 1.45; }
.home-page .member-access > a { min-height: 32px; padding-inline: 10px; font-size: 11px; }
.home-page .exam-guide { padding-block: 24px 36px; }
.home-page > main > .sr-only:first-child + .function-menu,
.home-page main > .function-menu:first-of-type { border-top: 0; }

/* Written exam: mode first, then questions. */
.quiz-heading .quiz-start-actions { gap: 6px; }
.quiz-heading .quiz-primary,
.quiz-heading .quiz-secondary { min-height: 38px; padding-inline: 14px; border-width: 1px; font-size: 12px; box-shadow: none; }
.quiz-heading .quiz-primary:hover,
.quiz-heading .quiz-primary:focus-visible { transform: none; box-shadow: none; }
.study-modes { padding-block: 20px 30px; }
.study-modes__header { display: block; }
.study-modes__header h2 { margin: 0; font-size: 22px; }
.study-mode-grid {
  display: block;
  margin-top: 10px;
  border-inline: 0;
}
.study-mode-card {
  min-height: 0;
  display: grid;
  grid-template-columns: 54px minmax(190px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid #c5ccd3;
  background: transparent;
}
.study-mode-card + .study-mode-card { border-left: 0; }
.study-mode-card > span { font-size: 11px; }
.study-mode-card h3 { margin: 0; font-size: 15px; }
.study-mode-card div { display: flex; gap: 5px; margin: 0; padding: 0; }
.study-mode-card button { min-height: 32px; flex: 0 0 auto; padding-inline: 11px; font-size: 11px; }
.last-result { margin-top: 14px; padding: 12px 15px; }
.past-exams {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding-block: 16px;
}
.past-exams > header { display: block; padding: 0; }
.past-exams h2 { margin: 0; font-size: 16px; }
.past-exam-links { display: flex; margin: 0; border: 0; }
.past-exam-links a { min-height: 32px; min-width: 58px; display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--ink); }
.past-exam-links a + a { border-left: 0; }
.past-exam-links strong { margin: 0; font-size: 12px; }
.keyboard-help { display: none; }
details.quiz-notice {
  display: block;
  padding-block: 13px 28px;
  border-top: 1px solid var(--ink);
}
details.quiz-notice > summary {
  width: max-content;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
details.quiz-notice > div { display: grid; max-width: 900px; gap: 6px; margin-top: 10px; font-size: 12px; line-height: 1.55; }

/* Concept setup and lesson pages. */
.concept-setup { padding-block: 16px 30px; }
.concept-setup > header { display: none; }
.concept-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px 16px;
  margin-top: 0;
  border: 0;
  background: transparent;
}
.concept-controls fieldset,
.concept-controls label { padding: 0; border: 0 !important; }
.concept-controls legend,
.concept-controls label span { margin-bottom: 5px; color: var(--muted); font-size: 11px; letter-spacing: 0; }
.concept-controls button { min-height: 34px; padding-inline: 10px; border-color: #9da7b0; font-size: 12px; }
.concept-controls select { min-height: 34px; font-size: 12px; }
.concept-start-row {
  min-height: 42px;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.concept-start-row p { margin-right: auto; font-size: 11px; }
.concept-start-row .quiz-primary { box-shadow: none !important; transform: none !important; }
.concept-next-row span { display: none; }
.lesson-main { padding-top: 20px; }
.lesson-heading { padding: 0 0 15px; border-bottom-width: 1px; }
.lesson-heading > p:first-child { display: none; }
.lesson-heading h1 { margin: 0; font-size: clamp(27px, 3vw, 34px); }
.lesson-heading__facts { gap: 0; margin-top: 9px; }
.lesson-heading__facts span {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.lesson-heading__facts span + span::before { content: "·"; margin-inline: 7px; color: #9ba4ad; }
.lesson-section { padding-top: 34px; }
.lesson-section > header { grid-template-columns: 35px minmax(0, 1fr); gap: 8px; margin-bottom: 15px; }
.lesson-section > header h2 { font-size: clamp(21px, 2.5vw, 28px); }
.lesson-section > header p { display: none; }

/* Excel function practice: controls and spreadsheet take priority. */
.function-layout,
.practical-main { padding-block: 20px 58px; }
.trainer { margin-top: 14px; }
.trainer > header { min-height: 50px; padding: 9px 14px; }
.trainer > header h2 { font-size: 17px; }
.trainer:has(#trainer-setup:not([hidden])) > header { display: none; }
.trainer-setup { gap: 9px; padding: 0; border: 0; background: transparent; }
.trainer-exam-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.trainer-exam-preset { min-height: 54px; padding: 8px 10px; }
.trainer-exam-preset strong { font-size: 13px; }
.trainer-exam-preset p { margin-top: 2px; font-size: 10px; }
.trainer-exam-preset button { min-height: 32px; padding-inline: 11px; }
.trainer-setup label span { margin-bottom: 4px; font-size: 11px; }
.trainer-setup select,
.trainer-setup > button { min-height: 36px; font-size: 12px; }
.cell-reference-help {
  margin: 7px 1px 0;
  padding: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}
.cell-reference-help summary { width: max-content; padding: 5px 0; cursor: pointer; font-weight: 800; }
.cell-reference-help p { padding: 0 0 6px; }
.function-history { margin-top: 30px; }
.function-history > header { padding-bottom: 9px; }

/* Function guide: remove the second introduction layer. */
.guide-main { padding-block: 20px 58px; }
.formula-basics { padding-top: 20px; }
.formula-basics > header,
.excel-usage > header { display: block; margin-bottom: 12px; }
.formula-basics > header h2,
.excel-usage > header h2 { margin: 0; font-size: 21px; }
.formula-basics > header > div > span,
.formula-basics > header > p,
.excel-usage > header > div > span,
.excel-usage > header > p { display: none; }
.excel-usage { padding-top: 24px; }
.guide-picker { padding-block: 13px; }
.guide-workspace { gap: 22px; margin-top: 16px; }

/* Practical exam and map. */
.exam-start { margin-top: 4px; padding: 0 0 20px; }
.exam-start h2 { margin: 0; font-size: 19px; }
.exam-start > div:first-child > p { display: none; }
.exam-start__rules { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 10px !important; padding: 0 !important; border: 0 !important; }
.exam-start__rules strong { min-width: 0; }
.exam-catalog {
  display: block;
  margin-top: 0;
  border: 0;
  border-top: 1px solid var(--ink);
}
.exam-catalog article {
  min-height: 50px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid #c5ccd3;
  background: transparent;
}
.exam-catalog strong { font-size: 14px; }
.exam-catalog button { min-height: 32px; padding-inline: 14px; font-size: 11px; }
.practical-history { margin-top: 32px; }
.intro { padding-block: 20px 15px; }
.intro h1 { font-size: clamp(27px, 3vw, 36px); }
.intro > div > p,
.intro > p { display: none; }
.map-source-note { margin: 0 auto; padding-block: 12px 28px; color: var(--muted); font-size: 11px; line-height: 1.5; }

@media (max-width: 1120px) {
  .site-header .masthead {
    grid-template-columns: minmax(180px, 1fr) auto;
    grid-template-areas:
      "brand account"
      "nav nav";
    row-gap: 4px;
    padding-bottom: 6px;
  }
  .site-header .header-nav { width: 100%; }
}

@media (max-width: 760px) {
  .site-header .masthead { column-gap: 10px; }
  .site-header .home-title strong,
  .site-header .wordmark__main,
  .site-header .lesson-brand strong { font-size: 17px; }
  .site-header .account-tools a,
  .site-header .account-tools button,
  .site-header .account-tools__status { padding-inline: 7px; font-size: 10px; }
  .site-header .header-nav a { min-height: 30px; padding-inline: 8px; font-size: 11px; }
  .page-intro,
  .quiz-heading,
  .learning-heading,
  .tool-heading,
  .guide-heading { align-items: flex-start; flex-direction: column; padding-block: 16px 12px; }
  .quiz-heading .quiz-start-actions { width: 100%; }
  .quiz-heading .quiz-start-actions button { flex: 1; }
  .home-page .function-menu { grid-template-columns: 1fr; gap: 8px; padding-block: 16px; }
  .home-page .function-menu h2 { padding-top: 0; }
  .home-page .member-access { align-items: flex-start; flex-direction: column; gap: 10px; }
  .study-mode-card { grid-template-columns: 46px minmax(0, 1fr) auto; }
  .trainer-exam-presets { grid-template-columns: 1fr; }
  .guide-workspace { gap: 14px; }
}

@media (max-width: 520px) {
  .study-mode-card { grid-template-columns: 40px minmax(0, 1fr); gap: 7px 10px; }
  .study-mode-card div { grid-column: 2; }
  .past-exams { grid-template-columns: 1fr auto; }
  .concept-controls { display: grid; grid-template-columns: 1fr; }
  .concept-start-row { align-items: stretch; flex-direction: column; }
  .concept-start-row p { margin: 0; }
  .guide-workspace { grid-template-columns: 1fr; }
}
