/* Resident surfaces (STYLE-RESIDENT-1). The shared look for compose, posts, replies, profile tabs, settings and the
   moderator workspace, extracted from the Community Vibe feed. Spec: docs/design/resident-surfaces-style-guide.md.
   Rules: tokens from trace.css only; no icons, emoji, toolbars or video; text links and soft pills, not rows of bordered
   buttons; one primary action per screen. Every class is prefixed .res-, so loading this file cannot change a screen
   that does not use it. The only literal values are the ones the guide names (white tile, tile line, tile shadow). */

:root {
  --res-tile: #fff;                         /* the one white (the feed's --vibe-tile); --card is a cream tint */
  --res-tile-line: #e7e1d2;                 /* the feed's tile hairline */
  --res-tile-shadow: 0 1px 2px rgba(60, 50, 20, .05);
  --res-tile-radius: 12px;                  /* the feed tile radius (FEED-TILES-1); --radius 14px is for page-level panels */
  --res-gap: 8px;                           /* space between tiles, as in the feed */
  --res-measure: 680px;                     /* feed column width at 1440 */
  --res-pad: 16px;                          /* tile padding */
  --res-pad-sm: 12px;                       /* tile padding below 480px */
}

/* ---------- page: cream paper, one column ---------- */
.res-page { width: min(100% - 2 * var(--s4), var(--res-measure)); margin-inline: auto; padding: var(--s5) 0 var(--s8); display: grid; gap: var(--s4); }
.res-page--wide { --res-measure: 920px; }
@media (min-width: 761px) { .res-page { padding-top: var(--s6); } }

/* ---------- page header + tab bar ---------- */
.res-head { display: grid; gap: var(--s1); }
.res-head__eyebrow { margin: 0; font: 700 var(--fs-xs)/1.3 var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.res-head__title { margin: 0; font: 600 var(--fs-2xl)/1.15 var(--font-display); letter-spacing: -0.01em; color: var(--ink); overflow-wrap: anywhere; }
.res-head__meta { margin: 0; font-size: var(--fs-sm); line-height: 1.4; color: var(--ink-3); }
.res-tabs { display: flex; flex-wrap: wrap; gap: 0 var(--s1); border-bottom: 1px solid var(--line); }   /* wraps, never scrolls: a hidden tab is a lost tab (and French labels run longer) */
.res-tab { flex: none; display: inline-flex; align-items: center; min-height: var(--btn-h); padding: 0 var(--s3); margin-bottom: -1px; border-bottom: 2px solid transparent; font: 600 var(--fs-sm)/1.2 var(--font-body); color: var(--ink-3); text-decoration: none; }
.res-tab:hover { color: var(--ink); }
.res-tab[aria-current="page"], .res-tab[aria-current="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.res-tab:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-tag); }

/* ---------- tile ---------- */
.res-tile { background: var(--res-tile); border: 1px solid var(--res-tile-line); border-radius: var(--res-tile-radius); box-shadow: var(--res-tile-shadow); padding: var(--res-pad); min-width: 0; display: grid; gap: var(--s2); align-content: start; }
.res-stack { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--res-gap); }
@media (max-width: 480px) { .res-tile { padding: var(--res-pad) var(--res-pad-sm); } .res-stack, .res-tile--bleed { margin-inline: calc(-1 * var(--s2)); } }
.res-tile:focus-within { border-color: var(--line-2); }

/* ---------- section heading ---------- */
.res-h { margin: 0; font: 600 var(--fs-xl)/1.2 var(--font-display); letter-spacing: -0.01em; color: var(--ink); }
.res-h--sm { font: 700 var(--fs-md)/1.3 var(--font-body); letter-spacing: 0; }
.res-lead { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-2); }   /* one line under a heading; never a paragraph */

/* ---------- settings row: heading, one-line hint, control ---------- */
.res-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s1) var(--s4); align-items: center; padding: var(--s3) 0; border-top: 1px solid var(--line); }
.res-row:first-child { border-top: 0; }
.res-row__label { margin: 0; font: 600 var(--fs-md)/1.3 var(--font-body); color: var(--ink); }
.res-row__hint { grid-column: 1; margin: 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--ink-3); }
.res-row__control { grid-column: 2; grid-row: 1 / span 2; justify-self: end; }
@media (max-width: 480px) { .res-row { grid-template-columns: minmax(0, 1fr); } .res-row__control { grid-column: 1; grid-row: auto; justify-self: start; } }

