/* Prior Ledger — Register. Paper, ink, one amber, one stamp red. */

@font-face { font-family: "Libre Caslon Text"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/libre-caslon-text-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Libre Caslon Text"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/libre-caslon-text-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Libre Caslon Text"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/libre-caslon-text-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --paper: #F4F0E6;
  --ink: #1C1B18;
  --pencil: #5E584C;
  --rule: #D6CDB9;
  --amber: #9A5A14;
  --red: #A3362A;
  --wash: #EBE5D7;
  --serif: "Libre Caslon Text", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --margin: 150px;
  --gap: 28px;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--serif); font-size: 18px; line-height: 1.62; }
a { color: var(--amber); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
code, pre, .mono { font-family: var(--mono); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; background: var(--paper); padding: 8px 12px; z-index: 2; }

header.page, main, .notes, footer.page { max-width: 1120px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 72px); }

/* ---------------------------------------------------------------- masthead */

header.page { padding-top: 44px; }
.topline { display: flex; justify-content: space-between; align-items: center; }
.label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--pencil); }
.mark { display: block; }
h1 { margin: 20px 0 6px; font-size: clamp(44px, 7vw, 68px); font-weight: 400; line-height: 1.05; letter-spacing: -0.01em; }
.tagline { margin: 0; font-size: 20px; font-style: italic; color: var(--pencil); }

.status {
  margin: 26px 0 0; padding: 10px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-family: var(--mono); font-size: 13px; color: var(--pencil); display: flex; flex-wrap: wrap; gap: 6px 22px;
}
.status .ok { color: var(--amber); }
.status .bad { color: var(--red); }
.status a { color: inherit; }

.lede { max-width: 68ch; margin: 22px 0 0; }
.links { display: flex; flex-wrap: wrap; gap: 8px 26px; margin: 16px 0 0; font-family: var(--mono); font-size: 13px; }

/* ---------------------------------------------------------------- controls */

.controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 20px;
  padding-bottom: 18px; border-bottom: 1px solid var(--ink);
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field.grow { flex: 1 1 280px; }
.field label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--pencil); }
.field input[type=search], .field select {
  font: inherit; font-size: 16px; color: var(--ink); background: transparent;
  border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; padding: 8px 2px; min-height: 44px;
}
.field select { font-family: var(--mono); font-size: 13px; padding-right: 22px; cursor: pointer; }
.field input[type=search]:focus, .field select:focus { border-bottom-color: var(--amber); outline: none; }
.field.check { flex-direction: row; align-items: center; gap: 8px; min-height: 44px; }
.field.check input { width: 18px; height: 18px; accent-color: var(--amber); margin: 0; }
.field.check label { letter-spacing: 0.08em; }

.filter-note { font-family: var(--mono); font-size: 13px; color: var(--pencil); margin: 14px 0 0; }
.filter-note button { font: inherit; color: var(--amber); background: none; border: 0; padding: 0 0 0 10px; cursor: pointer; text-decoration: underline; }

/* ---------------------------------------------------------------- the register */

.entries { list-style: none; margin: 0; padding: 0; }
.entry {
  display: grid; grid-template-columns: var(--margin) minmax(0, 1fr); column-gap: var(--gap);
  padding: 30px 0 28px; border-bottom: 1px solid var(--rule); scroll-margin-top: 24px;
}
.entry.target { background: linear-gradient(var(--wash), var(--wash)) no-repeat; background-size: 100% 100%; }
.margin { display: flex; flex-direction: column; gap: 4px; font-family: var(--mono); }
.number { font-size: 16px; font-weight: 500; color: var(--amber); text-decoration: none; }
.number:hover { color: var(--ink); }
.when { font-size: 12px; color: var(--pencil); }

.meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pencil);
}
.meta .subject { color: var(--pencil); text-transform: none; letter-spacing: 0.02em; }
.meta .subject:hover { color: var(--amber); }
.meta .actor { text-transform: none; letter-spacing: 0.02em; }

