/* ETO base: design tokens (light on :root, dark on [data-scheme="dark"]), reset, focus ring, skip link. */
:root {
  color-scheme: light;
  --bg: #F8F6F0; --sidebar: #F1EEE6; --surface: #FFFDF8; --surface-2: #F3F0E8; --surface-3: #E7E3D8;
  --line: #E4DFD3; --line-strong: #CCC5B5;
  --text: #1F1E1B; --text-2: #4F4C45; --muted: #67635A;
  --accent: #F5C518; --accent-hover: #FFD02E; --accent-edge: #9C7600; --on-accent: #1F1E1B; --accent-soft: #FBF0C9; --accent-ink: #755600;
  --right: #1D7A44; --right-soft: #E3F2E8; --wrong: #B42318; --wrong-soft: #FBE8E6; --on-mark: #FFFFFF; --mark: #FFF2A8;
  --reward: #E8650A; --reward-edge: #B4520A; --reward-ink: #9A4307; --reward-soft: #FDEEDD;
  --focus: #2563EB; --scrim: rgba(20, 19, 17, .45);
  --shadow: 0 1px 2px rgba(31, 30, 27, .05), 0 4px 14px rgba(31, 30, 27, .05);
  --r: 12px;
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, "Noto Serif", serif;
}
[data-scheme="dark"] {
  color-scheme: dark;
  --bg: #1B1A18; --sidebar: #201F1C; --surface: #262521; --surface-2: #2E2C28; --surface-3: #3A3832;
  --line: #3A3832; --line-strong: #57534A;
  --text: #ECE8DF; --text-2: #C4BFB3; --muted: #A9A497;
  --accent: #F0C020; --accent-hover: #FFD43B; --accent-edge: #8A6900; --on-accent: #1B1A18; --accent-soft: #3A3217; --accent-ink: #F2CD4F;
  --right: #6CCB93; --right-soft: #183022; --wrong: #F29389; --wrong-soft: #3A201D; --on-mark: #1B1A18; --mark: #5C4A12;
  --reward: #FB923C; --reward-edge: #C2410C; --reward-ink: #FDBA74; --reward-soft: #3A2614;
  --focus: #8DB4FF; --scrim: rgba(0, 0, 0, .6);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.6 var(--font-sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
img, svg, video { max-width: 100%; height: auto; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }

.skip-link { position: absolute; left: 8px; top: -100px; z-index: 1000; padding: 10px 16px; background: var(--accent); color: var(--on-accent); border-radius: 8px; font-weight: 650; text-decoration: none; }
.skip-link:focus { top: 8px; }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Logo: in dark mode the wordmark O turns yellow with an ink tick. */
[data-scheme="dark"] .eto-logo__o { fill: var(--accent); }
[data-scheme="dark"] .eto-logo__tick { stroke: var(--on-accent); }

/* Logo lockup */
.eto-logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; border-radius: 10px; min-height: 44px; }
.eto-logo__icon { flex: none; width: 36px; height: 36px; }
.eto-logo__text { display: inline-flex; align-items: center; gap: 10px; }
.eto-logo__wordmark { width: auto; height: 20px; flex: none; }
.eto-logo__name { font-size: 14px; font-weight: 650; line-height: 1.15; padding-left: 10px; border-left: 1px solid var(--line-strong); color: var(--text-2); white-space: nowrap; }

/* Shell: top bar 56px, sidebar 248px (64px collapsed), content max 1200px */
:root { --tb: 56px; --tb-stuck: var(--tb); --sb: 248px; } /* --tb-stuck: the part of the top bar that stays on screen */
html[data-eto-side="collapsed"] { --sb: 64px; }
html.eto-drawer-open { overflow: hidden; }

.eto-iconbtn { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text-2); }
.eto-iconbtn:hover { background: var(--surface-3); color: var(--text); }
.eto-ic { flex: none; }

