/*
 * Alice in Userland.
 *
 * This used to be Tailwind. Every value here was taken from the stylesheet
 * Tailwind compiled, so the page looks the same; what changed is that the
 * names are now the site's own.
 *
 * Colours are named by role, not by shade. Both themes are defined in terms
 * of the same names, so how light or dark the whole thing feels is decided in
 * one block and nowhere else. Nothing below ever writes a `.dark` rule for a
 * background or a border.
 */

/* ------------------------------------------------------------------ tokens */

:root {
  --font-sans:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Monaco, "Cascadia Code", monospace;

  /* The single accent, used for the current day and the selected file. */
  --ink-400: oklch(72% 0.13 55);
  --ink-500: oklch(64% 0.15 52);
  --ink-600: oklch(55% 0.15 50);

  /* The neutral ramp, referenced only by the roles below and by the
     translucent chips in the prose. */
  --neutral-500: oklch(55.6% 0 0);
  --neutral-950: oklch(14.5% 0 0);

  /*
   * Surfaces. Each pane gets its own tint so the eye can tell them apart
   * without a border to read: chrome is neutral grey, the story is the plain
   * reading surface, the notebook is warm like paper, the code is cool. The
   * chroma is deliberately tiny — enough to separate the panes, not enough to
   * compete with the accent or tint the text.
   */
  --canvas: oklch(0.985 0.002 250); /* the page behind everything */
  --topbar: oklch(0.962 0.004 250); /* chrome: top bar */
  --sidebar: oklch(0.973 0.003 250); /* chrome: the chapter list */
  --story: oklch(1 0 0); /* the story pane */
  --notebook: oklch(0.982 0.019 92); /* the notebook pane, warm */
  --panel: oklch(0.971 0.005 250); /* the code pane, cool */
  --raised: oklch(1 0 0); /* buttons and other controls */
  --hover: oklch(0.955 0.003 250); /* rows under the pointer */
  --line: oklch(0.915 0.003 250); /* every divider and border */
  --line-strong: oklch(0.86 0.004 250); /* a border being hovered */
  --scrollbar: oklch(0.87 0 0);

  /* Text, also by role. Each of these was a `text-neutral-x dark:text-neutral-y`
     pair repeated across the components. */
  --text: oklch(20.5% 0 0); /* body copy in the chrome */
  --text-strong: oklch(20.5% 0 0); /* what a hover reaches */
  --text-secondary: oklch(43.9% 0 0); /* icons, file names, paths */
  --text-muted: oklch(55.6% 0 0); /* pane labels, empty states */
  --text-faint: oklch(70.8% 0 0); /* line numbers, counts */
  --accent-text: var(--ink-600); /* the current day, the open file */

  /* The prose ramp, from the typography plugin's neutral palette. */
  --prose-body: oklch(37.1% 0 0);
  --prose-headings: oklch(20.5% 0 0);
  --prose-quotes: oklch(20.5% 0 0);
  --prose-code: oklch(20.5% 0 0);
  --prose-counters: oklch(55.6% 0 0);
  --prose-bullets: oklch(87% 0 0);
  --prose-th-borders: oklch(87% 0 0);
}

/*
 * The dark theme. Around #1e1e1e rather than near black: the earlier values
 * sat at neutral-950 and read as a hole in the screen.
 *
 * A ladder, not a set of unrelated values: chrome sits back, the reading
 * surfaces come forward. Nothing drops below the level the whole app used to
 * sit at, so lifting the panes apart does not make it feel darker.
 */
.dark {
  --topbar: oklch(0.228 0.004 250);
  --sidebar: oklch(0.242 0.003 250);
  --canvas: oklch(0.248 0.003 250);
  --panel: oklch(0.262 0.008 250);
  --story: oklch(0.278 0 0);
  --notebook: oklch(0.288 0.017 92);
  --raised: oklch(0.325 0.004 250);
  --hover: oklch(0.345 0.004 250);
  --line: oklch(0.385 0.005 250);
  --line-strong: oklch(0.48 0.006 250);
  --scrollbar: oklch(0.44 0 0);

  --text: oklch(92.2% 0 0);
  --text-strong: oklch(97% 0 0);
  --text-secondary: oklch(70.8% 0 0);
  --text-muted: oklch(70.8% 0 0);
  --text-faint: oklch(55.6% 0 0);
  --accent-text: var(--ink-400);

  --prose-body: oklch(87% 0 0);
  --prose-headings: #fff;
  --prose-quotes: oklch(97% 0 0);
  --prose-code: #fff;
  --prose-counters: oklch(70.8% 0 0);
  --prose-bullets: oklch(43.9% 0 0);
  --prose-th-borders: oklch(43.9% 0 0);
}

