:root {
  --ink: #f7f7f8;
  --muted: #9fa5ae;
  --line: #343840;
  --panel: #17191d;
  --canvas: #0d0e10;
  --accent: #6dcbf4;
  --accent-strong: #3d8dff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

button,
a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; }

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(109, 203, 244, .65);
  outline-offset: 3px;
}

.viewer-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.viewer-topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: #121316;
}

.viewer-brand {
  min-width: 0;
  display: grid;
  gap: 2px;
  text-decoration: none;
}

.viewer-brand span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.viewer-brand strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-topbar nav {
  flex: 0 0 auto;
  display: flex;
  gap: 18px;
  font-size: 13px;
  font-weight: 800;
}

.viewer-topbar nav a { text-underline-offset: 3px; }

.viewer-layout {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
}

.thumbnail-rail {
  min-height: 0;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 14px 12px 24px;
  border-right: 1px solid var(--line);
  background: #121316;
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 12px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

#close-thumbnails {
  display: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 24px;
}

.thumbnail-rail ol {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.thumbnail-button {
  width: 100%;
  display: grid;
  gap: 7px;
  padding: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.thumbnail-button:hover {
  border-color: #525862;
  color: var(--ink);
}

.thumbnail-button[aria-current="true"] {
  border-color: var(--accent);
  background: #1d2025;
  color: var(--ink);
}

.thumbnail-button img {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
}

.thumbnail-label {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 6px;
  font-size: 11px;
  line-height: 1.25;
}

.thumbnail-label span:first-child {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.presentation-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: 18px 22px 14px;
}

.slide-frame {
  min-height: 0;
  display: grid;
  place-items: center;
}

.stage-advance {
  width: min(100%, calc((100vh - 190px) * 16 / 9));
  max-height: calc(100vh - 190px);
  display: block;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #fff;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .45);
  cursor: e-resize;
}

.stage-advance img {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 16 / 9;
}

.slide-meta {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) minmax(120px, 24vw);
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.slide-meta strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#slide-counter { font-variant-numeric: tabular-nums; }

.progress-track {
  height: 3px;
  overflow: hidden;
  background: #33373d;
}

#slide-progress {
  width: calc(100% / 47);
  height: 100%;
  display: block;
  background: var(--accent-strong);
  transition: width 160ms ease;
}

.viewer-controls {
  min-height: 42px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
}

.control-group { display: flex; gap: 8px; }
.right-controls { justify-self: end; }

.viewer-controls button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #4a4f58;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.viewer-controls button:hover:not(:disabled) { border-color: var(--accent); }
.viewer-controls button:disabled { opacity: .38; cursor: default; }
.viewer-controls button.primary { border-color: var(--accent-strong); background: var(--accent-strong); }
.viewer-controls p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

kbd {
  padding: 1px 5px;
  border: 1px solid #4a4f58;
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #1a1c20;
  color: var(--ink);
  font: inherit;
}

.mobile-only { display: none; }

.notes-backdrop {
  position: fixed;
  z-index: 19;
  inset: 64px 0 0;
  border: 0;
  background: rgba(0, 0, 0, .38);
  cursor: default;
}

.presenter-notes {
  width: min(440px, 94vw);
  position: fixed;
  z-index: 20;
  inset: 64px 0 0 auto;
  overflow: hidden;
  border-left: 1px solid #d8dbe1;
  background: #f7f7f8;
  color: #111317;
  box-shadow: -22px 0 70px rgba(0, 0, 0, .35);
  color-scheme: light;
}

.notes-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 18px;
  border-bottom: 1px solid #d8dbe1;
  background: #fff;
}

.notes-header div { display: grid; gap: 3px; }

.notes-header span,
.notes-timing {
  color: #287df3;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.notes-header strong { font-size: 14px; }

#close-notes {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid #c9cdd5;
  border-radius: 4px;
  background: #fff;
  color: #111317;
  cursor: pointer;
  font: inherit;
  font-size: 24px;
  line-height: 1;
}

.notes-scroll {
  height: calc(100vh - 132px);
  overflow-y: auto;
  padding: 22px 22px 48px;
}

.notes-timing { margin: 0 0 7px; }

.notes-scroll h2 {
  margin: 0 0 24px;
  font-size: 25px;
  line-height: 1.12;
}

.notes-scroll section {
  padding: 18px 0;
  border-top: 1px solid #d8dbe1;
}

.notes-scroll h3 {
  margin: 0 0 8px;
  color: #5d6470;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.notes-scroll p {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
}

#notes-talk-track { display: grid; gap: 12px; }

.notes-sources {
  padding: 18px 0;
  border-top: 1px solid #d8dbe1;
}

.notes-sources summary {
  cursor: pointer;
  color: #5d6470;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.notes-sources ul {
  display: grid;
  gap: 9px;
  margin: 14px 0 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.4;
}

.notes-sources a { color: #176de0; text-underline-offset: 2px; }

noscript {
  position: fixed;
  inset: auto 16px 16px;
  padding: 14px;
  background: #fff;
  color: #08090a;
}

@media (max-width: 900px) {
  .viewer-layout { grid-template-columns: 1fr; }

  .thumbnail-rail {
    width: min(84vw, 320px);
    max-height: calc(100vh - 64px);
    position: fixed;
    z-index: 10;
    inset: 64px auto 0 0;
    transform: translateX(-104%);
    transition: transform 180ms ease;
    box-shadow: 22px 0 60px rgba(0, 0, 0, .5);
  }

  body.thumbnails-open .thumbnail-rail { transform: translateX(0); }
  #close-thumbnails,
  .mobile-only { display: inline-flex; }
  .presentation-stage { padding-inline: 14px; }
  .stage-advance { width: 100%; max-height: none; }
}

@media (max-width: 620px) {
  .viewer-topbar { min-height: 56px; padding-inline: 12px; }
  .viewer-topbar nav a:first-child { display: none; }
  .viewer-brand span { display: none; }
  .viewer-brand strong { font-size: 13px; }
  .presentation-stage { padding: 10px 8px 8px; }
  .slide-meta { grid-template-columns: 54px minmax(0, 1fr); }
  .slide-meta .progress-track { grid-column: 1 / -1; }
  .viewer-controls { grid-template-columns: 1fr auto; }
  .viewer-controls p { display: none; }
  #fullscreen { display: none; }
  .viewer-controls button { min-height: 42px; padding-inline: 10px; }
  .right-controls { gap: 0; }
  .notes-backdrop { inset-block-start: 56px; }
  .presenter-notes { inset-block-start: 56px; }
  .notes-scroll { height: calc(100vh - 124px); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

@media print {
  .viewer-topbar,
  .thumbnail-rail,
  .slide-meta,
  .viewer-controls,
  .presenter-notes,
  .notes-backdrop { display: none; }
  .presentation-stage { display: block; padding: 0; }
  .stage-advance { width: 100%; max-height: none; box-shadow: none; }
}