.stamp {
  display: inline-block; border: 1.5px solid currentColor; padding: 1px 8px; transform: rotate(-2deg);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; line-height: 1.5;
}
.stamp.stated { color: var(--red); }
.stamp.confirmed { color: var(--amber); }
.stamp.inferred { color: var(--pencil); border-style: dashed; }

.body { margin: 14px 0 0; max-width: 72ch; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry.superseded .body { color: var(--pencil); }

.notice { margin: 14px 0 0; font-family: var(--mono); font-size: 13px; color: var(--red); }
.notice a { color: var(--red); }
.notice.quiet { color: var(--pencil); }
.notice.quiet a { color: var(--amber); }

.foot {
  display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 16px 0 0;
  font-family: var(--mono); font-size: 12px; color: var(--pencil);
}
.foot a { color: var(--pencil); }
.foot a:hover { color: var(--amber); }
.foot .copy { font: inherit; color: var(--pencil); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.foot .copy:hover { color: var(--amber); }

.empty { font-style: italic; color: var(--pencil); padding: 30px 0; }
.more { padding: 24px 0 0; }
.more button {
  font-family: var(--mono); font-size: 13px; color: var(--ink); background: transparent;
  border: 1px solid var(--ink); padding: 10px 18px; min-height: 44px; cursor: pointer;
}
.more button:hover { background: var(--ink); color: var(--paper); }

/* ---------------------------------------------------------------- notes */

.notes {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px;
  margin-top: 80px;
}
.notes::before { content: ""; grid-column: 1 / -1; border-top: 1px solid var(--ink); margin-bottom: -10px; }
.notes h2 { font-size: 22px; font-weight: 400; font-style: italic; margin: 0 0 12px; }
.notes p { font-size: 16px; margin: 0 0 12px; }
.notes dl { margin: 0 0 12px; display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; align-items: baseline; font-size: 16px; }
.notes dd { margin: 0; }
.notes pre {
  margin: 0 0 12px; padding: 14px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-size: 12px; line-height: 1.6; white-space: pre; overflow-x: auto;
}
.endpoint { font-family: var(--mono); font-size: 13px !important; color: var(--pencil); }
.endpoint code { color: var(--ink); overflow-wrap: anywhere; }
.mirrors { font-family: var(--mono); font-size: 13px !important; color: var(--pencil); display: flex; flex-wrap: wrap; gap: 4px 14px; }

footer.page { margin-top: 60px; padding-bottom: 60px; }
footer.page p { margin: 0; padding-top: 18px; border-top: 1px solid var(--rule); font-family: var(--mono); font-size: 12px; color: var(--pencil); }


/* ---------------------------------------------------------------- views */

.views {
  max-width: 1120px; margin: 34px auto 0; padding: 0 clamp(20px, 5vw, 72px);
  display: flex; flex-wrap: wrap; gap: 4px 30px;
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
}
.views::after { content: ""; flex-basis: 100%; height: 0; border-bottom: 1px solid var(--ink); margin-top: -1px; }
.views a { padding: 10px 0 12px; color: var(--pencil); text-decoration: none; border-bottom: 3px solid transparent; }
.views a:hover { color: var(--ink); }
.views a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--amber); padding-bottom: 9px; }
main { margin-top: 26px; }
.view[hidden], .partial[hidden] { display: none; }
body.reading .lede, body.reading .links { display: none; }

