:root {
  --paper: #eef1ec;
  --sheet: #f8faf7;
  --ink: #1e2a2f;
  --muted: #5c6a68;
  --rule: #c9d1cb;
  --accent: #2f6b5a;
  --accent-ink: #ffffff;
  --ochre: #a8741c;
  --danger: #a33a2f;
  --code-bg: #e3e8e2;
  --serif: "Literata", Georgia, serif;
  --sans: "Familjen Grotesk", system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #172022; --sheet: #1d282a; --ink: #dde5e0; --muted: #94a39f; --rule: #34433f;
    --accent: #7fc4ae; --accent-ink: #10201b; --ochre: #e0b05a; --danger: #ef8a7d; --code-bg: #243134;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #172022; --sheet: #1d282a; --ink: #dde5e0; --muted: #94a39f; --rule: #34433f;
  --accent: #7fc4ae; --accent-ink: #10201b; --ochre: #e0b05a; --danger: #ef8a7d; --code-bg: #243134;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 400 1.0625rem/1.7 var(--serif); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1.25rem; background: var(--paper); border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand span { font-weight: 400; color: var(--muted); margin-left: .3em; }
.doc-name { flex: 1; min-width: 0; color: var(--muted); font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-name:empty { display: none; }
.bar nav { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }

button, .button {
  font: 500 .9rem/1 var(--sans); color: var(--ink); background: transparent;
  border: 1px solid var(--rule); border-radius: 6px; padding: .55rem .85rem; cursor: pointer;
  display: inline-flex; align-items: center;
}
button:hover, .button:hover { border-color: var(--ink); }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.notice {
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  margin: 0 auto; padding: .6rem 1.25rem; font: .9rem/1.4 var(--sans);
  background: var(--sheet); border-bottom: 1px solid var(--rule); word-break: break-all;
}
.notice button { border: 0; font-size: 1.2rem; padding: .2rem .5rem; }

.files { max-width: 46rem; margin: 1rem auto 0; padding: 0 1.25rem; font-family: var(--sans); }
.files ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: 8px; background: var(--sheet); }
.files li { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem .9rem; border-top: 1px solid var(--rule); }
.files li:first-child { border-top: 0; }
.files a { color: var(--ink); text-decoration: none; word-break: break-all; }
.files a:hover { color: var(--accent); text-decoration: underline; }
.files time { color: var(--muted); font-size: .85rem; white-space: nowrap; }

main { padding: 2.5rem 1.25rem 6rem; }

/* Empty state: the drop sheet is the one loud thing on the site. */
.drop { display: grid; place-items: center; min-height: 68vh; }
.drop-box {
  width: min(34rem, 100%); padding: 3.5rem 2.25rem 2.5rem; background: var(--sheet);
  border: 2px dashed var(--rule); border-radius: 4px 4px 4px 28px;
  font-family: var(--sans); color: var(--muted);
}
.drop-title { margin: 0 0 .75rem; font: 700 clamp(2rem, 6vw, 3.1rem)/1.02 var(--sans); letter-spacing: -.03em; color: var(--ink); }
.drop-box p { margin: 0 0 1.75rem; max-width: 30ch; }
.dragging .drop-box { border-color: var(--accent); }
.drop-overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  font: 700 2.5rem var(--sans); color: var(--accent); letter-spacing: -.02em;
}

.error { max-width: 46rem; margin: 0 auto 2rem; padding: 1rem 1.25rem; border-left: 4px solid var(--danger); background: var(--sheet); font-family: var(--sans); }
.error pre { margin: .5rem 0 0; white-space: pre-wrap; font: .85rem/1.5 var(--mono); }

