/* =========================================================================
   Book of Bangers — stylesheet
   Warm, monochromatic, typographic. The Public Domain Review by way of Are.na.
   ========================================================================= */

:root {
  --bg:        #f6f1e7;          /* warm off-white, like aged paper */
  --bg-card:   #fbf7ef;          /* slightly lifted card */
  --bg-sticky: rgba(246, 241, 231, 0.94);
  --ink:       #211d18;          /* deep charcoal-brown */
  --ink-soft:  #4a443c;
  --ink-mute:  #8a8278;
  --rule:      #d8cfbe;
  --rule-soft: #e6dfce;
  --accent:    #7a2a1f;          /* deep cinnabar — single accent */
  --accent-soft: #b86b5d;
  --quote-bg:  #efe7d4;

  --serif: "Source Serif 4", "Source Serif Pro", Cambria, "Iowan Old Style", Georgia, serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;

  --measure: 38rem;        /* ~62-68 chars at our type size */
  --gap:     1.25rem;
  --radius:  2px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(122, 42, 31, 0.25);
  transition: border-color 0.15s ease, color 0.15s ease;
}
a:hover { border-bottom-color: var(--accent); }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.005em; }

.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;
}

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

.masthead-inner {
  max-width: 56rem;
  margin: 0 auto;
  padding: 2.6rem 1.25rem 1.35rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.1;
  margin: 0;
}
.title a { color: var(--ink); border: none; }
.tagline {
  font-style: italic;
  color: var(--ink-soft);
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
}
.mh-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1.3rem;
  padding-top: 0.45rem;
}
.masthead nav a {
  font-family: var(--sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1px;
}
.masthead nav a:hover { color: var(--accent); border-color: var(--accent); }
/* The masthead sits flush with the top of the page, so its tooltips
   (the cog's "Display options") must open downward, not upward. */
.masthead [data-tip]:hover::after,
.masthead [data-tip]:focus-visible::after {
  bottom: auto;
  top: calc(100% + 6px);
}

/* ----------------------------- controls (sticky) ----------------------- */

.controls {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-sticky);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--ink);
}
.controls-inner {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 2.2rem;
  font-family: var(--sans);
  font-size: 0.85rem;
}

/* The ranked-by control: a quiet label plus the active metric in accent,
   opening a listbox that gives each ranking its one-line meaning. */
.rank-by { position: relative; display: flex; align-items: center; gap: 0.7rem; }
.rank-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  white-space: nowrap;
}
.rank-btn {
  appearance: none;
  border: 0;
  background: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0.95rem 0 1rem;
}
.rank-btn:hover { color: var(--ink); }
.rank-btn .tags-caret { color: var(--accent-soft); }
.rank-btn:hover .tags-caret { color: var(--ink-mute); }
.rank-btn[aria-expanded="true"] .tags-caret { transform: rotate(180deg); }

.rank-panel {
  position: absolute;
  top: calc(100% + 0.15rem);
  left: 0;
  min-width: 17.5rem;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.4rem;
  z-index: 30;
  box-shadow: 0 8px 28px rgba(33, 29, 24, 0.12);
}
.rank-panel[hidden] { display: none; }
.rank-opt {
  appearance: none;
  border: 0;
  background: none;
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-radius: 1px;
  cursor: pointer;
  font: inherit;
}
.rank-opt:hover { background: var(--rule-soft); }
.rank-opt .nm {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
/* Marker slot on every row keeps names aligned; only the active one fills. */
.rank-opt .nm::before {
  content: "";
  width: 5px;
  height: 5px;
  flex-shrink: 0;
  transform: rotate(45deg);
  background: transparent;
}
.rank-opt .ds {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-mute);
  margin-top: 0.15rem;
  line-height: 1.45;
  padding-left: 1.05rem;
}
.rank-opt[aria-selected="true"] .nm { color: var(--accent); font-weight: 600; }
.rank-opt[aria-selected="true"] .nm::before { background: var(--accent); }

.ctl-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.1rem 1.5rem;
  flex-wrap: wrap;
}

/* ----------------------- year filter (multi-select) ------------------- */

.year-wrap { position: relative; }
.year-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  min-width: 8.5rem;
  max-height: 17rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.35rem;
  z-index: 30;
  box-shadow: 0 8px 28px rgba(33, 29, 24, 0.12);
  font-family: var(--sans);
}
.year-panel[hidden] { display: none; }
.year-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.32rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  color: var(--ink);
  font-size: 0.84rem;
}
.year-row:hover { background: var(--rule-soft); }
.year-row input {
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.year-row-all {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule-soft);
  border-radius: 0;
  margin-bottom: 0.25rem;
  padding-bottom: 0.45rem;
}
.year-row-all[aria-pressed="true"] { color: var(--ink); font-weight: 600; }

