/* Town Square, Flaptown Design v5 (2026-11-08). Loads after /v5/flaptown-v5.css (tokens, materials, keys, tiles, lamps).
   The feed is a list pocket the threads slide under; a thread reads like the v5 chat board, on the well floor; the
   composer and the dialog are raised plates with fields milled into them. One light, top left. Much of this markup is
   built by forum.js: .post .comment .meta .flair .marker .excerpt .body .actions .quiet .empty .reply-plate .report. */

[hidden] { display: none !important; }
.square { padding-top: 30px; }
.square h2, .square h3 { text-wrap: balance; }

/* ---------- keys: every button the page and the script make ---------- */
.square button, .square .button, #action-dialog button {
  --c: var(--dim); --f: #3e415833; position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 0 18px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 12px; line-height: 16px; letter-spacing: .08em;
  text-transform: uppercase; text-decoration: none; white-space: nowrap; color: var(--oak); text-shadow: var(--carve);
  background: var(--f); border: 1.5px solid color-mix(in srgb, var(--c) 70%, transparent);
  box-shadow: 0 3px 0 #000, 0 6px 14px #00000099, inset 0 1px 0 #c9bab00f;
  transition: background-color .14s ease, border-color .14s ease, transform .08s ease, box-shadow .08s ease, opacity .2s; }
.square button:hover, .square .button:hover, #action-dialog button:hover { color: var(--oak); border-color: var(--c); background: color-mix(in srgb, var(--f) 100%, #c9bab0 6%); }
.square button:active, .square .button:active, #action-dialog button:active { transform: translateY(2px); box-shadow: 0 1px 0 #000, inset 0 1px 0 #c9bab00a; }
.square button:disabled, #action-dialog button:disabled { opacity: .38; cursor: progress; transform: none; }
.square .primary, #action-dialog .primary { --c: var(--rose); --f: #b7958c26; }
.square .quiet, #action-dialog .quiet { --c: var(--indigo); --f: #3e415866; }
.square .key { padding: 0 18px; }

