/* A worklog is a lab notebook: numbered, dated, written in prose, read slowly.
   So the prose is set in a serif, the chrome in a sans, and the page is one
   column of one width - the same width on the index, an entry, and everything
   else, so nothing moves when you click through.

   No webfonts. The stacks resolve to something good on every platform without
   a request, because a log that only looks right online does not look right. */

:root {
  color-scheme: light dark;

  --font-text: "Iowan Old Style", Charter, "Bitstream Charter", "Palatino Linotype",
               Palatino, Georgia, "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --paper: #faf8f3;
  --paper-sunk: #f2efe7;
  --ink: #1b1a15;
  --ink-soft: #423f36;
  --ink-faint: #7a756a;
  --rule: #e0dbcf;
  --rule-faint: #ebe7dd;
  --link: #1b4a76;
  --accent: #9c4221;
  --code-bg: #f3f0e8;
  --mark: #fbeeb0;

  /* Code, by what a token is rather than what language it is in. */
  --code-keyword: #8a3f8f;
  --code-string: #3d7a3a;
  --code-comment: #8f897b;
  --code-number: #b0571c;
  --code-function: #1f5f8b;
  --code-type: #8a6a00;

  --step--1: 0.8125rem;
  --step-0: 1.0625rem;
  --step-1: 1.1875rem;
  --step-2: 1.375rem;
  --step-3: 1.75rem;
  --step-4: 2.25rem;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.75rem;
  --space-4: 2.75rem;
  --space-5: 4rem;
  --space-6: 6.5rem;

  --page-width: 46rem;
  --radius: 0.375rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f0f12;
    --paper-sunk: #17171c;
    --ink: #eceae4;
    --ink-soft: #b8b4aa;
    --ink-faint: #858075;
    --rule: #33323a;
    --rule-faint: #24242a;
    --link: #8ab6e3;
    --accent: #e0845c;
    --code-bg: #202024;
    --mark: #4c421f;
    --code-keyword: #c99be0;
    --code-string: #a3c98a;
    --code-comment: #6f6b62;
    --code-number: #e8a46a;
    --code-function: #8cb8e3;
    --code-type: #e2c46e;
  }
}

*, *::before, *::after { box-sizing: border-box; }

/* The filters set `hidden` on a row, and the browser's own `[hidden]` rule is
   less specific than the class that gives that row a display. Filtering did
   nothing at all until this was here. It stays above every display rule. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.75;
}

::selection { background: var(--mark); color: var(--ink); }

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--accent); }

/* The shell: a rail that carries identity and navigation, and a column of
   content that is the same width on every page. */

/* Rail, column, contents. The third column is present on every page even when
   it is empty, so the reading column lands in the same place throughout. */
/* Three columns on any desktop: the rail, the reading column, and contents
   floating on the right. The side columns are the same width as each other at
   every width - they give way together - so the reading column is centred on
   the screen whether or not a page has contents. Two columns on a laptop put
   the rail and page centred as a pair, the page itself off to the right, and
   the contents above it. */
.shell {
  display: grid;
  grid-template-columns: minmax(10rem, 14rem) minmax(0, var(--page-width)) minmax(10rem, 14rem);
  gap: clamp(var(--space-3), 3.5vw, var(--space-5));
  justify-content: center;
  max-width: 88rem;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) var(--space-6);
}
@media (min-width: 62.0625rem) {
  .rail { grid-column: 1; grid-row: 1; }
  main { grid-column: 2; grid-row: 1; }
  .contents-rail { grid-column: 3; grid-row: 1; }
}


.contents-rail {
  position: sticky;
  top: var(--space-4);
  align-self: start;
  max-height: calc(100vh - var(--space-5));
  overflow-y: auto;
}
.contents-rail:empty { display: none; }

.rail {
  position: sticky;
  top: var(--space-4);
  align-self: start;
  max-height: calc(100vh - var(--space-5));
  overflow-y: auto;
}