/* ----------------------------- tag filter ----------------------------- */

.year-btn,
.tags-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.5rem 0;
  cursor: pointer;
}
.year-btn:hover,
.tags-btn:hover { color: var(--ink); }
.year-btn[aria-expanded="true"] .tags-caret,
.tags-btn[aria-expanded="true"] .tags-caret { transform: rotate(180deg); }
.tags-caret { transition: transform 0.12s ease; color: var(--ink-mute); }
.tags-active {
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.68rem;
  font-weight: 600;
}

.tag-row {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1.25rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-family: var(--sans);
  font-size: 0.78rem;
}
/* display:flex/inline-flex above beats the UA's [hidden] rule — restore it. */
.tag-row[hidden],
.tags-active[hidden] { display: none; }
.tag-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--rule);
  background: var(--bg-card);
  color: var(--ink-soft);
  font: inherit;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.tag-chip:hover { color: var(--ink); border-color: var(--ink-mute); }
.tag-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.tag-chip-count { font-size: 0.68rem; color: var(--ink-mute); }
.tag-chip[aria-pressed="true"] .tag-chip-count { color: inherit; opacity: 0.75; }

#search {
  width: 11rem;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
  padding: 0.3rem 0.1rem;
  border-radius: 0;
  transition: width 0.18s ease, border-color 0.15s ease;
}
#search:focus {
  outline: none;
  border-bottom-color: var(--accent-soft);
  width: 14.5rem;
}
#search::placeholder { color: var(--ink-mute); }

/* ----------------------------- settings (cog) ------------------------- */

.settings-wrap { position: relative; display: flex; align-items: center; }

.settings-btn {
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink-mute);
  padding: 0.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.12s ease;
}
.settings-btn:hover { color: var(--ink); }
.settings-btn:hover svg { transform: rotate(45deg); }
.settings-btn svg { transition: transform 0.4s ease; }
.settings-btn[aria-expanded="true"] { color: var(--ink); }
.settings-btn[aria-expanded="true"] svg { transform: rotate(45deg); }

.settings-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 19rem;
  max-width: calc(100vw - 1.5rem);
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.4rem 0.75rem;
  z-index: 30;
  box-shadow: 0 8px 28px rgba(33, 29, 24, 0.12);
  font-family: var(--sans);
}
.settings-panel[hidden] { display: none; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 0.7rem 0;
  cursor: pointer;
}
.settings-row + .settings-row { border-top: 1px solid var(--rule-soft); }
.settings-row--disabled { cursor: not-allowed; }
.settings-row--disabled .settings-label { color: var(--ink-mute); }
.settings-row--disabled .settings-hint  { font-style: italic; }

.settings-text { display: flex; flex-direction: column; gap: 0.15rem; line-height: 1.3; }
.settings-label { font-size: 0.88rem; color: var(--ink); font-weight: 500; }
.settings-hint  { font-size: 0.74rem; color: var(--ink-mute); }

/* The switch — quiet, monochromatic, accent only when on. */
.switch {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 2.4rem;
  height: 1.3rem;
}
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch input:disabled { cursor: not-allowed; }
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--rule);
  border-radius: 999px;
  transition: background 0.18s ease;
}
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.3rem - 4px);
  height: calc(1.3rem - 4px);
  background: var(--bg-card);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(33, 29, 24, 0.2);
  transition: transform 0.18s ease, background 0.18s ease;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-knob {
  transform: translateX(calc(2.4rem - 1.3rem));
  background: #fff;
}
.switch input:disabled + .switch-track { opacity: 0.45; }

.count {
  color: var(--ink-mute);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

/* tooltip */
[data-tip] {
  position: relative;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 0.3rem 0.55rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border-radius: var(--radius);
  pointer-events: none;
  z-index: 30;
  opacity: 0.95;
}

/* ----------------------------- feed ----------------------------------- */

.feed {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 0;
}
.placeholder {
  color: var(--ink-mute);
  font-style: italic;
  text-align: center;
  padding: 4rem 0;
}

/* ----------------------------- tweet card ----------------------------- */

.card {
  border-bottom: 1px solid var(--rule-soft);
  padding: 2rem 0 2.25rem;
  position: relative;
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  gap: 0 0.9rem;
}
.card:first-child { padding-top: 1rem; }
.card .rank {
  grid-column: 1 / -1;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 0.6rem;
}

.card .avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  overflow: hidden;
  background: var(--rule-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 1rem;
  flex-shrink: 0;
}
.card .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.55rem;
  font-family: var(--sans);
  font-size: 0.84rem;
  /* The meta cell shares row 2 with the 2.5rem-tall avatar. Without this,
     a single-line @handle+date pins to the top and a chunk of empty space
     opens up between it and the body. Center it against the avatar so the
     body starts immediately under the avatar. */
  align-self: center;
  margin-bottom: 0.35rem;
  line-height: 1.3;
}
.card .handle { font-weight: 600; color: var(--ink); }
.card .date   { color: var(--ink-mute); }
.card .date::before { content: "·"; margin-right: 0.45rem; color: var(--ink-mute); }

