/* Back to top + Contents buttons, and the Contents sheet (phones and tablets in portrait). */
#lnav { position: fixed; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 900; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
#lnav .lnav-b { pointer-events: auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; min-width: 48px; padding: 0 16px; border-radius: 24px; font: inherit; font-weight: 700; font-size: 14px; letter-spacing: .03em; color: #eaf6ff; background: rgba(7,22,42,.94); border: 1.5px solid #22d3ee; box-shadow: 0 6px 18px rgba(0,0,0,.45); cursor: pointer; -webkit-tap-highlight-color: transparent; }
#lnav .lnav-b[hidden] { display: none; }
#lnav .lnav-t { padding: 0; width: 48px; }
#lnav .lnav-b:hover { background: rgba(14,44,80,.98); }
#lnav .lnav-b:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
html.intro-open #lnav { display: none; }
#lnav-sheet { position: fixed; inset: 0; z-index: 950; }
.lnav-back { position: absolute; inset: 0; background: rgba(2,8,18,.66); }
.lnav-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: min(72vh, 560px); overflow: auto; -webkit-overflow-scrolling: touch; background: #0a2038; border-top: 1.5px solid #22d3ee; border-radius: 18px 18px 0 0; padding: 6px 12px calc(16px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -10px 30px rgba(0,0,0,.5); animation: lnav-up .22s ease-out; }
.lnav-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 12px 6px 8px; background: #0a2038; font-family: var(--rewired, inherit); font-size: 1.05rem; color: #eaf6ff; }
.lnav-x { min-width: 44px; min-height: 44px; font-size: 28px; line-height: 1; color: #cfe4f0; background: none; border: 0; cursor: pointer; }
.lnav-panel ol { list-style: none; margin: 0; padding: 0; }
.lnav-panel li a { display: flex; align-items: baseline; gap: 12px; padding: 13px 8px; min-height: 48px; box-sizing: border-box; color: #dcecf5; text-decoration: none; border-top: 1px solid rgba(255,255,255,.08); font-size: 15px; line-height: 1.3; }
.lnav-panel li a:hover, .lnav-panel li a:focus-visible { background: rgba(34,211,238,.1); outline: none; }
.lnav-panel .n { flex: 0 0 26px; font-family: var(--rewired, inherit); font-weight: 700; color: #22d3ee; }
@keyframes lnav-up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lnav-panel { animation: none; } }

/* Rewired Sans in a few more places (headings and labels only; body text stays in Inter) */
.les-sec h2 .num, .toc .num, .toc a, .callout-h, .les-table th, .les-table caption, .expand > summary { font-family: var(--rewired, inherit); }
.toc a { letter-spacing: .01em; }
.expand > summary { font-weight: 600; }

/* Wide tables become stacked cards when the screen is narrow, so nothing scrolls sideways.
   4+ columns stack up to tablet-portrait width; 3 columns stack on phones. */
@media (max-width: 900px) {
  .tbl-stack { overflow-x: visible; border: 0; }
}
@media (max-width: 900px) {
  .tbl-stack .les-table, .tbl-stack .les-table tbody, .tbl-stack .les-table tr, .tbl-stack .les-table td, .tbl-stack .les-table caption { display: block; width: 100%; box-sizing: border-box; }
  .tbl-stack .les-table caption { padding: 0 0 10px; }
  .tbl-stack .les-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tbl-stack .les-table tr { margin: 0 0 12px; border: 1px solid rgba(40,200,255,.3); border-radius: 10px; overflow: hidden; background: rgba(255,255,255,.03); }
  .tbl-stack .les-table td { padding: 7px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
  .tbl-stack .les-table td:last-child { border-bottom: 0; }
  .tbl-stack .les-table td:first-child { background: rgba(25,211,240,.12); color: #fff; font-weight: 700; font-family: var(--rewired, inherit); }
  .tbl-stack .les-table td[data-label]:not(:first-child):not([data-label=""])::before { content: attr(data-label) ": "; font-size: .8rem; color: #7fd7ea; font-weight: 700; font-family: var(--rewired, inherit); }
}
@media (max-width: 520px) {
  .tbl-stack3 { overflow-x: visible; border: 0; }
  .tbl-stack3 .les-table, .tbl-stack3 .les-table tbody, .tbl-stack3 .les-table tr, .tbl-stack3 .les-table td, .tbl-stack3 .les-table caption { display: block; width: 100%; box-sizing: border-box; }
  .tbl-stack3 .les-table caption { padding: 0 0 10px; }
  .tbl-stack3 .les-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tbl-stack3 .les-table tr { margin: 0 0 12px; border: 1px solid rgba(40,200,255,.3); border-radius: 10px; overflow: hidden; background: rgba(255,255,255,.03); }
  .tbl-stack3 .les-table td { padding: 7px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
  .tbl-stack3 .les-table td:last-child { border-bottom: 0; }
  .tbl-stack3 .les-table td:first-child { background: rgba(25,211,240,.12); color: #fff; font-weight: 700; font-family: var(--rewired, inherit); }
  .tbl-stack3 .les-table td[data-label]:not(:first-child):not([data-label=""])::before { content: attr(data-label) ": "; font-size: .8rem; color: #7fd7ea; font-weight: 700; font-family: var(--rewired, inherit); }
}
.results .res em{font-style:normal;color:var(--cyan,#19d3f0);font-size:.72rem;display:block}

/* Small round buttons stacked on the right edge: Contents, up, down. Semi-transparent so text shows through. */
#lnav .lnav-b { min-height: 40px; min-width: 40px; width: 40px; height: 40px; padding: 0; border-radius: 50%; opacity: .82; background: rgba(7,22,42,.8); }
#lnav .lnav-b svg { width: 20px; height: 20px; }
#lnav .lnav-lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#lnav .lnav-b:hover, #lnav .lnav-b:active { opacity: 1; }

/* Smaller and more see-through, so they cover less of the cards and text underneath. */
#lnav { gap: 6px; }
#lnav .lnav-b { min-height: 36px; min-width: 36px; width: 36px; height: 36px; opacity: .6; background: rgba(7,22,42,.55); }
#lnav .lnav-b svg { width: 18px; height: 18px; }
#lnav .lnav-b:hover, #lnav .lnav-b:active, #lnav .lnav-b:focus-visible { opacity: 1; background: rgba(7,22,42,.95); }

/* Phone lesson top (22 Nov): jump button and a shorter general-content note. Shown only where the side list is collapsed. */
.lnav-jump, .lnav-more { display: none; }
@media (max-width: 960px) {
  .lnav-jump { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; padding: 9px 14px; min-height: 40px; border-radius: 10px; border: 1px solid var(--cyan, #19d3f0); background: rgba(25,211,240,.1); color: #e8f9ff; font: inherit; font-weight: 600; cursor: pointer; }
  .les-general.is-clamped p:not(.callout-h) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  .lnav-more { display: inline-block; margin-top: 6px; padding: 6px 2px; min-height: 32px; border: 0; background: none; color: var(--cyan, #19d3f0); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
}
