:root {
  --bg: #f4f3ef;
  --fg: #1c1c1a;
  --muted: #6a6964;
  --line: #d9d7cf;
  --panel: #ffffff;
  --accent: #b8430f;
  --accent-fg: #ffffff;
  --slide-bg: #ffffff;
  --slide-fg: #1c1c1a;
  --code-bg: #1f2024;
  --code-fg: #f1f0ea;
  --error: #9f1c1c;
  --error-bg: #fbe7e5;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 4px 16px rgb(0 0 0 / 0.08);
  color-scheme: light dark;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --fg: #ecebe5;
    --muted: #9c9a92;
    --line: #34332f;
    --panel: #1d1d1b;
    --accent: #f08a4b;
    --accent-fg: #141413;
    --slide-bg: #1d1d1b;
    --slide-fg: #ecebe5;
    --code-bg: #0c0c0b;
    --error: #ffb4ab;
    --error-bg: #3b1714;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
}

header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
}

header .brand {
  font-weight: 800;
  letter-spacing: 0.02em;
}
header .title {
  flex: 1;
  color: var(--muted);
}

main {
  padding: 1rem;
}

button {
  font: inherit;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.muted {
  color: var(--muted);
}

.error {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 0.4rem;
  background: var(--error-bg);
  color: var(--error);
}

/* A slide keeps a projector's proportions, and everything in it is sized
   by its width, so the same slide reads the same as a preview and on the
   wall. */
.slide {
  container-type: inline-size;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 0.5rem;
  background: var(--slide-bg);
  color: var(--slide-fg);
  box-shadow: var(--shadow);
}

.slide > section {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2cqw;
  padding: 4.5cqw 6cqw;
  font-size: 2.7cqw;
  line-height: 1.35;
}

.slide h1 {
  margin: 0;
  font-size: 6cqw;
  line-height: 1.1;
}
.slide h2 {
  margin: 0;
  font-size: 4.4cqw;
  line-height: 1.15;
}
.slide h3 {
  margin: 0;
  font-size: 3.4cqw;
}
.slide p {
  margin: 0;
}
.slide ul,
.slide ol {
  margin: 0;
  padding-left: 1.2em;
}
.slide li + li {
  margin-top: 0.35em;
}
.slide a {
  color: var(--accent);
}
.slide img {
  max-width: 100%;
  max-height: 40cqw;
  object-fit: contain;
  align-self: center;
}

.slide blockquote {
  margin: 0;
  padding-left: 2cqw;
  border-left: 0.6cqw solid var(--accent);
  font-style: italic;
}

.slide code {
  font-family:
    ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
}

.slide :not(pre) > code {
  padding: 0 0.25em;
  border-radius: 0.2em;
  background: color-mix(in srgb, var(--slide-fg) 10%, transparent);
}

.slide pre {
  margin: 0;
  max-height: 100%;
  overflow: auto;
  padding: 0.2cqw 2cqw;
  border-radius: 0.8cqw;
  background: var(--code-bg);
  color: var(--code-fg);
  font-size: 2.1cqw;
  line-height: 1.45;
}

/* The presenter: the slide on the wall, what comes next, and the decks. */
#podium {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.on-stage {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(14rem, 1fr);
  gap: 1rem;
  align-items: start;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.position {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.side h3 {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.the-end {
  margin: 0;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 0.4rem;
  color: var(--muted);
  text-align: center;
}
.follow {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.follow a {
  color: var(--accent);
}

.idle {
  padding: 2rem;
  border: 1px dashed var(--line);
  border-radius: 0.5rem;
  text-align: center;
}

.idle h2 {
  margin: 0 0 0.5rem;
}

.decks h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}
.decks ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.decks li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.9rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.decks li.staged {
  border-left: 3px solid var(--accent);
  padding-left: 0.6rem;
}
.decks li .error {
  flex-basis: 100%;
}

/* A deck in sections lists them, each one a place to start from. */
.decks .parts {
  flex-basis: 100%;
  margin: 0;
  padding: 0 0 0 1.5rem;
  list-style: decimal;
}
.decks .parts li {
  display: list-item;
  padding: 0.25rem 0;
  border: 0;
}
.decks .parts li button {
  margin-right: 0.6rem;
}
.part {
  margin: 0;
  color: var(--muted);
}
.deck-line {
  color: var(--muted);
}

@media (max-width: 800px) {
  .on-stage {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The watcher: the slide, as large as the window allows. */
body.watching {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

body.watching main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
}

.following {
  display: flex;
  justify-content: center;
}
.following #live {
  width: min(100%, calc((100vh - 8rem) * 16 / 9));
}
.screen-control {
  margin: 0;
  text-align: center;
}

.live-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.25rem 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.waiting {
  text-align: center;
}
.waiting h1 {
  margin: 0 0 0.5rem;
}

/* Full screen is for the wall: nothing but the slide. */
body.watching:fullscreen header,
body.watching:fullscreen .live-line,
body.watching:fullscreen .screen-control {
  display: none;
}
body.watching:fullscreen .following #live {
  width: min(100vw, calc(100vh * 16 / 9));
}
body.watching:fullscreen main {
  padding: 0;
}
body.watching:fullscreen .slide {
  border-radius: 0;
  box-shadow: none;
}

/* The sentry's door. */
#entrance {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 1rem;
  text-align: center;
}

#entrance h1,
#entrance h2 {
  margin: 0;
}
#gate {
  display: flex;
  gap: 0.5rem;
}

#gate input {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--panel);
  color: var(--fg);
}