/* The document */
.prose { max-width: 42rem; margin: 0 auto; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--sans); line-height: 1.15; letter-spacing: -.015em; margin: 2.2em 0 .6em; }
.prose h1 { font-size: 2.6rem; letter-spacing: -.03em; margin-top: 0; }
.prose h2 { font-size: 1.75rem; }
.prose h3 { font-size: 1.3rem; }
.prose h4 { font-size: 1.05rem; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose pre { margin: 0 0 1.25em; }
.prose a { color: var(--accent); text-underline-offset: .18em; }
.prose strong { font-weight: 650; }
.prose li + li { margin-top: .3em; }
.prose li > p { margin: 0; }
.prose blockquote { margin-left: 0; padding-left: 1.25rem; border-left: 3px solid var(--rule); color: var(--muted); font-style: italic; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
.prose img { max-width: 100%; height: auto; border-radius: 4px; }
.prose code { font: .82em/1.5 var(--mono); background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
.prose pre { overflow-x: auto; padding: 1rem 1.15rem; background: var(--code-bg); border-radius: 6px; }
.prose pre code { background: none; padding: 0; font-size: .8rem; line-height: 1.65; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; font: .95rem/1.45 var(--sans); }
.prose th, .prose td { padding: .5rem .8rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.prose th { font-weight: 600; border-bottom-color: var(--ink); }
.prose input[type="checkbox"] { margin-right: .4em; }
.prose .contains-task-list { list-style: none; padding-left: .25rem; }

.callout { display: flex; gap: .85rem; margin: 0 0 1.25em; padding: .9rem 1.1rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; }
.callout > div > :last-child { margin-bottom: 0; }
.callout-icon { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; font: 700 .85rem/1 var(--sans); color: var(--accent-ink); background: var(--accent); margin-top: .2rem; }
.callout-title { font: 600 1rem/1.4 var(--sans); margin: .15rem 0 .35rem; }
.callout-warning .callout-icon { background: var(--ochre); }
.callout-warning { border-color: color-mix(in srgb, var(--ochre) 45%, var(--rule)); }
.callout-danger .callout-icon { background: var(--danger); }
.callout-danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--rule)); }
.badge { --badge: var(--accent); display: inline-block; font: 600 .78rem/1 var(--sans); padding: .25em .55em; border-radius: 99px; color: var(--badge); border: 1px solid currentColor; vertical-align: .1em; }
.details, .imports { margin: 0 0 1.25em; border: 1px solid var(--rule); border-radius: 6px; padding: .6rem 1rem; }
.details summary, .imports summary { cursor: pointer; font: 500 .95rem var(--sans); }
.details[open] summary { margin-bottom: .6rem; }
.imports { font-family: var(--sans); color: var(--muted); font-size: .9rem; }
.imports pre { font: .78rem/1.5 var(--mono); white-space: pre-wrap; margin: .6rem 0 0; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1.5rem; margin-bottom: 1.25em; }
.missing { margin: 0 0 1.25em; padding: .7rem 1rem; border: 1px dashed var(--rule); border-radius: 6px; font: .9rem/1.4 var(--sans); color: var(--muted); }
.missing-tag { font-family: var(--mono); font-size: .82rem; color: var(--ink); }
.missing-body { margin-top: .5rem; color: var(--ink); }

/* Code highlighting (highlight.js classes) */
.hljs-comment, .hljs-quote { color: var(--muted); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in { color: var(--accent); font-weight: 600; }
.hljs-string, .hljs-attr, .hljs-template-tag, .hljs-addition { color: var(--ochre); }
.hljs-number, .hljs-title, .hljs-section, .hljs-type, .hljs-name { color: var(--danger); }
.hljs-deletion { color: var(--danger); }

@media (max-width: 640px) {
  .bar { flex-wrap: wrap; padding: .6rem 1rem; }
  .doc-name { order: 3; flex-basis: 100%; }
  main { padding: 1.75rem 1rem 4rem; }
  .prose h1 { font-size: 2rem; }
  .drop-box { padding: 2.5rem 1.5rem 2rem; }
}
@media print {
  .bar, .notice, .files, .imports { display: none; }
  body { background: #fff; color: #000; }
  main { padding: 0; }
}