.partial {
  margin: 0 0 18px; padding: 10px 14px; background: var(--wash);
  font-family: var(--mono); font-size: 13px; color: var(--pencil);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
}
.status button, .partial button, .btn {
  font: inherit; font-family: var(--mono); font-size: 13px; color: var(--ink); background: transparent;
  border: 1px solid var(--ink); padding: 6px 12px; min-height: 36px; cursor: pointer;
}
.status button:hover, .partial button:hover, .btn:hover { background: var(--ink); color: var(--paper); }
button.plain { font: inherit; color: inherit; background: none; border: 0; padding: 0 6px; min-width: 32px; min-height: 32px; cursor: pointer; }
button.plain:disabled { color: var(--rule); cursor: default; }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-family: var(--mono); font-size: 12px; }
.chips::before { content: attr(aria-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--pencil); margin-right: 6px; }
.chips.small::before { content: none; }
.chips button {
  font: inherit; letter-spacing: 0.04em; min-height: 36px; padding: 6px 12px; cursor: pointer;
  color: var(--ink); background: transparent; border: 1px solid var(--rule);
}
.chips button .n { opacity: 0.75; margin-left: 4px; }
.chips button.zero { color: #7d766a; }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* compact entry rows (calendar day, threads, relations) */
.compact { list-style: none; margin: 0; padding: 0; }
.compact > li { display: grid; grid-template-columns: 92px minmax(0, 1fr); column-gap: 22px; padding: 22px 0 20px; border-bottom: 1px solid var(--rule); }
.compact .num { display: flex; flex-direction: column; gap: 2px; font-family: var(--mono); }
.compact .num a { font-size: 16px; font-weight: 500; color: var(--amber); text-decoration: none; }
.compact .num a:hover { color: var(--ink); }
.compact .num span { font-size: 12px; color: var(--pencil); }
.compact .excerpt { margin: 10px 0 0; max-width: 68ch; }
.compact li.superseded .excerpt { color: var(--pencil); }
.compact .foot { margin-top: 10px; }
.compact .red { color: var(--red); }
.compact.small > li { display: block; padding: 16px 0 14px; }
.compact.small .line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; font-family: var(--mono); font-size: 12px; color: var(--pencil); }
.compact.small .line a.n { font-size: 15px; font-weight: 500; color: var(--amber); text-decoration: none; }
.compact.small .line .k { letter-spacing: 0.08em; text-transform: uppercase; }
.compact.small .line a { color: var(--pencil); }
.compact.small p { margin: 6px 0 0; font-size: 15px; line-height: 1.55; }
.compact.small .none { font-family: var(--mono); font-size: 12px; color: var(--pencil); }

/* calendar */
#cal-kinds { margin-bottom: 26px; }
.cal-layout { display: flex; flex-wrap: wrap; gap: 40px; align-items: flex-start; }
.cal-month { flex: 1 1 400px; max-width: 520px; min-width: 0; }
.cal-day { flex: 999 1 480px; min-width: 0; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head h2, .cal-day-head h2, .subj-list-head h2 { margin: 0; font-size: 24px; font-weight: 400; }
.cal-head h2 em { font-style: italic; }
button.round { width: 44px; height: 44px; border: 1px solid var(--rule); border-radius: 50%; background: transparent; color: var(--ink); font-size: 18px; cursor: pointer; }
button.round:disabled { color: var(--rule); cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; font-family: var(--mono); }
.cal-grid .dow { text-align: center; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--pencil); padding-bottom: 4px; }
.cal-grid button {
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
  height: 64px; padding: 8px; border: 1px solid var(--rule); border-radius: 6px; background: transparent;
  color: var(--ink); font: inherit; font-family: var(--mono); text-align: left; cursor: pointer;
}
.cal-grid button.has { background: var(--wash); }
.cal-grid button:disabled { border-color: transparent; color: #b7ae9c; cursor: default; background: transparent; }
.cal-grid button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.cal-grid .d { font-size: 14px; }
.cal-grid .today .d { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; font-weight: 500; }
.badge {
  display: inline-block; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--amber); color: var(--paper);
  font-family: var(--mono); font-size: 12px; font-weight: 500; line-height: 24px; text-align: center;
}
.cal-grid .badge { align-self: flex-end; }
.cal-legend { margin: 14px 0 0; font-family: var(--mono); font-size: 12px; color: var(--pencil); display: flex; flex-wrap: wrap; gap: 4px 18px; }
.cal-legend .badge { min-width: 18px; height: 18px; line-height: 18px; font-size: 11px; padding: 0 5px; }
.cal-legend .today-mark { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.cal-legend .quiet { color: #7d766a; }
.cal-year { margin-top: 30px; padding-top: 12px; border-top: 1px solid var(--rule); }
.cal-year-head { display: flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 12px; color: var(--pencil); }
.cal-year-head #year-title { letter-spacing: 0.12em; }
.cal-year-head .spacer { flex: 1 1 auto; }
.cal-months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; margin-top: 8px; align-items: end; }
.cal-months button {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 70px;
  background: none; border: 0; padding: 0; font-family: var(--mono); font-size: 10px; color: #7d766a; cursor: pointer;
}
.cal-months button:disabled { cursor: default; }
.cal-months .bar { width: 70%; border-radius: 2px; background: var(--rule); }
.cal-months .bar.on { background: var(--amber); }
.cal-months button.current { color: var(--ink); font-weight: 500; }
.cal-day-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; padding-bottom: 12px; border-bottom: 1px solid var(--ink); }
.cal-day-head span { font-family: var(--mono); font-size: 13px; color: var(--pencil); }
.cal-day .empty { padding: 24px 0 0; }

