:root {
  --paper: #F2F0E9;
  --paper-2: #EAE6DA;
  --ink: #1C1A17;
  --ink-soft: #5C564C;
  --ink-faint: #948C7A;
  --rule: #CBC4B0;
  --stamp: #AE2A21;
  --stamp-soft: #F1D9D2;
  --good: #3E6B4F;
  --max-w: 640px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Serif 4", Georgia, serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  padding-bottom: 90px; /* room for the fixed Share button */
}

.meta {
  font-family: "Barlow Condensed", Arial Narrow, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

a { color: var(--stamp); }

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

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

.masthead { padding: 22px 20px 12px; text-align: left; position: relative; }
.masthead-row { display: flex; align-items: center; justify-content: space-between; }
.wordmark { font-family: "Barlow Condensed"; font-weight: 700; font-size: 25px; letter-spacing: 0.05em; }
.wordmark .mark { display: inline-block; width: 7px; height: 7px; background: var(--stamp); margin-left: 5px; vertical-align: middle; }
.masthead-links { display: flex; gap: 18px; font-size: 12px; color: var(--ink-soft); }
.link-btn:hover { color: var(--ink); }
.tagline { font-style: italic; font-size: 12.5px; color: var(--ink-soft); margin: 6px 0 0; }

.masthead::after {
  content: "";
  display: block;
  margin: 14px 0 0;
  height: 1px;
  background: var(--rule);
}
.masthead::before {
  content: "";
  position: absolute;
  left: 20px; right: 20px; bottom: -3px;
  height: 3px;
  background: var(--ink);
}

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 24px; padding: 18px 20px 10px; border-bottom: 1px solid var(--rule); }
.tab { font-size: 13px; color: var(--ink-faint); padding-bottom: 9px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--ink); border-bottom-color: var(--stamp); font-weight: 600; }

/* ---------- chips (mobile category filter) ---------- */

.chips { display: flex; gap: 8px; padding: 14px 20px; overflow-x: auto; }
.chip { flex: 0 0 auto; font-size: 11px; padding: 6px 11px; border: 1px solid var(--rule); color: var(--ink-soft); background: var(--paper); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- sidebar / filter drawer ---------- */

.sidebar {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(320px, 86vw);
  background: var(--paper);
  border-left: 3px solid var(--ink);
  padding: 24px 22px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  z-index: 40;
}
.sidebar.open { transform: translateX(0); }
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(28, 26, 23, 0.5);
  z-index: 39;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

.sidebar-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.d-title { font-size: 19px; font-weight: 700; font-style: italic; }
.d-sub { font-size: 11px; color: var(--ink-faint); margin-top: 3px; }
.closebtn { color: var(--ink); display: flex; }

.label { font-size: 11px; color: var(--ink-faint); margin: 18px 0 10px; }
.cat-list { display: flex; flex-direction: column; }
.cat-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 7px 0; font-size: 13.5px; text-align: left;
}
.cat-item .radio { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--ink-faint); flex: 0 0 auto; align-self: center; position: relative; }
.cat-item.active { font-weight: 700; }
.cat-item.active .radio { border-color: var(--ink); }
.cat-item.active .radio::after { content: ""; position: absolute; inset: 2.5px; border-radius: 50%; background: var(--stamp); }
.cat-item .leader { flex: 1; border-bottom: 1px dotted var(--rule); margin-bottom: 3px; }

.loc-summary { font-size: 12.5px; color: var(--ink-soft); border-bottom: 1px solid var(--ink); padding-bottom: 10px; }

.footer-actions { margin-top: 26px; }
.reset { font-size: 12px; color: var(--ink-faint); text-decoration: underline; text-underline-offset: 3px; }

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

.layout { position: relative; }
.feed-col { max-width: var(--max-w); margin: 0 auto; }