.brand { padding-bottom: var(--space-3); border-bottom: 1px solid var(--rule); }
.brand-name {
  display: block;
  font-family: var(--font-text);
  font-size: var(--step-3);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
}
.brand-name:hover { color: var(--accent); }
.brand-line {
  margin: var(--space-1) 0 0;
  color: var(--ink-faint);
  font-size: var(--step--1);
  line-height: 1.5;
}

.rail-nav { display: flex; flex-direction: column; margin: var(--space-2) 0 var(--space-3); }
.rail-nav a {
  padding: 0.3rem 0 0.3rem var(--space-2);
  border-left: 2px solid transparent;
  margin-left: -1px;
  color: var(--ink-soft);
  font-size: var(--step--1);
  text-decoration: none;
}
.rail-nav a:hover { color: var(--ink); }
.rail-nav a[aria-current="page"] {
  border-left-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}

.rail-links {
  display: flex;
  flex-direction: column;
  padding-top: var(--space-2);
  margin-bottom: var(--space-3);
  border-top: 1px solid var(--rule);
}
.rail-links a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem var(--space-1);
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: var(--step--1);
  text-decoration: none;
}
.rail-links a:hover { background: var(--paper-sunk); color: var(--ink); }
.rail-links svg {
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
  color: var(--ink-faint);
}
.rail-links a:hover svg { color: var(--accent); }
/* An icon from a URL or a non-SVG file draws its own colours; it only takes
   the size. */
.rail-links img { width: 0.95rem; height: 0.95rem; flex: 0 0 auto; object-fit: contain; }

.rail-label {
  margin: 0 0 var(--space-1);
  color: var(--ink-faint);
  font-size: var(--step--1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.tree, .filters { padding-top: var(--space-3); border-top: 1px solid var(--rule); }

.tree ul { list-style: none; margin: 0; padding: 0; font-size: var(--step--1); }
.tree li { margin: 0; }
.tree a {
  display: block;
  padding: 0.25rem var(--space-1);
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.4;
}
.tree a:hover { background: var(--paper-sunk); color: var(--ink); }
.tree a[aria-current="page"] { color: var(--accent); font-weight: 600; }
/* Anything that folds says so with one small chevron, turned when open. The
   browser's own triangle is a different size in every engine. */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.tree > summary,
.tree .folder summary,
.toc > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tree > summary::before,
.tree .folder summary::before,
.toc > summary::before {
  content: "";
  flex: 0 0 auto;
  width: 0.35em;
  height: 0.35em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  opacity: 0.6;
  transition: transform 0.15s;
}
.tree[open] > summary::before,
.tree .folder details[open] > summary::before,
.toc[open] > summary::before { transform: rotate(45deg); }
.tree .count, .toc .count {
  margin-left: auto;
  color: var(--ink-faint);
  font-weight: 400;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.tree > summary { margin: 0 0 var(--space-1); }
.tree > summary .count { margin-left: 0.25rem; }

/* A folder names itself and then indents what is inside it, which is the shape
   the tree already has on disk. */
/* A folder reads like a row of the Areas list - same size, same weight, count
   on the right - rather than a bold heading of its own. */
.tree .folder summary {
  margin-top: 2px;
  padding: 0.25rem var(--space-1);
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: var(--step--1);
  line-height: 1.4;
}
.tree .folder details[open] > summary { color: var(--ink); }
.tree .folder summary:hover { background: var(--paper-sunk); }
.tree .folder summary a { display: inline; padding: 0; color: inherit; }
.tree .folder summary a:hover { background: none; text-decoration: underline; }
.tree .folder summary .count { opacity: 0.55; }
.tree .folder ul {
  margin: 0 0 var(--space-1) 0.7rem;
  padding-left: var(--space-1);
  border-left: 1px solid var(--rule);
}
/* A facet list, not a row of pills stacked: no borders, counts aligned, the
   whole line a target. */
.filters .chip {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  width: 100%;
  padding: 0.25rem var(--space-1);
  border: 0;
  border-radius: var(--radius);
  text-align: left;
}
.filters .chip:hover { background: var(--paper-sunk); color: var(--ink); }
.filters .chip[aria-pressed="true"] {
  background: transparent;
  color: var(--accent);
  font-weight: 600;
}
.filters .chip .count { margin: 0; opacity: 0.55; }

main { min-width: 0; }

@media (max-width: 62rem) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
    padding-top: var(--space-3);
  }
  .rail { position: static; max-height: none; }
  .rail-nav { flex-direction: row; flex-wrap: wrap; gap: var(--space-2); }
  .rail-nav a { border-left: 0; padding-left: 0; }
  .rail-nav a[aria-current="page"] { border-bottom: 2px solid var(--accent); }
  /* One row that scrolls sideways. Wrapped, eighteen areas were a wall
     between the masthead and the first entry. The fade says there is more. */
  .filters .chip { width: auto; flex: 0 0 auto; }
  .filters {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--space-1);
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: var(--space-2);
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
            mask-image: linear-gradient(to right, #000 85%, transparent);
  }
  .filters::-webkit-scrollbar { display: none; }
  .filters .rail-label { flex: 0 0 auto; width: auto; margin: 0 var(--space-1) 0 0; }
  .rail-links {
  display: flex;
  flex-direction: column;
  padding-top: var(--space-2);
  margin-bottom: var(--space-3);
  border-top: 1px solid var(--rule);
}
.rail-links a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem var(--space-1);
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: var(--step--1);
  text-decoration: none;
}
.rail-links a:hover { background: var(--paper-sunk); color: var(--ink); }
.rail-links svg {
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
  color: var(--ink-faint);
}
.rail-links a:hover svg { color: var(--accent); }

.rail-label { width: 100%; }
}

