/* ======================================================================== */
/*  Lounge — "After the Last Reel"                                          */
/*  A private screening room after the audience has left and before the     */
/*  lights come up. Warm near-black, rationed cinema-red, worn film grain.   */
/*                                                                          */
/*  RED RULE — read before touching any colour:                             */
/*  --red (#c8423a) is a FILL / graphical colour ONLY (4.04:1 on bg — it     */
/*  FAILS AA as text). NEVER write `color: var(--red)` or `color:#c8423a`.   */
/*  Red that must be READ as a word uses --red-text (#e2685d, 5.99:1) or     */
/*  --red-text-hover (#ec8079). The seat-spine on a post card RESTS at       */
/*  --red-rest (oxblood) and ignites to --red only on hover / focus.         */
/*  Brass / sage / umber are ADMIN-LAYER ONLY — never in public nav, feed,   */
/*  hero, or the focus ring. One lamp, one meaning: red = live.              */
/* ======================================================================== */

/* ---------------------------------------------------------------------- */
/*  Self-hosted type (same-origin; required by CSP default-src 'self').     */
/*  font-display:swap — sane fallback glyphs while woff2 loads, no FOIT.     */
/* ---------------------------------------------------------------------- */
@font-face { font-family:'Newsreader'; font-style:normal; font-weight:400; font-display:swap; src:url('/theme/fonts/newsreader-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family:'Newsreader'; font-style:italic; font-weight:400; font-display:swap; src:url('/theme/fonts/newsreader-latin-400-italic.woff2') format('woff2'); }
@font-face { font-family:'Newsreader'; font-style:normal; font-weight:500; font-display:swap; src:url('/theme/fonts/newsreader-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family:'Hanken Grotesk'; font-style:normal; font-weight:400; font-display:swap; src:url('/theme/fonts/hanken-grotesk-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family:'Hanken Grotesk'; font-style:normal; font-weight:500; font-display:swap; src:url('/theme/fonts/hanken-grotesk-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family:'Hanken Grotesk'; font-style:normal; font-weight:600; font-display:swap; src:url('/theme/fonts/hanken-grotesk-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Mono'; font-style:normal; font-weight:400; font-display:swap; src:url('/theme/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); }

/* ---------------------------------------------------------------------- */
/*  Design tokens                                                           */
/* ---------------------------------------------------------------------- */
:root {
    /* ---- Core surfaces (warm near-black; elevate by warming, not shadow) ---- */
    --bg:            #0c0a0b;  /* warm near-black; R>G/B undertone, never #000 */
    --surface:       #15110f;  /* card/panel: one warm step up */
    --surface-raised:#1c1715;  /* hover/raised: second warm step */
    --well:          #100d0c;  /* recessed inputs, text-excerpt insets */
    --media-black:   #0a0809;  /* video/img letterbox: film-stock black, not #000 */

    /* ---- Text (warm off-white, never #fff) ---- */
    --text:        #ece4da;  /* body/heading: 15.67:1 on bg */
    --text-muted:  #b3a79c;  /* meta, secondary: 8.39:1 on bg */
    --text-faint:  #8a7e74;  /* separators/decoration: 5.00:1 on bg, AA-clean */
    --text-on-red: #f5efe8;  /* label on a red/oxblood fill only */

    /* ---- The lamp: one cinema-red, rationed ---- */
    --red:           #c8423a;  /* IGNITED: focus ring, primary fill, spine-on, active filter. FILL ONLY */
    --red-hover:     #d6584e;  /* primary button hover, spine brighten target */
    --red-rest:      #7a2a26;  /* oxblood: the spine AT REST; dim, persistent-safe, not 'red' */
    --red-text:      #e2685d;  /* the ONLY red allowed as a legible word: 5.99:1 */
    --red-text-hover:#ec8079;  /* link/danger text hover: 7.45:1 */
    --selection-bg:  #5a1f1c;  /* ::selection fill behind --text (10.12:1) */

    /* ---- Borders (hairlines; felt, not seen) ---- */
    --border:       #2a2320;  /* standard / hover edge */
    --border-soft:  #1e1916;  /* resting card edge */
    --border-strong:#4a3f39;  /* prefers-contrast backstop + secondary-button hover */

    /* ---- Brass: the admin / moderation room ONLY (never public, never focus) ---- */
    --brass:        #e0a955;  /* admin-link, override banner, public-view label/stripe */
    --brass-fill:   #241a0e;  /* dim brass chip ground */
    --brass-line:   #6b4f2a;  /* brass hairline (pending/override edges) */
    --brass-note-bg:#1a1206;  /* info-note ground (info != error temperature) */

    /* ---- Status semantics (dim-lit tinted chips, equal low intensity) ---- */
    --st-pending-fg:   #e0a955;  --st-pending-bg:   #241a0e;
    --st-rejected-fg:  #ec8079;  --st-rejected-bg:  #2a1411;  /* = banned; earned red-as-alarm */
    --st-deleted-fg:   #a89e90;  --st-deleted-bg:   #1d191a;
    --st-active-fg:    #7fbf8a;  --st-active-bg:    #14211a;  /* dim cinema-sage, the only green */
    --st-banned-fg:    #ec8079;  --st-banned-bg:    #2a1411;
    --st-shadow-fg:    #d09a6a;  --st-shadow-bg:    #241a10;  /* umber: dim, ambiguous */
    --st-neutral-fg:   #b3a79c;  --st-neutral-bg:   #211c1d;
    --perm-on-fg:      #7fbf8a;  --perm-on-bg:      #14211a;
    --perm-off-fg:     #8a7e74;  --perm-off-bg:     #1c1715;

    /* ---- Error / info boxes (dark palette, distinct temperatures) ---- */
    --error-fg:  #ec8079;  --error-bg:  #1f1210;  --error-border: #7a2a26;
    --info-fg:   #e0a955;  --info-bg:   #1a1206;  --info-border:  #6b4f2a;

    /* ---- Radius / spacing / motion ---- */
    --radius:      4px;    /* cards, tiles, inputs, buttons, banners */
    --radius-sm:   3px;    /* small chips, comments */
    --radius-pill: 999px;  /* tags, status pills, view-mode toggle ONLY */
    --radius-media:2px;    /* media wells */
    --space-1:.25rem; --space-2:.5rem; --space-3:.75rem; --space-4:1rem;
    --space-5:1.5rem; --space-6:2rem;  --space-7:3rem;   --space-8:4.5rem;
    --gutter: 1.5rem;      /* mobile; -> 2rem at >=720px */
    --ease: cubic-bezier(.2,0,.2,1);
    --dur: 160ms;

    /* ---- Font stacks (self-hosted; fallbacks keep swap legible) ---- */
    --font-display:'Newsreader', Georgia, 'Times New Roman', serif;
    --font-body:'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono:'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

/* ---------------------------------------------------------------------- */
/*  Base                                                                    */
/* ---------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Two fixed atmosphere layers behind content (z-index:0); content rides above
   at z-index:1 so neither ever muddies text. We deliberately avoid
   background-attachment:fixed (scroll jank) — fixed pseudo-elements give the
   same "the room stays still while you scroll" effect, cheaper to composite. */

/* (1) Worn film-grain — ONE continuous layer; soft-light warms, not speckles. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: url('/theme/images/grain.svg');
    background-size: 200px 200px;
    opacity: .045;
    mix-blend-mode: soft-light;
}
/* (2) One work-lamp vignette pulls the corners of the dark field down. */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(120% 90% at 50% 38%, transparent 55%, rgba(0,0,0,.34) 100%);
}

::selection { background: var(--selection-bg); color: var(--text); }

img, video { max-width: 100%; height: auto; }

/* ---- Headings: Newsreader (serif) is SIGNAGE only — top of hierarchy ---- */
h1 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.45rem, 1.05rem + 1.7vw, 1.75rem);
    line-height: 1.2;
    letter-spacing: -.015em;
    margin: 0 0 var(--space-5);
    color: var(--text);
    overflow-wrap: anywhere;   /* user-supplied h1s (tag/username) can't overflow */
}
h2 {
    font-family: var(--font-display);
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: -.01em;
}

p { margin: .5rem 0 1rem; }

/* ---- Links: warm, quiet; red only as a hover word (legible-red token) ---- */
a {
    color: var(--text);
    text-decoration: none;
    transition: color var(--dur) var(--ease);
}
a:hover, a:focus { color: var(--red-text); text-decoration: underline; text-underline-offset: 2px; }

.muted { color: var(--text-muted); }

/* ---------------------------------------------------------------------- */
/*  Layout                                                                  */
/* ---------------------------------------------------------------------- */
main {
    position: relative;   /* lifts content above the grain overlay */
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 2.5rem var(--gutter);
}
/* Wider container for grid pages (library, search, my-posts). */
main.wide { max-width: 1400px; }

/* Skip link — first focusable element; hidden until focused (keyboard a11y). */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    padding: .55rem 1rem;
    background: var(--surface-raised);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
}
.skip-link:focus { left: var(--gutter); top: .5rem; color: var(--text); text-decoration: none; }