/* ---------- form fields ---------- */
.res-field { display: grid; gap: var(--s1); min-width: 0; }
.res-field__label { font: 600 var(--fs-sm)/1.3 var(--font-body); color: var(--ink); }
.res-field__hint { margin: 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--ink-3); }  /* max one line of help */
.res-input, .res-select, .res-textarea { width: 100%; min-height: var(--btn-h); padding: 0 var(--s3); border: 1px solid var(--line-2); border-radius: var(--radius-field); background: var(--res-tile); color: var(--ink); font: 400 var(--fs-md)/1.5 var(--font-body); }
.res-input--title { font: 600 var(--fs-lg)/1.3 var(--font-body); }
.res-textarea { padding: var(--s3); min-height: calc(var(--btn-h) * 2); resize: none; field-sizing: content; max-height: 60vh; }   /* grows with the text */
.res-select { appearance: none; -webkit-appearance: none; padding-right: var(--s6); background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.res-input:hover, .res-select:hover, .res-textarea:hover { border-color: var(--ink-3); }
.res-input:focus-visible, .res-select:focus-visible, .res-textarea:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--ink); }
.res-field[data-invalid] .res-input, .res-field[data-invalid] .res-textarea, .res-field[data-invalid] .res-select { border-color: var(--red); }
.res-field__error { margin: 0; font: 600 var(--fs-sm)/1.4 var(--font-body); color: var(--red); }   /* red text, same sentence-case voice; never a banner inside a form */
.res-field__count { justify-self: end; font-size: var(--fs-xs); color: var(--ink-3); }

/* segmented choice: 2 to 4 short options; labels wrap, no fixed width */
.res-seg { display: flex; flex-wrap: wrap; gap: var(--s1); padding: 0; margin: 0; border: 0; }
.res-seg__opt { position: relative; }
.res-seg__opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.res-seg__opt span { display: inline-flex; align-items: center; min-height: var(--btn-h); padding: 0 var(--s3); border-radius: var(--radius-pill); font: 600 var(--fs-sm)/1.2 var(--font-body); color: var(--ink-2); background: var(--paper-2); }
.res-seg__opt input:checked + span { background: var(--ink); color: var(--paper); }
.res-seg__opt input:focus-visible + span { box-shadow: var(--focus-ring); }

/* ---------- buttons: ONE primary per screen; everything else is quiet, a text link, or destructive text ---------- */
.res-btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--btn-h); padding: 0 var(--s5); border: 1px solid transparent; border-radius: var(--radius-pill); font: 700 var(--fs-btn)/1.2 var(--font-body); text-decoration: none; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.res-btn--primary { background: var(--tc-amber, #F9B32E); border-color: var(--tc-amber, #F9B32E); color: var(--night); }
.res-btn--primary:hover { background: var(--tc-amber-hover, var(--accent-bright)); border-color: var(--tc-amber-hover, var(--accent-bright)); }
.res-btn--quiet { background: var(--paper-2); color: var(--ink); font-weight: 600; }
.res-btn--quiet:hover { background: var(--line); }
.res-btn[disabled], .res-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.res-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.res-link { display: inline-flex; align-items: center; min-height: var(--btn-h); padding: 0; border: 0; background: none; font: 600 var(--fs-sm)/1.3 var(--font-body); color: var(--accent); text-decoration: none; cursor: pointer; }
.res-link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.res-link:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-tag); }
.res-link--danger { color: var(--red); }
/* amber text (--accent) measured: 5.42:1 on white, 4.81:1 on the cream page: AA on both, but not on paper-2 or a wash. On any tinted fill (paper-2, washes) a link is ink and underlined. */
.res-undo .res-link, .res-notice .res-link, .res-confirm .res-link, .res-pill .res-link { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.res-link--inline { min-height: 0; display: inline; }   /* inside a sentence; the 44px target is the whole row or line it sits in */
.res-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s4); }