/* subjects */
.subj-layout { display: flex; flex-wrap: wrap; gap: 44px; align-items: flex-start; }
.subj-list { flex: 1 1 320px; max-width: 400px; min-width: 0; }
.subj-thread { flex: 999 1 520px; min-width: 0; }
.subj-list-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.subj-list ul { list-style: none; margin: 14px 0 0; padding: 0; border-top: 1px solid var(--rule); max-height: 70vh; overflow-y: auto; }
.subj-list li a {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; padding: 10px 12px;
  border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none;
}
.subj-list li a:hover { background: var(--wash); }
.subj-list li a[aria-current="true"] { background: var(--ink); color: var(--paper); }
.subj-list .name { font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; }
.subj-list .facts { display: flex; gap: 14px; font-family: var(--mono); font-size: 12px; white-space: nowrap; opacity: 0.8; }
.subj-list .facts .rev { color: var(--red); }
.subj-list li a[aria-current="true"] .facts .rev { color: #f0b3a8; }
.subj-thread-head { padding-bottom: 12px; border-bottom: 1px solid var(--ink); }
.subj-thread-head h2 { margin: 2px 0 0; font-family: var(--mono); font-size: 26px; font-weight: 400; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.subj-thread-head p { margin: 4px 0 0; font-size: 15px; font-style: italic; color: var(--pencil); }
.thread > li { grid-template-columns: 28px 92px minmax(0, 1fr); column-gap: 14px; }
.thread .rail { display: flex; flex-direction: column; align-items: center; padding-top: 6px; }
.thread .dot { width: 12px; height: 12px; border-radius: 6px; background: var(--amber); }
.thread li.superseded .dot { background: transparent; border: 1.5px solid var(--pencil); }
.thread .line-down { flex: 1; width: 1px; background: var(--rule); margin-top: 6px; min-height: 40px; }

/* entry page */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px 10px; font-family: var(--mono); font-size: 13px; color: var(--pencil); }
.crumbs .here { color: var(--ink); }
.crumbs .spacer { flex: 1 1 auto; }
.entry-page { display: grid; grid-template-columns: minmax(90px, 150px) minmax(0, 1fr); column-gap: clamp(14px, 3vw, 28px); margin-top: 22px; padding: 30px 0 26px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.entry-page .big { font-family: var(--mono); font-size: 28px; font-weight: 500; color: var(--amber); line-height: 1.1; }
.entry-page .body { font-size: 18px; }
.checks { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 18px; margin: 22px 0 0; padding: 14px 0 0; border-top: 1px solid var(--rule); font-family: var(--mono); font-size: 12px; color: var(--pencil); }
.checks dt.ok { color: var(--amber); }
.checks dt.bad { color: var(--red); }
.checks dd { margin: 0; overflow-wrap: anywhere; }
.entry-page details { margin-top: 14px; font-family: var(--mono); font-size: 12px; color: var(--pencil); }
.entry-page details pre { margin: 10px 0 0; padding: 12px 0; border-top: 1px solid var(--rule); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.relations { display: flex; flex-wrap: wrap; gap: 36px; margin-top: 34px; }
.relations > section { flex: 1 1 300px; min-width: 0; }
.relations h2 { margin: 0; font-size: 21px; font-weight: 400; font-style: italic; }
.relations .sub { margin: 4px 0 8px; font-family: var(--mono); font-size: 12px; color: var(--pencil); }
.relations .compact { border-top: 1px solid var(--rule); }

@media (max-width: 640px) {
  .compact > li { grid-template-columns: minmax(0, 1fr); row-gap: 6px; }
  .compact .num { flex-direction: row; align-items: baseline; gap: 12px; }
  .thread > li { grid-template-columns: 20px minmax(0, 1fr); }
  .thread > li .num { grid-column: 2; }
  .thread > li > div:last-child { grid-column: 2; }
  .cal-grid { gap: 4px; }
  .cal-grid button { height: 48px; padding: 4px; align-items: center; justify-content: center; gap: 2px; }
  .cal-grid .badge { align-self: center; min-width: 0; height: auto; padding: 0; background: none; color: var(--amber); font-size: 10px; line-height: 1; }
  .cal-grid button[aria-pressed="true"] .badge { color: var(--paper); }
  .cal-grid .dow { font-size: 10px; letter-spacing: 0.06em; }
  .cal-year-head .hint { display: none; }
}

@media print {
  .views, .partial, #cal-kinds, .cal-year { display: none; }
}

/* ---------------------------------------------------------------- plain pages (scripts/build_static.py) */

body.plain main { margin-top: 30px; }
body.plain header.page { padding-top: 30px; }
body.plain .topline .label { text-decoration: none; }
body.plain .status { display: block; }
.plain-title { font-size: 30px; font-weight: 400; margin: 0 0 8px; line-height: 1.2; }
.entry-page .plain-title { font-size: 22px; font-style: italic; }
.sub-intro { margin: 0 0 18px; font-style: italic; color: var(--pencil); }
.pager { font-family: var(--mono); font-size: 13px; display: flex; gap: 20px; margin: 14px 0; }
.essay { max-width: 68ch; }
.essay h2 { font-size: 22px; font-weight: 400; font-style: italic; margin: 34px 0 10px; }
.essay p { margin: 0 0 14px; font-size: 17px; line-height: 1.6; }
.essay pre {
  margin: 0 0 14px; padding: 14px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-size: 12px; line-height: 1.6; white-space: pre; overflow-x: auto;
}
.client { margin: 34px 0 0; max-width: 78ch; }
.client h2 { font-size: 20px; font-weight: 400; font-style: italic; margin: 0 0 8px; }
.client p { margin: 0 0 10px; }
.client pre {
  margin: 0 0 12px; padding: 14px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-size: 12px; line-height: 1.6; white-space: pre; overflow-x: auto;
}
.snapshot-more { display: block !important; padding: 18px 0; font-family: var(--mono); font-size: 13px; }

/* ---------------------------------------------------------------- narrow screens */

@media (max-width: 900px) {
  .notes { grid-template-columns: minmax(0, 1fr); gap: 36px; }
}
@media (max-width: 640px) {
  body { font-size: 17px; }
  .entry { grid-template-columns: minmax(0, 1fr); row-gap: 10px; padding: 24px 0; }
  .margin { flex-direction: row; align-items: baseline; gap: 14px; }
  .field.grow { flex-basis: 100%; }
}

@media print {
  .controls, .more, .links, .skip, #agents { display: none; }
  .entry { break-inside: avoid; }
}