/* Logged-out landing — the title-card. A dramatic serif name marooned in black:
   the most important silence in the system, "standing at the back of the house
   before the lights come up." Renders from home.php's .landing branch. */
.landing {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 56vh;
    max-width: 34ch;
}
.landing h1 {
    font-size: clamp(2.75rem, 7vw, 4.25rem);
    line-height: 1.04;
    letter-spacing: -.025em;
    margin: 0 0 var(--space-4);
}
.landing-lede {
    margin: 0 0 var(--space-5);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.2rem;
    line-height: 1.5;
    color: var(--text-muted);
}
.landing-cta { margin: 0; color: var(--text-muted); font-size: .95rem; }

.site-footer {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: var(--space-7) auto 0;
    padding: var(--space-5) var(--gutter) var(--space-6);
    color: var(--text-faint);
    font-size: .8rem;
    text-align: center;
}

/* ---------------------------------------------------------------------- */
/*  Forms                                                                   */
/* ---------------------------------------------------------------------- */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 360px;
    margin-top: 1.5rem;
}
.field { display: flex; flex-direction: column; gap: .3rem; }

label { font-family: var(--font-body); font-weight: 500; font-size: .95rem; color: var(--text); }
small { color: var(--text-muted); font-size: .85rem; }

input[type=text],
input[type=password],
textarea,
.admin-select {
    font: inherit;
    color: var(--text);
    background: var(--well);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .5rem .75rem;
    transition: border-color var(--dur) var(--ease), outline-color 120ms var(--ease);
}
textarea { resize: vertical; min-height: 6rem; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

/* Focus is RED — the lamp finding the field. Border + ring together. */
input:focus, textarea:focus, .admin-select:focus { outline: none; border-color: var(--red); }
input:focus-visible, textarea:focus-visible, .admin-select:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 2px;
    border-color: var(--red);
}
input:disabled, textarea:disabled {
    background: var(--well);
    color: var(--text-faint);
    cursor: not-allowed;
}

