/* Version 10 corrective control layer: one header, mobile menu and theme control system. */
.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;
}

[data-unified-replaced="true"],
.drm-floating-tools,
.theme-menu { display: none !important; }

.unified-scroll-header {
  transition: transform 230ms cubic-bezier(.2,.75,.25,1), opacity 210ms ease,
    background-color 220ms ease, border-color 220ms ease, box-shadow 220ms ease !important;
  will-change: transform, opacity;
}

.unified-scroll-header.is-header-hidden {
  transform: translateY(calc(-100% - 10px)) !important;
  opacity: .12;
  pointer-events: none;
}

.unified-scroll-header.unified-menu-open,
.unified-scroll-header:focus-within {
  transform: translateY(0) !important;
  opacity: 1;
  pointer-events: auto;
}

.unified-header-container { position: relative; }
.unified-menu-drawer { display: contents; }
.unified-control-cluster {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  margin-left: 0;
  white-space: nowrap;
}

.unified-icon-button,
.unified-quiz-theme-button {
  width: 42px !important;
  min-width: 42px !important;
  height: 42px !important;
  min-height: 42px !important;
  padding: 0 !important;
  display: inline-grid !important;
  place-items: center !important;
  flex: 0 0 42px !important;
  border: 1px solid var(--line, var(--soft-border, var(--menu-line, rgba(127,127,127,.35)))) !important;
  border-radius: 50% !important;
  color: var(--text, var(--menu-text, currentColor)) !important;
  background: var(--surface, var(--card, var(--menu-surface, rgba(255,255,255,.08)))) !important;
  box-shadow: none !important;
  cursor: pointer;
  line-height: 1 !important;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease !important;
}