/* Controls ---------------------------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
}

/* A field, not a form: filled rather than outlined, so it sits in the page
   instead of being a box bolted onto it. */
.search { position: relative; flex: 1 1 16rem; min-width: 0; display: flex; align-items: center; }
.search svg {
  position: absolute;
  left: 0.8rem;
  width: 0.95rem;
  height: 0.95rem;
  color: var(--ink-faint);
  pointer-events: none;
}

input[type="search"] {
  width: 100%;
  padding: 0.55rem 0.9rem 0.55rem 2.3rem;
  font: inherit;
  font-size: var(--step--1);
  color: var(--ink);
  background: var(--paper-sunk);
  border: 1px solid transparent;
  border-radius: var(--radius);
  -webkit-appearance: none;
  appearance: none;
}
input[type="search"]::placeholder { color: var(--ink-faint); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[type="search"]:focus { outline: none; border-color: var(--rule); background: var(--paper); }
.search:focus-within svg { color: var(--accent); }

/* Two words you can click, rather than a segmented control. */
/* Two icons in one quiet frame; the one in use is filled. */
.switch {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
  padding: 2px;
  border-radius: calc(var(--radius) + 2px);
  background: var(--paper-sunk);
}
.switch button {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}
.switch button svg { width: 1rem; height: 1rem; }
.switch button:hover { color: var(--ink); }
.switch button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--rule-faint), 0 1px 2px rgb(0 0 0 / 0.12);
}
.switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.sort { display: flex; gap: var(--space-2); flex: 0 0 auto; }
.sort button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--step--1);
  color: var(--ink-faint);
  cursor: pointer;
}
.sort button:hover { color: var(--ink); }
.sort button[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
.sort button[aria-pressed="true"]::before { content: ""; }

.chip {
  font-family: var(--font-ui);
  font-size: var(--step--1);
  line-height: 1.6;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 1rem;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
}
.chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.chip .count { opacity: 0.6; margin-left: 0.35rem; font-variant-numeric: tabular-nums; }

#status {
  display: block;
  min-height: 1.3rem;
  margin: 0 0 var(--space-2);
  color: var(--ink-faint);
  font-size: var(--step--1);
}

/* The entry list ---------------------------------------------------------- */

.entries { list-style: none; margin: 0; padding: 0; }
.entries li + li { border-top: 1px solid var(--rule-faint); }

/* A heading per day, held at the top while its entries scroll under it, so a
   reader three screens into a long day still knows which one it is. */
