/* Plainview: a quiet, bookish reading view. */

:root {
  --bg: #f8f5ef;
  --surface: #fffdf9;
  --ink: #23201c;
  --muted: #6b645a;
  --rule: #e3ddd2;
  --accent: #9a4a2b;
  --accent-soft: rgba(154, 74, 43, 0.35);
  --code-bg: #efeae1;

  --serif: 'Literata', 'Iowan Old Style', 'Charter', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --measure: 38rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #1f1d1a;
    --ink: #e7e2d8;
    --muted: #a19a8e;
    --rule: #34302b;
    --accent: #e39a74;
    --accent-soft: rgba(227, 154, 116, 0.4);
    --code-bg: #27241f;
  }
}

*, *::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.125rem;
  line-height: 1.7;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-color: var(--accent-soft); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: calc(var(--measure) + 2rem);
  margin: 0 auto;
  padding: 1.25rem 1rem 0;
  font-family: var(--sans);
  font-size: 0.875rem;
}
.brand { font-weight: 600; letter-spacing: 0.02em; text-decoration: none; color: var(--muted); }
.brand:hover { color: var(--ink); }

button, .button {
  font: 500 0.875rem/1 var(--sans);
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { border-color: var(--muted); color: var(--ink); }
.share[hidden] { display: none; }

main { max-width: calc(var(--measure) + 2rem); margin: 0 auto; padding: 0 1rem 4rem; }

/* Article */
article { padding-top: 2rem; }

.cover { margin: 0 0 2.25rem; }
.cover img { display: block; width: 100%; height: auto; border-radius: 6px; background: var(--rule); }

h1 {
  font-size: clamp(1.9rem, 1.2rem + 3vw, 2.6rem);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 1.25rem;
  text-wrap: balance;
}

.byline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 2.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.45;
}
.byline .avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.byline .name { font-weight: 600; }
.byline a { color: var(--muted); text-decoration: none; }
.byline a:hover { color: var(--accent); }
.byline .meta { color: var(--muted); }

.body > * { margin: 0 0 1.25em; }
.body h2 { font-size: 1.5rem; line-height: 1.3; font-weight: 600; margin: 2.25em 0 0.75em; letter-spacing: -0.01em; text-wrap: balance; }
.body h3, .body h4 { font-size: 1.2rem; line-height: 1.35; font-weight: 600; margin: 2em 0 0.5em; }
.body strong { font-weight: 600; }
.body ul, .body ol { padding-left: 1.4em; }
.body li { margin: 0 0 0.5em; padding-left: 0.2em; }
.body li::marker { color: var(--muted); }
.body blockquote { margin-left: 0; padding-left: 1.25em; border-left: 3px solid var(--accent-soft); color: var(--muted); font-style: italic; }
.body blockquote p { margin: 0; }
.body figure { margin: 2em 0; }
.body figure img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 4px; }
.body hr { border: 0; text-align: center; margin: 2.5em 0; }
.body hr::after { content: '· · ·'; color: var(--muted); letter-spacing: 0.5em; }
.body code { font-size: 0.88em; background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 3px; }
.body pre { background: var(--code-bg); padding: 1em; border-radius: 6px; overflow-x: auto; font-size: 0.9rem; line-height: 1.5; }
.body pre code { background: none; padding: 0; }
.body .embed { font-family: var(--sans); font-size: 0.9rem; }
.body a { overflow-wrap: anywhere; }

.end {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
}
.end p { margin: 0 0 0.5rem; }
.end .small { font-size: 0.8rem; }

/* Posts and threads */
.posts { padding-top: 2rem; }
.post-author { margin-bottom: 1.75rem; }
.post-author .avatar { width: 44px; height: 44px; }

.post { padding: 0 0 1.75rem; }
.post + .post { padding-top: 1.75rem; border-top: 1px solid var(--rule); }
.post-text p { margin: 0 0 0.9em; }
.post-text a { overflow-wrap: anywhere; }
.single .post-text { font-size: 1.3rem; line-height: 1.6; }
.replying { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); margin: 0 0 0.75rem; }
.replying a { text-decoration: none; }

.post-meta {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  margin: 1rem 0 0;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
}
.post-meta a { color: var(--muted); text-decoration: none; }
.post-meta a:hover { color: var(--accent); }
.post-meta .count { font-variant-numeric: tabular-nums; }

.media { display: grid; gap: 4px; margin: 1.25rem 0; border-radius: 10px; overflow: hidden; }
.media-2, .media-4 { grid-template-columns: 1fr 1fr; }
.media-3 { grid-template-columns: 1fr 1fr; }
.media-3 figure:first-child { grid-row: span 2; }
.media figure { margin: 0; background: var(--rule); }
.media img, .media video { display: block; width: 100%; height: auto; }
.media-2 img, .media-3 img, .media-4 img { height: 100%; object-fit: cover; aspect-ratio: 1; }
.media-3 figure:first-child img { aspect-ratio: auto; }
.media video { max-height: 80vh; background: #000; }

.quote {
  margin: 1.25rem 0;
  padding: 1rem 1.1rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  font-size: 1rem;
}
.quote .post-text, .quote p { font-size: 1rem; }
.quote p { margin: 0 0 0.7em; }
.quote .media { margin: 0.75rem 0; }
.quote-head { display: flex; align-items: center; gap: 0.4rem; font-family: var(--sans); font-size: 0.85rem; }
.quote-head .avatar { width: 20px; height: 20px; border-radius: 50%; }
.quote-head .name { font-weight: 600; }
.quote-head .handle { color: var(--muted); }
.quote-title { font-weight: 600; font-size: 1.15rem; }
.quote-open { font-family: var(--sans); font-size: 0.8rem; }
.quote-open a { color: var(--muted); text-decoration: none; }
.quote-gone { color: var(--muted); font-family: var(--sans); font-size: 0.9rem; padding-bottom: 1rem; }

.poll { margin: 1.25rem 0; font-family: var(--sans); font-size: 0.95rem; }
.poll ul { list-style: none; margin: 0; padding: 0; }
.poll li { display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 1rem; margin-bottom: 0.7rem; }
.poll .pct { color: var(--muted); font-variant-numeric: tabular-nums; }
.poll progress { grid-column: 1 / -1; width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--rule); overflow: hidden; }
.poll progress::-webkit-progress-bar { background: var(--rule); }
.poll progress::-webkit-progress-value { background: var(--accent); }
.poll progress::-moz-progress-bar { background: var(--accent); }
.poll .small { color: var(--muted); font-size: 0.8rem; }

.note {
  margin: 1.25rem 0;
  padding: 0.9rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 8px 8px 0;
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.55;
}
.note p { margin: 0 0 0.5em; }
.note .note-label { font-weight: 600; color: var(--accent); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* Home and error pages */
.center { padding-top: 14vh; }
.center h1 { font-size: clamp(2rem, 1.4rem + 3vw, 2.9rem); }
.lede { color: var(--muted); font-size: 1.15rem; margin: 0 0 2rem; max-width: 34rem; }

.paste { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.paste input {
  flex: 1;
  min-width: 0;
  font: 1rem/1.4 var(--sans);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.paste input::placeholder { color: var(--muted); opacity: 0.7; }
.paste button {
  border-radius: 10px;
  padding: 0 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.paste button:hover { color: var(--bg); background: var(--accent); border-color: var(--accent); }

.hint { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }
.hint code { font-size: 0.95em; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }

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

@media (max-width: 30rem) {
  body { font-size: 1.0625rem; }
  .paste { flex-direction: column; }
  .paste button { padding: 0.85rem; }
}

@media print {
  .bar, .end .small { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { text-decoration: underline; }
}
