/* Layout: one centered reading column (~66ch), with the comments section below the essay. */
:root {
  --paper: #ffffff;
  --ink: #000000;
  --ink-soft: #3a3a3a;
  --rule: #d9d9d9;
  --link: #1a3a8a;
  --serif: "Times New Roman", Tinos, Times, "Liberation Serif", "Noto Serif", Georgia, serif;
  --measure: 40rem;
  --kb: 0px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 1.5rem; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;          /* 19px */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
}
@media (max-width: 600px) { body { font-size: 1.125rem; line-height: 1.58; } }

a { color: var(--link); text-decoration-thickness: 0.06em; text-underline-offset: 0.16em; }
a:hover { text-decoration-thickness: 0.12em; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 2px; }

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

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-size: 0.95rem;
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--ink); background: var(--paper); color: var(--ink);
  border-radius: 999px; padding: 0.42rem 0.95rem; min-height: 2.5rem;
  cursor: pointer; touch-action: manipulation;
  transition: background-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #f2f2f2; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: #222; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.small { font-size: 0.875rem; min-height: 2.2rem; padding: 0.3rem 0.8rem; }
.count-pill { display: inline-flex; align-items: center; gap: 0.4rem; }
.count-pill b { font-weight: normal; font-variant-numeric: tabular-nums; }

/* ---------- article ---------- */
main {
  max-width: calc(var(--measure) + 2rem);
  margin: 0 auto;
  padding-block: 2.5rem 5rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

header.title-block { text-align: center; margin-bottom: 2.25rem; }
h1 {
  font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.6rem);
  line-height: 1.15; font-weight: normal; letter-spacing: -0.005em;
  margin: 0 0 0.9rem; text-wrap: balance;
}
.byline { margin: 0; font-style: italic; color: var(--ink-soft); }
.meta { margin: 0.6rem 0 0; font-size: 0.9rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }
.meta span + span::before { content: "·"; margin: 0 0.55em; }