.day + .day { margin-top: var(--space-3); }
.day-label {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0;
  padding: var(--space-1) 0;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.02em;
}
/* Time, wherever it is shown, is the quietest thing on the line. */
.took, .day-took { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.day-took { margin-left: auto; font-weight: 400; }
.row .meta .took { margin-left: -0.35rem; }
.row .meta .took::before, .dateline .took::before { content: "\00b7"; margin-right: 0.4rem; }
.dateline .took::before { margin: 0 0.4rem 0 0; }
.glance-stats .wide { grid-column: 1 / -1; }
.area-time { margin-right: 0.6rem; font-variant-numeric: tabular-nums; opacity: 0.8; }
@media (max-width: 62rem) { .area-time { display: none; } }

.day-count {
  color: var(--ink-faint);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* The whole row is the target. A title-only hit area in a list of summaries is
   a list that is annoying to use. */
.row {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  margin: 0 calc(var(--space-2) * -1);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.row:hover { background: var(--paper-sunk); }

/* The number is the log's own identifier, so it is legible rather than a
   footnote - but quiet, so the title still leads. */
.row .no {
  flex: 0 0 2.5rem;
  padding-top: 0.15rem;
  color: var(--ink-faint);
  font-family: var(--font-text);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-0);
  line-height: 1.35;
  text-align: right;
}
.row:hover .no { color: var(--accent); }

.row-main { min-width: 0; }
.row-title {
  display: block;
  font-family: var(--font-text);
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.row:hover .row-title { text-decoration: underline; text-decoration-thickness: 1px; }

/* Two lines at most. The summary is there to tell rows apart, and one that
   runs to five lines makes the list a column of paragraphs. */
.row .summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-family: var(--font-text);
  margin-top: 0.3rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.55;
}
.row .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.3rem;
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.row .meta time { font-variant-numeric: tabular-nums; }

/* A row reached by keyboard is the row you are on. */
.row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--paper-sunk);
}
.row:focus-visible .no { color: var(--accent); }

/* Compact: one line an entry, for a reader who knows what they are looking
   for and wants all of them in view. The full title is on hover. */
.days.compact .day + .day { margin-top: var(--space-2); }
.days.compact .row { padding: 0.4rem var(--space-2); align-items: baseline; }
.days.compact .row .summary,
.days.compact .row .meta { display: none; }
.days.compact .row .no { font-size: var(--step--1); padding-top: 0; font-family: var(--font-ui); }
.days.compact .row-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: var(--step-0);
  font-weight: 500;
}
.days.compact .entries li + li { border-top-color: transparent; }


/* The log at a glance ----------------------------------------------------- */

.glance { font-family: var(--font-ui); font-size: var(--step--1); }
.glance-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5rem, 1fr));
  gap: var(--space-1);
  margin: 0 0 var(--space-3);
}
.glance-stats div {
  padding: var(--space-1) 0.75rem;
  border: 1px solid var(--rule-faint);
  border-radius: var(--radius);
}
.glance-stats dt {
  color: var(--ink-faint);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}
.glance-stats dd {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--step-3);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.glance-stats dd a { color: var(--accent); text-decoration: none; }
.glance-stats dd a:hover { text-decoration: underline; }