/* ---------- flair and status pills: soft fill, quiet text, content-width (French runs about 25% longer) ---------- */
.res-pill { display: inline-flex; align-items: center; max-width: 100%; min-height: var(--chip-h); padding: 0 var(--s3); border-radius: var(--radius-pill); background: var(--paper-2); color: var(--ink-2); font: 600 var(--fs-xs)/1.2 var(--font-body); white-space: normal; text-decoration: none; }
.res-pill--sm { min-height: 24px; padding: 0 var(--s2); }
.res-pill--accent { background: var(--accent-wash); color: var(--ink); }
.res-pill--ok { background: var(--green-wash); color: var(--green); }
.res-pill--warn { background: var(--accent-wash); color: var(--ink); }   /* amber text on amber wash is 4.44:1: too low, so ink */
.res-pill--bad { background: var(--red-wash); color: var(--red); }
.res-pill--level { background: color-mix(in srgb, var(--lvl, var(--ink-3)) 12%, var(--res-tile)); color: var(--lvl, var(--ink-2)); }   /* only where the government level IS the meaning */
a.res-pill:hover, button.res-pill:hover { background: var(--line); }
.res-pill[aria-current="true"], .res-pill[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.res-pill:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.res-pills { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
/* filter pills sit on a 44px row even though the pill is 32px: the row owns the target */
.res-pills--filter { min-height: var(--btn-h); }

/* ---------- notices ---------- */
.res-notice { margin: 0; padding: var(--s3) var(--s4); border-radius: var(--radius-field); background: var(--paper-2); color: var(--ink); font: 400 var(--fs-sm)/1.45 var(--font-body); }
.res-notice--ok { background: var(--green-wash); color: var(--ink); }
.res-notice--warn { background: var(--accent-wash); color: var(--ink); }
.res-notice--error { background: var(--red-wash); color: var(--ink); }
.res-notice--ok::first-line, .res-notice--error::first-line { font-weight: 600; }
/* the post-confirmation line: sits ABOVE the post it confirms, one sentence, one text link */
.res-confirm { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s3); margin: 0; padding: var(--s3) var(--s4); border-radius: var(--radius-field); background: var(--green-wash); font: 600 var(--fs-sm)/1.45 var(--font-body); color: var(--ink); }

/* ---------- author line + date, post body ---------- */
.res-byline { margin: 0; font: 700 var(--fs-sm)/1.35 var(--font-body); color: var(--ink); overflow-wrap: anywhere; }
.res-meta { margin: 0; font: 400 var(--fs-xs)/1.4 var(--font-body); color: var(--ink-3); }   /* date, place, kind: one line, dot separated, never bold */
.res-meta a { color: inherit; }
.res-title { margin: 0; font: 700 var(--fs-lg)/1.3 var(--font-body); color: var(--ink); overflow-wrap: anywhere; }   /* post title in tiles: the feed headline */
.res-title--page { font: 600 var(--fs-2xl)/1.15 var(--font-display); letter-spacing: -0.01em; }
.res-body { margin: 0; font: 400 var(--fs-md)/1.6 var(--font-body); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; max-width: var(--measure); }
.res-snippet { margin: 0; font: 400 var(--fs-sm)/1.5 var(--font-body); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.res-snippet--solo { font-size: var(--fs-md); line-height: 1.5; color: var(--ink); -webkit-line-clamp: 3; }   /* an untitled post: its first words stand in for the title */
.res-words { display: grid; gap: var(--s3); }
.res-context { margin: 0; font: 400 var(--fs-xs)/1.4 var(--font-body); color: var(--ink-3); }   /* "Replying to ..." */
.res-context a { color: var(--ink-2); font-weight: 600; text-underline-offset: 3px; }

/* ---------- replies: a hairline rail, 16px indent, one level of visual nesting ---------- */
.res-replies { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.res-reply { display: grid; gap: var(--s1); min-width: 0; }
.res-reply .res-replies { margin-top: var(--s3); margin-left: var(--s4); padding-left: var(--s3); border-left: 2px solid var(--line); }
.res-reply .res-reply .res-replies { margin-left: 0; padding-left: var(--s3); }   /* deeper levels keep the same indent: depth is shown by the rail, not by shrinking the column */

/* ---------- empty state: one sentence and, at most, one text link ---------- */
.res-empty { margin: 0; padding: var(--s5) 0; text-align: center; color: var(--ink-3); font-size: var(--fs-sm); display: grid; gap: var(--s2); justify-items: center; }

/* ---------- list row (Your words) and moderator queue row ---------- */
.res-item { display: grid; gap: var(--s1); }
.res-item--linked { position: relative; }
.res-item__open { color: inherit; text-decoration: none; }
.res-item__open::after { content: ""; position: absolute; inset: 0; border-radius: var(--res-tile-radius); }   /* whole tile is the link: no repeated "View thread" */
.res-item__open:focus-visible { outline: none; }
.res-item__open:focus-visible::after { box-shadow: var(--focus-ring); }
.res-item--linked:hover .res-title { color: var(--accent); }
.res-item__foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); position: relative; z-index: 1; }
.res-queue { display: grid; gap: var(--s2); }
.res-queue__quote { margin: 0; padding: var(--s2) var(--s3); border-left: 2px solid var(--line-2); color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.res-queue__decide { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s4); }

/* ---------- confirmation and undo ---------- */
.res-undo { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s3); margin: 0; padding: var(--s3) var(--s4); border-radius: var(--radius-field); background: var(--paper-2); font-size: var(--fs-sm); line-height: 1.45; color: var(--ink); }
.res-confirm-delete { display: grid; gap: var(--s3); }

/* ---------- accessibility ---------- */
@media (prefers-reduced-motion: reduce) { .res-btn, .res-pill, .res-link { transition: none; } }
@media (forced-colors: active) {
  .res-tab[aria-current="page"], .res-pill[aria-current="true"], .res-seg__opt input:checked + span { outline: 2px solid CanvasText; }
  .res-tile { border-color: CanvasText; }
}

/* ---------- What mattered to you: month headings and the inline Undo form ---------- */
.res-month { list-style: none; margin: var(--s2) 0 0; padding: 0; }
.res-month__title { margin: 0; font: 700 var(--fs-xs)/1.3 var(--font-body); color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }
.res-item__undo { margin: 0; display: inline; }