nav.toc {
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  padding-block: 0.9rem; margin: 0 0 2.25rem;
}
nav.toc h2 { font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: normal; margin: 0 0 0.4rem; color: var(--ink-soft); }
nav.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.2rem; }
nav.toc a { text-decoration: none; display: inline-block; padding-block: 0.15rem; }
nav.toc a:hover { text-decoration: underline; }
nav.toc .num { display: inline-block; min-width: 2.4em; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

#essay p { margin: 0 0 1.05em; text-align: left; overflow-wrap: break-word; }
#essay p.indent { text-indent: 2em; }
@media (max-width: 600px) { #essay p.indent { text-indent: 1.4em; } }

#essay h2 {
  font-size: 1.45rem; font-weight: normal; line-height: 1.25;
  margin: 2.6rem 0 1rem; text-wrap: balance;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.9rem;
}
#essay h2 .roman { font-variant-numeric: lining-nums; min-width: 1.6em; }
#essay h2 .skip { font-size: 0.85rem; letter-spacing: 0.02em; font-style: italic; margin-left: auto; }
@media (max-width: 520px) { #essay h2 .skip { margin-left: 0; flex-basis: 100%; } }

#essay h3 { font-size: 1.15rem; font-weight: normal; font-style: italic; margin: 1.8rem 0 0.8rem; }

#essay blockquote {
  margin: 1.3rem 0 1.5rem; padding: 0 0 0 1.1rem;
  border-left: 2px solid var(--ink);
}
#essay blockquote p { margin-bottom: 0.7em; }
#essay blockquote p:last-child { margin-bottom: 0; }
#essay blockquote footer { font-size: 0.92rem; color: var(--ink-soft); margin-top: 0.5rem; }

#essay blockquote.statute { font-size: 0.97rem; }
#essay blockquote.statute ol { list-style: none; padding: 0; margin: 0.4rem 0 0.7rem; }
#essay blockquote.statute ol ol { padding-left: 1.4rem; }
#essay blockquote.statute li { margin: 0 0 0.35rem; }

#essay ol.recs { padding-left: 1.6rem; margin: 0 0 1.4rem; }
#essay ol.recs > li { margin-bottom: 0.55rem; padding-left: 0.2rem; }
#essay ol.recs ol { list-style: lower-alpha; padding-left: 1.4rem; margin: 0.35rem 0 0; }
#essay ol.recs ol li { margin-bottom: 0.25rem; }

figure.screens { margin: 1.6rem 0 1.8rem; }
figure.screens .shots { display: grid; gap: 0.75rem; }
figure.screens img {
  display: block; width: 100%; max-width: 100%; height: auto;
  border: 1px solid var(--rule); border-radius: 6px; background: #fff;
}
figure.screens figcaption { font-size: 0.92rem; color: var(--ink-soft); margin-top: 0.6rem; font-style: italic; }

.signoff { margin-top: 2rem !important; font-style: italic; }
.ai-note { margin-top: 1.25rem !important; font-size: 0.9em; }

sup { line-height: 0; font-size: 0.7em; }
sup a, a.fnref { text-decoration: none; padding: 0 0.08em; }
sup a:hover { text-decoration: underline; }

/* notes & references */
.endmatter { margin-top: 3rem; border-top: 1px solid var(--ink); padding-top: 1.2rem; }
.endmatter h2 { font-size: 1.15rem !important; letter-spacing: 0.06em; text-transform: uppercase; margin-top: 1.6rem !important; }
.notes, .refs { padding-left: 0; list-style: none; font-size: 0.97rem; line-height: 1.55; }
.notes > li, .refs > li { margin-bottom: 0.9rem; display: grid; grid-template-columns: 2.4rem minmax(0, 1fr); }
.notes .mark, .refs .mark { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.notes p, .refs p { margin: 0 0 0.5em !important; }
.backrefs { font-size: 0.85rem; white-space: nowrap; }
.backrefs a { text-decoration: none; margin-right: 0.35rem; }
.refs .url { overflow-wrap: anywhere; }
.editor-note { font-size: 0.9rem; color: var(--ink-soft); font-style: italic; }
:target { scroll-margin-top: 1.5rem; }
li:target, .notes li:target, .refs li:target { background: #f4f4f4; border-radius: 4px; outline: 6px solid #f4f4f4; }

::selection { background: #b9d1ff; }

/* ---------- comments section ---------- */
.discussion { margin-top: 3.5rem; border-top: 1px solid var(--ink); padding-top: 1.2rem; }
.discussion-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; }
.discussion h2 { font-size: 1.15rem; font-weight: normal; letter-spacing: 0.06em; text-transform: uppercase; margin: 0; }
.discussion h2 .c-count { color: var(--ink-soft); font-variant-numeric: tabular-nums; margin-left: 0.3em; }
.discussion-note { font-size: 0.92rem; color: var(--ink-soft); font-style: italic; margin: 0.6rem 0 1.1rem; }

.sort { display: inline-flex; border: 1px solid var(--ink); border-radius: 999px; overflow: hidden; }
.sort-btn { font: inherit; font-size: 0.875rem; border: 0; background: var(--paper); color: var(--ink); padding: 0.3rem 0.9rem; min-height: 2.2rem; cursor: pointer; touch-action: manipulation; }
.sort-btn + .sort-btn { border-left: 1px solid var(--ink); }
.sort-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.composer { margin: 0 0 1.6rem; }
.composer textarea {
  display: block; width: 100%;
  font: inherit; font-size: 1rem; line-height: 1.5; /* ≥16px avoids iOS zoom */
  border: 1px solid #9a9a9a; border-radius: 8px;
  padding: 0.65rem 0.75rem; resize: vertical; min-height: 6rem;
  background: #fff; color: var(--ink);
}
.reply-composer { margin: 0.8rem 0 0.4rem; }
.reply-composer textarea { min-height: 4.5rem; }
.composer textarea:focus { outline: 2px solid var(--link); outline-offset: 0; border-color: var(--link); }
.composer-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.3rem 1rem; font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.45rem; }
.composer-foot .count { font-variant-numeric: tabular-nums; }
.form-error { color: #a40000; font-size: 0.92rem; margin: 0.5rem 0 0; min-height: 1.2em; }
.form-error:empty { min-height: 0; margin: 0; }
.actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.6rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }

.comment-list, .replies { list-style: none; margin: 0; padding: 0; }
.comment-list > .c { padding: 1rem 0; border-top: 1px solid var(--rule); }
.replies { margin-top: 0.6rem; padding-left: 1rem; border-left: 2px solid var(--rule); }
.replies > .c { padding: 0.6rem 0; }
.c { border-radius: 4px; }
.c-head { margin: 0 0 0.25rem; font-size: 0.9rem; color: var(--ink-soft); }
.c-author { color: var(--ink); font-weight: bold; }
.c-sep { margin: 0 0.4em; }
.c-body { margin: 0 0 0.4rem; white-space: pre-wrap; overflow-wrap: break-word; font-size: 1.02rem; line-height: 1.5; }
.c-deleted { color: var(--ink-soft); font-style: italic; }
.c-actions { display: flex; align-items: center; gap: 0.9rem; font-size: 0.9rem; }
.votes { display: inline-flex; align-items: center; gap: 0.15rem; }
.vote {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  border: 0; background: transparent; color: #8a8a8a; cursor: pointer; touch-action: manipulation;
}
.vote svg { fill: currentColor; }
.vote:hover { background: #f0f0f0; color: var(--ink); }
.vote.up[aria-pressed="true"] { color: #b33a00; }
.vote.down[aria-pressed="true"] { color: #1a3a8a; }
.score { min-width: 1.6em; text-align: center; font-variant-numeric: tabular-nums; }
.link-btn { font: inherit; font-size: 0.9rem; border: 0; background: none; color: var(--link); padding: 0.3rem 0.2rem; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.empty { color: var(--ink-soft); font-style: italic; padding: 1rem 0; border-top: 1px solid var(--rule); margin: 0; }
@media (prefers-reduced-motion: no-preference) {
  .c.flash { animation: flash 1.8s ease-out; }
  @keyframes flash { 0%, 40% { background: #fff1a8; } 100% { background: transparent; } }
}

/* toast */
#toast {
  position: fixed; z-index: 60; left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 10px); opacity: 0;
  background: var(--ink); color: var(--paper);
  padding: 0.55rem 1.1rem; border-radius: 999px; font-size: 0.95rem;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media print {
  .discussion, #toast, .skip { display: none !important; }
  a { color: inherit; }
}