/* Entries over time. Each bar is a day (or a week, or a month, for a long
   log) and goes to that day in the list. */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 4.5rem;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--rule);
}
.spark > * { flex: 1 1 0; min-width: 1px; }
.spark a {
  height: var(--h);
  background: var(--ink-faint);
  border-radius: 1px 1px 0 0;
  opacity: 0.55;
}
.spark a:hover { background: var(--accent); opacity: 1; }
.spark span { height: 1px; }
.spark-axis {
  display: flex;
  justify-content: space-between;
  margin: 0.3rem 0 var(--space-3);
  color: var(--ink-faint);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.keys { margin: 0; color: var(--ink-faint); font-size: 0.75rem; }
kbd {
  display: inline-block;
  min-width: 1.4em;
  margin: 0 0.15em;
  padding: 0 0.3em;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 0.25rem;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-align: center;
}

/* On a phone the glance would sit above the list, pushing the first entry down
   for numbers that matter less than it. It goes; the open count is in the nav
   anyway. */
@media (max-width: 62rem) {
  .contents-rail:has(.glance) { display: none; }
}

.empty { color: var(--ink-faint); padding: var(--space-4) 0; }

.entries h3 {
  font-family: var(--font-text);
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}
.entries h3 a { color: var(--ink); text-decoration: none; }
.entries h3 a:hover { text-decoration: underline; }
.entries li > .meta, .entries li > .summary { padding: 0 var(--space-2); }
.entries li > .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: var(--space-3) 0 var(--space-1);
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.entries li > .summary {
  font-family: var(--font-text);
  margin: var(--space-1) 0 var(--space-3);
  color: var(--ink-soft);
  font-size: var(--step-0);
}
.entries li > h3 { padding: 0 var(--space-2); }

h2.section {
  margin: var(--space-4) 0 var(--space-2);
  font-family: var(--font-text);
  font-size: var(--step-2);
  font-weight: 600;
}
h2.section a { color: var(--ink); text-decoration: none; }
h2.section a:hover { color: var(--accent); }

/* How sure a page is, in words, quiet - except a guess, which is the one a
   reader should not lean on. */
.status { letter-spacing: 0.04em; }
.status--solid, .status--partial { color: var(--ink-faint); }
.status--guess { color: var(--accent); }

/* The reference index: a section is headed like a day on the entry list, and
   says what it is before its pages. */
.doc-section + .doc-section, .doc-list + .doc-section { margin-top: var(--space-4); }
.doc-section .day-label a { color: inherit; text-decoration: none; }
.doc-section .day-label a:hover { color: var(--accent); }
.section-lead {
  margin: var(--space-2) 0 var(--space-1);
  color: var(--ink-soft);
  font-family: var(--font-text);
}

/* Contents ---------------------------------------------------------------- */

.toc { font-family: var(--font-ui); font-size: var(--step--1); line-height: 1.5; }
.toc-label {
  margin: 0 0 var(--space-1);
  font-size: var(--step--1);
  color: var(--ink-faint);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 0.2rem var(--space-1);
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink-soft);
  text-decoration: none;
}
.toc a:hover { background: var(--paper-sunk); color: var(--ink); }
.toc .toc-3 a { padding-left: var(--space-2); color: var(--ink-faint); }

/* Where they sit beside the page, the Reference and Contents labels are labels,
   like Areas and This log: nothing to fold, so no chevron and no toggle. */
@media (min-width: 62.0625rem) {
  .tree > summary { pointer-events: none; }
  .tree > summary::before { display: none; }
}
@media (min-width: 62.0625rem) {
  .toc > summary { pointer-events: none; }
  .toc > summary::before { display: none; }
}

/* On a phone, contents sits above the prose rather than vanishing. */
@media (max-width: 62rem) {
  .contents-rail {
    position: static;
    max-height: none;
    order: 0;
    padding: var(--space-2) var(--space-3);
    background: var(--paper-sunk);
    border-radius: var(--radius);
  }
  .rail { order: -1; }
  main { order: 1; }
}


/* One entry --------------------------------------------------------------- */

article { max-width: none; }

.entry-number {
  display: block;
  margin: 0 0 var(--space-1);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

article h1 {
  font-family: var(--font-text);
  font-size: var(--step-4);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-2);
}
article h2 {
  font-family: var(--font-text);
  font-size: var(--step-1);
  font-weight: 600;
  margin: var(--space-4) 0 var(--space-2);
  scroll-margin-top: var(--space-3);
}
article p, article li { font-family: var(--font-text); line-height: 1.7; }
article p { margin: 0 0 var(--space-3); overflow-wrap: break-word; }
article ul, article ol { margin: 0 0 var(--space-3); padding-left: 1.4rem; }
article li { margin-bottom: var(--space-1); }
article img { max-width: 100%; height: auto; }
article > *:last-child { margin-bottom: 0; }

