@import url("themes.css");
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--canvas); font: 14px/1.35 var(--brand-font-sans); color: var(--text); }
#viewport { position: fixed; inset: 0; }
#viewport canvas { display: block; touch-action: none; }
#panel { position: fixed; top: 12px; left: 12px; width: 300px; max-height: calc(100% - 64px); overflow: auto; background: var(--surface); border: 1px solid var(--divider); border-radius: 0; padding: 10px 12px; box-shadow: 0 2px 10px var(--shadow); }
#panel h2 { margin: 0 0 4px; font-size: 16px; }
.muted { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.row { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 6px 0; border-top: 1px solid var(--divider); }
.row .head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.row .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 0; margin-right: 6px; vertical-align: -1px; }
.row .count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.row input[type=range] { width: 100%; }
.row .next { font-size: 12px; color: var(--muted); min-height: 1.3em; }
.row details { font-size: 12px; }
.row ol { margin: 4px 0 2px 18px; padding: 0; }
.row li { cursor: pointer; padding: 1px 0; }
.row li.off { color: var(--muted); text-decoration: line-through; }
.row li.edge { font-weight: 600; }
#hide-all { margin-top: 8px; }
#view-tools { position: fixed; right: 14px; bottom: 54px; display: grid; gap: 6px; }
#view-tools button { width: 36px; height: 36px; border: 1px solid var(--divider); background: var(--surface); border-radius: 0; font-size: 18px; cursor: pointer; }
#message { position: fixed; max-width: calc(100% - 390px - 104px); overflow-wrap: anywhere; left: 390px; top: calc(56px + 8px + env(safe-area-inset-top, 0px)); z-index: 40; background: var(--surface); padding: 4px 10px; border-radius: 0; font-size: 13px; }
#message:empty { display: none; }
#msg-retry, #gl-reload { position: fixed; left: 390px; top: calc(56px + 8px + 34px + env(safe-area-inset-top, 0px)); z-index: 41; min-height: 44px; min-width: 44px; padding: 0 18px; border: 1px solid var(--brand-cyan); border-radius: 0; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
#msg-retry[hidden], #gl-reload[hidden] { display: none !important; }
#signin-again { position: fixed; left: 390px; top: calc(56px + 8px + 40px + env(safe-area-inset-top, 0px)); z-index: 41; display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; background: var(--surface); color: var(--text); border: 1px solid var(--accent); border-radius: 0; font-size: 14px; }
#signin-again[hidden] { display: none !important; }
#attribution { position: static; margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--divider); font-size: 12px; color: var(--muted); white-space: nowrap; }
#attribution a { color: var(--accent); }
body.capture #panel, body.capture #view-tools, body.capture #message, body.capture #attribution { display: none; }
.row.pending { opacity: .55; }
.skin { display: grid; gap: 4px; margin-top: 4px; font-size: 12px; }
.skin .tones { display: flex; gap: 6px; }
.skin .tones button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
.skin .tones button.on { box-shadow: 0 0 0 2px var(--accent); }
#attribution .lic { display: block; }

#study { border-top: 1px solid var(--divider); margin-top: 10px; padding-top: 6px; }
#study h3 { margin: 0; font-size: 14px; }
#region-pick { width: 100%; }
#explorer { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(560px, calc(100% - 28px)); background: var(--surface); border: 1px solid var(--divider); border-radius: 0; padding: 10px 14px; box-shadow: 0 2px 12px var(--shadow); }
#explorer[hidden] { display: none; }
#explorer .ex-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
#ex-label { font-size: 22px; font-weight: var(--brand-w-semibold); margin: 4px 0 0; color: var(--text); }
#ex-sub { font-size: 12px; color: var(--muted); min-height: 1.2em; }
#explorer .ex-nav { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
#explorer .ex-nav button { padding: 4px 10px; border: 1px solid var(--border); background: var(--surface); border-radius: 0; cursor: pointer; }
#ex-count { font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: center; color: var(--muted); }
#explorer .ex-iso { margin-left: auto; font-size: 13px; }
#explorer details { font-size: 12px; margin-top: 4px; }
#ex-list { max-height: 140px; overflow: auto; margin: 4px 0 0 18px; padding: 0; }
#ex-list li { cursor: pointer; }
#ex-list li.on { font-weight: var(--brand-w-semibold); color: var(--attention); }
body.capture #explorer details { display: none; }