.unified-icon-button svg,
.unified-quiz-theme-button svg {
  width: 20px !important;
  height: 20px !important;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.unified-theme-button svg path { fill: currentColor; stroke: none; }
.unified-icon-button:hover,
.unified-icon-button:focus-visible,
.unified-quiz-theme-button:hover,
.unified-quiz-theme-button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--blue, var(--primary, var(--menu-accent, currentColor))) !important;
  outline: 3px solid color-mix(in srgb, var(--blue, var(--primary, var(--menu-accent, #0aa89e))) 28%, transparent) !important;
  outline-offset: 2px !important;
}

.unified-menu-button { display: none !important; }

/* Keep the quiz-attempt theme control visually identical without changing quiz logic. */
#themeToggleBtn.unified-quiz-theme-button {
  border-radius: 50% !important;
  font-size: 0 !important;
}
#themeToggleBtn.unified-quiz-theme-button svg { font-size: initial; }

/* Self Quiz Sepia palette: semantic colors remain distinct and readable. */
html[data-site-scope="selfquiz"][data-theme="sepia"] {
  color-scheme: light;
  --bg: #f2e6cf;
  --panel: #fff8e9;
  --card: #fffaf0;
  --text: #35271c;
  --muted: #6f5a44;
  --soft-border: #cdb58e;
  --soft-bg: #efe0c3;
  --primary: #77501f;
  --accent: #80541e;
  --success: #24633a;
  --danger: #9b342c;
  --line: rgba(78, 52, 26, .25);
  --menu-bg: #f2e6cf;
  --menu-surface: #fffaf0;
  --menu-surface-2: #ead8b8;
  --menu-text: #35271c;
  --menu-muted: #6f5a44;
  --menu-line: #cdb58e;
  --menu-accent: #6a4a20;
  --menu-accent-2: #563814;
  --ink: #f2e6cf;
  --ink-2: #ead8b8;
  --paper: #fff8e9;
  --paper-2: #ead9ba;
}

html[data-site-scope="selfquiz"][data-theme="sepia"] body,
html[data-site-scope="selfquiz"][data-theme="sepia"] .view,
html[data-site-scope="selfquiz"][data-theme="sepia"] .results-view,
html[data-site-scope="selfquiz"][data-theme="sepia"] .resume-view {
  color: var(--text) !important;
  background-color: var(--bg) !important;
}

html[data-site-scope="selfquiz"][data-theme="sepia"] :is(
  p, label, legend, dt, dd, li, summary, .small, .lead, .breadcrumbs,
  .quiz-card-description, .quiz-meta, .category-label small, .modal-description,
  .q-meta, .exp-box, .ans-label, .stat-label, .chapter-stat, .creator-bio,
  .copyright-footer, .resume-status, .ai-form-note
) { color: var(--muted); }

html[data-site-scope="selfquiz"][data-theme="sepia"] :is(
  h1, h2, h3, h4, h5, h6, strong, .field-label, .q-text, .q-content,
  .quiz-title, .category-label span, .ans-val, .stat-num, .creator-name,
  .menu-hero, .menu-modal-card, .brand, .nav a, .main-nav a
) { color: var(--text); }

html[data-site-scope="selfquiz"][data-theme="sepia"] :is(
  textarea, input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select, option, .option-item, .nav-dot, .panel, .input-card, .question-area,
  .nav-panel, .quiz-header, .score-card, .stat-tile, .chapter-breakdown,
  .review-item, .modal-card, .sample-dialog, .resume-status, .ai-preview-form
) {
  color: var(--text) !important;
  background-color: var(--card) !important;
  border-color: var(--soft-border) !important;
}

html[data-site-scope="selfquiz"][data-theme="sepia"] ::placeholder {
  color: #78634d !important;
  opacity: 1;
}

html[data-site-scope="selfquiz"][data-theme="sepia"] :is(.btn, .button.primary, .start-quiz, .cta, .nav-dot.answered) {
  color: #fffaf0 !important;
  background-color: var(--primary) !important;
}

html[data-site-scope="selfquiz"][data-theme="sepia"] :is(.btn-outline, .button.secondary, .menu-control, .menu-link, .social-btn) {
  color: var(--text) !important;
  background-color: var(--card) !important;
  border-color: var(--soft-border) !important;
}

html[data-site-scope="selfquiz"][data-theme="sepia"] .option-item.selected {
  color: #2e251b !important;
  background: #e2d1ad !important;
  border-color: #77501f !important;
}
html[data-site-scope="selfquiz"][data-theme="sepia"] .option-item.correct,
html[data-site-scope="selfquiz"][data-theme="sepia"] .ans-correct,
html[data-site-scope="selfquiz"][data-theme="sepia"] .stat-correct .stat-num,
html[data-site-scope="selfquiz"][data-theme="sepia"] .resume-status.ok {
  color: #174b2a !important;
  border-color: #2c7444 !important;
}
html[data-site-scope="selfquiz"][data-theme="sepia"] .option-item.correct { background: #d9ead8 !important; }
html[data-site-scope="selfquiz"][data-theme="sepia"] .option-item.wrong,
html[data-site-scope="selfquiz"][data-theme="sepia"] .ans-wrong,
html[data-site-scope="selfquiz"][data-theme="sepia"] .stat-wrong .stat-num,
html[data-site-scope="selfquiz"][data-theme="sepia"] .resume-status.bad {
  color: #81291f !important;
  border-color: #a7473c !important;
}
html[data-site-scope="selfquiz"][data-theme="sepia"] .option-item.wrong { background: #f3d8d0 !important; }
html[data-site-scope="selfquiz"][data-theme="sepia"] :disabled,
html[data-site-scope="selfquiz"][data-theme="sepia"] [aria-disabled="true"] { opacity: .65; }
html[data-site-scope="selfquiz"][data-theme="sepia"] :focus-visible {
  outline-color: #694515;
}

/* Generated topic pages inherit all three Self Quiz themes. */
html[data-site-scope="selfquiz"][data-theme="light"] body:not(.selfquiz-home-page):not(.features-page):not(.ai-page),
html[data-site-scope="selfquiz"][data-theme="light"] body:not(.selfquiz-home-page):not(.features-page):not(.ai-page) :is(.site-header, .hero, .content-card, .related) {
  --bg: #f4f7f8; --card: #fff; --text: #182229; --muted: #5e6b72; --line: #d7e1e4; --accent: #0d766f; --accent2: #075e59;
}
html[data-site-scope="selfquiz"][data-theme="dark"] body:not(.selfquiz-home-page):not(.features-page):not(.ai-page) {
  --bg: #0b0c0e; --card: #151619; --text: #f2f4f6; --muted: #adb0b6; --line: #34363b; --accent: #4fd1c5; --accent2: #8ce6de;
  color: var(--text);
  background: #0b0c0e;
}
html[data-site-scope="selfquiz"][data-theme="dark"] body:not(.selfquiz-home-page):not(.features-page):not(.ai-page) :is(.site-header, .hero, .content-card, .related) {
  color: var(--text);
  background: #151619;
  border-color: var(--line);
}

@media (max-width: 1120px) {
  .unified-scroll-header { overflow: visible !important; }
  .unified-header-container {
    min-width: 0;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    padding-left: max(12px, env(safe-area-inset-left)) !important;
    padding-right: max(12px, env(safe-area-inset-right)) !important;
  }
  .unified-header-container > .brand,
  .unified-header-container > .menu-brand,
  .unified-header-container > .quiz-brand-chip {
    min-width: 0;
    max-width: calc(100% - 102px);
    overflow: hidden;
  }
  .unified-header-container > :is(.brand, .menu-brand, .quiz-brand-chip) span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .unified-control-cluster {
    margin-left: auto !important;
    gap: 8px !important;
  }
  .unified-menu-button { display: inline-grid !important; }
  .unified-menu-drawer {
    position: absolute;
    top: calc(100% + 8px);
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    z-index: 1000;
    display: none;
    max-height: min(72vh, 560px);
    overflow: auto;
    overscroll-behavior: contain;
    padding: 12px;
    border: 1px solid var(--line, var(--soft-border, var(--menu-line, rgba(127,127,127,.3))));
    border-radius: 16px;
    color: var(--text, var(--menu-text, currentColor));
    background: var(--surface, var(--card, var(--menu-surface, #fff))) !important;
    box-shadow: 0 18px 55px rgba(0,0,0,.24);
  }
  .unified-menu-open .unified-menu-drawer {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .unified-menu-drawer :is(.nav-links, .nav-actions, .main-nav, .menu-toolbar-actions, .split-top-links, .nav) {
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 7px !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
  }
  .unified-menu-drawer :is(a, button) {
    width: 100%;
    min-height: 44px;
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    white-space: normal;
  }
  .unified-menu-drawer .theme-menu,
  .unified-menu-drawer #menuThemeBtn { display: none !important; }

  .menu-toolbar.unified-scroll-header {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 9px !important;
    padding: 10px max(12px, env(safe-area-inset-right)) !important;
  }
  .menu-toolbar .menu-search {
    order: 3;
    flex: 1 0 100%;
    width: 100%;
  }
  .menu-toolbar .unified-control-cluster { order: 2; }
  .menu-toolbar .menu-brand { order: 1; }

  .app-topbar.unified-scroll-header {
    position: sticky !important;
    top: 0;
    z-index: 120;
    width: 100%;
    max-width: none;
    min-height: 66px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    border-bottom: 1px solid var(--soft-border);
    backdrop-filter: blur(16px);
  }
  .app-topbar .quiz-brand-chip { display: inline-flex !important; }
  .app-topbar .quiz-brand-chip small { display: none; }

  .site-header.unified-fallback-header { padding-block: 10px; }
}

@media (max-width: 360px) {
  .unified-header-container { gap: 7px !important; }
  .unified-control-cluster { gap: 6px !important; }
  .unified-icon-button {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    flex-basis: 40px !important;
  }
  .unified-header-container > :is(.brand, .menu-brand, .quiz-brand-chip) { max-width: calc(100% - 92px); }
  .unified-header-container > .brand span { font-size: .92rem; }
}

@media (prefers-reduced-motion: reduce) {
  .unified-scroll-header,
  .unified-icon-button,
  .unified-quiz-theme-button { transition: none !important; }
}
