:root {
  color-scheme: light dark;
  --bg: light-dark(#f7f8f8, #15191b);
  --surface: light-dark(#ffffff, #1c2225);
  --text: light-dark(#1d2528, #e2e7e8);
  --muted: light-dark(#5c6a70, #94a3a9);
  --line: light-dark(#d5dcde, #344045);
  --accent: light-dark(#17637a, #74c0d6);
  --on-accent: light-dark(#ffffff, #10191c);
  --error: light-dark(#a8322a, #f09a92);
  --serif: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, Georgia, serif;
  --sans: system-ui, sans-serif;
  /* Each text's height on the timeline. Smaller means faster scrolling. */
  --marker-height: 8px;
  /* The space between texts, which the connecting line fills. */
  --post-gap: 3.5rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.125rem/1.65 var(--serif);
}

a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button {
  padding: 0.55rem 1.1rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font: 600 0.95rem var(--sans);
  cursor: pointer;
}
.quiet { padding: 0.25rem; background: none; color: var(--muted); font: 400 0.95rem var(--sans); text-decoration: none; }
.quiet:hover { color: var(--text); }

.page {
  display: grid;
  grid-template-columns: minmax(0, 42rem) 13rem;
  justify-content: center;
  gap: 4rem;
  padding-inline: 1.5rem;
}

main { min-width: 0; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 5rem;
}
h1 { margin: 0; font: 600 1rem var(--sans); }

/* Editor */

.composer {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 8rem);
  min-height: calc(100dvh - 8rem);
  padding-bottom: 3rem;
}
.composer[inert] { opacity: 0.6; }

/* The box is a .post and the contents are .content, like a published text. */
.composer .post { display: flex; flex: 1; flex-direction: column; }
.title-input {
  width: 100%;
  margin: 0.35rem 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: 700 1.75rem/1.25 var(--serif);
}
.title-input:focus { outline: 0; }
::placeholder { color: var(--muted); opacity: 1; }

.composer trix-editor {
  flex: 1;
  min-height: 12rem;
  padding: 0;
  border: 0;
}
.composer trix-editor:focus { outline: 0; }
.composer trix-editor:empty::before { color: var(--muted); }

.composer trix-toolbar .trix-button-group--file-tools { display: none; }
.composer trix-toolbar .trix-button-row { flex-wrap: wrap; gap: 0.5rem; }
.composer trix-toolbar .trix-button-group { margin: 0 0 0.5rem; border-color: var(--line); }
.composer trix-toolbar .trix-button {
  border-color: var(--line);
  border-radius: 0;
  background: none;
  color: var(--text);
}
.composer trix-toolbar .trix-button.trix-active { background: light-dark(#cfe5ec, #86a9b5); }
.composer trix-toolbar .trix-dialog {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 4px 16px rgb(0 0 0 / 25%);
}
.composer trix-toolbar .trix-input--dialog { background: var(--bg); color: var(--text); border-color: var(--line); }
@media (prefers-color-scheme: dark) {
  /* Trix's icons are black images. */
  .composer trix-toolbar .trix-button--icon:not(.trix-active)::before { filter: invert(1); }
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}
.note { margin: 0; color: var(--muted); font: 0.875rem/1.4 var(--sans); }
/* Connects the editor to the newest text. The note wraps to stay clear of it. */
.composer-footer { position: relative; }
.composer-footer .note { max-width: calc(50% - 1rem); }
.composer:has(+ .posts > .post) .composer-footer::after {
  content: '';
  position: absolute;
  top: -1rem; /* The footer's margin. */
  bottom: -3rem; /* The composer's padding. */
  left: calc(50% - 1px);
  border-left: 2px dotted var(--accent);
}
.error { color: var(--error); }

/* Texts */

.posts { padding-bottom: 4rem; }
.post {
  position: relative;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  overflow-wrap: anywhere;
}
.post + .post { margin-top: var(--post-gap); }
/* Connects each box to the one above, across the gap between them. */
.post + .post::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 1px); /* Clears the box's border. */
  left: calc(50% - 1px);
  height: var(--post-gap);
  border-left: 2px dotted var(--accent);
}
.post > time, .post-date { color: var(--muted); font: 0.875rem var(--sans); }
.post h2 { margin: 0.35rem 0 0; font-size: 1.75rem; line-height: 1.25; text-wrap: balance; }
.empty { color: var(--muted); }

.content { margin-top: 0.75rem; }
.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }
/* Headings are h1 in the editor and h3 once published. */
.content h1, .content h3 { margin: 1.25rem 0 0.5rem; font: 600 1.3rem/1.3 var(--serif); }
.content blockquote {
  margin: 1rem 0;
  padding: 0 0 0 1rem;
  border: 0 solid var(--line);
  border-left-width: 3px;
  color: var(--muted);
}
.content pre {
  padding: 0.9rem;
  border-radius: 6px;
  background: light-dark(#e9eef0, #262f33);
  color: inherit;
  font: 0.9rem/1.5 ui-monospace, monospace;
  white-space: pre;
  overflow-x: auto;
  overflow-wrap: normal;
}
.content ul, .content ol { padding-left: 1.5rem; }

/* Timeline */

.timeline {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  font: 0.8125rem/1.35 var(--sans);
}
/* The fixed point that markers scroll past. */
.timeline::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-5px, -50%);
  pointer-events: none;
}

.rail {
  position: relative;
  height: 100%;
  overflow-y: scroll;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scrollbar-width: none;
  border-left: 1px solid var(--line);
  cursor: grab;
  user-select: none;
}
.rail.dragging { cursor: grabbing; }
.rail::-webkit-scrollbar { display: none; }
.rail:focus-visible { outline-offset: -2px; }

/* The padding lets the first and last markers reach the center. */
.rail ol {
  margin: 0;
  padding: calc(50vh - var(--marker-height) / 2) 0;
  padding-block: calc(50dvh - var(--marker-height) / 2);
  list-style: none;
}
.marker { position: relative; height: var(--marker-height); }
.marker::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 10px;
  height: 1px;
  background: var(--muted);
}
.marker[aria-current]::before { width: 14px; background: var(--accent); }
/* Only screen readers use these. Everyone else sees .current-label. */
.marker > * {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Stays beside the dot, and lets drags through to the timeline. */
.current-label {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  left: 1.5rem;
  display: flex;
  flex-direction: column;
  font-weight: 600;
  transform: translateY(-50%);
  pointer-events: none;
}
.marker-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow-wrap: anywhere;
}

/* Login */

.login { max-width: 22rem; margin: 20vh auto 0; padding-inline: 1.5rem; }
.login form { display: grid; gap: 0.75rem; margin-top: 1.5rem; font-family: var(--sans); }
.login input {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: 1rem var(--sans);
}
.login p { margin: 0; font-size: 0.95rem; }

@media (max-width: 50rem) {
  body { font-size: 1.0625rem; }
  .page { grid-template-columns: minmax(0, 1fr) 4.25rem; gap: 1rem; padding-inline: 1rem 0; }
  .timeline { font-size: 0.75rem; }
  .current-label { left: 1.1rem; }
  .marker-title { display: none; }
  .composer-footer { flex-direction: column; align-items: flex-start; }
  .post { padding: 1rem; }
  .post h2, .title-input { font-size: 1.45rem; }
}