/* ---- Buttons ---- */
/* PRIMARY: the cue lamp you press — the one red fill per screen. */
button {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 1rem;            /* MUST stay >=16px: label contrast is AA-large only */
    line-height: 1.2;
    padding: .55rem 1.25rem;
    color: var(--text-on-red);
    background: var(--red);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    cursor: pointer;
    align-self: flex-start;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
button:hover, button:focus { background: var(--red-hover); border-color: var(--red-hover); }

/* SECONDARY: an unlit metal switch — warms, never reddens. */
.button-secondary,
a.button-secondary {
    display: inline-block;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: .9rem;
    padding: .4rem .85rem;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.button-secondary:hover, .button-secondary:focus {
    background: var(--surface-raised);
    border-color: var(--border-strong);
    color: var(--text);
    text-decoration: none;
}

/* DANGER: legible-red as a word at rest; fills red only on hover. */
.button-danger,
.button-secondary.button-danger {
    color: var(--red-text);
    background: transparent;
    border-color: var(--red-rest);
}
.button-danger:hover, .button-danger:focus,
.button-secondary.button-danger:hover, .button-secondary.button-danger:focus {
    color: var(--text-on-red);
    background: var(--red);
    border-color: var(--red);
}

/* Quiet text-button (Log out, comment delete/approve) — never a red fill. */
.link-button {
    font: inherit;
    background: none;
    border: none;
    padding: 0;
    color: var(--text-muted);
    cursor: pointer;
    align-self: auto;
    transition: color var(--dur) var(--ease);
}
.link-button:hover, .link-button:focus {
    color: var(--red-text);
    background: none;
    border: none;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.inline-form {
    display: inline;
    flex-direction: row;
    margin: 0;
    max-width: none;
    gap: 0;
}

/* ---- Error / info boxes (distinct temperatures: error=red, info=brass) ---- */
.errors {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: var(--radius);
    padding: .6rem .85rem;
    margin: 1rem 0 0;
    color: var(--error-fg);
}
.errors p { margin: .15rem 0; }

.info-note {
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    border-radius: var(--radius);
    padding: .55rem .85rem;
    margin: .5rem 0 1rem;
    color: var(--info-fg);
    font-size: .9rem;
}

.honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ---------------------------------------------------------------------- */
/*  Top nav — floats in the same darkness, lit only by its text            */
/* ---------------------------------------------------------------------- */
.topnav {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding: .85rem var(--gutter);
    background: var(--bg);
    border-bottom: 1px solid var(--border-soft);
}
.topnav-brand {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.15rem;
    letter-spacing: .01em;
    color: var(--text);
    text-decoration: none;
    /* a red baseline ignites on hover with no layout shift */
    border-bottom: 2px solid transparent;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.topnav-brand:hover, .topnav-brand:focus {
    color: #fff7ee;
    border-bottom-color: var(--red);
    text-decoration: none;
}
.topnav-links {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    gap: 1rem 1.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: .95rem;
}
.topnav-links li { display: flex; align-items: center; }
.topnav-links a {
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    padding-bottom: 1px;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.topnav-links a:hover, .topnav-links a:focus {
    color: var(--text);
    border-bottom-color: var(--red);
    text-decoration: none;
}
.topnav-user {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
    gap: .85rem;
    margin-left: auto;
    font-size: .9rem;
    color: var(--text-muted);
}
.topnav-username {
    color: var(--text);
    min-width: 0;
    max-width: 22ch;          /* a very long username truncates instead of overflowing */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Admin nav links: a brass-edged door to the side — present, but another room.
   Scoped to beat `.topnav-links a` (0,1,1) specificity so the chip + brass win. */
.admin-link,
.topnav-links a.admin-link {
    font-size: .85rem;
    color: var(--brass);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .15rem .55rem;
    transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.topnav-links a.admin-link:hover,
.topnav-links a.admin-link:focus {
    color: var(--brass);
    background: var(--brass-fill);
    border-color: var(--brass-line);
    text-decoration: none;
}

/* ---------------------------------------------------------------------- */
/*  Home feed — rows of dark seats catching low light                      */
/* ---------------------------------------------------------------------- */
.feed { display: flex; flex-direction: column; gap: 2.5rem; }

/* THE SIGNATURE COMPONENT: the seat-spine. A 3px left edge that RESTS at
   oxblood and ignites to cinema-red on hover / keyboard focus-within, while
   the surface warms one step — that one seat catching the projector's beam. */
.post-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--red-rest);
    border-radius: var(--radius);
    padding: 1rem 1.25rem 1.25rem;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.post-card:hover,
.post-card:focus-within {
    background: var(--surface-raised);
    border-color: var(--border);
    border-left-color: var(--red);
}

.post-full {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem 1.5rem;
}

/* Card titles are SANS (serif is reserved for true page/section headings). */
.post-card-title { margin: 0 0 .5rem; font-family: var(--font-body); font-weight: 600; font-size: 1.15rem; line-height: 1.3; word-break: break-word; }
.post-card-title a { color: var(--text); }
.post-card-title a:hover, .post-card-title a:focus { color: #fff7ee; text-decoration: none; }

/* The post-detail H1 IS signage — serif. */
.post-title { margin: 0 0 1rem; font-family: var(--font-display); font-weight: 500; font-size: clamp(1.45rem, 1.05rem + 1.7vw, 1.75rem); line-height: 1.2; letter-spacing: -.015em; overflow-wrap: anywhere; }

/* Media sits in a projector gate: film-stock black with a hairline frame. */
.post-media { margin: .25rem 0 .9rem; }
.post-media video,
.post-media img {
    display: block;
    width: 100%;
    height: auto;
    background: var(--media-black);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-media);
}

/* Meta in the booth's mono ledger voice. */
.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: .5rem;
    font-family: var(--font-mono);
    font-size: .8rem;
    letter-spacing: .02em;
    color: var(--text-muted);
}
.post-author::before { content: "by "; color: var(--text-faint); }
.post-date::before  { content: "· "; color: var(--text-faint); }

.post-body {
    margin: 1rem 0;
    white-space: pre-wrap;
    color: var(--text);
}

/* Text-post card: the body sinks into a recessed well (inner rule stays a
   quiet hairline — the card's own seat-spine already says "a seat"). */
.post-card-text .post-text-excerpt {
    margin: .5rem 0 .75rem;
    padding: .75rem 1rem;
    background: var(--well);
    border-left: 3px solid var(--border);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text);
    font-size: .95rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Status banners on the post-detail page. */
.post-status-banner {
    margin: 0 0 1rem;
    padding: .45rem .7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    color: var(--text-muted);
}
.post-status-banner strong { color: var(--text); }
.override-banner {
    background: var(--brass-fill);
    border-color: var(--brass-line);
    color: var(--brass);
}
.override-banner strong { color: var(--brass); }
.rejection-reason {
    background: var(--well);
    border-color: var(--red-rest);
    color: var(--red-text);
    font-family: var(--font-display);
    font-style: italic;
}
.rejection-reason strong { color: var(--red-text); }

/* ---------------------------------------------------------------------- */
/*  Tags — quiet reel-can markings; never an action, never red             */
/* ---------------------------------------------------------------------- */
.tag-groups {
    list-style: none;
    margin: .75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    font-size: .85rem;
}
.tag-group { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem; }
.tag-group-label {
    margin-right: .25rem;
    font-family: var(--font-mono);
    font-size: .78rem;
    letter-spacing: .02em;
    color: var(--text-faint);
}
a.tag {
    display: inline-block;
    padding: .1rem .65rem;
    line-height: 1.5;
    background: var(--surface-raised);
    color: var(--text-muted);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-pill);
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
a.tag:hover, a.tag:focus {
    background: var(--surface-raised);
    border-color: var(--border);
    color: var(--text);
    text-decoration: none;
}

/* ---------------------------------------------------------------------- */
/*  Pagination / breadcrumb                                                 */
/* ---------------------------------------------------------------------- */
.pagination { margin-top: 2rem; font-size: .95rem; color: var(--text-muted); }
.pagination a { color: var(--text-muted); font-family: var(--font-mono); letter-spacing: .02em; }
.pagination a:hover, .pagination a:focus { color: var(--red-text); }

.breadcrumb {
    margin: 0 0 1rem;
    font-family: var(--font-mono);
    font-size: .8rem;
    letter-spacing: .02em;
    color: var(--text-muted);
}

/* ---------------------------------------------------------------------- */
/*  Library / search — a contact sheet of frames in the dark               */
/* ---------------------------------------------------------------------- */
.library-filters {
    display: inline-flex;
    margin: .5rem 0 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.library-filter {
    padding: .4rem 1rem;
    font-size: .9rem;
    color: var(--text-muted);
    background: transparent;
    border-right: 1px solid var(--border);
    text-decoration: none;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.library-filter:last-child { border-right: none; }
.library-filter:hover { background: var(--surface-raised); color: var(--text); text-decoration: none; }
/* aria-current / active = live: red fill behind off-white, shared by pointer + keyboard */
.library-filter.active {
    color: var(--text-on-red);
    background: var(--red);
    box-shadow: inset 0 2px 0 var(--red-hover);
}
.library-filter.active:hover { background: var(--red); color: var(--text-on-red); }

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
    margin: 1rem 0 0;
}
.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tile:hover, .tile:focus { background: var(--surface-raised); border-color: var(--border); text-decoration: none; }
/* a 2px red seat-edge lights under the frame as you pass — hover/focus only */
.tile-thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    background: var(--media-black);
    overflow: hidden;
    border-bottom: 2px solid transparent;
    transition: border-color var(--dur) var(--ease);
}
.tile:hover .tile-thumb, .tile:focus .tile-thumb { border-bottom-color: var(--red); }
.tile-thumb img,
.tile-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-title {
    padding: .55rem .75rem .65rem;
    font-size: .9rem;
    line-height: 1.35;
    color: var(--text-muted);
    /* 2-line truncation with ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.7em;
    word-break: break-word;
    transition: color var(--dur) var(--ease);
}
.tile:hover .tile-title, .tile:focus .tile-title { color: var(--text); }

.empty-state { margin: 2rem 0; color: var(--text-muted); }

/* Search */
.search-form { max-width: none; margin: .5rem 0 1.5rem; }
.search-input-row { display: flex; gap: .5rem; align-items: stretch; }
.search-input-row input[type=text] { flex: 1; min-width: 0; }
.search-input-row button { align-self: stretch; }
.search-types { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: .75rem; font-size: .9rem; }
.search-types label {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-weight: 400;
    color: var(--text);
    cursor: pointer;
}
/* Checked controls rest at oxblood (the spine's resting tone) so no bright-red
   pixel sits on a resting page — full --red stays reserved for the one primary
   button fill + the active library-filter, and out of the admin permission grid. */
input[type=checkbox], input[type=radio] { accent-color: var(--red-rest); }

/* ---------------------------------------------------------------------- */
/*  Text tiles in grids                                                     */
/* ---------------------------------------------------------------------- */
.tile-text { background: var(--well); }
.tile-text-body {
    aspect-ratio: 16 / 9;
    padding: .65rem .8rem;
    overflow: hidden;
    border-left: 3px solid var(--border);   /* neutral edge — brass is admin-layer only, never the member feed */
    font-size: .85rem;
    line-height: 1.45;
    color: var(--text-muted);
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    line-clamp: 6;
    -webkit-box-orient: vertical;
}
.tile-text:hover .tile-text-body, .tile-text:focus .tile-text-body { color: var(--text); }

/* ---------------------------------------------------------------------- */
/*  Status badges — dim-lit tinted chips; none glows brighter than another  */
/* ---------------------------------------------------------------------- */
.tile-status {
    position: absolute;
    top: .45rem;
    right: .45rem;
    padding: .12rem .55rem;
    font-family: var(--font-body);
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-radius: var(--radius-sm);
    color: var(--st-neutral-fg);
    background: var(--st-neutral-bg);
}
.tile-status.status-pending  { color: var(--st-pending-fg);  background: var(--st-pending-bg); }
.tile-status.status-rejected { color: var(--st-rejected-fg); background: var(--st-rejected-bg); }
.tile-status.status-deleted  { color: var(--st-deleted-fg);  background: var(--st-deleted-bg); }

.user-status {
    padding: .12rem .6rem;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-radius: var(--radius-pill);
    color: var(--st-neutral-fg);
    background: var(--st-neutral-bg);
}
.user-status.status-active       { color: var(--st-active-fg); background: var(--st-active-bg); }
.user-status.status-banned       { color: var(--st-banned-fg); background: var(--st-banned-bg); }
.user-status.status-shadowbanned { color: var(--st-shadow-fg); background: var(--st-shadow-bg); }

.user-perms { white-space: nowrap; }
.perm-chip {
    display: inline-block;
    width: 1.5rem;
    margin-right: .15rem;
    padding: .05rem .1rem;
    text-align: center;
    font-family: var(--font-mono);
    font-size: .72rem;
    border-radius: var(--radius-sm);
}
.perm-chip.on  { color: var(--perm-on-fg);  background: var(--perm-on-bg); }
.perm-chip.off { color: var(--perm-off-fg); background: var(--perm-off-bg); }

/* ---------------------------------------------------------------------- */
/*  Comments                                                                */
/* ---------------------------------------------------------------------- */
.comments-section,
.comments-placeholder,
.rejected-notes {
    margin-top: var(--space-7);
    padding-top: 1rem;
    border-top: 1px solid var(--border-soft);
}
.comments-section h2,
.comments-placeholder h2,
.rejected-notes h2 { font-size: 1.15rem; margin: 0 0 .75rem; color: var(--text); }
.comment-count { font-family: var(--font-mono); font-weight: 400; font-size: .9rem; color: var(--text-muted); }

.comment-list {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .85rem;
}
.comment {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: .6rem .85rem;
}
.comment-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .5rem;
    margin-bottom: .3rem;
    font-size: .85rem;
    color: var(--text-muted);
}
.comment-author { color: var(--text); font-weight: 600; }
.comment-when { font-family: var(--font-mono); font-size: .78rem; letter-spacing: .02em; color: var(--text-muted); }
.comment-body { color: var(--text); word-break: break-word; }
.comment-deleted {
    background: var(--well);
    border-color: transparent;
    color: var(--text-muted);
}
.comment-deleted .comment-meta { font-family: var(--font-display); font-style: italic; color: var(--text-muted); }
.comment-delete-form { margin-left: auto; }
.comment-delete-button, .comment-approve-button { font-size: .8rem; }

/* Pending = house-lights-half-up: brass, never red (awaiting != rejected). */
.comment-pending { background: var(--surface); border-color: var(--brass-line); border-left-width: 2px; }
.comment-pending-marker {
    padding: .05rem .55rem;
    border-radius: var(--radius-pill);
    font-size: .72rem;
    font-weight: 600;
    color: var(--st-pending-fg);
    background: var(--st-pending-bg);
}
.comment-override-marker {
    padding: .05rem .55rem;
    border-radius: var(--radius-pill);
    font-size: .72rem;
    font-weight: 600;
    color: var(--brass);
    background: transparent;
    border: 1px solid var(--brass-line);
}

.comment-form { display: flex; flex-direction: column; gap: .45rem; max-width: none; margin-top: 0; }
.comment-form label { font-size: .9rem; }
.comment-form button { align-self: flex-start; }

/* ---------------------------------------------------------------------- */
/*  Rejected notes (on /my-posts)                                           */
/* ---------------------------------------------------------------------- */
.rejected-note {
    margin-bottom: .5rem;
    padding: .5rem .85rem;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: var(--radius-sm);
}
.rejected-note strong { color: var(--red-text); }
.rejected-note p { margin: .25rem 0 0; color: var(--text); }

/* ---------------------------------------------------------------------- */
/*  Admin — the projection-booth ledger: functional, dim, monospaced        */
/* ---------------------------------------------------------------------- */
.admin-form { max-width: 640px; }
.admin-form textarea { min-height: 6rem; }
.admin-form input[type=file] { font: inherit; color: var(--text-muted); padding: .25rem 0; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: .9rem;
}
/* On small screens wide admin tables (7 cols) scroll within themselves rather
   than forcing the whole page to scroll horizontally. display:block keeps the
   internal table layout via anonymous table boxes. */
@media (max-width: 680px) {
    .admin-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
.admin-table th, .admin-table td {
    text-align: left;
    padding: .5rem .65rem;
    vertical-align: top;
    border-bottom: 1px solid var(--border-soft);
}
.admin-table th {
    font-weight: 600;
    color: var(--text);
    background: var(--surface-raised);
    border-bottom: 1px solid var(--border);
}
.admin-table tr:hover td { background: var(--surface); }
/* Machine values in the table read in the mono ledger voice. */
.admin-table td code, .log-table code, .action-log-inline code {
    font-family: var(--font-mono);
    font-size: .82rem;
    padding: .05rem .35rem;
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    color: var(--text-muted);
}

.checkbox-row { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.checkbox-row input { margin: 0; }

.action-log-inline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    font-size: .85rem;
}

/* Queue list / detail */
.queue-list { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.queue-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: .75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
}
.queue-item-main { flex: 1; min-width: 0; }
.queue-item-actions { flex-shrink: 0; }   /* a long title can never squeeze the action column */
.queue-item-actions .button-secondary { white-space: nowrap; }
.queue-item-title a { color: var(--text); }
.queue-item-title a:hover { color: #fff7ee; text-decoration: none; }
.queue-item-meta { margin: .25rem 0; font-family: var(--font-mono); font-size: .8rem; letter-spacing: .02em; color: var(--text-muted); }
.queue-item-meta span { margin-right: .25rem; }
.queue-item-excerpt { margin: .35rem 0 0; font-size: .9rem; color: var(--text-muted); word-break: break-word; }

.queue-detail {
    margin: 1rem 0;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
}
.queue-detail-meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1rem;
    row-gap: .25rem;
    margin: 0 0 1rem;
    font-family: var(--font-mono);
    font-size: .85rem;
}
.queue-detail-meta dt { color: var(--text-muted); }
.queue-detail-meta dd { margin: 0; min-width: 0; color: var(--text); word-break: break-word; }
.queue-detail h2 { font-family: var(--font-display); font-size: 1rem; margin: .75rem 0 .25rem; color: var(--text); }
.queue-detail-title { margin: 0 0 1rem; font-family: var(--font-display); font-weight: 500; font-size: 1.35rem; word-break: break-word; }
.queue-detail-body { white-space: pre-wrap; color: var(--text); }

.queue-actions h2 { font-family: var(--font-display); font-size: 1rem; margin: 1.5rem 0 .5rem; }
.queue-action-form {
    max-width: none;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
}

/* Admin controls cluster on post-detail / queue. */
.post-full-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}
.post-full-header .post-title { margin: 0; }
.post-admin-controls { display: flex; gap: .4rem; flex-wrap: wrap; font-size: .85rem; }

/* View-mode toggle — admin (quiet) vs public (prominent brass, content filtered). */
.view-mode-form { margin: 0; }
.view-mode-toggle {
    font-family: var(--font-body);
    font-size: .8rem;
    font-weight: 500;
    padding: .2rem .7rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.view-mode-admin {
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
}
.view-mode-admin:hover { background: var(--surface-raised); color: var(--text); border-color: var(--border-strong); }
.view-mode-public {
    color: var(--brass);
    background: var(--brass-fill);
    border: 1px solid var(--brass-line);
}
.view-mode-public:hover { background: #2e2212; border-color: var(--brass); color: var(--brass); }

/* When admin is in public view, a brass top stripe = "house lights filtering
   what you see." Brass, not red, so the public red language stays untouched. */
body.admin-public-view { border-top: 3px solid var(--brass); }

/* ---------------------------------------------------------------------- */
/*  Focus — mandatory, consistent, RED (the cue lamp on every control)      */
/* ---------------------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
.button-secondary:focus-visible,
.link-button:focus-visible,
.topnav-brand:focus-visible,
.topnav-links a:focus-visible,
.admin-link:focus-visible,
.library-filter:focus-visible,
.view-mode-toggle:focus-visible,
.tile:focus-visible,
a.tag:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 2px;
}
/* On the red-filled primary button + active filter, ring switches to off-white. */
button:focus-visible,
.library-filter.active:focus-visible { outline-color: var(--text-on-red); }
/* Keyboard users tabbing into a card light the seat exactly like hover. */
.tile:focus-within { background: var(--surface-raised); border-color: var(--border); }

/* ---------------------------------------------------------------------- */
/*  Responsive                                                              */
/* ---------------------------------------------------------------------- */
@media (min-width: 720px) {
    :root { --gutter: 2rem; }
    main { padding: var(--space-8) var(--gutter); }
}

/* Narrow: nav settles into two calm rows (brand+user, then links). No JS, no
   hamburger — navigation stays fully visible to a brand-new user. */
@media (max-width: 560px) {
    .topnav { gap: .75rem 1rem; }
    .topnav-links { order: 3; flex-basis: 100%; gap: .85rem 1.1rem; }
    .topnav-user { margin-left: auto; }
}

@media (max-width: 480px) {
    body::before { opacity: .035; }   /* avoid shimmer on dense thumbnail grids */
    .post-full { padding: 1rem 1.1rem 1.25rem; }
}

/* ---------------------------------------------------------------------- */
/*  Preference media queries                                                */
/* ---------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

@media (prefers-contrast: more) {
    :root {
        --border:       #4a3f39;
        --border-soft:  #4a3f39;
        --text-muted:   #c6bbb0;
        --text-faint:   #a89c90;
    }
    body::before { opacity: 0; }   /* never muddy text when max contrast is asked for */
    a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible,
    .button-secondary:focus-visible, .link-button:focus-visible, .tile:focus-visible,
    .library-filter:focus-visible, a.tag:focus-visible, .view-mode-toggle:focus-visible,
    .topnav-links a:focus-visible, .topnav-brand:focus-visible, .admin-link:focus-visible,
    .admin-select:focus-visible {
        outline-width: 3px;
    }
}

/* ---------------------------------------------------------------------- */
/*  Progressive scrollbar (never load-bearing)                              */
/* ---------------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--border) var(--bg); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border: 3px solid var(--bg); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