.feed { display: flex; flex-direction: column; }
.card { padding: 18px 20px; border-bottom: 1px solid var(--rule); text-align: left; width: 100%; }
.headline { font-size: 18px; font-weight: 700; line-height: 1.3; margin: 0 0 6px; text-wrap: balance; }
.byline { font-size: 11px; color: var(--ink-faint); margin-bottom: 9px; display: flex; gap: 7px; flex-wrap: wrap; align-items: baseline; }
.byline .cat { color: var(--ink); font-weight: 700; }
.btext { font-size: 15px; line-height: 1.55; color: var(--ink); white-space: pre-wrap; }
.foot { display: flex; align-items: center; gap: 18px; margin-top: 13px; font-size: 12px; color: var(--ink-soft); }
.foot button { display: flex; align-items: center; gap: 6px; }
.foot .relate.related { color: var(--stamp); font-weight: 700; }
.foot .report { margin-left: auto; color: var(--ink-faint); }

.feed-status { text-align: center; font-size: 11px; color: var(--ink-faint); padding: 20px; }

.status-badge { font-size: 10px; padding: 2px 7px; border: 1px solid currentColor; margin-left: auto; }
.status-badge.active { color: var(--good); }
.status-badge.flagged { color: var(--stamp); }

/* ---------- share button ---------- */

.share-btn {
  position: fixed; right: 20px; bottom: 22px;
  background: var(--ink); color: var(--paper);
  font-weight: 700; font-size: 13px;
  padding: 14px 20px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 4px 4px 0 var(--stamp);
  z-index: 20;
}

/* ---------- compose sheet ---------- */

.sheet-overlay { position: fixed; inset: 0; z-index: 60; }
.sheet-overlay .dim { position: absolute; inset: 0; background: rgba(28, 26, 23, 0.5); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: var(--max-w); margin: 0 auto;
  background: var(--paper);
  border-top: 3px solid var(--ink);
  padding: 22px 20px calc(26px + env(safe-area-inset-bottom, 0px));
  max-height: 88vh; overflow-y: auto;
}
.sheet-close { position: absolute; top: 20px; right: 20px; }
.sheet-title { font-size: 20px; font-weight: 700; font-style: italic; margin: 0; }
.sheet-sub { font-size: 11.5px; color: var(--ink-faint); margin: 3px 0 18px; }

.cat-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

.field-title {
  width: 100%;
  border: none; border-bottom: 1px solid var(--ink);
  background: transparent;
  padding: 0 0 10px; font-size: 17px; font-weight: 700;
  color: var(--ink); font-family: "Source Serif 4", Georgia, serif;
}
.field-title:focus { outline: none; }
.field-title::placeholder { color: var(--ink-faint); font-weight: 400; font-style: italic; }

.field-textarea {
  width: 100%;
  border: none; border-bottom: 1px solid var(--ink);
  background: transparent;
  padding: 0 0 12px; font-size: 15px; line-height: 1.6;
  color: var(--ink); font-family: inherit;
  resize: vertical;
}
.field-textarea:focus { outline: none; }
.field-textarea::placeholder { color: var(--ink-faint); font-style: italic; }
.counter { text-align: right; font-size: 11px; color: var(--ink-faint); margin: 6px 0 20px; }
.counter.warn { color: var(--stamp); }

.nick-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--rule); }
.nick-label { font-size: 11px; color: var(--ink-faint); }
.nick-value { font-size: 15px; font-weight: 700; font-style: italic; margin-left: 8px; font-family: "Source Serif 4", serif; }
.shuffle { font-size: 11px; color: var(--stamp); display: flex; align-items: center; gap: 5px; text-decoration: underline; text-underline-offset: 3px; }

.turnstile-note { font-size: 10.5px; color: var(--ink-faint); margin: 0 0 16px; }
#turnstileWidget { position: fixed; bottom: 0; right: 0; z-index: 90; }

.field-error { color: var(--stamp); font-size: 12px; margin: 0 0 14px; font-family: "Source Serif 4", serif; text-transform: none; letter-spacing: normal; }