/* -------------------------------------------------------------------- base */

*,
*::before,
*::after {
  box-sizing: border-box;
  border: 0 solid var(--line);
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  /* The page itself never scrolls; every scroller is inside a pane. Leaving a
     gutter reserved here only put a dead strip down the right edge. */
  overflow: hidden;
}

body {
  height: 100%;
  margin: 0;
  background-color: var(--canvas);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure,
blockquote,
pre {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: inherit;
}

button {
  margin: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: inherit;
}

svg {
  display: block;
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 1em;
}

hr {
  height: 0;
  color: inherit;
  border-top-width: 1px;
}

/* Restrained scrollbars, so three scrolling panes are not three loud bars. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar);
  border: 3px solid transparent;
  border-radius: 9999px;
  background-clip: content-box;
}

:focus-visible {
  outline: 2px solid var(--ink-500);
  outline-offset: 2px;
}

/*
 * Browsers give buttons the arrow cursor. Anything that responds to a click
 * should say so.
 */
button:not(:disabled),
[role="tab"]:not([aria-disabled="true"]),
summary,
label[for] {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ shell */

.app {
  display: flex;
  height: 100%;
  flex-direction: column;
}

/* relative, because below the breakpoint the day list slides over this row. */
.shell {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
}

.main {
  display: flex;
  min-height: 0;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

/* ----------------------------------------------------------------- top bar */

.topbar {
  display: grid;
  height: 2.75rem;
  flex-shrink: 0;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
  background-color: var(--topbar);
  padding-inline: 0.75rem;
}

.topbar__side {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.625rem;
}

.topbar__side--end {
  justify-content: flex-end;
}

.book-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.book-title a {
  transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.book-title a:hover {
  color: var(--accent-text);
}

.day-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
}

.icon-button {
  flex-shrink: 0;
  border-radius: 0.375rem;
  border: 1px solid var(--line);
  background-color: var(--raised);
  padding: 0.375rem;
  color: var(--text-secondary);
  transition:
    color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    background-color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--text-strong);
}

.icon-button[aria-pressed="true"] {
  border-color: color-mix(in oklab, var(--ink-500) 30%, transparent);
  background-color: color-mix(in oklab, var(--ink-500) 10%, transparent);
  color: var(--accent-text);
}

.icon-button svg {
  width: 1rem;
  height: 1rem;
}

/* Sized to sit inside a pane header rather than the top bar. */
.icon-button--small {
  margin-left: auto;
  padding: 0.1875rem;
}

.icon-button--small svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* One icon per theme, both in the page, so switching builds no DOM. */
.icon-moon {
  display: none;
}

.dark .icon-sun {
  display: none;
}

.dark .icon-moon {
  display: block;
}

/* ---------------------------------------------------------------- day list */

.scrim {
  position: absolute;
  inset: 0;
  z-index: 20;
  background-color: color-mix(in oklab, var(--neutral-950) 40%, transparent);
}

/*
 * Closed on arrival. From the breakpoint up it takes its own column and
 * pushes the panes across; below that it slides over them, because there is
 * no room to give it.
 *
 * The border lives on the open state only: with border-box sizing a 1px
 * border would keep the collapsed panel 1px wide, leaving a hairline down the
 * left edge.
 */
.sidebar {
  position: absolute;
  inset-block: 0;
  left: 0;
  z-index: 30;
  width: 18rem;
  overflow: hidden;
  background-color: var(--sidebar);
  translate: -100% 0;
  transition: translate 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.is-open {
  translate: 0 0;
  border-right: 1px solid var(--line);
}

/* Fixed width inside, so the text does not reflow while it animates. */
.sidebar__inner {
  display: flex;
  height: 100%;
  width: 18rem;
  flex-direction: column;
}

.sidebar__close {
  margin-left: auto;
  border-radius: 0.25rem;
  padding: 0.25rem;
  color: var(--text-muted);
  transition:
    color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar__close:hover {
  background-color: var(--hover);
  color: var(--text-strong);
}

.sidebar__close svg {
  width: 1rem;
  height: 1rem;
}

.day-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding-block: 0.25rem;
}

.day-list__row {
  display: flex;
  width: 100%;
  align-items: baseline;
  gap: 0.625rem;
  border-left: 2px solid transparent;
  padding-block: 0.5rem;
  padding-right: 1rem;
  padding-left: 1.125rem;
  text-align: left;
  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.day-list__row:hover {
  background-color: var(--hover);
}

.day-list__row.is-active {
  border-left-color: var(--ink-500);
  background-color: color-mix(in oklab, var(--ink-500) 10%, transparent);
}

.day-list__number {
  width: 1rem;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

.day-list__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
}

.day-list__row.is-active .day-list__number,
.day-list__row.is-active .day-list__title {
  color: var(--accent-text);
}

/* ------------------------------------------------------------------- panes */

/*
 * The header strip every pane starts with.
 *
 * The height is fixed rather than derived from the contents. A badge, a plain
 * label and a button all have different natural heights, and letting each
 * header size itself left the rules underneath them at four different heights
 * across the window.
 */
.pane-header {
  display: flex;
  height: 2.75rem;
  flex-shrink: 0;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--line);
  padding-inline: 1.25rem;
}

.pane-title {
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pane {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.pane__scroll {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}

.pane__empty {
  padding-inline: 1.25rem;
  padding-block: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-style: italic;
  color: var(--text-muted);
}

.pane--story {
  background-color: var(--story);
}

.pane--notebook {
  background-color: var(--notebook);
}

.pane--code {
  background-color: var(--panel);
}

.pen-icon {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
  color: var(--accent-text);
}

/* --------------------------------------------------------------- the split */

/*
 * Three resizable regions, each a percentage so it holds its share when the
 * window changes. The three live on the root rather than on the panes, so the
 * script that restores them before first paint can set them without waiting
 * for a body to exist.
 *
 * The panes carry no minimum content width, which is what stops a long line
 * of code from dictating the split. How far each one may be dragged is the
 * splitter's business, in alice.js: with no script there is no dragging and
 * nothing to bound.
 */
:root {
  --split-story: 42%; /* the prose column, beside the code */
  --split-notes: 58%; /* the story, above the notebook */
  --split-files: 22%; /* the file tree, beside the file */
}

.panes {
  display: flex;
  min-height: 0;
  min-width: 0;
  flex: 1;
}

/*
 * A pane is exactly its share of the width. The divider is a real element
 * between two panes rather than a border inside one, so no pane pays a pixel
 * of text for it — and one pixel is enough to move the last word of a line
 * onto the next one.
 */
.story-column {
  display: flex;
  flex: 0 0 var(--split-story);
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.story-column > .pane--story {
  flex: 0 0 var(--split-notes);
  overflow: hidden;
}

.story-column > .pane--notebook {
  flex: 1 1 0;
  min-height: 0;
}

.pane--code {
  flex: 1 1 0;
  min-width: 0;
  flex-direction: row;
}

.tree-column {
  display: flex;
  flex: 0 0 var(--split-files);
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.code-column {
  display: flex;
  min-height: 0;
  min-width: 0;
  flex: 1 1 0;
  flex-direction: column;
}

/* ----------------------------------------------------------- the splitters */

/*
 * The line between two panes is the handle that moves it.
 *
 * One pixel of line, with four either side of it as an invisible hit area, so
 * it is easy to catch without becoming a visible bar. The area is drawn over
 * the panes rather than between them, so neither gives up any width for it.
 */
.splitter {
  position: relative;
  flex: 0 0 1px;
  background-color: var(--line);
  /* The drag is handled by the pointer events, never by scrolling. */
  touch-action: none;
  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.splitter::before {
  content: "";
  position: absolute;
}

.splitter--x {
  cursor: col-resize;
}

.splitter--x::before {
  inset-block: 0;
  inset-inline: -4px;
}

.splitter--y {
  cursor: row-resize;
}

.splitter--y::before {
  inset-inline: 0;
  inset-block: -4px;
}

/*
 * Quiet until it is wanted, which is the bargain the old divider struck too:
 * at rest it is one more rule between two panes, and it colours in only once
 * the pointer is on it or a drag is under way.
 */
.splitter:hover,
.splitter:focus-visible,
.splitter.is-dragging {
  background-color: var(--ink-500);
}

/* A pixel changing colour is not enough to find with a keyboard. */
.splitter:focus-visible {
  outline: 2px solid var(--ink-500);
  outline-offset: 1px;
}

/* The pointer is captured for the whole drag, so it keeps its shape even
   when it runs ahead of the line it is moving. */
body.is-dragging {
  cursor: var(--dragging-cursor, col-resize);
  user-select: none;
}

/* ------------------------------------------------------------- pane switch */

/* Below the breakpoint there is no room to split anything, so the three panes
   become a switch. Hidden from the wide layout entirely. */
.pane-switch {
  display: none;
  flex-shrink: 0;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
  padding-inline: 0.75rem;
  padding-block: 0.5rem;
}

.pane-switch button {
  flex: 1;
  border-radius: 0.375rem;
  padding-block: 0.375rem;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.pane-switch button:hover {
  background-color: var(--hover);
}

.pane-switch button[aria-selected="true"] {
  background-color: color-mix(in oklab, var(--ink-500) 10%, transparent);
  font-weight: 600;
  color: var(--accent-text);
}

/* --------------------------------------------------------------- file tree */

.tree-column__scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.file-count {
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

.file-tree {
  padding-block: 0.5rem;
  font-size: 0.8125rem;
}

.tree-dir,
.tree-file {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.375rem;
  padding-block: 0.25rem;
  padding-right: 0.75rem;
  text-align: left;
  color: var(--text-secondary);
  transition:
    color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.tree-dir:hover {
  color: var(--text-strong);
}

.tree-file {
  border-right: 2px solid transparent;
}

.tree-file:hover {
  background-color: var(--hover);
  color: var(--text-strong);
}

.tree-file.is-active {
  border-right-color: var(--ink-500);
  background-color: color-mix(in oklab, var(--ink-500) 10%, transparent);
  font-weight: 500;
  color: var(--accent-text);
}

.tree-file.is-active:hover {
  background-color: color-mix(in oklab, var(--ink-500) 10%, transparent);
  color: var(--accent-text);
}

.tree-dir .tree-name {
  font-weight: 500;
}

.tree-file .tree-name {
  font-family: var(--font-mono);
}

.tree-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-chevron {
  width: 0.75rem;
  height: 0.75rem;
  flex-shrink: 0;
  rotate: 90deg;
  transition: rotate 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

[aria-expanded="false"] > .tree-chevron {
  rotate: 0deg;
}

[role="treeitem"][aria-expanded="false"] > [role="group"] {
  display: none;
}

/* --------------------------------------------------------------- code view */

.code-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--text-secondary);
}

.copy-button {
  margin-left: auto;
  flex-shrink: 0;
  border-radius: 0.25rem;
  border: 1px solid var(--line);
  padding-inline: 0.5rem;
  padding-block: 0.125rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition:
    color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.copy-button:hover {
  border-color: var(--line-strong);
  color: var(--text-strong);
}

.code-block {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding-block: 0.75rem;
}

.code-column__empty {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--text-muted);
}

/* The panes paint their own backgrounds, so the block stays transparent. */
.code-block .shiki {
  background-color: transparent;
  padding: 0;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.65;
}

.code-block .shiki code {
  display: block;
  width: max-content;
  min-width: 100%;
  counter-reset: line;
}

/* Line numbers, drawn from a counter so they cannot be selected or copied. */
.code-block .shiki code .line {
  counter-increment: line;
  display: inline-block;
  width: 100%;
  padding-inline: 1.25rem 1.5rem;
}

.code-block .shiki code .line::before {
  content: counter(line);
  display: inline-block;
  width: 2.5rem;
  margin-inline-start: -1.25rem;
  margin-inline-end: 1.25rem;
  text-align: right;
  color: var(--text-faint);
  user-select: none;
  -webkit-user-select: none;
}

.code-block .shiki code .line:hover {
  background-color: color-mix(in oklab, var(--ink-500) 7%, transparent);
}

/* ------------------------------------------------------------------- prose */

/*
 * Both markdown panes sit on the same 1.75rem baseline grid, so a line of the
 * story and a line of the notebook are at the same height whatever the split.
 * Adjacent margins collapse to one step, which keeps the grid.
 */
.prose {
  --rule: 1.75rem;

  padding-inline: 1.25rem;
  padding-block: 1.25rem;
  font-size: 0.9375rem;
  line-height: var(--rule);
  color: var(--prose-body);
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote {
  margin-block: 0 var(--rule);
  line-height: var(--rule);
}

.prose li {
  margin-block: 0;
  line-height: var(--rule);
}

.prose li > ul,
.prose li > ol {
  margin-block: 0;
}

.prose ul {
  padding-inline-start: 1.625em;
  list-style-type: disc;
}

.prose ol {
  padding-inline-start: 1.625em;
  list-style-type: decimal;
}

.prose ul > li,
.prose ol > li {
  padding-inline-start: 0.375em;
}

.prose ul > li::marker {
  color: var(--prose-bullets);
}

.prose ol > li::marker {
  color: var(--prose-counters);
  font-weight: 400;
}

.prose strong {
  color: var(--prose-headings);
  font-weight: 600;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  color: var(--prose-headings);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: var(--rule);
}

.prose h1 {
  font-size: 1.125rem;
  margin-block: 0 var(--rule);
}

.prose h2 {
  font-size: 1rem;
  margin-block: var(--rule) 0;
}

.prose h3 {
  font-size: 0.875rem;
  margin-block: var(--rule) 0;
}

.prose h4 {
  font-size: 0.875rem;
  margin-block: var(--rule) 0;
  letter-spacing: 0;
}

.prose > :first-child {
  margin-block-start: 0;
}

.prose > :last-child {
  margin-block-end: 0;
}

/* comrak puts an empty anchor inside every heading. rehype-slug set only the
   id, so it is taken back out of the tab order and off the page. */
.prose .anchor {
  display: none;
}

/* Translucent rather than a surface colour, so the chip sits on whichever
   pane tint it lands in. A fixed panel colour looked cool and grey against
   the warm notebook. */
.prose code {
  border-radius: 0.25rem;
  padding-inline: 0.375rem;
  padding-block: 0.125rem;
  font-size: 0.85em;
  font-weight: 400;
  font-family: var(--font-mono);
  color: var(--prose-code);
  background-color: color-mix(in oklab, var(--neutral-500) 15%, transparent);
}

/* A chip inside something that already has a colour keeps that colour. */
.prose h1 code,
.prose h4 code,
.prose a code,
.prose blockquote code,
.prose thead th code {
  color: inherit;
}

.prose h2 code {
  color: inherit;
  font-size: 0.875em;
}

.prose h3 code {
  color: inherit;
  font-size: 0.9em;
}

.prose pre code {
  background-color: transparent;
  padding: 0;
}

.prose blockquote {
  border-left: 2px solid color-mix(in oklab, var(--ink-500) 40%, transparent);
  padding-left: 1rem;
  font-weight: 400;
  font-style: normal;
  color: var(--prose-quotes);
}

.prose a {
  color: var(--accent-text);
  font-weight: 500;
  text-decoration-line: underline;
  text-decoration-color: color-mix(in oklab, var(--ink-500) 40%, transparent);
  text-underline-offset: 2px;
}

/* GFM tables. */
.prose table {
  margin-block: 1.75rem;
  width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  font-size: 0.9em;
}

.prose thead {
  border-bottom: 1px solid var(--prose-th-borders);
}

.prose th,
.prose td {
  border: 1px solid var(--line);
  padding-inline: 0.75rem;
  padding-block: 0.375rem;
  text-align: left;
  vertical-align: top;
  line-height: var(--rule);
}

.prose th {
  font-weight: 600;
  color: var(--prose-headings);
  background-color: color-mix(in oklab, var(--neutral-500) 9%, transparent);
}

/* GFM task lists: no bullet, and the box sits with the text. */
.prose li:has(> input[type="checkbox"]) {
  list-style-type: none;
  margin-inline-start: -1.25rem;
}

.prose input[type="checkbox"] {
  margin-right: 0.5rem;
  vertical-align: middle;
  accent-color: var(--ink-500);
}

.prose del {
  color: var(--text-muted);
}

.prose hr {
  margin-block: 1.75rem;
  border-top: 1px solid var(--line);
}

.prose img {
  margin-block: 1.75rem;
  max-width: 100%;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
}

.prose kbd {
  border-radius: 0.25rem;
  border: 1px solid var(--line);
  padding-inline: 0.375rem;
  padding-block: 0.125rem;
  font-size: 0.8em;
  font-weight: 500;
  font-family: var(--font-mono);
  background-color: color-mix(in oklab, var(--neutral-500) 9%, transparent);
}

/* The footnote list appended at the end of the document. */
.prose .footnotes {
  margin-top: 1.75rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  font-size: 0.9em;
  color: var(--text-secondary);
}

.prose [data-footnote-ref] {
  padding-inline: 0.125rem;
  text-decoration-line: none;
}

/*
 * Fenced code inside the prose: same colours, simpler frame, and no line
 * numbers. A translucent grey rather than a surface colour, for the same
 * reason as the inline chips.
 */
.prose pre.syntax-highlighting {
  margin-block: 0 var(--rule);
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  padding: 1rem;
  font-size: 0.8125rem;
  line-height: 1.625;
  font-family: var(--font-mono);
  overflow-x: auto;
  background-color: color-mix(in oklab, var(--neutral-500) 9%, transparent);
}

/* ------------------------------------------------------------ empty state */

/* ------------------------------------------------------------------- cover */

/*
 * The way in. No top bar, no day list, no toggle: one link, centred, on the
 * plain reading surface rather than the chrome.
 *
 * `html` never scrolls, here as everywhere else. The copy is short enough to
 * sit on a phone without being clipped, and the cover keeps a scroller of its
 * own for the viewport short enough to prove that wrong.
 */
.cover {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  background-color: var(--story);
  padding: 2rem 1.5rem;
  text-align: center;
}

.cover__inner {
  max-width: 34rem;
}

.cover__eyebrow {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.cover__title {
  margin-top: 0.75rem;
  font-size: clamp(2rem, 7vw, 2.75rem);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--prose-headings);
}

.cover__lede {
  margin-top: 1.25rem;
  font-size: 1rem;
  line-height: 1.7;
  text-wrap: pretty;
  color: var(--prose-body);
}

.cover__lede--quiet {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.cover__start {
  display: inline-block;
  margin-top: 2rem;
  border-radius: 0.375rem;
  background-color: var(--ink-500);
  padding-inline: 1.25rem;
  padding-block: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: oklch(1 0 0);
  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.cover__start:hover {
  background-color: var(--ink-600);
}

.dark .cover__start:hover {
  background-color: var(--ink-400);
}

/* Small screens, and short ones: the cover has to fit a phone held either
   way round, and there is nothing here worth making it scroll for. */
@media (max-width: 30rem), (max-height: 40rem) {
  .cover {
    padding-block: 1.5rem;
  }

  .cover__lede {
    margin-top: 1rem;
    font-size: 0.9375rem;
    line-height: 1.6;
  }

  .cover__start {
    margin-top: 1.5rem;
  }
}

.empty-state {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding-inline: 1.5rem;
  text-align: center;
}

.empty-state h2 {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
}

.empty-state p {
  margin-top: 0.5rem;
  max-width: 28rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--text-muted);
}

.empty-state code {
  font-family: var(--font-mono);
}

/* ------------------------------------------------------------- wide layout */

/*
 * Matches the old `lg` breakpoint. Above it there is room for three panes at
 * once; below it the day list slides over the content instead of pushing it,
 * and the panes become a switch.
 */
@media (min-width: 64rem) {
  .scrim {
    display: none !important;
  }

  .sidebar {
    position: static;
    z-index: auto;
    width: 0;
    translate: 0 0;
    transition: width 200ms cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.is-open {
    width: 18rem;
  }

  .sidebar__close {
    display: none;
  }
}

@media (max-width: 63.9375rem) {
  .pane-switch {
    display: flex;
  }

  /* One pane at a time, so nothing is split and there is nothing to drag. */
  .panes {
    display: block;
    position: relative;
  }

  .splitter {
    display: none;
  }

  .story-column,
  .pane--code {
    height: 100%;
    flex: 1 1 auto;
  }

  .story-column {
    display: none;
  }

  .story-column > .pane--story,
  .story-column > .pane--notebook {
    height: 100%;
    flex: 1 1 auto;
  }

  .pane--code {
    display: none;
  }

  .panes[data-pane="story"] .story-column,
  .panes[data-pane="notebook"] .story-column {
    display: flex;
  }

  .panes[data-pane="story"] .pane--notebook,
  .panes[data-pane="notebook"] .pane--story {
    display: none;
  }

  .panes[data-pane="code"] .pane--code {
    display: flex;
  }

  /* Phones get a fixed narrow tree rather than a draggable one. */
  .tree-column {
    flex: 0 0 10rem;
    border-right: 1px solid var(--line);
  }
}