.dateline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--rule);
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.dateline time { font-variant-numeric: tabular-nums; }
.dateline .from { color: var(--ink-faint); }
/* A section's own evidence, under its heading: quieter than the page's. */
.section-from { margin: -0.4rem 0 var(--space-2); padding: 0; border: 0; font-size: 0.85em; }
.section-from .chip { padding: 0 0.5rem; }
.chip--elsewhere { border-style: dashed; }
/* The evidence a reference page rests on, as the entries' own numbers. */
.dateline .evidence {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0 0.55rem;
  font-variant-numeric: tabular-nums;
}
.dateline .evidence a { color: var(--ink-soft); }
.dateline .evidence a:hover { color: var(--accent); }
/* Links in a dateline are metadata, not body links: they take the meta colour
   and earn the accent on hover rather than arriving blue and underlined. */
.dateline a { color: inherit; text-decoration: none; }
.dateline a.chip:hover { border-color: var(--accent); color: var(--accent); }

.dateline .chip { text-decoration: none; }
.dateline .chip:hover { border-color: var(--ink-faint); color: var(--ink); }

.files {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.75rem;
  margin: calc(var(--space-4) * -1 + var(--space-2)) 0 var(--space-4);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.files-label {
  color: var(--ink-faint);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.files a { color: var(--ink-soft); text-decoration: none; }
.files a:hover { color: var(--accent); }
.files code { font-size: 0.95em; background: none; padding: 0; }
/* What a reference page covers: items, not links, quieter than an entry's
   files, comma-separated within a group. */
.covers code { color: var(--ink-soft); }
.covers .files-group { gap: 0 0.5rem; }
.covers .files-group code:not(:last-child)::after { content: ","; color: var(--ink-faint); }

/* A directory is said once and its files follow it, so the directory is the
   quiet part and the names are what the eye lands on. */
.files-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.6rem;
}
.files-dir {
  /* Cancels the group's gap: the directory and its first file are one path. */
  margin-right: -0.6rem;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 0.95em;
}

/* Past a handful the list folds behind its count. It is still one line of
   chrome above the prose, not a wall of paths. */
details.files { display: block; }
details.files summary {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  cursor: pointer;
  list-style: none;
  width: fit-content;
}
details.files summary::-webkit-details-marker { display: none; }
details.files summary::after {
  content: "";
  width: 0.4em;
  height: 0.4em;
  border-right: 1.5px solid var(--ink-faint);
  border-bottom: 1.5px solid var(--ink-faint);
  transform: translateY(-0.2em) rotate(45deg);
  transition: transform 0.15s;
}
details.files[open] summary::after { transform: translateY(0.05em) rotate(-135deg); }
.files-count { color: var(--ink-soft); }
details.files summary:hover .files-count { color: var(--accent); }
.files-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-left: 2px solid var(--rule);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--rule-faint);
  border-left: 2px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-3);
  overflow-x: auto;
  font-size: var(--step--1);
  line-height: 1.6;
}
code { font-family: var(--font-mono); font-size: 0.9em; }
p code, li code, td code, .summary code {
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
}
pre code { background: none; padding: 0; }

/* Code named in prose: a link to its lines, quiet until hovered. */
a.code-ref { text-decoration: none; }
a.code-ref code { color: var(--link); }
a.code-ref:hover code { text-decoration: underline; }
.code-ref--missing { text-decoration: line-through; color: var(--ink-faint); cursor: help; }
/* Code embedded from the repository: a block with where it came from above it. */
.code-embed { margin: 0 0 var(--space-3); }
.code-embed figcaption {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.4rem var(--space-3);
  border: 1px solid var(--rule-faint);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--paper-sunk);
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.code-embed figcaption code { background: none; padding: 0; }
.code-embed pre { margin: 0; border-top-left-radius: 0; border-top-right-radius: 0; }

/* Highlighted code. A handful of scopes carry colour; everything else - the
   punctuation, the operators, the plain identifiers - stays ink, so the
   colour means something when it appears. */
.hl-comment { color: var(--code-comment); font-style: italic; }
.hl-string { color: var(--code-string); }
.hl-constant.hl-numeric, .hl-constant.hl-language,
.hl-constant.hl-character { color: var(--code-number); }
.hl-keyword, .hl-storage { color: var(--code-keyword); }
.hl-keyword.hl-operator { color: inherit; }
.hl-entity.hl-name.hl-function, .hl-support.hl-function,
.hl-entity.hl-name.hl-tag, .hl-markup.hl-heading { color: var(--code-function); }
.hl-storage.hl-type, .hl-support.hl-type, .hl-entity.hl-name.hl-type,
.hl-entity.hl-name.hl-class, .hl-entity.hl-name.hl-struct,
.hl-entity.hl-name.hl-section { color: var(--code-type); }

