:root {
  --plum: #4b237c;
  --mint: #c9ffd8;
  --red: #b52c1f;
  --ink: #111111;
  --pale: #f1d7ff;
  --dim: #a68bb9;
}

* { box-sizing: border-box; }
html { background: var(--plum); }
body { margin: 0; color: var(--ink); font-family: "Courier New", Courier, monospace; font-size: 16px; }
button, a { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }

.archive-header { display: flex; min-height: 44px; align-items: stretch; border-bottom: 3px solid var(--ink); background: var(--mint); font-weight: bold; }
.archive-header > * { display: flex; align-items: center; padding: 9px 14px; }
.archive-header .vita-plaque { background: var(--ink); color: var(--mint); text-decoration: none; }
.archive-header span:nth-child(2) { flex: 1; }
.archive-header span:last-child { border-left: 2px solid var(--ink); background: var(--pale); }

main { width: min(1440px, 100%); margin: 0 auto; padding: 24px; }
.archive-intro { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, .6fr); gap: 30px; align-items: end; color: var(--pale); }
.terminal-line { margin: 0 0 12px; color: var(--mint); font-weight: bold; }
h1 { max-width: 18ch; margin: 0; font-size: clamp(2.6rem, 7vw, 6rem); line-height: .87; letter-spacing: -.04em; text-wrap: balance; }
.archive-intro p:last-child { max-width: 70ch; line-height: 1.55; }
.archive-intro pre { margin: 0; padding: 20px; border: 2px dashed var(--mint); color: var(--mint); font: inherit; line-height: 1.5; overflow: auto; }

.branch-console { margin-top: 24px; padding: 18px; border: 3px solid var(--ink); background: var(--mint); }
.branch-console h2 { margin: 0 0 6px; font-size: 1.25rem; }
.branch-console p { max-width: 78ch; margin: 0; line-height: 1.45; }
.branch-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.branch-buttons button { min-height: 42px; padding: 8px 16px; border: 2px solid var(--ink); border-radius: 0; background: var(--pale); color: var(--ink); font-weight: bold; cursor: pointer; }
.branch-buttons button:hover, .branch-buttons button[aria-pressed="true"] { background: var(--red); }
.branch-console .route-status { margin-top: 12px; padding-top: 10px; border-top: 2px dashed var(--ink); font-weight: bold; }

.archive-grid { display: grid; grid-template-columns: minmax(270px, 390px) minmax(0, 1fr); min-height: 690px; margin-top: 18px; border: 3px solid var(--ink); background: var(--pale); }
.record-index { border-right: 3px solid var(--ink); background: var(--mint); }
.index-head { display: flex; justify-content: space-between; padding: 11px; border-bottom: 3px solid var(--ink); background: var(--ink); color: var(--mint); }
.record-list { max-height: 820px; overflow: auto; }
.record-button { width: 100%; min-height: 0; padding: 13px 11px; border: 0; border-bottom: 2px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.record-button:hover, .record-button[aria-current="true"] { background: var(--pale); }
.record-button small, .record-button b, .record-button span { display: block; }
.record-button small { margin-bottom: 5px; }
.record-button b { margin-bottom: 8px; font-size: 1.05rem; }
.record-button span { color: #3d2450; line-height: 1.35; }
.no-records { padding: 20px 12px; line-height: 1.45; }

.record-reader { min-width: 0; padding: 22px; }
.empty-record { margin: 13vh auto 0; text-align: center; }
.empty-record pre { display: inline-block; padding: 22px; border: 2px dashed var(--ink); background: #fff; text-align: left; }
.record-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 14px; border-bottom: 3px solid var(--ink); }
.record-head p { margin: 0 0 7px; }
.record-head h2 { max-width: 24ch; margin: 0; font-size: clamp(2rem, 5vw, 4rem); line-height: .95; letter-spacing: -.035em; overflow-wrap: anywhere; }
.record-state { display:flex; align-self:flex-start; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.record-head span { padding: 5px 8px; border: 2px solid var(--ink); background: var(--mint); font-weight: bold; }
#record-read-state { background:var(--red); }
#record-read-state[data-read="true"] { background:#fff; }
.record-meta { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 2px dashed var(--ink); font-size: .85rem; }
.record-body { max-width: 76ch; padding: 24px 0 12px; font-size: 1.08rem; line-height: 1.72; white-space: pre-wrap; text-wrap: pretty; }
.record-body p { margin: 0 0 1.15em; }
.record-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 0; border-top: 2px dashed var(--ink); }
.record-tags span { padding: 4px 7px; border: 1px solid var(--ink); background: var(--mint); font-size: .8rem; }
.record-actions { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.record-actions button { min-height: 42px; padding: 8px 13px; border: 2px solid var(--ink); border-radius: 0; background: var(--red); color: var(--ink); font-weight: bold; cursor: pointer; }
.record-actions #confirm-reading { background:var(--ink); color:var(--mint); }
.record-actions #confirm-reading:disabled { background:#fff; color:var(--ink); cursor:default; }
.record-actions a { color: var(--ink); font-weight: bold; }
.copy-status { min-height: 1.4em; font-weight: bold; }
.read-marker { display:inline-block!important; width:max-content; margin-top:7px; padding:2px 5px; border:1px solid var(--ink); background:var(--red); color:var(--ink)!important; font-size:.7rem; font-weight:bold; }
.read-marker[data-read="true"] { background:#fff; }

.archive-warning { display: flex; gap: 18px; margin-top: 18px; padding: 14px; border: 3px solid var(--ink); background: var(--red); }
.archive-warning p { margin: 0; }
.archive-footer { display: flex; justify-content: space-between; gap: 20px; padding: 14px 24px; border-top: 3px solid var(--ink); background: var(--ink); color: var(--mint); }

@media (max-width: 850px) {
  .archive-intro { grid-template-columns: 1fr; }
  .archive-grid { grid-template-columns: 1fr; }
  .record-index { border-right: 0; border-bottom: 3px solid var(--ink); }
  .record-list { max-height: 310px; }
  .record-reader { min-height: 540px; }
}

@media (max-width: 560px) {
  main { padding: 12px; }
  .archive-header span:nth-child(2) { display: none; }
  .archive-intro pre { font-size: .78rem; }
  .branch-buttons button { flex: 1 1 calc(50% - 8px); }
  .record-meta, .archive-warning, .archive-footer { align-items: flex-start; flex-direction: column; }
  .record-actions { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