.submit {
  display: block; width: 100%;
  background: var(--ink); color: var(--paper);
  text-align: center; padding: 15px;
  font-weight: 700; font-size: 13.5px;
  box-shadow: 4px 4px 0 var(--stamp);
}
.submit[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* ---------- detail / my-posts panels ---------- */

.panel-overlay {
  position: fixed; inset: 0;
  background: var(--paper);
  z-index: 50;
  display: flex; flex-direction: column;
}
.panel-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 20px 14px;
  border-bottom: 1px solid var(--rule);
  font-size: 12px;
  max-width: var(--max-w); width: 100%; margin: 0 auto;
}
.back { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.report-link { color: var(--ink-faint); }
.h-title { font-size: 17px; font-weight: 700; font-style: italic; font-family: "Source Serif 4", serif; text-transform: none; letter-spacing: normal; }

.panel-body { flex: 1; overflow-y: auto; max-width: var(--max-w); width: 100%; margin: 0 auto; padding-bottom: 90px; }

.detail-post { padding: 20px 20px 18px; }
.headline.detail { font-size: 24px; margin-bottom: 10px; }
.dropcap::first-letter { font-weight: 700; font-size: 46px; line-height: 0.75; float: left; padding: 5px 9px 0 0; }
.relate-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 1.5px solid var(--ink); font-weight: 700; font-size: 12px; margin-top: 6px; }
.relate-btn.related { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.comments-h { padding: 8px 20px 6px; font-size: 12px; color: var(--ink-faint); border-top: 3px solid var(--ink); margin-top: 6px; }
.comment { padding: 13px 20px; border-bottom: 1px solid var(--rule); }
.c-top { display: flex; align-items: baseline; gap: 8px; font-size: 10.5px; color: var(--ink-faint); margin-bottom: 5px; }
.c-nick { font-weight: 700; color: var(--ink); }
.c-body { font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.empty-note { padding: 16px 20px; color: var(--ink-faint); font-size: 13px; font-style: italic; }

.banner { margin: 16px 20px; padding: 13px 15px; border: 1px solid var(--rule); font-size: 11.5px; line-height: 1.6; color: var(--ink-soft); font-style: italic; }

.composer {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: var(--max-w); margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--ink);
  background: var(--paper);
}
.c-input-wrap { flex: 1; border-bottom: 1px solid var(--rule); padding-bottom: 8px; display: flex; justify-content: space-between; gap: 10px; }
.c-input { flex: 1; border: none; background: none; font-size: 13.5px; color: var(--ink); font-family: "Source Serif 4", serif; }
.c-input:focus { outline: none; }
.c-input::placeholder { color: var(--ink-faint); font-style: italic; }
.c-counter { color: var(--ink-faint); font-size: 10px; align-self: center; }
.send { color: var(--ink); flex: 0 0 auto; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 10px 18px; font-size: 12.5px;
  z-index: 80; max-width: 86vw; text-align: center;
}

[hidden] { display: none !important; }

/* ---------- desktop / tablet ---------- */

@media (min-width: 900px) {
  body { padding-bottom: 40px; }

  .masthead {
    text-align: center;
    padding: 28px 44px 16px;
    border-bottom: 3px solid var(--ink);
  }
  .masthead::after, .masthead::before { content: none; }
  .masthead-row { justify-content: center; position: relative; }
  .masthead-links { position: absolute; right: 0; top: 4px; }
  .filter-toggle { display: none; }
  .wordmark { font-size: 34px; }

  .tabs { justify-content: center; }

  .chips { display: none; }

  .layout { display: flex; justify-content: center; gap: 40px; padding: 26px 44px; max-width: 1200px; margin: 0 auto; }
  .sidebar {
    position: static; width: 246px; flex: 0 0 auto;
    border-left: none; padding: 0; transform: none;
    background: transparent; overflow: visible;
  }
  .sidebar-backdrop { display: none; }
  .sidebar-head { display: none; }
  .closebtn { display: none; }

  .feed-col { max-width: 720px; margin: 0; }
  .feed { column-count: 2; column-gap: 32px; column-rule: 1px solid var(--rule); display: block; }
  .card { break-inside: avoid; display: inline-block; width: 100%; }

  .share-btn { right: 44px; bottom: 32px; }
}