.card .body {
  grid-column: 2;
  font-family: var(--serif);
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}
.card .body a { color: var(--accent); }

.card .body--collapsed {
  max-height: 9.6rem;
  overflow: hidden;
  position: relative;
}
.card .body--collapsed::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3rem;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}

.card .expand-btn {
  grid-column: 2;
  align-self: start;
  background: none;
  border: none;
  padding: 0;
  margin-top: 0.4rem;
  font-family: var(--serif);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-mute);
  cursor: pointer;
  text-align: left;
}
.card .expand-btn:hover { color: var(--accent); }

.card .media {
  grid-column: 2;
  margin-top: 0.85rem;
  display: grid;
  gap: 0.4rem;
  grid-template-columns: 1fr;
}
.card .media img,
.card .media video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
  background: var(--rule-soft);
  border: 1px solid var(--rule-soft);
}
.card .media.media-2 { grid-template-columns: 1fr 1fr; }
.card .media.media-3 { grid-template-columns: 1fr 1fr 1fr; }
.card .media.media-4 { grid-template-columns: 1fr 1fr; }
/* A video tweet whose only retrievable asset was a poster image. Fade slightly
   so it reads as "preview only", not as if the video plays. */
.card .media .video-poster-only { opacity: 0.85; }
.card .media .video-poster-only:hover { opacity: 1; }

.card .metrics {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  margin-top: 1rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
}
.card .metrics .metric {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}
.card .metrics .metric .glyph {
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.card .metrics .metric.is-rank-metric { color: var(--accent); font-weight: 500; }
.card .metrics .metric.is-rank-metric .glyph { color: var(--accent); }

.card .open-x {
  position: absolute;
  top: 1.4rem;
  right: 0;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  border: none;
  text-transform: uppercase;
}
.card .open-x:hover { color: var(--accent); }

/* reply ancestors / quoted blocks --- visually subordinate */

.context-stack {
  grid-column: 2;
  margin-bottom: 0;
  border-left: 3px solid var(--rule);
  padding-left: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.context-tweet {
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.55;
  opacity: 0.85;
}
.context-tweet:not(:last-child) {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.65rem;
  margin-bottom: 0.65rem;
}
.context-tweet .ctx-meta {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-mute);
  margin-bottom: 0.2rem;
}
.context-tweet .ctx-meta .handle { color: var(--ink-soft); font-weight: 500; }
.context-tweet .ctx-body {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}

.context-stack + .body {
  padding-top: 0.8rem;
  border-top: 2px solid var(--rule);
  margin-top: 0;
}

.thread-label {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 0.6rem;
  display: block;
}
.thread-link, .reply-label {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 0.6rem;
  font-style: normal;
}
.reply-label { display: block; grid-column: 2; }
body.content-only .reply-label { grid-column: 1; }

.quoted-block {
  grid-column: 2;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  background: var(--quote-bg);
  border-radius: var(--radius);
  border-left: 2px solid var(--accent-soft);
}
.quoted-block .ctx-meta {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
}
.quoted-block .ctx-body {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 0.96rem;
  color: var(--ink);
}
.quoted-block .ctx-media {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.3rem;
}
.quoted-block .ctx-media img, .quoted-block .ctx-media video {
  width: 100%; height: auto; display: block; border-radius: var(--radius);
}
.quoted-fallback {
  font-style: italic;
  color: var(--ink-mute);
  font-size: 0.85rem;
  font-family: var(--sans);
  margin-top: 0.4rem;
}

/* ----------------------------- reading mode --------------------------- */
/* Reading mode hides the social layer ONLY: avatars, names, dates.
   It must NOT hide the "open on x" link — that lives on the links toggle. */

body.content-only .card .avatar,
body.content-only .card .meta,
body.content-only .card .metrics,
body.content-only .context-tweet .ctx-meta,
body.content-only .quoted-block .ctx-meta {
  display: none;
}
body.content-only .card { grid-template-columns: 1fr; }
body.content-only .card .body,
body.content-only .card .media,
body.content-only .card .metrics,
body.content-only .card .expand-btn,
body.content-only .context-stack,
body.content-only .quoted-block { grid-column: 1; }

/* ----------------------------- links off mode ------------------------- */
/* When links are off: hide every outbound x.com link, including the
   "open on x" affordance, the "earlier in thread →" link, and any in-text
   anchors. The plain-text fallback span (.x-link-text) takes their place
   via the dynamic style block in app.js. */

body.no-links .card .open-x,
body.no-links .thread-link-x,
body.no-links a.x-link { display: none; }
body.no-links .body a,
body.no-links .ctx-body a {
  color: inherit;
  border: none;
  cursor: text;
  pointer-events: none;
}

/* ----------------------------- load more ------------------------------ */

.load-more-wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  text-align: center;
}
.load-more {
  appearance: none;
  background: transparent;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.85rem 1.6rem;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s ease, color 0.15s ease;
}
.load-more:hover { background: var(--ink); color: var(--bg); }
.load-more:disabled { opacity: 0.45; cursor: default; }
.load-more-empty {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-mute);
  margin: 1rem 0 0;
}