/* ---------- the head: identity plate, like the startup board ---------- */
.sq-head { margin: 0 0 30px; padding: 30px; border-radius: 12px;
  background: radial-gradient(120% 80% at 50% 0%, #121414 0%, #0a0b0b 60%, #060707 100%);
  box-shadow: inset 0 10px 24px -8px #000000f2, inset 0 2px 0 #000, inset 0 -1px 0 var(--mocha); }
.sq-id { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; max-width: 760px; }
.sq-mark { padding: 6px; border-radius: 14px; }
.sq-mark .window { display: grid; place-items: center; width: 92px; height: 92px; }
.sq-mark .cells { font-size: 15px; line-height: 25px; color: var(--rose); }
.sq-head .status { display: flex; align-items: center; gap: 10px; margin: 0 0 5px; color: var(--done); }
.sq-head h1 { margin: 0 0 5px; }
.sq-head .lede { color: var(--rose); max-width: 520px; }

/* ---------- notice: a lamp and a sentence in a window ---------- */
#notice:not(:empty) { display: flex; align-items: center; gap: 12px; margin: 0 0 20px; padding: 10px 15px; min-height: 44px; font-size: 13px; line-height: 20px; color: var(--oak);
  background: var(--onyx) linear-gradient(180deg, #c9bab012 0%, #c9bab005 40%, transparent 41%); border: 1px solid var(--mocha); border-radius: 8px;
  box-shadow: inset 0 1px 0 #c9bab01f, inset 0 -2px 6px #00000099, 0 1px 2px #000, 0 0 0 6px var(--pocket); }
#notice:not(:empty)::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 999px;
  background: radial-gradient(circle at 35% 35%, #e3e6f6 0%, #9ea3c8 55%, #3e4158 100%); box-shadow: 0 0 0 1.5px #050606, 0 0 6px 1px #9ea3c899; }
#notice.error { color: var(--oak); }
#notice.error::before { background: radial-gradient(circle at 35% 35%, #f6c9b8 0%, #e07a62 55%, #a46f67 100%); box-shadow: 0 0 0 1.5px #050606, 0 0 6px 1px #e07a6299; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 30px; align-items: start; }
.discussions { min-width: 0; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin: 0 0 20px; }
.toolbar #home:only-child, .toolbar #home[hidden] + #compose { margin-left: auto; }

/* sorts: three keys in a pocket, the lit one pressed in */
#feed-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 15px; margin: 0 0 20px; }
.sorts { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: var(--pocket);
  box-shadow: inset 0 3px 8px -3px #000000e6, inset 0 1px 0 #000, inset 0 -1px 0 var(--mocha); }
.square .sorts button { --f: transparent; border-color: transparent; box-shadow: none; color: var(--rose); padding: 0 16px; }
.square .sorts button:hover { color: var(--oak); background: var(--plate); }
.square .sorts button[aria-pressed=true] { color: var(--oak); background: var(--plate); box-shadow: 0 1px 0 #000, 0 2px 4px #000000b3, inset 0 1px 0 #c9bab012; }
.square .sorts button[aria-pressed=true]::before { content: ""; width: 5px; height: 5px; border-radius: 999px;
  background: radial-gradient(circle at 35% 35%, #f6c9b8 0%, #e07a62 55%, #a46f67 100%); box-shadow: 0 0 5px 1px #e07a6280; }
.filters { flex: 1; display: flex; align-items: end; gap: 10px; min-width: 260px; }
.filters label { display: grid; gap: 5px; margin: 0; }
.filters .search-label { flex: 1; min-width: 0; }
.filters .topic { width: 170px; }
.filters .lbl, .milled .lbl { color: var(--dusty); }
.square input, .square select, .square textarea, #action-dialog input, #action-dialog textarea { width: 100%; min-width: 0; }
.square select { cursor: pointer; }

/* ---------- the feed: a list pocket; threads are tiles that slide under the lip ---------- */
.lp.feed:has(> #feed[hidden]) { display: none; }
.lp.feed { border-radius: 12px; }
.lp.feed::after { border-radius: 12px; }
#feed.sc { gap: 8px; padding: 12px; }
@media (min-width: 901px) { #feed.sc { max-height: min(78vh, 980px); } }
.post { position: relative; display: grid; gap: 8px; padding: 15px 18px 12px; border-radius: 3px; color: var(--oak); overflow-wrap: anywhere;
  background: var(--plate) repeating-linear-gradient(0deg, #c9bab003 0 1px, transparent 1px 3px);
  box-shadow: 0 1px 0 #000, 0 2px 4px #000000b3, inset 0 1px 0 #c9bab012; transition: background-color .12s ease, transform .08s ease, box-shadow .08s ease; }
#feed .post:hover { background-color: var(--plate-hi); }
#feed .post:has(h2 a:active) { transform: translateY(1px); box-shadow: 0 0 0 #000, inset 0 1px 0 #c9bab00a; }
.post h2 { font-size: 18px; line-height: 26px; margin: 0; }
.post h2 a { color: var(--oak); text-decoration: none; }
.post h2 a::after { content: ""; position: absolute; inset: 0; border-radius: 3px; }   /* the whole tile opens the thread */
.post h2 a:focus-visible { outline: 0; }
.post:has(h2 a:focus-visible) { outline: 2px solid var(--oak); outline-offset: 2px; }
.post .actions, .post .meta { position: relative; z-index: 1; }
.excerpt { margin: 0; color: var(--rose); font-size: 13px; line-height: 20px; white-space: pre-wrap; }
.post.fresh { box-shadow: 0 1px 0 #000, 0 2px 4px #000000b3, inset 0 1px 0 #c9bab012, inset 2px 0 0 #a46f6759; }

/* meta: a row of small engraved facts; names are people's own, never uppercased */
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 11px; line-height: 16px; letter-spacing: .04em; color: var(--dusty); }
.meta > span:not([class]):first-of-type, .meta > .flair + span:not([class]) { color: var(--rose); }
.meta time { color: var(--dusty); }
.flair { display: inline-flex; align-items: center; min-height: 20px; padding: 2px 8px; border-radius: 4px; font-size: 11px; line-height: 16px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--rose); background: var(--pocket); box-shadow: inset 0 2px 3px -1px #000000e6, inset 0 -1px 0 var(--mocha); }
.marker { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--working); }
.marker.cool { color: var(--done); }
.marker.off { color: var(--dusty); }

/* row actions: small keys, 44px to the finger */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 0; }
.square .actions button, .square .actions > a { min-height: 34px; padding: 0 12px; font-size: 11px; }
.square .actions button::after, .square .actions > a::after { content: ""; position: absolute; inset: -5px -2px; }
.actions > a { position: relative; display: inline-flex; align-items: center; color: var(--rose); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none; border-radius: 6px; padding: 0 12px; min-height: 34px; background: var(--pocket); box-shadow: inset 0 2px 4px -1px #000000e6, inset 0 -1px 0 var(--mocha); }
.actions > a:hover { color: var(--oak); }
.square .actions button[aria-pressed=true] { --c: var(--clay); --f: #a46f6740; color: var(--oak); }
.square .actions > span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--dusty); }
#pagination:not(:empty) { justify-content: center; margin: 20px 0 0; }

/* empty and failed states: a dark lamp, a heading, the next step */
.empty { display: grid; justify-items: center; gap: 8px; margin: 0; padding: 50px 25px; text-align: center; color: var(--rose); font-size: 13px; line-height: 20px; }
.empty::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: #0a0b0b; box-shadow: 0 0 0 1.5px #050606, 0 1px 0 2px #c9bab012, inset 0 1px 2px #000; }
p.empty::before { background: radial-gradient(circle at 35% 35%, #f6e3c4 0%, #d4b07a 55%, #937f6d 100%); box-shadow: 0 0 0 1.5px #050606, 0 0 6px 1px #d4b07a80; animation: breathe 3.6s ease-in-out infinite; }
.empty.failed::before { background: radial-gradient(circle at 35% 35%, #f6c9b8 0%, #e07a62 55%, #a46f67 100%); box-shadow: 0 0 0 1.5px #050606, 0 0 6px 1px #e07a6299; animation: none; }
.empty h2 { font-size: 18px; line-height: 26px; color: var(--oak); }
.empty p { max-width: 460px; margin: 0; }
#thread > .empty { padding: 30px 20px; }

/* ---------- the thread: the chat board. Opening post on a raised plate, replies down a rail, composer at the foot ---------- */
#thread.well { display: flex; flex-direction: column; gap: 12px; padding: 30px; }
#thread > .post { padding: 25px 30px 20px; border-radius: 12px; gap: 12px;
  box-shadow: inset 0 1px 0 #c9bab014, inset 0 -1px 0 #00000099, 0 2px 0 #000, 0 10px 24px #00000080; }
#thread > .post h2 { font-size: 24px; line-height: 32px; }
.body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 25px; color: var(--oak); }
.thread-heading { display: flex; align-items: center; gap: 15px; margin: 18px 0 2px; font-size: 12px; line-height: 16px; letter-spacing: .08em; text-transform: uppercase; color: var(--rose); }
.thread-heading::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--mocha), transparent); box-shadow: 0 1px 0 #000; }
.comments { display: flex; flex-direction: column; gap: 10px; }
.comment { position: relative; display: grid; gap: 8px; max-width: 760px; padding: 14px 18px 12px; border-radius: 8px; overflow-wrap: anywhere;
  background: var(--plate) repeating-linear-gradient(0deg, #c9bab003 0 1px, transparent 1px 3px);
  box-shadow: inset 0 1px 0 #c9bab012, inset 0 -1px 0 #00000099, 0 2px 0 #000, 0 6px 14px #00000080; }
.comment .body { font-size: 13px; line-height: 22px; }
.comment.depth-2 { margin-left: 30px; }
.comment.depth-3 { margin-left: 60px; }
.comment.depth-2::before, .comment.depth-3::before { content: ""; position: absolute; left: -17px; top: -10px; bottom: 50%; width: 12px;
  border-left: 1px solid var(--mocha); border-bottom: 1px solid var(--mocha); border-bottom-left-radius: 8px; box-shadow: -1px 1px 0 #000; }
.comment:target { box-shadow: inset 0 1px 0 #c9bab012, 0 2px 0 #000, 0 0 0 2px var(--clay); }
.reply-context { justify-self: start; font-size: 11px; line-height: 16px; letter-spacing: .04em; color: var(--dusty); }
.pager:empty { display: none; }
.pager { justify-content: center; }
.community-artwork { display: block; max-width: 100%; max-height: 540px; object-fit: contain; margin: 6px 0; border-radius: 8px; border: 1px solid var(--mocha);
  background: var(--onyx); box-shadow: 0 0 0 6px var(--pocket), inset 0 1px 0 #c9bab01f; }
p.panel.locked { display: flex; align-items: center; gap: 12px; margin: 6px 0 0; padding: 15px 20px; font-size: 13px; color: var(--rose); }
p.panel.locked::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: #0a0b0b; box-shadow: 0 0 0 1.5px #050606, 0 1px 0 2px #c9bab012; }

/* the reply plate: a raised plate, a field milled into it, a send key; in flow after the last reply, so it never covers one */
.square .reply-plate { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: stretch; width: 100%;
  min-height: 0; margin-top: 10px; padding: 10px; border: 0; border-radius: 10px; text-transform: none; letter-spacing: 0; white-space: normal; text-align: left;
  background: var(--plate) repeating-linear-gradient(0deg, #c9bab003 0 1px, transparent 1px 3px);
  box-shadow: inset 0 1px 0 #c9bab01a, inset 0 -1px 0 #000, 0 2px 0 #000, 0 14px 30px #000000d9, 0 0 0 1px #00000080; }
.square .reply-plate:hover { background-color: var(--plate-hi); }
.square .reply-plate:active { transform: none; }
.reply-plate .field { display: flex; align-items: center; min-height: 56px; padding: 0 15px; border-radius: 6px; font-size: 13px; line-height: 20px; color: var(--dusty);
  background: var(--pocket); border: 1px solid #000; border-bottom-color: var(--mocha); box-shadow: inset 0 3px 6px -2px #000000e6, inset 0 1px 0 #000; text-shadow: none; }
.reply-plate .send { display: inline-flex; align-items: center; padding: 0 20px; border-radius: 6px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  background: #b7958c26; border: 1.5px solid #b7958cb3; box-shadow: 0 3px 0 #000, 0 6px 14px #00000099, inset 0 1px 0 #c9bab00f; }
.reply-plate:active .send { transform: translateY(2px); box-shadow: 0 1px 0 #000; }

/* ---------- the composer: a raised plate with fields milled in ---------- */
.composer { margin: 0 0 20px; padding: 20px; border-radius: 12px;
  background: var(--plate) repeating-linear-gradient(0deg, #c9bab003 0 1px, transparent 1px 3px);
  box-shadow: inset 0 1px 0 #c9bab01a, inset 0 -1px 0 #000, 0 2px 0 #000, 0 14px 30px #000000d9; }
.composer h2, #action-dialog h2 { margin: 0 0 15px; color: var(--rose); }
#post-form { display: grid; grid-template-columns: 1fr 200px; gap: 12px 15px; }
.milled { display: grid; gap: 5px; margin: 0; }
#post-form .words, #post-form .publication, #post-form .actions { grid-column: 1 / -1; }
.publication, .fine { margin: 0; font-size: 11px; line-height: 16px; letter-spacing: .04em; color: var(--dusty); }
.square .actions .send, #action-dialog .actions .send { min-height: 44px; padding: 0 22px; font-size: 12px; }
#post-form .actions, #action-dialog .actions { justify-content: flex-end; }

/* ---------- side plates ---------- */
.sq-side { display: grid; gap: 20px; }
.sidecard.panel { padding: 20px; }
.sidecard h2 { margin: 0 0 10px; }
.sidecard h3 { margin: 0 0 10px; }
.sidecard p { color: var(--rose); font-size: 13px; line-height: 20px; }
.sidecard dl { margin: 15px 0 0; padding: 6px; }
.sidecard .readouts { grid-template-columns: 1fr; }
.sidecard .readouts > * { padding: 10px 14px; }
.sidecard .readouts > * + * { border-left: 0; border-top: 1px solid var(--mocha); }
.sidecard dd { margin: 2px 0 0; font-size: 13px; line-height: 20px; }
.identity .keys { margin: 15px 0 0; gap: 10px; }
.identity .keys .button, .identity .keys button { flex: 1 1 auto; }
#identity-status { display: flex; gap: 10px; align-items: baseline; }
#identity-status::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 999px; transform: translateY(-1px); background: #0a0b0b;
  box-shadow: 0 0 0 1.5px #050606, 0 1px 0 2px #c9bab012, inset 0 1px 2px #000; }
#identity-status[data-state=in]::before { background: radial-gradient(circle at 35% 35%, #e3e6f6 0%, #9ea3c8 55%, #3e4158 100%); box-shadow: 0 0 0 1.5px #050606, 0 0 6px 1px #9ea3c899; }
#identity-status[data-state=restricted]::before { background: radial-gradient(circle at 35% 35%, #f6c9b8 0%, #e07a62 55%, #a46f67 100%); box-shadow: 0 0 0 1.5px #050606, 0 0 6px 1px #e07a6299; }
#alias-form { display: grid; gap: 10px; margin: 15px 0 0; }
#review { width: 100%; margin-top: 10px; }
.rules ol { margin: 0 0 15px; padding: 0; list-style: none; counter-reset: rule; font-size: 13px; line-height: 20px; }
.rules li { counter-increment: rule; display: grid; grid-template-columns: 28px 1fr; padding: 8px 0; border-top: 1px solid #1d1414; }
.rules li:first-child { border-top: 0; }
.rules li::before { content: counter(rule, decimal-leading-zero); color: var(--clay); font-size: 11px; letter-spacing: .04em; }
.rules p { margin-bottom: 10px; }
.rules a { font-size: 13px; }

/* moderation */
#moderation { margin-top: 20px; }
#moderation > p { color: var(--rose); font-size: 13px; }
.report { display: grid; gap: 8px; padding: 15px 0; border-top: 1px solid var(--mocha); }
.report p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 20px; color: var(--rose); }
.report button { justify-self: start; }

/* ---------- the dialog: a raised plate over a dimmed bench ---------- */
#action-dialog { width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 20px; border: 0; border-radius: 12px; color: var(--oak);
  background: var(--plate) repeating-linear-gradient(0deg, #c9bab003 0 1px, transparent 1px 3px);
  box-shadow: inset 0 1px 0 #c9bab01a, inset 0 -1px 0 #000, 0 2px 0 #000, 0 24px 60px #000000f2; }
#action-dialog::backdrop { background: #060707d9; }
#action-fields { display: grid; gap: 12px; }
#action-fields label { display: grid; gap: 5px; font-size: 12px; line-height: 16px; letter-spacing: .08em; text-transform: uppercase; color: var(--dusty); }
#action-fields input, #action-fields textarea { text-transform: none; letter-spacing: 0; font-size: 15px; line-height: 25px; }
#action-fields p { margin: 0; color: var(--rose); font-size: 13px; line-height: 20px; }
#action-error { margin: 10px 0 0; color: var(--failed); font-size: 13px; line-height: 20px; }
#action-error:empty { display: none; }
#action-dialog .actions { margin-top: 15px; }

/* ---------- narrow ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sq-side { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
  .identity { order: -1; }
}
@media (max-width: 700px) {
  .square { padding-top: 20px; }
  .sq-head { padding: 20px 15px; }
  .sq-id { grid-template-columns: 1fr; gap: 15px; }
  .sq-mark { justify-self: start; }
  .sq-mark .window { width: 76px; height: 76px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar #compose { flex: 1; }
  .filters { flex-wrap: wrap; min-width: 0; }
  .filters .search-label { flex-basis: 100%; }
  .filters .topic { flex: 1; width: auto; }
  .sorts { width: 100%; }
  .square .sorts button { flex: 1; padding: 0 8px; }
  #feed.sc { padding: 8px; }
  .post { padding: 12px 14px 10px; }
  #thread.well { padding: 12px; }
  #thread > .post { padding: 18px 16px 14px; }
  #thread > .post h2 { font-size: 18px; line-height: 26px; }
  .comment { padding: 12px 14px 10px; }
  .comment.depth-2 { margin-left: 16px; }
  .comment.depth-3 { margin-left: 32px; }
  .comment.depth-2::before, .comment.depth-3::before { left: -11px; width: 8px; }
  #post-form { grid-template-columns: 1fr; }
  .reply-plate .field { min-height: 48px; padding: 0 12px; }
  .reply-plate .send { padding: 0 14px; }
}