blockquote {
  margin: 0 0 var(--space-3);
  padding-left: var(--space-3);
  border-left: 2px solid var(--rule);
  color: var(--ink-soft);
  font-style: italic;
}

.table-scroll { overflow-x: auto; margin: 0 0 var(--space-3); }
table { border-collapse: collapse; width: 100%; font-family: var(--font-ui); font-size: var(--step--1); }
th, td { text-align: left; padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--rule-faint); vertical-align: top; }
/* The first column is usually what a row is - a page, a field, a name - and a
   long last column squeezed it to a word a line. It keeps enough room to be
   read; the table scrolls in its own box before it gives that up. */
td:first-child, th:first-child { min-width: 9rem; }
th {
  font-weight: 600;
  white-space: nowrap;
  border-bottom-color: var(--rule);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.9em;
  color: var(--ink-faint);
}

/* A correction, which is why the log is append-only ------------------------ */

.notice {
  background: var(--paper-sunk);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-4);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  line-height: 1.65;
}
.notice p { margin: 0; font-family: inherit; }
.notice p + p { margin-top: var(--space-1); }

.unknown {
  margin-top: var(--space-5);
  padding: var(--space-3);
  background: var(--paper-sunk);
  border-radius: var(--radius);
  font-family: var(--font-text);
  color: var(--ink-soft);
}
.unknown strong {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.unknown p { margin: 0; }
/* A trailer may be a list of questions rather than one. */
.unknown-text ul, .unknown-text ol { margin: 0; padding-left: 1.2rem; }
.unknown-text li + li, .unknown-text p + p { margin-top: var(--space-1); }

/* A question a later entry answered: kept where it was asked, struck through
   the way a notebook strikes one out, with the answer named. */
.unknown--answered { opacity: 0.85; }
.unknown--answered strong { color: var(--ink-faint); }
.unknown--answered > .unknown-text { text-decoration: line-through; color: var(--ink-faint); }
.unknown--answered .numbered .closed { text-decoration: none; }
/* Carried: still open, elsewhere. Quiet, never struck. */
.unknown--carried > .unknown-text { color: var(--ink-faint); }
/* A list trailer, numbered: those numbers are how a later entry names one. */
.unknown .numbered { margin: 0; padding-left: 1.6rem; }
.unknown .numbered li + li { margin-top: var(--space-1); }
.unknown .numbered li::marker { color: var(--ink-faint); font-family: var(--font-ui); font-size: var(--step--1); }
.unknown .numbered .closed .q-text { text-decoration: line-through; color: var(--ink-faint); }
.unknown .numbered .carried .q-text { color: var(--ink-faint); }
.q-note {
  display: block;
  margin-top: 0.15rem;
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.q-note a { color: var(--ink-soft); }
.unknown .answered {
  margin-top: var(--space-1);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: var(--ink-soft);
}

nav.pager {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  line-height: 1.5;
}
nav.pager a { flex: 1 1 0; text-decoration: none; color: var(--ink-soft); }
nav.pager a:hover { color: var(--accent); }
nav.pager .next { text-align: right; margin-left: auto; }
nav.pager .label {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

/* Open questions ---------------------------------------------------------- */

.lead {
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--rule);
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}

.questions { list-style: none; margin: 0; padding: 0; }
/* One card an entry: its number in the gutter as on the index, its title,
   then what it left open. Only these are rows - a trailer written as a list
   has items of its own, and they are not. */
.questions > li {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) 0;
}
.questions > li + li { border-top: 1px solid var(--rule-faint); }
.q-no {
  flex: 0 0 2.5rem;
  padding-top: 0.1rem;
  color: var(--ink-faint);
  font-family: var(--font-text);
  font-size: var(--step-0);
  font-variant-numeric: tabular-nums;
  text-align: right;
  text-decoration: none;
}
.q-no:hover { color: var(--accent); }
.q-main { flex: 1 1 auto; min-width: 0; }
.q-title {
  display: block;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
}
.q-title:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.q-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.3rem 0 var(--space-2);
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.q-meta time { font-variant-numeric: tabular-nums; }
.q-count { color: var(--accent); }
.question {
  color: var(--ink-soft);
  font-family: var(--font-text);
  font-size: var(--step-0);
  line-height: 1.6;
}
.question p { margin: 0; }
.question p + p, .question p + ul, .question ul + p { margin-top: var(--space-1); }
.question ul, .question ol { margin: 0; padding-left: 1.1rem; }
.question ol.numbered { padding-left: 1.6rem; }
.question ol.numbered li::marker { color: var(--ink-faint); font-family: var(--font-ui); font-size: var(--step--1); }
.question ol.numbered .closed { text-decoration: line-through; color: var(--ink-faint); }
.question li + li { margin-top: 0.4rem; }
.question li::marker { color: var(--accent); }
/* The rest of a long list, folded in the page as served. Its summary sits where
   the next item would, and opening it only adds below - nothing above moves. */
.question details.more > ul, .question details.more > ol { margin-top: 0.4rem; }
.question details.more > summary {
  margin-top: 0.4rem;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.question details.more > summary:hover { text-decoration: underline; }
.question details.more[open] > summary { display: none; }

/* Open and closed: one list, two views. Which rows show first is decided
   here rather than by a script, so the page is laid out right from the start. */
.questions > li[data-state="closed"] { display: none; }
.questions.show-closed > li[data-state="closed"] { display: flex; }
.questions.show-closed > li[data-state="open"] { display: none; }
.questions > li[data-state="closed"] .question { color: var(--ink-faint); }
.questions > li[data-state="closed"] .question li::marker { color: var(--ink-faint); }
.q-closed { color: var(--link); }
.q-closed a { color: inherit; }

/* A switch of words rather than icons, for a choice an icon would not say. */
.switch--words button { width: auto; padding: 0 0.7rem; gap: 0.4rem; display: flex; font: inherit; font-size: var(--step--1); }
.switch--words .count { color: var(--ink-faint); font-variant-numeric: tabular-nums; }



footer {
  margin-top: var(--space-6);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
  color: var(--ink-faint);
  font-size: var(--step--1);
}
footer p { margin: 0; }
footer a { color: var(--ink-faint); }

mark { background: var(--mark); color: inherit; padding: 0 0.1em; }

@media (max-width: 46rem) {
  :root {
    --step-0: 1rem;
    --step-4: 1.75rem;
    --space-3: 1.35rem;
    --space-5: 2.75rem;
    --space-6: 3.5rem;
  }
  nav.pager { flex-direction: column; gap: var(--space-2); }
  nav.pager .next { text-align: left; }
}

/* [colors] from cairns.toml */
@media (prefers-color-scheme: light) {
  :root {
    --accent: #3f8f1a;
    --code-bg: #efedf5;
    --code-comment: #87859a;
    --code-function: #6d3fc0;
    --code-keyword: #c2410c;
    --code-number: #b45309;
    --code-string: #3f7f12;
    --code-type: #0b6aa8;
    --ink: #1c1b20;
    --ink-faint: #7a788c;
    --ink-soft: #47455a;
    --link: #5a3fc0;
    --mark: #dff3c8;
    --paper: #f7f6fa;
    --paper-sunk: #edebf3;
    --rule: #dad7e4;
    --rule-faint: #e7e5ee;
  }
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #7ac943;
    --code-bg: #1b1a21;
    --code-comment: #807e90;
    --code-function: #d9c6ff;
    --code-keyword: #ff7a59;
    --code-number: #ffb84d;
    --code-string: #9bdc5f;
    --code-type: #7ec8ff;
    --ink: #ecebf0;
    --ink-faint: #85839a;
    --ink-soft: #bcbac7;
    --link: #b9a8ff;
    --mark: #2f4a1e;
    --paper: #151419;
    --paper-sunk: #1d1c23;
    --rule: #2e2c37;
    --rule-faint: #23222a;
  }
}