.eto-top { position: sticky; top: 0; z-index: 30; height: var(--tb); display: flex; align-items: center; gap: 12px; padding: 0 20px 0 8px; background: color-mix(in srgb, var(--bg) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.eto-top__left { display: flex; align-items: center; gap: 4px; flex: none; }
.eto-top__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.eto-search { position: relative; flex: 1; max-width: 640px; }
.eto-search .eto-ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.eto-search input { width: 100%; height: 44px; padding: 0 14px 0 44px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--text); font: inherit; font-size: 15.5px; }
.eto-search input::placeholder { color: var(--muted); opacity: 1; }
.eto-search input:focus-visible { outline-offset: 0; border-radius: var(--r); }
.eto-signin { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-weight: 650; font-size: 14.5px; text-decoration: none; white-space: nowrap; }
.eto-signin:hover { background: var(--surface-2); }
.eto-dark__sun { display: none; }
[data-scheme="dark"] .eto-dark__sun { display: inline; }
[data-scheme="dark"] .eto-dark__moon { display: none; }

.eto-app { display: grid; grid-template-columns: var(--sb) minmax(0, 1fr); min-height: calc(100vh - var(--tb)); transition: grid-template-columns .2s; }
.eto-main { min-width: 0; padding: 28px 32px 56px; }
.eto-main > * { max-width: 1200px; margin-left: auto; margin-right: auto; }
.eto-main:focus { outline: none; }
.eto-rail { display: none; }
@media (min-width: 1280px) { .eto-rail { display: block; } }

.eto-sidebar { display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--line); position: sticky; top: var(--tb); height: calc(100vh - var(--tb)); overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; }
.eto-side__head { display: none; }
.eto-nav { display: flex; flex-direction: column; flex: 1; padding: 6px 12px 4px; }
.eto-nav__group { display: flex; flex-direction: column; }
.eto-nav__group--bare:last-child { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.eto-nav__label { margin: 0; padding: 16px 12px 6px; font-size: 12px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.eto-nav__list { display: flex; flex-direction: column; gap: 2px; }
.eto-nav__levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 2px 0 4px; }
.eto-nav__item, .eto-side__collapse { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font-size: 15px; font-weight: 500; text-decoration: none; white-space: nowrap; width: 100%; text-align: left; }
.eto-nav__item:hover, .eto-side__collapse:hover { background: var(--surface-3); color: var(--text); }
.eto-nav__item[aria-current="page"] { background: var(--accent-soft); color: var(--text); font-weight: 650; }
.eto-nav__item[aria-current="page"] .eto-ic { color: var(--accent-ink); }
.eto-nav__item--off, .eto-nav__item--off:hover { background: transparent; color: var(--muted); cursor: default; }
.eto-nav__note { margin-left: auto; padding: 1px 7px; border: 1px dashed var(--line-strong); border-radius: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.eto-nav__levels .eto-nav__item { justify-content: center; padding: 0; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 700; font-size: 14px; }
.eto-nav__levels .eto-nav__item[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.eto-side__collapse { margin: 0 12px 12px; width: calc(100% - 24px); border-top: 1px solid transparent; }
.eto-side__collapse .eto-ic { transition: transform .2s; }
.eto-side__collapse[aria-pressed="true"] .eto-ic { transform: rotate(180deg); }

.eto-scrim { position: fixed; inset: 0; z-index: 55; background: var(--scrim); }

/* No JS: the menu, dark-mode and collapse buttons would do nothing, so they are hidden. */
html:not(.js) .eto-menu, html:not(.js) .eto-dark, html:not(.js) .eto-side__collapse { display: none; }

/* Collapsed rail (wide screens only) */
@media (min-width: 768px) {
  html[data-eto-side="collapsed"] .eto-nav__lbl, html[data-eto-side="collapsed"] .eto-top .eto-logo__text { display: none; }
  html[data-eto-side="collapsed"] .eto-nav__label { height: 1px; padding: 0; margin: 10px 12px; background: var(--line); font-size: 0; }
  html[data-eto-side="collapsed"] .eto-nav__levels { grid-template-columns: 1fr; }
  html[data-eto-side="collapsed"] .eto-nav__levels .eto-nav__lbl { display: inline; } /* level items have no icon: keep "B1" */
  html[data-eto-side="collapsed"] .eto-nav__levels .eto-nav__item { min-height: 36px; }
  html[data-eto-side="collapsed"] .eto-nav__item, html[data-eto-side="collapsed"] .eto-side__collapse { justify-content: center; padding: 0; }
  html[data-eto-side="collapsed"] .eto-side__collapse { margin: 0 8px 12px; width: calc(100% - 16px); }
  html[data-eto-side="collapsed"] .eto-nav { padding: 6px 8px 4px; }
}

/* Narrow screens: drawer (JS) or the sidebar stacked above the content (no JS) */
@media (max-width: 767px) {
  .eto-app { grid-template-columns: 1fr; }
  .eto-main { padding: 18px 16px 48px; }
  /* Two rows on phones (mockup screen 7): menu, logo, toggle, sign in; then a full-width search. */
  /* Only the last 56px (the search row) stays stuck, so header + quiz progress stay under 110px of the screen. */
  :root { --tb: 110px; --tb-stuck: 56px; }
  .eto-top { top: calc(var(--tb-stuck) - var(--tb)); }
  .eto-top { flex-wrap: wrap; align-content: flex-start; padding: 0 10px 9px 4px; gap: 0 8px; }
  .eto-top__left, .eto-top__right { height: 56px; }
  .eto-search { order: 3; flex: 1 0 100%; max-width: none; margin-left: 6px; }
  .eto-logo__name { display: none; }
  .eto-top .eto-logo__text { gap: 0; }
  .eto-signin { padding: 0 12px; }
  .eto-sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .eto-side__collapse, .eto-menu, .eto-dark, .eto-scrim { display: none; }
  .js .eto-menu, .js .eto-dark { display: inline-grid; }
  .js .eto-scrim:not([hidden]) { display: block; }
  .js .eto-sidebar { position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: 304px; max-width: 86vw; height: auto; border: 0; border-right: 1px solid var(--line); transform: translateX(-102%); visibility: hidden; transition: transform .22s ease, visibility 0s .22s; padding-bottom: env(safe-area-inset-bottom); }
  .js.eto-drawer-open .eto-sidebar { transform: none; visibility: visible; transition: transform .22s ease; box-shadow: 8px 0 30px rgba(0, 0, 0, .2); }
  .js .eto-side__head { display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 0 10px 0 14px; }
}
@media (max-width: 400px) { .eto-search input::placeholder { font-size: 14px; } }

/* Footer */
.eto-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0 20px; padding: 22px 32px 28px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.eto-foot a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; text-decoration: none; }
.eto-foot .eto-ic { width: 16px; height: 16px; }
.eto-foot > span { margin-right: auto; }
@media (max-width: 1023px) { .eto-foot > span { flex-basis: 100%; margin: 0 0 4px; } }
.eto-foot a:hover { color: var(--text); text-decoration: underline; }
@media (max-width: 767px) { .eto-foot { padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); } }

/* Ad slots. Each place reserves its height inline; the intro slot is taller on phones (the inline value needs !important to yield). */
.eto-ad { margin: 24px 0; }
.eto-ad__label { margin: 0 0 6px; font-size: 12px; line-height: 1.3; color: var(--muted); text-align: center; }

/* Logged-in admin bar offsets. On phones the header keeps its stuck-part offset (only the search row stays) under the 46px bar. */
.admin-bar .eto-top { top: 32px; }
.admin-bar .eto-sidebar { top: calc(var(--tb) + 32px); height: calc(100vh - var(--tb) - 32px); }
@media (max-width: 782px) { .admin-bar .eto-top { top: calc(46px + var(--tb-stuck) - var(--tb)); } .admin-bar .eto-sidebar { top: calc(var(--tb) + 46px); height: calc(100vh - var(--tb) - 46px); } }
@media (max-width: 600px) { .admin-bar .eto-top { top: calc(var(--tb-stuck) - var(--tb)); } } /* WordPress lets its admin bar scroll away below 601px */
@media (max-width: 767px) { .admin-bar .eto-sidebar { position: static; height: auto; } .admin-bar.js .eto-sidebar, .js .admin-bar .eto-sidebar { position: fixed; top: 0; height: auto; } }

/* No JavaScript: <html data-scheme="auto"> (printed by the theme, replaced by its head script) follows the device.
   Twins of the [data-scheme="dark"] rules above; keep them in step (tests/js/guards.test.mjs checks). */
@media (prefers-color-scheme: dark) {
  [data-scheme="auto"] { color-scheme: dark; --bg: #1B1A18; --sidebar: #201F1C; --surface: #262521; --surface-2: #2E2C28; --surface-3: #3A3832; --line: #3A3832; --line-strong: #57534A; --text: #ECE8DF; --text-2: #C4BFB3; --muted: #A9A497; --accent: #F0C020; --accent-hover: #FFD43B; --accent-edge: #8A6900; --on-accent: #1B1A18; --accent-soft: #3A3217; --accent-ink: #F2CD4F; --right: #6CCB93; --right-soft: #183022; --wrong: #F29389; --wrong-soft: #3A201D; --on-mark: #1B1A18; --mark: #5C4A12; --reward: #FB923C; --reward-edge: #C2410C; --reward-ink: #FDBA74; --reward-soft: #3A2614; --focus: #8DB4FF; --scrim: rgba(0, 0, 0, .6); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25); }
  [data-scheme="auto"] .eto-logo__o { fill: var(--accent); }
  [data-scheme="auto"] .eto-logo__tick { stroke: var(--on-accent); }
  [data-scheme="auto"] .eto-dark__sun { display: inline; }
  [data-scheme="auto"] .eto-dark__moon { display: none; }
}