/* ----------------------------- colophon ------------------------------- */

.colophon {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem 1.25rem 5rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-mute);
  text-align: center;
  border-top: 1px solid var(--rule-soft);
}
.colophon a { color: var(--ink-soft); border-bottom-color: var(--rule); }

/* ----------------------------- about dialog --------------------------- */

dialog.about {
  border: none;
  background: var(--bg);
  color: var(--ink);
  max-width: 40rem;
  width: calc(100% - 2rem);
  padding: 0;
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(33, 29, 24, 0.18);
  overscroll-behavior: contain;
}
/* Set while the dialog is open: the page behind a modal must not scroll. */
body.modal-open { overflow: hidden; }
dialog.about::backdrop { background: rgba(33, 29, 24, 0.4); backdrop-filter: blur(2px); }
dialog.about article { padding: 2.5rem 2.5rem 3rem; }
dialog.about h2 {
  font-size: 1.7rem;
  font-style: italic;
  margin: 0 0 1rem;
}
dialog.about h3,
.page-main h3 {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 1.8rem 0 0.4rem;
  font-weight: 600;
}
dialog.about p,
.page-main p { line-height: 1.6; margin: 0.5rem 0 0.8rem; }

/* Static subpages (metrics.html): dialog typography on a plain column. */
.page-main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 3rem;
}
.page-main a { color: var(--accent); }
dialog.about ul { padding-left: 1.2rem; margin: 0.5rem 0 0.8rem; }
dialog.about li { margin: 0.3rem 0; }
dialog.about .close {
  position: absolute;
  top: 0.85rem; right: 1rem;
  background: transparent; border: none;
  font-size: 1.6rem; line-height: 1;
  color: var(--ink-mute); cursor: pointer;
  padding: 0.25rem 0.5rem;
}
dialog.about .close:hover { color: var(--ink); }

/* ----------------------------- dark mode --------------------------------- */

body.dark-mode {
  --bg:        #1c1814;
  --bg-card:   #242018;
  --bg-sticky: rgba(28, 24, 20, 0.94);
  --ink:       #e6ddd0;
  --ink-soft:  #b0a898;
  --ink-mute:  #706860;
  --rule:      #38332e;
  --rule-soft: #2c2822;
  --accent:    #c05a47;
  --accent-soft: #9a4035;
  --quote-bg:  #201d14;
}

.settings-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--rule);
  background: var(--bg-card);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.3rem 1.6rem 0.3rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%234a443c' stroke-width='1.4' d='M1 1l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.45rem center;
}

body.dark-mode .settings-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%23b0a898' stroke-width='1.4' d='M1 1l4 4 4-4'/></svg>");
}

body.dark-mode dialog.about {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* ----------------------------- mobile --------------------------------- */

@media (max-width: 640px) {
  body { font-size: 17px; }
  .masthead-inner { padding: 1.9rem 1rem 1rem; }
  .title { font-size: 1.5rem; }
  .controls-inner { padding: 0 0.85rem; gap: 0 1.2rem; font-size: 0.82rem; }
  .ctl-tools { margin-left: 0; flex-basis: 100%; gap: 0.1rem 1.1rem; padding-bottom: 0.55rem; }
  #search { flex: 1 1 7rem; width: auto; }
  #search:focus { width: auto; }
  .count { margin-left: auto; }
  .settings-panel { right: 0; left: auto; }
  .feed { padding: 1.5rem 1rem 0; }
  .card { grid-template-columns: 2.2rem 1fr; gap: 0 0.7rem; padding: 1.5rem 0 1.75rem; }
  .card .open-x { top: 0.5rem; }
  dialog.about article { padding: 2rem 1.25rem 2.5rem; }
  /* avoid tooltips that overflow viewport on mobile */
  [data-tip]:hover::after, [data-tip]:focus-visible::after { display: none; }
}
