/* Layout: fixed left module rail + one reading column; widgets sit in the column as framed "instrument panels".
   Palette borrowed from a nautical chart: pale chart water, deep-sounding blue, sea teal, and safety-orange for calls to action. */
:root {
  --bg: #eef3f2;
  --surface: #ffffff;
  --surface-2: #e3ecea;
  --ink: #0f2433;
  --muted: #4a6170;
  --line: #c8d6d6;
  --deep: #0b3a53;
  --sea: #1a7184;
  --sea-soft: #d4ebee;
  --signal: #e8572a;
  --signal-ink: #ffffff;
  --good: #1f8a4c;
  --good-soft: #dff3e6;
  --bad: #b8322a;
  --bad-soft: #fbe3e0;
  --water-top: #2c7fa0;
  --water-bottom: #0b3a53;
  --sky: #cfe6ef;
  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07141d; --surface: #0d2230; --surface-2: #112b3b; --ink: #e2eef1; --muted: #93aab6; --line: #1f3b4c;
    --deep: #9fd3e3; --sea: #4fb6c9; --sea-soft: #12394a; --signal: #ff7a4a; --signal-ink: #1a0a04;
    --good: #5ccf8d; --good-soft: #10331f; --bad: #ff8a80; --bad-soft: #3a1714;
    --water-top: #1d6a87; --water-bottom: #04202f; --sky: #16384a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07141d; --surface: #0d2230; --surface-2: #112b3b; --ink: #e2eef1; --muted: #93aab6; --line: #1f3b4c;
  --deep: #9fd3e3; --sea: #4fb6c9; --sea-soft: #12394a; --signal: #ff7a4a; --signal-ink: #1a0a04;
  --good: #5ccf8d; --good-soft: #10331f; --bad: #ff8a80; --bad-soft: #3a1714;
  --water-top: #1d6a87; --water-bottom: #04202f; --sky: #16384a; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 17px; line-height: 1.6; -webkit-text-size-adjust: 100%; }
img, video { max-width: 100%; display: block; }
a { color: var(--sea); }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; color: var(--deep); }
.mono { font-family: var(--font-mono); }

.shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: var(--deep); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar { background: #04121b; } }
:root[data-theme="dark"] .topbar { background: #04121b; }
.brand { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 500; font-size: 1rem; min-width: 0; }
.brand b { font-weight: 800; }
.brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 30px; height: 18px; flex: none; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-60 -14 120 56'%3E%3Cpath d='M0 18C-4 6-10 0-22-6-34-12-46-12-58-8L-54-4-58-1-52 0C-40 2-22 2-6 14L0 10 6 14C22 2 40 2 52 0L58-1 54-4 58-8C46-12 34-12 22-6 10 0 4 6 0 18ZM-3 16H3V40H-3Z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-60 -14 120 56'%3E%3Cpath d='M0 18C-4 6-10 0-22-6-34-12-46-12-58-8L-54-4-58-1-52 0C-40 2-22 2-6 14L0 10 6 14C22 2 40 2 52 0L58-1 54-4 58-8C46-12 34-12 22-6 10 0 4 6 0 18ZM-3 16H3V40H-3Z'/%3E%3C/svg%3E") center/contain no-repeat; color: #7fd0e0; }
.top-progress { flex: none; margin-left: auto; display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: .8rem; }
.top-progress .bar { width: 120px; }
.bar { height: 6px; background: rgba(127,127,127,.3); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--signal); transition: width .4s; }
.menu-btn { display: none; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 6px; padding: 4px 10px; }

.sidebar { position: sticky; top: 52px; align-self: start; height: calc(100vh - 52px); overflow-y: auto; padding: 24px 16px 24px max(16px, env(safe-area-inset-left, 0px)); border-right: 1px solid var(--line); background: var(--surface); }
.eyebrow { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.side-progress { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); margin-bottom: 18px; }
.module-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: mod; }
.module-list button { width: 100%; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; text-align: left; background: none; border: 0; border-radius: 8px; padding: 8px; color: var(--ink); cursor: pointer; }
.module-list button:hover { background: var(--surface-2); }
.module-list button[aria-current="page"] { background: var(--sea-soft); font-weight: 700; }
.module-list button:disabled { color: var(--muted); cursor: not-allowed; opacity: .7; }
.module-list .num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-mono); font-size: .78rem; border: 1.5px solid var(--line); }
.module-list .done .num { background: var(--good); border-color: var(--good); color: #fff; }
.module-list .min { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); }
.side-foot { font-size: .8rem; color: var(--muted); margin-top: 20px; }