/* W14 sections */
#sections { border-top: 1px solid var(--divider); margin-top: 10px; padding-top: 6px; }
#sections h3 { margin: 0; font-size: 14px; }
.sec-row { padding: 4px 0; }
.sec-row .head { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.sec-row .head label { flex: 1; }
.sec-row .val { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.sec-row button { border: 1px solid var(--border); background: var(--surface); border-radius: 0; cursor: pointer; padding: 0 6px; }
.sec-row input[type=range] { width: 100%; }
.sec-opt { display: block; font-size: 12px; margin-top: 4px; }
#slice { position: fixed; right: 60px; top: 12px; width: auto; background: var(--surface); border: 1px solid var(--divider); border-radius: 0; padding: 8px; box-shadow: 0 2px 10px var(--shadow); font-size: 12px; }
#slice[hidden] { display: none; }
#slice-title { font-weight: 600; margin-bottom: 4px; color: var(--text); }
#slice .wrap { position: relative; display: inline-block; }
#slice canvas { display: block; border-radius: 0; cursor: crosshair; }
#slice .o { position: absolute; font: 600 12px var(--brand-font-sans); color: var(--slice-text); text-shadow: 0 0 2px var(--slice-bg); }
#slice .o.t { top: 4px; left: 50%; transform: translateX(-50%); } #slice .o.b { bottom: 4px; left: 50%; transform: translateX(-50%); }
#slice .o.l { left: 6px; top: 50%; transform: translateY(-50%); } #slice .o.r { right: 6px; top: 50%; transform: translateY(-50%); }
#slice-hover { min-height: 1.4em; margin-top: 4px; font-weight: 600; }
#slice-note { margin: 2px 0 0; color: var(--muted); }
#sec-note { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: var(--label-bg); color: var(--label-text); padding: 4px 10px; border-radius: 0; font-size: 13px; }
#sec-note[hidden] { display: none; }
body.slicefull #slice { left: 0; top: 0; right: auto; width: calc(100vh - 110px); border-radius: 0; }
body.slicefull #panel, body.slicefull #view-tools { display: none; }

/* O387: phone layout (390 px): the layer panel is a bottom sheet so the body stays visible above it */
@media (max-width: 700px) {
  #panel { top: auto; left: 6px; right: 6px; bottom: 6px; width: auto; max-height: 40vh; border-radius: 0; padding: 8px 10px; }
  #view-tools { right: 8px; top: 8px; bottom: auto; }
  #view-tools button { width: 32px; height: 32px; }
  #attribution { display: block; }
  #slice { right: 52px; top: 8px; padding: 4px; }
  #slice-title { font-size: 11px; } #slice-note, #slice-hover { font-size: 10px; }
  #explorer { bottom: 42vh; }
  #msg-retry, #gl-reload { left: 50%; transform: translateX(-50%); top: calc(56px + 8px + 48px + env(safe-area-inset-top, 0px)); }
  #message { max-width: calc(100% - 208px); left: 50%; transform: translateX(-50%); top: calc(56px + 8px + env(safe-area-inset-top, 0px)); font-size: 12px; }
  #signin-again { left: 50%; transform: translateX(-50%); }
}


#slice-hover:empty, #slice-note:empty { display: none; }
#slice { width: fit-content; } #slice-title { width: 0; min-width: 100%; }
.follow { display: block; font-size: 12px; margin: 4px 0 6px; color: var(--muted); }

/* Phone control sheet: only its visible rectangle receives touches. */
#sheet-toggle { display: none; }
#panel-content { display: contents; }
#credits-open, #credits-close { min-height: 44px; border: 1px solid var(--divider); border-radius: 0; padding: 0 12px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
#credits-open { position: fixed; right: 12px; top: 12px; }
#credits-dialog { box-sizing: border-box; width: 100%; max-width: none; height: 100%; max-height: 100%; margin: 0; padding: 24px; border: 0; background: var(--surface); color: var(--text); overflow: auto; }
#credits-dialog::backdrop { background: var(--backdrop); }
.credits-wrap { max-width: 65ch; margin: 0 auto; }
#credits-close { float: right; margin: 0 0 20px 12px; }
#credits-title { clear: both; margin: 24px 0; font-size: 24px; }
#credits-content > span { display: block; margin: 0 0 24px; line-height: 1.6; }
#credits-content a { display: inline-block; min-height: 44px; padding: 4px 8px; box-sizing: border-box; color: var(--accent); text-underline-offset: 3px; }
#credits-content .lic { padding-top: 16px; border-top: 1px solid var(--divider); }
#sheet-toggle:focus-visible, #credits-open:focus-visible, #credits-close:focus-visible, #credits-dialog a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
body.capture #sheet-toggle, body.capture #credits-open { display: none; }
@media (max-width: 700px) {
  #panel { box-sizing: border-box; max-height: 38vh; max-height: 38dvh; padding: 0; overflow: hidden; display: flex; flex-direction: column; background: var(--surface); box-shadow: 0 4px 18px var(--shadow); }
  #sheet-toggle { display: flex; flex: 0 0 48px; min-height: 48px; width: 100%; align-items: center; gap: 10px; padding: 0 14px; border: 0; background: transparent; color: var(--text); font: 600 14px var(--brand-font-sans); cursor: pointer; touch-action: manipulation; }
  .sheet-grip { width: 24px; height: 4px; background: var(--muted); border-radius: 0; }
  #sheet-action { margin-left: auto; color: var(--accent); }
  #panel-content { display: block; padding: 0 14px 12px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  #panel.is-collapsed #panel-content { display: none; }
  #panel-content h2 { display: none; }
  #panel input[type=range] { box-sizing: border-box; display: block; width: 100%; height: 44px; margin: 0; touch-action: pan-y; accent-color: var(--accent); }
  #panel button, #panel select, #panel summary, #panel li { box-sizing: border-box; min-height: 44px; min-width: 44px; }
  #panel select { max-width: 100%; }
  #panel summary, #panel li { padding-top: 12px; padding-bottom: 12px; }
  #panel .follow, #panel .sec-opt { display: flex; align-items: center; min-height: 44px; gap: 6px; }
  #panel .skin .tones button { width: 44px; height: 44px; }
  #view-tools { gap: 6px; }
  #view-tools button { width: 44px; height: 44px; }
  #reset { font-size: 0 !important; width: 88px !important; }
  #reset::after { content: 'Reset view'; font-size: 13px; }
  #credits-open { left: 8px; right: auto; top: 8px; }
  #explorer { bottom: calc(38dvh + 16px); box-sizing: border-box; max-height: 35dvh; overflow: auto; }
  #credits-dialog { padding: 20px; }
  #panel :focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
}


/* Reuses the existing row palette; native buttons support touch and keyboard. */
.reproductive-toggle { border: 0; margin: 0 0 4px; padding: 0; display: flex; gap: 6px; }
.reproductive-toggle legend { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.reproductive-toggle button { min-width: 72px; min-height: 44px; border: 1px solid var(--border); border-radius: 0; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.reproductive-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.reproductive-toggle button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.reproductive-toggle button:disabled { cursor: wait; opacity: .65; }

/* v4 shell: a single scrolling flow contains tabs, panels and the footer. */
[hidden] { display: none !important; }
button, select, input { font: inherit; accent-color: var(--accent); }
button, select { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--on-accent); }
.shell-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
#viewer-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
#viewer-tabs button { flex: 1; min-height: 44px; padding: 6px 4px; font-size: 13px; }
/* tab states: see the site block at the end of this file */
.layer-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.layer-actions button { flex: 1; min-height: 44px; padding: 4px 8px; margin: 0 !important; }
#attribution button { border: 0; background: transparent; color: var(--accent); padding: 0 4px; min-height: 44px; text-decoration: underline; }
#view-tools { position: fixed; right: 14px; bottom: 54px; display: grid; gap: 6px; margin: 0; }
#panel #explorer, #panel #slice { position: static; transform: none; width: auto; max-width: 100%; max-height: none; box-sizing: border-box; margin-top: 10px; padding: 8px 0; border: 0; border-radius: 0; box-shadow: none; overflow: visible; }
#panel #slice canvas { max-width: 100%; height: auto; }
#panel #slice .wrap { max-width: 100%; }
#panel #explorer .ex-nav { flex-wrap: wrap; gap: 6px; }
#panel #ex-label { font-size: 19px; overflow-wrap: anywhere; }
#panel #ex-sub { overflow-wrap: anywhere; }
.reproductive-toggle { flex-wrap: wrap; }
.reproductive-toggle button { flex: 1; }
@media (max-width: 700px) {
  #view-tools { right: 8px; top: 8px; bottom: auto; }
  #view-tools button { min-width: 44px; min-height: 44px; }
  #panel #panel-content { overscroll-behavior: contain; }
}


/* Optional whole-body control, scoped to its own element. */

/* PWA / notched phones: keep controls out of the safe-area insets (env() is 0 where there is no notch, so nothing moves elsewhere). */
#credits-open { top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); }
@media (max-width: 700px) {
  #panel { left: calc(6px + env(safe-area-inset-left, 0px)); right: calc(6px + env(safe-area-inset-right, 0px)); bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  #credits-open { left: calc(8px + env(safe-area-inset-left, 0px)); right: auto; top: calc(8px + env(safe-area-inset-top, 0px)); }
  #view-tools { right: calc(8px + env(safe-area-inset-right, 0px)); top: calc(8px + env(safe-area-inset-top, 0px)); }
  #message { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

#update-ready { position: fixed; left: 50%; transform: translateX(-50%); top: calc(56px + 8px + 52px + env(safe-area-inset-top, 0px)); z-index: 50; min-height: 44px; padding: 0 16px; border: 1px solid var(--accent); border-radius: 0; background: var(--surface); color: var(--text); font: 600 14px var(--brand-font-sans); cursor: pointer; }

/* Start screen, top tabs, collapsible panels, sections collapsed to a title. Brand colours come from themes.css (--brand-*). */
#start-screen { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; box-sizing: border-box; text-align: center; background: var(--brand-bg); color: var(--brand-ink); font-family: var(--brand-font-sans); padding-bottom: calc(24px + var(--foot)); }
#start-screen[hidden] { display: none !important; }
#start-screen .start-vector { width: 77px; height: 96px; }   /* FIX1 F2/F12: the approved alpha hexagon, native size, full opacity, no loop */
#start-screen .start-title { margin: 0; font-size: 20px; font-weight: var(--brand-w-heavy); letter-spacing: .02em; }
#start-screen .start-wait { margin: 0; font-size: 16px; color: var(--brand-muted); }
#start-screen[data-failed] .start-wait, #start-screen[data-stay] .start-wait { display: none; }
#start-status { margin: 0; min-height: 2.8em; font-size: 14px; color: var(--brand-cyan); }
#start-screen #gate-plans { display: inline-flex; align-items: center; justify-content: center; min-height: var(--brand-tap); min-width: var(--brand-tap); padding: 0 12px; color: var(--brand-cyan); font-weight: 600; text-decoration: underline; }   /* FIX1 F3: 44 px target */
#start-screen #gate-plans:focus-visible { outline: var(--brand-focus-width) solid var(--brand-cyan); outline-offset: var(--brand-focus-offset, 5px); }
/* FINAL1 (R4 brand N3): every start-screen state has a way out. The page's own "Back to the 3D page" control shows in loading and unavailable; the refusal states already carry the gate's own #gate-back. */
#start-screen #start-back { display: inline-flex; align-items: center; justify-content: center; min-height: var(--brand-tap); min-width: var(--brand-tap); padding: 0 12px; color: var(--brand-cyan); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
#start-screen #start-back:focus-visible { outline: var(--brand-focus-width) solid var(--brand-cyan); outline-offset: var(--brand-focus-offset, 5px); }
#start-screen[data-failed] #start-back { display: none; }

#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; box-sizing: border-box; padding: calc(4px + env(safe-area-inset-top, 0px)) calc(8px + env(safe-area-inset-right, 0px)) 4px calc(8px + env(safe-area-inset-left, 0px)); background: var(--surface); border-bottom: 1px solid var(--divider); }
#topbar #viewer-tabs { margin: 0; max-width: 560px; }
#viewer-tabs button { min-height: 44px; font-size: 15px; }
#panel { top: calc(56px + 8px + env(safe-area-inset-top, 0px)); max-height: calc(100% - 56px - 64px); transition: transform .18s ease; }
#credits-open { top: calc(56px + 8px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); }
#view-tools { transition: transform .18s ease; }
#start-hint { position: fixed; left: 390px; top: calc(56px + 12px + env(safe-area-inset-top, 0px)); z-index: 6; max-width: min(420px, calc(100% - 390px - 104px)); margin: 0; padding: 8px 12px; border-radius: 0; background: var(--surface); color: var(--text); border: 1px solid var(--divider); font-size: 13px; text-align: center; pointer-events: none; }
#start-hint[hidden] { display: none !important; }

.row-toggle { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 4px 8px; text-align: left; cursor: pointer; }
.row-toggle::after { content: '\25B8'; margin-left: 4px; color: var(--muted); transition: transform .15s ease; }
.row-toggle[aria-expanded="true"]::after { transform: rotate(90deg); }
.row-toggle label { flex: 1; pointer-events: none; }
.row .head { display: block; }
.row-body { padding: 4px 4px 8px; }
.row-body[hidden] { display: none !important; }

.edge-handle { position: fixed; z-index: 30; min-width: 44px; min-height: 44px; padding: 0; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 24px; line-height: 1; cursor: pointer; touch-action: manipulation; }
.edge-handle.edge-left { left: env(safe-area-inset-left, 0px); top: calc(56px + 8px + env(safe-area-inset-top, 0px)); border-left: 0; border-radius: 0; transition: transform .18s ease; }
.edge-handle.edge-left[aria-expanded="true"] { transform: translateX(338px); }
.edge-handle.edge-right { right: env(safe-area-inset-right, 0px); bottom: calc(6px + env(safe-area-inset-bottom, 0px)); border-right: 0; border-radius: 0; }
#panel.edge-collapsed { transform: translateX(calc(-100% - 16px)); }
#view-tools.edge-collapsed { transform: translateX(calc(100% + 16px)); }
@media (min-width: 701px) { #panel.edge-collapsed { visibility: hidden; transition: transform .18s ease, visibility 0s .18s; } }
@media (max-width: 700px) {
  #panel { top: auto; max-height: 38dvh; }
  #panel-handle { display: none; }
  #panel.edge-collapsed { transform: none; }
  #credits-open { left: calc(8px + env(safe-area-inset-left, 0px)); right: auto; top: calc(56px + 8px + env(safe-area-inset-top, 0px)); }
  #view-tools { right: calc(8px + env(safe-area-inset-right, 0px)); top: calc(56px + 8px + env(safe-area-inset-top, 0px)); }
  .edge-handle.edge-right { top: calc(56px + 160px + env(safe-area-inset-top, 0px)); bottom: auto; }
  #start-hint { left: 62px; right: calc(104px + env(safe-area-inset-right, 0px)); max-width: none; transform: none; top: calc(56px + 8px + env(safe-area-inset-top, 0px)); font-size: 12px; }
}
body.capture #topbar, body.capture .edge-handle, body.capture #start-hint { display: none; }

/* Reviewer round 1: 44 px labels everywhere, a coarse pointer (phone on its side, tablet) gets the phone sizes, and the retry button on the start screen. */
#panel .sec-row .head label { display: flex; align-items: center; min-height: 44px; }
#panel .ex-iso { display: flex; align-items: center; min-height: 44px; }
#start-retry { min-height: 44px; min-width: 44px; padding: 0 20px; border: 1px solid var(--brand-cyan); border-radius: 0; background: transparent; color: var(--brand-ink); font: inherit; cursor: pointer; }
#start-retry[hidden] { display: inline-block !important; visibility: hidden; }   /* keeps its place: showing it at 20 s must not move the picture */
@media (pointer: coarse) and (min-width: 701px) {
  #panel input[type=range] { box-sizing: border-box; display: block; width: 100%; height: 44px; margin: 0; }
  #panel button, #panel select, #panel summary { box-sizing: border-box; min-height: 44px; min-width: 44px; }
  #panel .follow, #panel .sec-opt { display: flex; align-items: center; min-height: 44px; gap: 6px; }
  #panel .skin .tones button { width: 44px; height: 44px; }
  #panel li { box-sizing: border-box; min-height: 44px; padding-top: 12px; padding-bottom: 12px; }
  #view-tools button { width: 44px; height: 44px; }
}

/* ===== The site's look on the viewer chrome (brand/tokens.css values). Rules above stay for layout; these win on colour, type and shape. ===== */
html, body, button, input, select, textarea { font-family: var(--brand-font-sans); }
legend { font-family: var(--brand-mono); }   /* FIX1 F1: the mono face is for short labels only; labels that carry layer names or sentences are Montserrat */
label { font-family: var(--brand-font-sans); }
strong, b, summary { font-weight: var(--brand-w-semibold); }
#topbar { display: flex; align-items: center; gap: 12px; background: var(--brand-header-bg); border-bottom: 1px solid var(--brand-header-line); color: var(--brand-text); }
/* WEB-W1 R1 (BS 1.3, 1.5): L1 lockup, visible hexagon 48 px (40 at <= 760 px), gap 12 / 10, one-line SYNLEARNS; the crop file is tight, so box = visible (brand.css 7b) */
#topbar .wordmark { flex: none; display: inline-flex; align-items: center; gap: var(--brand-logo-x); min-height: var(--brand-tap); color: var(--brand-text); text-decoration: none; font-size: calc(1.25 * var(--brand-logo-x) / var(--brand-cap-ratio)); font-weight: var(--brand-w-semibold); letter-spacing: var(--brand-tr-wordmark); line-height: 1; }
#topbar .wordmark img { width: auto; height: var(--brand-logo-h); object-fit: contain; }
@media (max-width: 760px) { #topbar .wordmark { gap: var(--brand-logo-x-phone); font-size: calc(1.25 * var(--brand-logo-x-phone) / var(--brand-cap-ratio)); } #topbar .wordmark img { height: var(--brand-logo-h-phone); } }
body.starting #topbar .wordmark img { visibility: hidden; }
#topbar .wordmark:focus-visible, #topbar #viewer-tabs button:focus-visible { outline: var(--brand-focus-width) solid var(--brand-cyan); outline-offset: 2px; }
#topbar .wm-text { display: none; }
@media (min-width: 900px) { #topbar .wm-text { display: block; } #topbar { padding-left: calc(16px + env(safe-area-inset-left, 0px)); } }
#topbar #viewer-tabs { flex: 1; min-width: 0; gap: 0; }
#topbar #viewer-tabs button { flex: 1; min-height: var(--brand-tap); padding: 6px 4px; font-size: 14px; font-weight: var(--brand-nav-weight); letter-spacing: var(--brand-nav-tracking); color: var(--brand-text); background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: 0; cursor: pointer; }
#topbar #viewer-tabs button:hover { color: var(--brand-cyan); }
#topbar #viewer-tabs [aria-selected="true"] { color: var(--brand-ink); background: transparent; border-bottom-color: var(--brand-gold); }
@media (min-width: 760px) { #topbar #viewer-tabs button { font-size: var(--brand-nav-size); } }
#panel { border-radius: 0; border-color: var(--divider); }
button, select { border-radius: 0; }
#view-tools button, #explorer .ex-nav button, .sec-row button, .reproductive-toggle button { border-radius: 0; }
#hide-all, #show-all-layers, #layers-undo, #layers-redo, #ex-exit, #credits-open, #credits-close { border: 1px solid var(--border); background: transparent; color: var(--text); font-weight: var(--brand-w-semibold); letter-spacing: var(--brand-button-tracking); }
#hide-all:hover, #show-all-layers:hover, #layers-undo:hover, #layers-redo:hover, #ex-exit:hover, #credits-open:hover, #credits-close:hover, #view-tools button:hover { background: var(--hover); }
#credits-open, #start-retry { clip-path: none; }
#panel h2, #panel h3 { font-weight: var(--brand-h3-weight); letter-spacing: var(--brand-h3-tracking); }
#panel .muted { color: var(--muted); }
:focus-visible { outline: var(--brand-focus-width) solid var(--brand-cyan); outline-offset: 2px; }
@media (max-width: 700px) { #panel { border-radius: 0; } #sheet-action { color: var(--accent); } }
@media (forced-colors: active) { #topbar { border-bottom-color: CanvasText; } #topbar #viewer-tabs [aria-selected="true"] { border-bottom-color: Highlight; } }

/* F9: Prev / Next / Isolate stay in view at the top of the sheet while the structure text scrolls under them */
#explorer .ex-bar { position: sticky; top: 0; z-index: 3; background: var(--surface); }
#explorer .ex-bar .ex-nav { margin-top: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--divider); }

/* Heart peel button: only in the isolated phone heart view, only in the builds that have the peel */
#heart-peel { position: fixed; left: 50%; transform: translateX(-50%); z-index: 12; min-height: var(--brand-tap, 44px); padding: 0 18px; border: 1px solid var(--brand-cyan, var(--divider)); border-radius: 0; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
#heart-peel[hidden] { display: none; }
#heart-peel:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
body.capture #heart-peel { display: none; }

/* F10: help text that matches the device */
.help-touch { display: none; }
@media (pointer: coarse) { .help-mouse { display: none; } .help-touch { display: block; } }

/* the opening screen embeds this page as its self-running heart (?hero=1): the scene only, on a transparent page, nothing to tap but the heart */
html.hero { color-scheme: dark !important; }
html.hero, html.hero body { background: transparent !important; }
html.hero body > :not(#viewport):not(script) { display: none !important; }
html.hero #viewport canvas { touch-action: pan-y !important; cursor: pointer; }

/* ===== FIX1 (R3 brand F1, F2, F4): footer row, 44 px controls at every width, the space the footer takes ===== */
:root { --foot: calc(var(--brand-tap) + env(safe-area-inset-bottom, 0px)); }
#site-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 101; box-sizing: border-box; display: flex; align-items: center; gap: var(--brand-s3); min-height: var(--foot); padding: 0 calc(var(--brand-s2) + env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) calc(var(--brand-s2) + env(safe-area-inset-left, 0px)); background: var(--brand-header-bg); border-top: 1px solid var(--brand-header-line); overflow-x: auto; white-space: nowrap; font-family: var(--brand-font-mono); font-size: var(--brand-t-label); font-weight: var(--brand-w-semibold); }
#site-footer a { display: inline-flex; align-items: center; flex: none; min-height: var(--brand-tap); color: var(--brand-soft); text-decoration: underline; text-underline-offset: 3px; }
#site-footer a:hover { color: var(--brand-cyan); }
#site-footer a:focus-visible { outline: var(--brand-focus-width) solid var(--brand-focus); outline-offset: var(--brand-focus-offset); }
body.capture #site-footer { display: none; }
#ghost { box-sizing: border-box; display: block; width: 100%; height: var(--brand-tap); margin: 0; }
#panel .follow { display: flex; align-items: center; min-height: var(--brand-tap); gap: 6px; }
#view-tools button { width: var(--brand-tap); height: var(--brand-tap); }
/* everything that sat on the bottom edge moves up by the footer's height */
#view-tools { bottom: calc(54px + var(--foot)); }
#explorer { bottom: calc(14px + var(--foot)); }
#sec-note { bottom: calc(40px + var(--foot)); }
.edge-handle.edge-right { bottom: calc(6px + var(--foot)); }
@media (max-width: 700px) {
  #panel { bottom: calc(6px + var(--foot)); max-height: calc(38dvh - var(--foot)); }
  #view-tools { bottom: auto; }
  #explorer { bottom: calc(38dvh + 16px); }
  .edge-handle.edge-right { bottom: auto; }
}

/* FINAL1 (R4 brand N2): at 700 px and below the footer link row wraps to two rows inside the viewport (7 links do not fit one row at 390), each link at least 44 px wide; --foot is two rows so the UI above keeps clear of it */
@media (max-width: 700px) {
  :root { --foot: calc(var(--brand-tap) * 2 + env(safe-area-inset-bottom, 0px)); }
  #site-footer { flex-wrap: wrap; align-content: center; column-gap: var(--brand-s2); row-gap: 0; overflow-x: visible; white-space: normal; }
  #site-footer a { min-width: var(--brand-tap); justify-content: center; }
}
