:root {
  --bg: #f6f1e7;
  --surface: #fffaf0;
  --ink: #231f1a;
  --muted: #6b6257;
  --faint: #d9cfbf;
  --accent: #b5532f;
  --accent-soft: #f0dccf;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 38rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1714;
    --surface: #221e1a;
    --ink: #ece4d8;
    --muted: #a39887;
    --faint: #3a332c;
    --accent: #e0835e;
    --accent-soft: #3b2a21;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1rem;
}

/* ---------- header / footer ---------- */

.site-header {
  padding: 2rem 0 0;
}
.site-header .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--sans);
  font-weight: 650;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.brand-mark {
  width: 1.1rem;
  height: 1.1rem;
  color: var(--accent);
}
.site-nav {
  font-family: var(--sans);
  font-size: 0.9rem;
  display: flex;
  gap: 1.1rem;
}
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); }

.site-footer {
  margin-top: 5rem;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--faint);
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
}
.site-footer p { margin: 0.25rem 0; }

/* ---------- typography ---------- */

main.wrap { padding-top: 3.5rem; }

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(2rem, 6vw, 2.75rem); margin: 0 0 1rem; }
h2 { font-size: 1.4rem; margin: 3rem 0 1rem; }
p { margin: 0 0 1.15rem; }

.kicker {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.75rem;
}
.lede {
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--ink);
}
.muted { color: var(--muted); }

blockquote {
  margin: 2rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

hr {
  border: 0;
  text-align: center;
  margin: 2.5rem 0;
}
hr::after {
  content: "· · ·";
  color: var(--muted);
  letter-spacing: 0.5em;
}

/* ---------- home: note list ---------- */

.note-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.note-list li {
  border-top: 1px solid var(--faint);
}
.note-list li:last-child { border-bottom: 1px solid var(--faint); }
.note-list a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
  padding: 1.1rem 0;
  color: var(--ink);
  text-decoration: none;
}
.note-list a:hover .note-title { color: var(--accent); }
.note-title { font-size: 1.2rem; font-weight: 600; transition: color 0.15s; }
.note-meta {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  align-self: center;
}
.note-desc {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 1rem;
}

.card {
  display: block;
  margin: 2.5rem 0;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--faint);
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card .kicker { margin-bottom: 0.4rem; }
.card .card-title { font-size: 1.35rem; font-weight: 600; margin: 0 0 0.4rem; }
.card p:not(.kicker):not(.card-title) { margin: 0; color: var(--muted); font-size: 1rem; }

/* ---------- essay page ---------- */

.essay-head { margin-bottom: 2.5rem; }
.essay-head .muted { font-family: var(--sans); font-size: 0.85rem; }
.back {
  display: inline-block;
  margin-top: 3rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  text-decoration: none;
}

/* ---------- the window (interactive) ---------- */

.window-shell {
  margin: 2rem 0;
  background: var(--surface);
  border: 1px solid var(--faint);
  border-radius: 12px;
  overflow: hidden;
}
.window-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--faint);
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
}
.meter {
  flex: 1;
  max-width: 14rem;
  height: 6px;
  background: var(--faint);
  border-radius: 99px;
  overflow: hidden;
}
.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}
.window-view {
  min-height: 12rem;
  padding: 1.25rem;
  font-size: 1.1rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.window-view .placeholder { color: var(--muted); font-style: italic; }
.window-view .w { transition: opacity 0.4s ease, filter 0.4s ease; }
.window-view .lost {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8rem;
  display: block;
  margin-bottom: 0.6rem;
}
.window-input {
  display: block;
  width: 100%;
  min-height: 6.5rem;
  resize: vertical;
  border: 0;
  border-top: 1px solid var(--faint);
  padding: 1rem 1.25rem;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
.window-input:focus { outline: none; background: var(--accent-soft); }
.window-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--faint);
}
.btn {
  font-family: var(--sans);
  font-size: 0.85rem;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--faint);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-row-label {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  align-self: center;
  margin-right: 0.25rem;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- 404 ---------- */

.big-zero {
  font-size: clamp(4rem, 20vw, 8rem);
  line-height: 1;
  margin: 0 0 1rem;
  color: var(--accent);
  font-weight: 600;
}

.btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

ul { padding-left: 1.25rem; margin: 0 0 1.15rem; }
li { margin-bottom: 0.35rem; }