.main { padding: 32px max(16px, env(safe-area-inset-right, 0px)) 80px max(16px, env(safe-area-inset-left, 0px)); min-width: 0; outline: none; }
.page { max-width: 760px; margin: 0 auto; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); margin: 6px 0 0; font-weight: 800; letter-spacing: -.01em; }
.page section { margin: 0 0 40px; }
.page h2 { font-size: 1.5rem; margin: 0 0 12px; }
.lede { font-size: 1.2rem; }
.small { font-size: .9rem; color: var(--muted); }
.credit { color: var(--muted); font-size: .85em; }
ul.ticks { padding-left: 0; list-style: none; display: grid; gap: 10px; }
ul.ticks li { padding-left: 26px; position: relative; }
ul.ticks li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--sea); }
ol.steps { padding-left: 0; list-style: none; counter-reset: s; display: grid; gap: 12px; }
ol.steps li { counter-increment: s; position: relative; padding-left: 44px; }
ol.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--deep); color: var(--bg); display: grid; place-items: center; font-family: var(--font-mono); font-size: .85rem; }

.callout { background: var(--sea-soft); border-radius: var(--radius); padding: 14px 18px; margin: 16px 0; }
.callout.talk { background: var(--surface); border: 1.5px dashed var(--signal); }
.callout.talk b:first-child { color: var(--signal); font-family: var(--font-mono); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; display: block; margin-bottom: 4px; }
.script { background: var(--surface); border-left: 4px solid var(--signal); padding: 8px 20px; border-radius: 0 var(--radius) var(--radius) 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 18px 0; }
.facts div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 2px; align-content: start; }
.facts span { font-family: var(--font-mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.facts b { font-family: var(--font-display); font-size: 1.5rem; color: var(--deep); font-variant-numeric: tabular-nums; }
.facts small { color: var(--muted); font-size: .82rem; line-height: 1.35; }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.rules div { background: var(--surface); border-top: 4px solid var(--signal); border-radius: 6px; padding: 12px 14px; display: grid; gap: 4px; }
.rules b:first-child { font-family: var(--font-display); font-size: 1.25rem; color: var(--deep); }
.rules span { font-size: .92rem; }
.media { margin: 16px 0; }
.media video, .media img { width: 100%; border-radius: var(--radius); background: #000; max-height: 70vh; }
figcaption { font-size: .9rem; color: var(--muted); margin-top: 6px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; }
.gallery img { border-radius: 8px; aspect-ratio: 16/10; object-fit: cover; width: 100%; }

/* Widget frame */
.widget { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; min-width: 0; }
.w-label { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 700; }
.btn:hover { border-color: var(--sea); }
.btn.primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn[aria-pressed="true"] { background: var(--deep); border-color: var(--deep); color: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.panel { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; margin-top: 12px; }
.panel h3 { margin: 0 0 4px; font-size: 1.15rem; }
.panel p { margin: 6px 0; }
.say { font-style: italic; border-left: 3px solid var(--signal); padding-left: 10px; }
canvas.stage, svg.stage { width: 100%; height: auto; display: block; border-radius: 8px; }
.feedback { margin-top: 10px; font-weight: 700; min-height: 1.6em; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.score-pill { font-family: var(--font-mono); font-size: .8rem; background: var(--surface-2); border-radius: 99px; padding: 3px 10px; }
.yt { position: relative; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: #04121b; }
.yt button { position: absolute; inset: 0; width: 100%; border: 0; background: radial-gradient(circle at 50% 45%, #1a5a73, #04121b); color: #fff; cursor: pointer; display: grid; place-content: center; gap: 10px; text-align: center; padding: 16px; }
.yt .play { width: 68px; height: 48px; border-radius: 12px; background: var(--signal); margin: 0 auto; display: grid; place-items: center; }
.yt .play::after { content: ""; border-left: 18px solid #fff; border-top: 11px solid transparent; border-bottom: 11px solid transparent; margin-left: 4px; }
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Knowledge check & exam */
.check { background: var(--surface); border: 2px solid var(--deep); border-radius: var(--radius); padding: 18px; }
.check h2 { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.q { margin: 0 0 18px; padding: 0; border: 0; }
.q legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: pointer; background: var(--surface); }
.opt:hover { border-color: var(--sea); }
.opt input { margin-top: 5px; accent-color: var(--sea); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.why { font-size: .92rem; margin: 4px 0 0; color: var(--muted); }
.nav-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field input { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.result { text-align: center; padding: 24px; }
.result .big { font-family: var(--font-display); font-size: 3.5rem; font-weight: 800; color: var(--deep); }
.sources li { margin-bottom: 6px; font-size: .92rem; }

/* Cards (birds, talks) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.flip { perspective: 900px; border: 0; padding: 0; background: none; cursor: pointer; text-align: left; color: inherit; min-height: 290px; }
.flip-inner { position: relative; height: 100%; min-height: 290px; transition: transform .5s; transform-style: preserve-3d; }
.flip[aria-pressed="true"] .flip-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); padding: 12px; display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.face.back { transform: rotateY(180deg); background: var(--surface); font-size: .88rem; line-height: 1.45; }
.face h3 { margin: 0; font-size: 1.1rem; }
.face .haw { font-family: var(--font-mono); font-size: .75rem; color: var(--signal); text-transform: uppercase; letter-spacing: .06em; }
.face svg { width: 100%; height: auto; background: var(--sky); border-radius: 6px; }
.talk-card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.talk-card summary { cursor: pointer; padding: 10px 12px; font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.talk-card summary span { font-family: var(--font-mono); font-weight: 500; font-size: .75rem; color: var(--muted); white-space: nowrap; }
.talk-card div { padding: 0 12px 12px; font-size: .95rem; }
.talk-grid { display: grid; gap: 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

/* Timeline */
.tl { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.tl button { border: 0; border-radius: 6px; padding: 10px 6px; background: var(--sea-soft); color: var(--ink); cursor: pointer; font-size: .8rem; text-align: left; display: grid; gap: 2px; }
.tl button b { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); }
.tl button[aria-pressed="true"] { background: var(--deep); color: var(--bg); }
.tl button[aria-pressed="true"] b { color: inherit; opacity: .8; }
@media (max-width: 640px) { .tl { grid-template-columns: repeat(3, 1fr); } }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-block; }
  .sidebar { position: fixed; top: 52px; left: 0; width: min(320px, 88vw); height: calc(100vh - 52px); height: calc(100dvh - 52px); max-height: calc(100dvh - 52px); overflow-y: auto; overscroll-behavior: contain; z-index: 30; transform: translateX(-105%); transition: transform .25s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.open { transform: none; }
  .top-progress .bar { width: 60px; }
  .brand span:last-child { font-size: .9rem; }
  .brand .long { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.gal-h { margin: 18px 0 8px; font-size: 1rem; }
.gallery figcaption { font-size: .86rem; margin-top: 6px; line-height: 1.4; }
.gallery figcaption .credit, figure.media .credit { display: block; margin-top: 2px; font-size: .8rem; }
.gallery + .gallery, .gallery + .widget, .gallery + p { margin-top: 14px; }
[hidden] { display: none !important; }
.fg-dl { margin: 0; display: grid; gap: 2px; } .fg-dl dt { font-weight: 700; margin-top: 8px; } .fg-dl dd { margin: 0; }
.media.portrait video { width: auto; max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; background: transparent; }
