@font-face {
  font-family: 'Geist';
  src: url('fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: block;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('fonts/GeistMono-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: block;
}

:root {
  --navy: #0f1b24;
  --blue: #115377;
  --cream: #f5f3ee;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
body { font-family: 'Geist', system-ui, sans-serif; color: var(--navy); -webkit-font-smoothing: antialiased; }

/* ---------- Audience view ---------- */
#app { position: fixed; inset: 0; }
#app.hide-cursor, #app.hide-cursor * { cursor: none !important; }
#stage {
  position: absolute; left: 50%; top: 50%;
  width: 1920px; height: 1080px;
  transform-origin: 0 0;
  overflow: hidden;
  background: var(--cream);
}
.slide {
  position: absolute; inset: 0;
  visibility: hidden;
  overflow: hidden;
}
.slide.active, .slide.leaving { visibility: visible; }
.slide.active { z-index: 2; }
.slide.leaving { z-index: 1; }
.slide > .bg { position: absolute; inset: 0; }

.el { position: absolute; margin: 0; }
img.el { display: block; object-fit: fill; user-select: none; -webkit-user-drag: none; }
.shape { display: flex; flex-direction: column; }
.shape p { margin: 0; line-height: calc(var(--ls-pct, 1) * var(--lh-k, 1.2)); }
.shape p:first-child { margin-top: calc((1 - var(--ls-pct, 1)) * var(--lh-k, 1.2) * var(--lh-shift, 0.5) * 1em); }
.shape.code p { font-variant-ligatures: none; font-feature-settings: 'liga' 0, 'calt' 0; }
.shape p { white-space: pre-wrap; overflow-wrap: break-word; }
.shape.code p { white-space: pre; }
.inner { position: absolute; }

.video { display: flex; align-items: center; justify-content: center; }
.video video {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  display: block;
  border-radius: 18px;
  background: transparent;
}
.video-error {
  display: none;
  font: 600 32px/1.3 'Geist', sans-serif; color: var(--blue);
  padding: 32px 48px; border: 3px dashed currentColor; border-radius: 16px;
}
.video.failed video { display: none; }
.video.failed .video-error { display: block; }

#dimmer { position: fixed; inset: 0; background: #000; z-index: 40; opacity: 0; pointer-events: none; transition: opacity .4s; }
#blackout { position: fixed; inset: 0; background: #000; z-index: 50; opacity: 0; pointer-events: none; transition: opacity .8s ease-in-out; }
#blackout.on { opacity: 1; }

#help {
  position: fixed; right: 24px; bottom: 24px; z-index: 60;
  background: rgba(15, 27, 36, .94); color: #f5f3ee;
  border-radius: 14px; padding: 20px 26px; font-size: 15px; line-height: 1.5;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
#help[hidden] { display: none; }
#help h2 { margin: 0 0 10px; font-size: 17px; }
#help dl { display: grid; grid-template-columns: auto auto; gap: 4px 20px; margin: 0; }
#help dt { font-family: 'Geist Mono', monospace; color: #9cc3d8; }
#help dd { margin: 0; }

/* ---------- Presenter view ---------- */
body.presenter #app { display: none; }
#presenter[hidden] { display: none; }
#presenter {
  position: fixed; inset: 0;
  display: grid; grid-template-rows: auto 1fr;
  background: #10161b; color: #e8e6e1;
  font-size: 16px;
}
.pv-bar {
  display: flex; align-items: center; gap: 32px;
  padding: 14px 24px; border-bottom: 1px solid #26313a;
}
.pv-timer { display: flex; align-items: center; gap: 10px; }
#pv-elapsed { font: 700 44px/1 'Geist Mono', monospace; letter-spacing: -1px; min-width: 4.2ch; }
.pv-bar button, .pv-notes-tools button {
  font: 600 14px 'Geist', sans-serif; color: #e8e6e1;
  background: #1d2831; border: 1px solid #34424d; border-radius: 8px;
  padding: 7px 12px; cursor: pointer;
}
.pv-bar button:hover, .pv-notes-tools button:hover { background: #26343f; }
.pv-act { flex: 1; display: flex; align-items: baseline; gap: 14px; font-size: 18px; min-width: 0; }
#pv-act-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pv-act-delta { font-weight: 700; font-family: 'Geist Mono', monospace; white-space: nowrap; }
#pv-act-delta.ok { color: #7fd1a3; }
#pv-act-delta.early { color: #9cc3d8; }
#pv-act-delta.late { color: #ff8a7a; }
.pv-right { display: flex; align-items: baseline; gap: 22px; }
#pv-count { font: 700 26px 'Geist Mono', monospace; }
#pv-clock { font: 500 22px 'Geist Mono', monospace; color: #9aa6af; }
.pv-link { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: #ff8a7a; }
.pv-link.on { color: #7fd1a3; }

.pv-main {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 20px; padding: 20px 24px; min-height: 0;
}
.pv-current, .pv-side { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.pv-current .pv-frame { flex: none; }
.pv-acts { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; flex: 1; font-size: 15px; }
.pv-acts li { display: grid; grid-template-columns: 4.2em 1fr auto; gap: 10px; padding: 6px 10px; border-radius: 8px; color: #8b98a2; cursor: pointer; }
.pv-acts li:hover { background: #1a242c; }
.pv-acts li.done { color: #5d6a74; }
.pv-acts li.now { color: #e8e6e1; background: #1d2b36; font-weight: 600; }
.pv-acts .at { font-family: 'Geist Mono', monospace; }
.pv-acts .sl { font-family: 'Geist Mono', monospace; color: #5d6a74; }
.pv-keys { font-size: 12px; color: #5d6a74; }
.pv-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #000; border-radius: 10px; overflow: hidden;
  outline: 3px solid #2f8fc4; outline-offset: 0;
}
.pv-next { outline-color: #34424d; opacity: .92; }
.pv-frame .mini { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; overflow: hidden; }
.pv-frame .mini .slide { visibility: visible; }
.pv-frame .end {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 20px; color: #6d7a84;
}
.pv-next-label { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: #8b98a2; }
.pv-video { display: flex; align-items: center; gap: 14px; font-family: 'Geist Mono', monospace; font-size: 16px; }
.pv-video[hidden] { display: none; }
.pv-progress { flex: 1; height: 8px; background: #26313a; border-radius: 4px; overflow: hidden; }
.pv-progress i { display: block; height: 100%; width: 0; background: #2f8fc4; }
.pv-video.paused .pv-progress i { background: #e0b25a; }
.pv-video.failed { color: #ff8a7a; }

.pv-notes-tools { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: #8b98a2; }
.pv-notes-tools span { flex: 1; }
.pv-notes {
  flex: 1; min-height: 0; overflow-y: auto;
  font-size: var(--notes-size, 22px); line-height: 1.45;
  padding-right: 8px;
}
.pv-notes p { margin: 0 0 .7em; }
.pv-notes .dir { color: #8b98a2; font-style: italic; font-size: .86em; }
.pv-notes .star { font-size: .8em; }
.pv-notes .mark { color: #9cc3d8; font-weight: 700; font-family: 'Geist Mono', monospace; font-size: .9em; }
.pv-notes .cut { display: inline-block; font-size: .8em; font-weight: 700; color: #10161b; background: #e0b25a; border-radius: 6px; padding: 1px 8px; }
.pv-notes.late .cut { background: #ff8a7a; }

/* Optional dark code panels (key D). Light stays the default. */
.code-dark .el.code-panel { background: #16232d !important; box-shadow: inset 0 0 0 2px #2c3b47 !important; }
.code-dark .el.code.in-panel span { color: #c9d3da !important; }
.code-dark .el.code.in-panel span[style*="#6b7580"] { color: #7f8b97 !important; }
.code-dark .el.code.in-panel span[style*="#115377"] { color: #8fd0f5 !important; }

/* Public web version (body[data-public]): on-screen controls */
#pubnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; font: 500 14px/1 'Geist', system-ui, sans-serif; color: #e8eef2;
  background: linear-gradient(to top, rgba(15, 27, 36, .78), rgba(15, 27, 36, 0)); transition: opacity .4s; }
#app.hide-cursor #pubnav { opacity: 0; }
#pubnav a { color: inherit; text-decoration: none; opacity: .9; }
#pubnav a:hover { opacity: 1; text-decoration: underline; }
#pubnav .pn-ctrl { display: flex; align-items: center; gap: 6px; }
#pubnav button { appearance: none; border: 0; border-radius: 8px; min-width: 36px; height: 36px; padding: 0 8px;
  font: inherit; font-size: 18px; color: inherit; background: rgba(255, 255, 255, .14); cursor: pointer; }
#pubnav button:hover { background: rgba(255, 255, 255, .26); }
#pn-count { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
#help .help-note { margin: 14px 0 0; font-size: 14px; opacity: .8; max-width: 34em; }
@media (hover: none) { #app.hide-cursor #pubnav { opacity: 1; } }
body[data-public] #help { bottom: 68px; z-index: 61; max-width: calc(100vw - 48px); }
