/* ============================================================
   The Refuge — Basecamp
   Communal, unglossy. Navy identity, lichen-green accent, stone
   ground — and the same room after dark, which is the other half
   of the same design rather than an inversion of it.

   Every colour on the site is one of the tokens below. That is
   what makes two themes possible without two stylesheets: the
   rules underneath never name a colour, so the dark blocks only
   have to say what the words mean, not repeat what uses them.

   Three blocks, in this order, and the order matters:

     :root                          the light palette, always
     prefers-color-scheme: dark     unless light was chosen
     [data-theme="dark"]            when dark was chosen

   The middle one is guarded with :not([data-theme="light"]) so
   that somebody on a dark device who picks light actually gets
   it. The last one has to come after, so that picking dark on a
   light device wins too. Miss either and the control works in
   one direction only.

   The theme is written onto <html> by the server, from a cookie,
   before the page is sent — see Helpers/Theme.cs. The content
   policy forbids inline script, so there is no way to set it in
   the head from JavaScript, which is exactly why there is no
   flash of the wrong colours here.
   ============================================================ */

:root {
    color-scheme: light;

    --ground: #f3f4f0;
    --card: #ffffff;
    --sunk: #eceee8;

    --ink: #1c2233;
    --ink-soft: #5f6572;
    --ink-faint: #878d99;

    --rule: #d8dbd3;
    --rule-soft: #e6e8e1;

    /* The masthead. The site's own colour, and the one thing that does not lighten after dark. */
    --navy: #151d31;
    --navy-soft: #1e2942;
    --navy-ink: #eef0ea;

    /* A solid slab of the identity colour on a page: the selected room, a pinned notice, an
       organisation badge. Separate from --navy because the two go opposite ways in the dark —
       a slab has to stand off the page, and the masthead has to stay the masthead. */
    --mark: #151d31;
    --mark-ink: #eef0ea;

    --green: #415c49;
    --green-bright: #4a6b52;
    --green-ink: #ffffff;

    /* Where a link goes when you hover it. Towards the ink in the light, towards the accent in
       the dark — the same intent, which is "more of it", pointing at different ends. */
    --link-hover: #151d31;

    --chip: #e5e9e0;
    --chip-ink: #2f4436;
    --chip-line: #cdd3c6;

    --danger: #8c2f2f;
    --danger-soft: #f4e9e9;
    --danger-line: #e2c9c9;

    /* A name's colour. Only the hue travels from the server — see Palette.cs — because how
       saturated and how light it should be is a question about the background it lands on, and
       a colour that reads on stone is a highlighter pen on navy.

       --who is the per-name hue, set inline on the element. The fallback is here so that a name
       whose hue never arrived still gets a colour rather than an invalid one. */
    --who: 210;
    --who-s: 42%;
    --who-l: 30%;

    /* The same hue as the letter in the circle, which needs to be a background rather than text. */
    --av-s: 30%;
    --av-l: 32%;
    --av-ink: #ffffff;

    --f-head: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
    --f-body: 'Segoe UI', system-ui, -apple-system, sans-serif;

    --r: 6px;
    --shell: 1120px;
}

/* The dark palette, written once and applied twice. The device's preference, unless the reader
   asked for light. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --ground: #0e1425;
        --card: #151d31;
        --sunk: #1b2440;

        --ink: #e7eaf1;
        --ink-soft: #a6aec1;
        --ink-faint: #7b8599;

        --rule: #2b3450;
        --rule-soft: #222b45;

        --navy: #0a0f1d;
        --navy-soft: #151d31;
        --navy-ink: #e7eaf1;

        --mark: #2d3b60;
        --mark-ink: #e7eaf1;

        --green: #7aab88;
        --green-bright: #8cbd9a;
        --green-ink: #0e1425;

        --link-hover: #a9d3b6;

        --chip: #1f2b41;
        --chip-ink: #a8c9b3;
        --chip-line: #35425e;

        --danger: #e2a3a3;
        --danger-soft: #341d21;
        --danger-line: #5c3436;

        --who-s: 55%;
        --who-l: 72%;

        --av-s: 40%;
        --av-l: 46%;
        --av-ink: #0e1425;
    }
}

/* And the same again for somebody who asked for dark on a device that did not. Duplicated
   values rather than a shared class, because a class would have to be put on the element by
   script, and script runs after the first paint. */
:root[data-theme="dark"] {
    color-scheme: dark;

    --ground: #0e1425;
    --card: #151d31;
    --sunk: #1b2440;

    --ink: #e7eaf1;
    --ink-soft: #a6aec1;
    --ink-faint: #7b8599;

    --rule: #2b3450;
    --rule-soft: #222b45;

    --navy: #0a0f1d;
    --navy-soft: #151d31;
    --navy-ink: #e7eaf1;

    --mark: #2d3b60;
    --mark-ink: #e7eaf1;

    --green: #7aab88;
    --green-bright: #8cbd9a;
    --green-ink: #0e1425;

    --link-hover: #a9d3b6;

    --chip: #1f2b41;
    --chip-ink: #a8c9b3;
    --chip-line: #35425e;

    --danger: #e2a3a3;
    --danger-soft: #341d21;
    --danger-line: #5c3436;

    --who-s: 55%;
    --who-l: 72%;

    --av-s: 40%;
    --av-l: 46%;
    --av-ink: #0e1425;
}

* { box-sizing: border-box; }

/* The hidden attribute has to beat any display rule we write later. This has already caused two
   bugs — a reply banner that could never be dismissed, and an empty preview box under the chat
   composer — both because a plain `display: flex` or `display: block` silently outranks the
   user-agent's [hidden] rule. One line, once, so it cannot happen a third time. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--f-body);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* The landmark wrapping the page content. It has to be transparent to layout, not merely
   present: body is a flex column and the room, which fills the screen exactly, reaches that by
   being a flex child of it. Dropping a plain div in between makes the room a grandchild and it
   stops filling anything. flex: 1 passes the height through, and min-height: 0 is what lets the
   chat log scroll inside it rather than growing the page. */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

a { color: var(--green); }
a:hover { color: var(--link-hover); }

:focus-visible {
    outline: 2px solid var(--green-bright);
    outline-offset: 2px;
    border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------------- masthead ---------------- */

.mast {
    background: var(--navy);
    color: var(--navy-ink);
}

.mast-inner {
    max-width: var(--shell);
    margin: 0 auto;
    padding: 0 20px;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    flex-wrap: wrap;
}

.wordmark {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: var(--f-head);
    font-weight: 700;
    font-size: 17.5px;
    letter-spacing: -0.01em;
    color: var(--navy-ink);
    text-decoration: none;
    white-space: nowrap;
}

.wordmark svg { display: block; flex: none; }
.wordmark:hover { color: #fff; }

/* The nav sits after the auth block in the markup so that on a phone it can wrap onto its own
   full-width row without pushing the account controls down with it. order puts it back in the
   middle on a wide screen, where there is room for all three across. */
.mast-nav {
    display: flex;
    gap: 19px;
    flex-wrap: wrap;
    align-items: center;
    order: 2;
}

.mast-nav a {
    color: var(--navy-ink);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    padding: 7px 0;
    border-bottom: 2px solid transparent;
    opacity: 0.86;
}

.mast-nav a:hover { opacity: 1; border-bottom-color: rgba(238, 240, 234, 0.45); }
.mast-nav a.on { opacity: 1; border-bottom-color: var(--green-bright); }

.mast-auth {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    order: 3;
    flex-wrap: wrap;
}

.mast-who { color: rgba(238, 240, 234, 0.72); white-space: nowrap; }
.mast-who b { color: var(--navy-ink); font-weight: 600; }

.role-tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(238, 240, 234, 0.15);
    color: var(--navy-ink);
    margin-left: 6px;
}

/* ---------------- light and dark ---------------- */

/* Which icon and which label show is decided here rather than by the server, and that is the
   point: the server knows what the cookie says, and CSS knows what the reader is actually
   looking at. Those differ in exactly one case — a device set to dark, belonging to somebody
   who has never touched the control — and it is the case a server-rendered icon gets wrong.

   The labels are the button's accessible name. The hidden one is display:none rather than
   visually hidden, so a screen reader announces the one on screen and not both. */
.theme-form { display: flex; margin: 0; }

.theme-toggle { padding: 5px 9px; }

/* Everything off, then exactly one pair back on. Written this way, and every selector carrying
   .theme-toggle, because specificity decides this and not source order: a bare `.i-sun` loses
   to a `.theme-toggle svg` sitting above it, which is how both icons ended up on screen at once.
   Keeping all four rules at the same shape means the only thing that varies is the theme. */
.theme-toggle svg,
.theme-toggle .on-light,
.theme-toggle .on-dark { display: none; }

.theme-toggle .i-moon,
.theme-toggle .on-light { display: block; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .i-moon,
    :root:not([data-theme="light"]) .theme-toggle .on-light { display: none; }

    :root:not([data-theme="light"]) .theme-toggle .i-sun,
    :root:not([data-theme="light"]) .theme-toggle .on-dark { display: block; }
}

/* Same specificity as the block above, later in the file — which is what makes an explicit
   choice of dark beat a device that merely prefers light, and vice versa. */
:root[data-theme="dark"] .theme-toggle .i-moon,
:root[data-theme="dark"] .theme-toggle .on-light { display: none; }

:root[data-theme="dark"] .theme-toggle .i-sun,
:root[data-theme="dark"] .theme-toggle .on-dark { display: block; }

/* The words are for screen readers and for a wide screen with room for them. Below that the
   masthead already carries five links, an account name and two buttons, and a word here is the
   one that pushes it onto another row. */
.on-light, .on-dark { font-size: 12px; }

@media (max-width: 900px) {
    .on-light, .on-dark {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

/* ---------------- buttons & controls ---------------- */

.btn {
    font-family: var(--f-body);
    font-size: 13.5px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--r);
    border: 1px solid var(--green-bright);
    background: var(--green-bright);
    color: var(--green-ink);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    line-height: 1.2;
}

.btn:hover { background: var(--green); border-color: var(--green); color: var(--green-ink); }

.btn-ghost {
    background: transparent;
    color: var(--navy-ink);
    border-color: rgba(238, 240, 234, 0.4);
}

.btn-ghost:hover { background: rgba(238, 240, 234, 0.12); color: #fff; border-color: rgba(238, 240, 234, 0.6); }

.btn-quiet {
    background: var(--card);
    color: var(--ink-soft);
    border-color: var(--rule);
}

.btn-quiet:hover { background: var(--sunk); color: var(--ink); border-color: var(--ink-faint); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--rule);
}

.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Every kind of box a form on this site uses. The list is spelled out rather than written as a
   bare `input`, because a checkbox and a radio must not be stretched to the full width — but it
   has to stay complete, and it did not: `email` was missing, so the address box on registering,
   on the forgotten-password form and on the account page fell back to whatever width the browser
   picked. It sat visibly narrower than the boxes above and below it on the first page anybody
   sees. Adding a type of input to a form means adding it here. */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="tel"],
select,
textarea {
    font-family: var(--f-body);
    font-size: 14.5px;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    padding: 9px 12px;
    width: 100%;
}

textarea { resize: vertical; min-height: 120px; line-height: 1.55; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--green-bright);
    box-shadow: 0 0 0 3px rgba(74, 107, 82, 0.14);
}

label { font-size: 13px; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 5px; }

.field { margin-bottom: 16px; }
.field-hint { font-size: 12.5px; color: var(--ink-faint); margin-top: 5px; }

.validation-summary-errors ul { margin: 0; padding-left: 18px; }

.validation-summary-errors,
.field-validation-error {
    color: var(--danger);
    font-size: 13px;
}

.validation-summary-errors {
    background: var(--danger-soft);
    border: 1px solid var(--danger-line);
    border-radius: var(--r);
    padding: 11px 14px;
    margin-bottom: 16px;
}

.validation-summary-valid { display: none; }

/* ---------------- page shell ---------------- */

.shell {
    flex: 1;
    width: 100%;
    max-width: var(--shell);
    margin: 0 auto;
    padding: 26px 20px 60px;
}

.shell-wide { max-width: none; padding: 0; display: flex; flex-direction: column; }

.page-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--rule);
}

.page-head h1 {
    margin: 0;
    font-family: var(--f-head);
    font-size: 25px;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.2;
    text-wrap: balance;
}

.page-head p { margin: 0; color: var(--ink-soft); font-size: 14.5px; max-width: 70ch; }

.crumb { font-size: 12px; color: var(--ink-faint); font-weight: 600; }
.crumb a { color: var(--ink-faint); text-decoration: none; }
.crumb a:hover { color: var(--green); text-decoration: underline; }

.head-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.notice {
    background: var(--chip);
    border: 1px solid var(--chip-line);
    color: var(--chip-ink);
    border-radius: var(--r);
    padding: 11px 14px;
    font-size: 13.5px;
    margin-bottom: 18px;
}

.empty {
    border: 1px dashed var(--rule);
    border-radius: var(--r);
    padding: 34px 22px;
    text-align: center;
    color: var(--ink-faint);
    background: var(--card);
}

.empty b {
    display: block;
    font-family: var(--f-head);
    font-size: 16.5px;
    color: var(--ink-soft);
    margin-bottom: 5px;
}

.empty span { font-size: 13.5px; }

/* ---------------- rooms ---------------- */

.rooms-shell {
    flex: 1;
    display: grid;
    grid-template-columns: 224px minmax(0, 1fr);
    max-width: var(--shell);
    width: 100%;
    margin: 0 auto;
    border-left: 1px solid var(--rule);
    border-right: 1px solid var(--rule);
    background: var(--card);
    min-height: 0;
}

/* The room list is a <details>. On a wide screen it is simply always open and the summary is
   hidden, which is the sidebar it has always been. Narrow, it collapses to one bar — see the
   mobile section at the foot of this file.

   The wrapper is a flex column and carries the sidebar's own background, so the stone panel runs
   the full height of the conversation beside it and the note at the end still sits at the foot
   of the column rather than immediately under the last room. */
.rail-wrap {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--sunk);
    border-right: 1px solid var(--rule);
}

.rail-summary {
    display: none;
    cursor: pointer;
    list-style: none;
}

.rail-summary::-webkit-details-marker { display: none; }

.rail {
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-height: 0;
}

.rail-label {
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ink-faint);
    margin: 0 0 9px;
    padding: 0 8px;
}

.rail a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 9px;
    border-radius: var(--r);
    text-decoration: none;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 500;
}

.rail a:hover { background: var(--rule-soft); color: var(--ink); }
.rail a.on { background: var(--mark); color: var(--mark-ink); font-weight: 600; }

.rail a i { font-style: normal; font-size: 11.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.rail a.on i { color: rgba(238, 240, 234, 0.6); }

.rail-note {
    margin-top: auto;
    padding: 12px 9px 0;
    font-size: 11.5px;
    color: var(--ink-faint);
    line-height: 1.45;
    border-top: 1px solid var(--rule);
}

.chat { display: flex; flex-direction: column; min-width: 0; }

.chat-head {
    padding: 13px 20px;
    border-bottom: 1px solid var(--rule);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.chat-head h1 {
    margin: 0;
    font-family: var(--f-head);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.chat-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); }

.chat-log {
    flex: 1;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    max-height: 62vh;
}

.chat-start { color: var(--ink-faint); font-size: 13px; font-style: italic; text-align: center; }

/* The top of the log, while there is still more above it. Sits where the "beginning of #room"
   line will sit once there isn't — same place, same size, so nothing shifts when the last batch
   arrives and one becomes the other.

   flex: none matters. The log is a flex column, and without it this button stretches to fill
   whatever height is left over in a room with only a few messages in it. */
.chat-earlier {
    flex: none;
    align-self: center;
    background: none;
    border: 1px solid var(--rule);
    border-radius: 999px;
    padding: 4px 14px;
    font-family: var(--f-body);
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-faint);
    cursor: pointer;
}

.chat-earlier:hover { border-color: var(--green-bright); color: var(--green); }
.chat-earlier[disabled] { cursor: default; opacity: 0.6; }

.msg { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 11px; align-items: start; }

/* The circle beside a name. Two things wear this class and they are not the same element: a
   div holding an initial, and an img holding a photograph. Sharing the class is what keeps them
   exactly the same size and shape, so a room where half the people have pictures does not have
   two columns of slightly different circles down the left of it. */
.av {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex: none;
    background: hsl(var(--who) var(--av-s) var(--av-l));
    color: var(--av-ink);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

/* object-fit is the whole trick: a photograph is almost never square, and without this a
   portrait one is squashed into the circle rather than cropped to it. The border is there for
   pictures that are mostly one pale colour, which otherwise dissolve into the page. */
.av-shot {
    object-fit: cover;
    background: var(--sunk);
    border: 1px solid var(--rule);
}

.av-sm { width: 24px; height: 24px; font-size: 10px; }


.msg-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.msg-by { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
/* A name, in the colour derived from itself. --who is set on the element by whoever rendered
   it; how strong that hue ends up is a per-theme decision, which is why only the number travels
   from the server. */
.msg-by b { font-size: 13.5px; font-weight: 700; color: hsl(var(--who) var(--who-s) var(--who-l)); }
.msg-by time { font-size: 11.5px; color: var(--ink-faint); }
.msg-body p { margin: 0; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; }
.msg-removed { color: var(--ink-faint); font-style: italic; }

.composer {
    border-top: 1px solid var(--rule);
    padding: 13px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.composer input[type="text"] { flex: 1; }

.composer-locked {
    border-top: 1px solid var(--rule);
    padding: 14px 20px;
    font-size: 13.5px;
    color: var(--ink-faint);
    background: var(--sunk);
}

/* ---------------- groups ---------------- */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
    gap: 12px;
}

.gcard {
    border: 1px solid var(--rule);
    border-radius: var(--r);
    padding: 15px;
    background: var(--card);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gcard:hover { border-color: var(--green-bright); color: inherit; }

.gcard b {
    font-family: var(--f-head);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.gcard p { margin: 0; font-size: 13px; color: var(--ink-soft); line-height: 1.45; }

.gcard .meta {
    font-size: 11.5px;
    color: var(--ink-faint);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

/* the one cross-corner link on the site, and only when the shelf exists */
.xlink {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    border: 1px solid var(--chip-line);
    background: var(--chip);
    color: var(--chip-ink);
    border-radius: var(--r);
    padding: 12px 15px;
    margin-bottom: 20px;
}

.xlink-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.xlink-txt b { font-size: 13.5px; font-weight: 700; }
.xlink-txt span { font-size: 12.5px; opacity: 0.85; }

.xlink a {
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--green);
    border: 1px solid var(--green);
    padding: 7px 12px;
    border-radius: var(--r);
    background: var(--card);
    white-space: nowrap;
}

.xlink a:hover { background: var(--green); color: var(--green-ink); }

.threads { display: flex; flex-direction: column; border-top: 1px solid var(--rule-soft); }

.thread-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 14px 6px;
    border-bottom: 1px solid var(--rule-soft);
    text-decoration: none;
    color: inherit;
}

.thread-row:hover { background: var(--sunk); color: inherit; }

.thread-row h3 {
    margin: 0 0 3px;
    font-family: var(--f-head);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.008em;
    line-height: 1.3;
}

.thread-row .tmeta {
    font-size: 12px;
    color: var(--ink-faint);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tcount {
    text-align: right;
    font-size: 11.5px;
    color: var(--ink-faint);
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.tcount b { display: block; font-size: 16px; color: var(--ink); font-weight: 700; }

/* ---------------- thread & comments ---------------- */

.article {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    padding: 18px 20px;
    margin-bottom: 22px;
}

.article h1 {
    margin: 0 0 8px;
    font-family: var(--f-head);
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.25;
    text-wrap: balance;
}

.byline {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.byline-kinds { margin-bottom: 10px; }

.prose { font-size: 15px; line-height: 1.65; color: var(--ink); }
.prose p { margin: 0 0 12px; overflow-wrap: anywhere; }
.prose p:last-child { margin-bottom: 0; }

.chip {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 3px;
    background: var(--chip);
    color: var(--chip-ink);
    border: 1px solid var(--chip-line);
    text-decoration: none;
    white-space: nowrap;
}

.vote {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--sunk);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    padding: 2px;
}

.vote form { display: flex; margin: 0; }

.vote button {
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--ink-faint);
    font-size: 13px;
    line-height: 1;
}

.vote button:hover { background: var(--rule-soft); color: var(--ink); }
.vote button.on { color: var(--green-bright); font-weight: 700; }
.vote .score { font-size: 12.5px; font-weight: 700; min-width: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.vote-static { color: var(--ink-faint); font-size: 12.5px; font-weight: 600; }

.comments { display: flex; flex-direction: column; gap: 2px; }

.comment {
    padding: 12px 0 12px 14px;
    border-left: 2px solid var(--rule);
}

.comment:hover { border-left-color: var(--chip-line); }

.comment-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.comment-body { font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.comment-body p { margin: 0 0 9px; }
.comment-body p:last-child { margin-bottom: 0; }

.comment-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 7px;
    font-size: 12px;
}

.comment-tools button,
.comment-tools .linkish {
    background: none;
    border: 0;
    padding: 0;
    color: var(--ink-faint);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--f-body);
    text-decoration: none;
}

.comment-tools button:hover, .comment-tools .linkish:hover { color: var(--green); }
.comment-tools .remove:hover { color: var(--danger); }

.removed {
    color: var(--ink-faint);
    font-style: italic;
    font-size: 13.5px;
}

.reply-form { margin-top: 10px; display: none; }
.reply-form.open { display: block; }
.reply-form textarea { min-height: 80px; font-size: 14px; }
.reply-form .row { display: flex; gap: 8px; margin-top: 8px; }

.replies { margin-left: 16px; }

@media (max-width: 620px) {
    .replies { margin-left: 8px; }
    .comment { padding-left: 10px; }
}

/* ---------------- sources ---------------- */

.shelf { margin-bottom: 26px; }
.shelf:last-child { margin-bottom: 0; }

.shelf-label {
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ink-faint);
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.shelf-label::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

.src {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 14px;
    align-items: start;
    padding: 13px 14px;
    border: 1px solid var(--rule);
    border-radius: var(--r);
    background: var(--card);
    margin-bottom: 8px;
}

.src-ico {
    width: 36px;
    height: 36px;
    border-radius: var(--r);
    display: grid;
    place-items: center;
    background: var(--chip);
    border: 1px solid var(--chip-line);
    color: var(--chip-ink);
    flex: none;
}

.src-b { min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.src-b strong {
    font-family: var(--f-head);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.008em;
}

.src-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    font-size: 11.5px;
    color: var(--ink-faint);
}

.org {
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 10.5px;
    background: var(--mark);
    color: var(--mark-ink);
    padding: 3px 7px;
    border-radius: 3px;
}

.src-b p { margin: 0; font-size: 13px; color: var(--ink-soft); line-height: 1.45; }

.src-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

@media (max-width: 640px) {
    .src { grid-template-columns: auto minmax(0, 1fr); }
    .src-actions { grid-column: 2; flex-direction: row; align-items: center; }
}

.policy {
    background: var(--card);
    border: 1px solid var(--rule);
    border-left: 3px solid var(--green-bright);
    border-radius: var(--r);
    padding: 14px 16px;
    font-size: 13.5px;
    color: var(--ink-soft);
    line-height: 1.55;
    margin-bottom: 22px;
}

.policy b { color: var(--ink); }

/* The policy box is written as a heading and then separate statements. They are different
   claims and they read as different claims only if they sit on their own lines. */
.policy span { display: block; margin-top: 8px; }

/* ---------------- feed ---------------- */

.feed { display: flex; flex-direction: column; gap: 12px; }

.fpost {
    border: 1px solid var(--rule);
    border-radius: var(--r);
    background: var(--card);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    box-shadow: 0 1px 2px rgba(28, 34, 51, 0.04);
}

.fpost h2 { margin: 0; font-family: var(--f-head); font-size: 19px; font-weight: 700; letter-spacing: -0.012em; line-height: 1.25; }
.fpost h2 a { color: inherit; text-decoration: none; }
.fpost h2 a:hover { color: var(--green); }
.fpost p { margin: 0; font-size: 14.5px; color: var(--ink-soft); line-height: 1.55; }

.fpost-foot {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 12px;
    color: var(--ink-faint);
    border-top: 1px solid var(--rule-soft);
    padding-top: 10px;
    font-weight: 600;
    flex-wrap: wrap;
}

/* ---------------- auth pages ---------------- */

.narrow { max-width: 420px; margin: 0 auto; }

.panel {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    padding: 22px;
}

.panel h1 {
    margin: 0 0 4px;
    font-family: var(--f-head);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.015em;
}

.panel > p.sub { margin: 0 0 20px; color: var(--ink-soft); font-size: 14px; }

.dev-creds {
    margin-top: 18px;
    padding: 12px 14px;
    background: var(--sunk);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    font-size: 12.5px;
    color: var(--ink-soft);
    line-height: 1.6;
}

.dev-creds b { color: var(--ink); }
.dev-creds code { background: var(--card); border: 1px solid var(--rule); border-radius: 3px; padding: 1px 5px; font-size: 12px; }

/* ---------------- admin ---------------- */

.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }

@media (max-width: 900px) {
    .admin-grid { grid-template-columns: minmax(0, 1fr); }
}

.shelf-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }

.shelf-picker a {
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    color: var(--ink-soft);
    border: 1px solid var(--rule);
    background: var(--card);
    padding: 6px 10px;
    border-radius: var(--r);
}

.shelf-picker a:hover { border-color: var(--green-bright); color: var(--green); }
.shelf-picker a.on { background: var(--mark); border-color: var(--mark); color: var(--mark-ink); }

.admin-note {
    font-size: 12.5px;
    color: var(--ink-faint);
    line-height: 1.5;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--rule);
}

/* ---------------- site strips ---------------- */

.strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 9px 20px;
    font-size: 13.5px;
    background: var(--chip);
    color: var(--chip-ink);
    border-bottom: 1px solid var(--chip-line);
}

.strip a { color: var(--chip-ink); font-weight: 700; }
.strip-notice { background: var(--sunk); color: var(--ink-soft); border-bottom-color: var(--rule); }

/* ---------------- edited marker ---------------- */

.edited {
    font-size: 11px;
    color: var(--ink-faint);
    font-style: italic;
}

/* ---------------- own-message controls in chat ---------------- */

.msg-tools {
    display: flex;
    gap: 10px;
    margin-top: 2px;
    opacity: 0;
    transition: opacity 90ms ease;
}

.msg:hover .msg-tools,
.msg-tools:focus-within { opacity: 1; }

.msg-tools button {
    background: none;
    border: 0;
    padding: 0;
    font-family: var(--f-body);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ink-faint);
    cursor: pointer;
}

.msg-tools button:hover { color: var(--green); }
.msg-tools button.remove:hover { color: var(--danger); }

.msg-edit { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.msg-edit input[type="text"] { flex: 1; padding: 6px 10px; font-size: 14px; }

/* ---------------- honeypot ---------------- */

/* Off-screen rather than display:none — some form-fillers skip what is hidden outright, and
   the whole point of the field is that they fill it in. */
.trap {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ---------------- checkbox rows ---------------- */

.field.check { display: flex; align-items: center; gap: 8px; }
.field.check input[type="checkbox"] { width: auto; margin: 0; }
.field.check label { margin: 0; }

.chip-warn { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }

/* ---------------- shelf management ---------------- */

.shelf-row {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    padding: 14px 16px 4px;
    margin-bottom: 0;
}

.shelf-row-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 12.5px;
    color: var(--ink-faint);
}

.shelf-row-head code {
    background: var(--sunk);
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 12px;
    color: var(--ink);
}

.shelf-row-foot { display: flex; gap: 8px; padding-bottom: 12px; }

.shelf-row-delete {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px 16px;
    background: var(--card);
    border: 1px solid var(--rule);
    border-top: 0;
    border-radius: 0 0 var(--r) var(--r);
    margin: -1px 0 16px;
}

.shelf-row-delete .hint { font-size: 12.5px; color: var(--ink-faint); }
.shelf-row-delete button[disabled] { opacity: 0.45; cursor: not-allowed; }
.shelf-row-delete button[disabled]:hover { background: var(--card); border-color: var(--rule); color: var(--ink-soft); }

/* ---------------- misc ---------------- */

.mast-who { text-decoration: none; }
.mast-who:hover b { color: #fff; }

.narrow .panel { margin-bottom: 16px; }

/* ---------------- reports: the charter, search, kinds ---------------- */

/* The one-off block at the top of Reports saying what the channel is for. Loud enough to read
   once, quiet enough not to fight the reports underneath it every time you come back. */
.charter {
    background: var(--card);
    border: 1px solid var(--rule);
    border-left: 3px solid var(--green-bright);
    border-radius: var(--r);
    padding: 14px 18px;
    margin-bottom: 18px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink-soft);
}

.charter b { color: var(--ink); }
.charter span { display: block; margin-top: 8px; font-size: 13px; color: var(--ink-faint); }

/* The one sentence in the box that says what we actually want from people. */
.charter .charter-em { font-weight: 600; color: var(--ink); font-size: 13.5px; }

/* Set further apart than the rest: it is an aside about a different page, not a
   continuation of what makes a good report. */
.charter .charter-aside { margin-top: 18px; }

/* One line of the latest notice, so somebody about to file a report can see it's already known. */
.news-line {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 9px 14px;
    margin-bottom: 18px;
    background: var(--mark);
    color: var(--mark-ink);
    border-radius: var(--r);
    text-decoration: none;
    font-size: 13.5px;
}

.news-line:hover { color: #fff; }
.news-line:hover .news-title { text-decoration: underline; }

.news-tag {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--green-bright);
    color: var(--green-ink);
    border-radius: 3px;
    padding: 2px 7px;
    flex: none;
}

.news-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.news-line time { font-size: 11.5px; opacity: 0.6; flex: none; }

.finder { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.finder input[type="search"] {
    flex: 1;
    min-width: 220px;
    font-family: var(--f-body);
    font-size: 14.5px;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    padding: 9px 12px;
}
.finder input[type="search"]:focus {
    outline: none;
    border-color: var(--green-bright);
    box-shadow: 0 0 0 3px rgba(74, 107, 82, 0.14);
}
.finder select { width: auto; flex: none; }

.areas {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 7px;
    margin-bottom: 20px;
    font-size: 12.5px;
    color: var(--ink-faint);
}

.areas a {
    background: var(--chip);
    color: var(--chip-ink);
    border: 1px solid var(--chip-line);
    border-radius: 20px;
    padding: 2px 10px;
    text-decoration: none;
    font-weight: 600;
}

.areas a:hover { border-color: var(--green-bright); color: var(--green); }

.kind {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-radius: 3px;
    padding: 2px 7px;
    background: var(--sunk);
    color: var(--ink-soft);
    border: 1px solid var(--rule);
}

/* Conditions gets the accent because it is the thing we are asking for. */
.kind-conditions { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.kind-incident { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.kind-pinned { background: var(--mark); border-color: var(--mark); color: var(--mark-ink); }

.stale {
    margin: 0 !important;
    font-size: 12.5px !important;
    color: var(--danger) !important;
    font-style: italic;
}

.policy-warn { background: var(--danger-soft); border-color: var(--danger-line); }

.fpost.pinned { border-left: 3px solid var(--mark); }

/* ---------------- chat: quotes, replies, name-line controls ---------------- */

.msg-quote {
    display: flex;
    gap: 7px;
    align-items: baseline;
    font-size: 12px;
    color: var(--ink-faint);
    text-decoration: none;
    padding-left: 9px;
    border-left: 2px solid var(--rule);
    margin-bottom: 3px;
    max-width: 100%;
}

.msg-quote b { color: var(--ink-soft); font-weight: 700; flex: none; }
.msg-quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-quote:hover { border-left-color: var(--green-bright); color: var(--ink-soft); }

.msg-by .me { font-size: 11.5px; color: var(--ink-faint); font-weight: 600; }

/* Controls sit inside the name line, so they occupy no height of their own. Hidden until the
   row is hovered or something in it takes focus, which keeps a busy log calm without hiding
   them from the keyboard. */
.msg-by .msg-tools {
    display: inline-flex;
    gap: 9px;
    margin-left: 4px;
    opacity: 0;
    transition: opacity 90ms ease;
}

.msg:hover .msg-tools,
.msg-tools:focus-within { opacity: 1; }

/* The hidden attribute has to win, or the banner shows on page load with nobody's name in it
   and can never be dismissed. A bare display:flex silently overrides the UA's [hidden] rule. */
.replying {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 10px;
    margin-bottom: 8px;
    background: var(--sunk);
    border-left: 2px solid var(--green-bright);
    border-radius: 3px;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.replying b { color: var(--ink); }
.replying-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-faint); }

.replying button {
    background: none;
    border: 0;
    padding: 0 2px;
    font-size: 16px;
    line-height: 1;
    color: var(--ink-faint);
    cursor: pointer;
}

.replying button:hover { color: var(--danger); }

.composer { flex-direction: column; align-items: stretch; }
.composer-row { display: flex; gap: 10px; align-items: center; }
.composer-row input[type="text"] { flex: 1; }

/* ---------------- image picker and attachments ---------------- */

.picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

.picker-btn {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    cursor: pointer;
    white-space: nowrap;
}

.picker-btn:hover { border-color: var(--green-bright); color: var(--green); }

.picker-clear {
    background: none;
    border: 0;
    padding: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-faint);
    cursor: pointer;
}

.picker-clear:hover { color: var(--danger); }
.picker-status { font-size: 12.5px; color: var(--ink-faint); }

.picker-preview {
    display: block;
    max-height: 90px;
    width: auto;
    border-radius: 4px;
    border: 1px solid var(--rule);
}

/* Attachments are capped by height rather than width so a tall phone photo cannot push a
   conversation off the screen, and the aspect ratio is left to the image itself. */
.shot { display: block; margin-top: 8px; max-width: 100%; }

.shot img {
    display: block;
    max-width: 100%;
    max-height: 380px;
    width: auto;
    height: auto;
    /* Honour the orientation the file carries. This is the browser default, so it is stated
       here only to keep it that way: a stray `image-orientation: none` anywhere up the cascade
       would put every phone photo back on its side. Uploads re-emit a clean orientation tag for
       exactly this to read. */
    image-orientation: from-image;
    border-radius: var(--r);
    border: 1px solid var(--rule);
    background: var(--sunk);
}

.shot-card img { max-height: 220px; }

/* ---------------- report composer bits ---------------- */

.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

@media (max-width: 620px) {
    .two-up { grid-template-columns: 1fr; }
}

.opt {
    font-size: 11px;
    font-weight: 500;
    color: var(--ink-faint);
    text-transform: none;
    letter-spacing: 0;
}

/* Dates read as a time, not a place, so they get a quieter chip than the area. */
.chip-when { background: transparent; border-style: dashed; }

/* ---------------- chat quote line ---------------- */

.msg-quote i {
    font-style: normal;
    font-size: 11.5px;
    color: var(--ink-faint);
    flex: none;
}

/* ---------------- grouped chat runs ---------------- */

/* A run of messages from one person needs far less air than a change of speaker. The log's own
   15px gap is pulled almost all the way back, leaving a couple of pixels between lines. */
.msg-run { margin-top: -13px; }

/* The blank avatar holds the grid column open so continued messages line up under the first —
   but it must not hold a row open. Left at the avatar's 32px it forced every single-line message
   in a run to be 32px tall, which is where the stray whitespace was coming from. */
.av-blank { background: none; border: 0; height: 0; min-height: 0; }

/* The controls row on a continued message carries no name and no time, only the hover buttons.
   It collapses to nothing until the message is hovered, then opens to exactly one line — no
   floating box off to the side, no reserved gap when idle.

   Razor's own indentation means this element is never :empty, so collapsing it by that route
   never worked; height with overflow is what actually holds. */
.msg-by-quiet {
    height: 0;
    min-height: 0;
    overflow: hidden;

    /* Below the message it belongs to, not above it. .msg-body is a flex column, so one
       order property moves this past the text without touching the markup -- which
       matters, because the same partial renders from Razor on first paint and from
       site.js for every message that arrives over the hub afterwards. Two renderers, one
       stylesheet.

       The first message of a run is unaffected: it has a real name line, the buttons sit
       inside it on the side, and it never gets this class. */
    order: 1;
}

.msg:hover > .msg-body > .msg-by-quiet,
.msg-by-quiet:focus-within,
.msg-by-quiet:has(.edited) { height: auto; }

.msg-quote em { font-style: normal; color: var(--ink-faint); flex: none; }

/* ---------------- composer ---------------- */

.composer-foot {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--ink-faint);
}

.composer-foot .hint { opacity: 0.75; }

.counter { font-variant-numeric: tabular-nums; }
.counter.near { color: var(--ink-soft); }
.counter.full { color: var(--danger); font-weight: 700; }

.composer-error { color: var(--danger); font-weight: 600; }

/* The picker sits inline in the composer row, so it must not add height of its own. */
.composer .picker { margin: 0; }
.composer .picker-preview { max-height: 34px; }

/* ---------------- markup output ---------------- */

.msg-text code,
.prose code,
.comment-body code {
    background: var(--sunk);
    border: 1px solid var(--rule-soft);
    border-radius: 3px;
    padding: 0 4px;
    font-size: 0.92em;
}

.prose blockquote,
.comment-body blockquote {
    margin: 0 0 12px;
    padding-left: 12px;
    border-left: 3px solid var(--rule);
    color: var(--ink-soft);
}

.prose ul, .comment-body ul { margin: 0 0 12px; padding-left: 20px; }
.prose li, .comment-body li { margin-bottom: 4px; }

/* ---------------- legal pages ---------------- */

.legal { max-width: 68ch; font-size: 15px; line-height: 1.65; }
.legal h2 { font-family: var(--f-head); font-size: 17px; margin: 30px 0 8px; }
.legal p { margin: 0 0 12px; }
.legal ul { margin: 0 0 14px; padding-left: 20px; }
.legal li { margin-bottom: 6px; }

.legal-summary {
    background: var(--chip);
    border: 1px solid var(--chip-line);
    border-radius: var(--r);
    padding: 14px 18px;
    margin-bottom: 8px;
    color: var(--chip-ink);
}

.legal-note {
    font-size: 13px;
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid var(--danger-line);
    border-radius: var(--r);
    padding: 10px 14px;
}

.legal-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 13.5px; }
.legal-table th, .legal-table td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--rule-soft); }
.legal-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); }

/* ---------------- agreeing to the terms ----------------
   Its own block rather than a fifth field, because it is not one. The four boxes above it are
   things you fill in; this is a thing you are asked to decide, and the whole label is the target
   so it can be agreed to with a thumb rather than only by hitting a 13px square. It sat as a bare
   checkbox tucked against the bottom of the password box, which is how consent forms come to
   mean nothing: nobody noticed there was anything to agree to. */
.consent {
    display: block;
    margin: 22px 0 18px;
    background: var(--sunk);
    border: 1px solid var(--rule-soft);
    border-radius: var(--r);
}

.consent-agree {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 14px;
    margin: 0;
    cursor: pointer;
    font-weight: 400;
    font-size: 13.5px;
    color: var(--ink);
    line-height: 1.5;
}

.consent-agree input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex: none;
    margin: 0;
    accent-color: var(--green);
    cursor: pointer;
}

.consent-agree:hover { color: var(--ink); }
.consent-agree a { text-decoration: underline; }

/* Inside the block, so the refusal appears against the thing it refused rather than adrift
   between the block and the button. */
.consent .field-validation-error { display: block; padding: 0 14px 12px 43px; margin: 0; }
.consent .field-validation-error:empty { display: none; }

/* ---------------- thin footer ---------------- */

.thinfoot {
    display: flex;
    justify-content: center;
    gap: 18px;
    padding: 18px 20px 26px;
    font-size: 12.5px;
}

.thinfoot a { color: var(--ink-faint); text-decoration: none; }
.thinfoot a:hover { color: var(--green); text-decoration: underline; }

/* ---------------- security panel ---------------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 6px; }

.tile {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    padding: 12px 14px;
}

.tile b { display: block; font-size: 22px; font-family: var(--f-head); font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--ink-faint); }
.tile.hot { border-color: var(--danger-line); background: var(--danger-soft); }
.tile.hot b { color: var(--danger); }

.tiles-note { font-size: 12px; color: var(--ink-faint); margin: 0 0 18px; }

.logtable { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r); background: var(--card); }
.logtable table { width: 100%; border-collapse: collapse; font-size: 13px; }
.logtable th, .logtable td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--rule-soft); white-space: nowrap; }
.logtable th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); background: var(--sunk); }
.logtable tr.bad td { background: var(--danger-soft); }
.logtable .when { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.logtable .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.logtable .detail { white-space: normal; max-width: 40ch; color: var(--ink-soft); }

.ekind { font-size: 11.5px; font-weight: 700; }

.notfound-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.danger-panel { border-color: var(--danger-line); }
.danger-panel h1 { color: var(--danger); }

/* ---------------- small shared classes ----------------
   These replaced the handful of style="" attributes that were scattered through the views. Same
   result, but the sizes live here with the rest of the design rather than inside the markup. */

.h-sub { font-size: 18px; }
.h-panel { font-size: 17px; }
.sub-sm { font-size: 13px; }
.field-tight { margin-bottom: 10px; }
.faint { opacity: 0.6; }
.form-spaced { margin-top: 16px; }

.panel-note {
    font-size: 14px;
    color: var(--ink-soft);
    line-height: 1.6;
}

textarea.tall { min-height: 220px; }
textarea.short { min-height: 80px; }

/* Wide content scrolls inside its own box rather than making the whole page scroll sideways. */
.table-scroll { overflow-x: auto; }

/* ============================================================
   Narrow screens
   ============================================================ */

/* iOS zooms the whole page in when a focused field is smaller than 16px, which then leaves the
   layout scrolled sideways with no obvious way back. The fix is the font size, not the meta tag:
   disabling zoom would fix the symptom by taking away pinch-to-zoom from people who need it. */
@media (max-width: 760px) {
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="url"],
    input[type="number"],
    input[type="search"],
    select,
    textarea { font-size: 16px; }
}

@media (max-width: 760px) {
    body { min-height: 100dvh; }

    .shell { padding: 18px 14px 44px; }

    /* Two rows: who you are on the first, where you can go on the second. Five short words fit
       across a phone, so the corners of the site stay one tap away instead of going behind a
       menu button. */
    .mast-inner { padding: 7px 14px; gap: 8px 14px; }
    .mast-auth { order: 2; gap: 8px; }
    .mast-nav {
        order: 3;
        flex-basis: 100%;
        gap: 4px;
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: space-between;
        scrollbar-width: none;
    }

    .mast-nav::-webkit-scrollbar { display: none; }
    .mast-nav a { font-size: 13px; padding: 8px 2px; white-space: nowrap; }
    .mast-who { font-size: 12.5px; }

    .page-head h1 { font-size: 21px; }
    .article h1 { font-size: 20px; }
    .fpost h2 { font-size: 17px; }

    .finder { gap: 6px; }
    .finder input[type="search"] { min-width: 0; flex-basis: 100%; }
    .finder select { flex: 1; }

    .thinfoot { padding: 16px 14px 22px; }
}

/* ---- the rooms on a phone ---- */

@media (max-width: 760px) {
    .rooms-shell {
        /* One column, two rows: the room bar takes what it needs, the conversation takes
           everything else. */
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        border-left: 0;
        border-right: 0;
    }

    /* One bar naming the room you are in. Tapping it drops the list down over the conversation
       instead of permanently sitting on top of it. */
    .rail-summary {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 11px 16px;
        background: var(--sunk);
        border-bottom: 1px solid var(--rule);
        font-size: 13.5px;
        color: var(--ink-soft);
    }

    .rail-summary b { color: var(--ink); font-weight: 700; }
    .rail-summary-label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }

    /* The chevron is the only thing saying this opens, so it turns when it does. */
    .rail-summary::after {
        content: "";
        margin-left: auto;
        width: 7px;
        height: 7px;
        border-right: 2px solid var(--ink-faint);
        border-bottom: 2px solid var(--ink-faint);
        transform: rotate(45deg) translate(-2px, -2px);
        transition: transform 120ms ease;
    }

    .rail-wrap[open] .rail-summary::after { transform: rotate(-135deg) translate(-2px, -2px); }

    /* Collapsed to a bar, the wrapper is just the bar, so the panel colouring belongs back on
       the list itself. */
    .rail-wrap {
        background: none;
        border-right: 0;
        display: block;
    }

    .rail {
        background: var(--sunk);
        border-bottom: 1px solid var(--rule);
        padding: 10px 10px 14px;
        max-height: 60dvh;
        overflow-y: auto;
    }

    .rail a { padding: 11px 10px; font-size: 15px; }
    .rail-label { display: none; }
    .rail-note { font-size: 11.5px; padding-top: 10px; }

    /* The chat fills exactly what is left of the screen instead of guessing at a height.
       The masthead, the room bar and the composer take what they need, the log gets the rest,
       and the box you type in is on screen when the page loads — which on a 375px phone it was
       not, by 29px, when the log was a fixed fraction of the viewport.

       Scoped with :has so only this page becomes a fixed-height app; every other page keeps
       ordinary document scrolling. */
    body:has(.rooms-shell) {
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    /* The footer would take a slice of a screen that the conversation needs more. Privacy and
       Terms are one tap away from every other page on the site. */
    body:has(.rooms-shell) .thinfoot { display: none; }

    .rooms-shell { min-height: 0; }
    .chat { min-height: 0; }

    .chat-head { padding: 11px 16px; }
    .chat-head h1 { font-size: 16px; }
    .chat-log { padding: 14px 16px; gap: 14px; max-height: none; flex: 1 1 auto; min-height: 0; }

    .composer { padding: 11px 16px; }
    .composer-locked { padding: 12px 16px; }

    /* Type on one line, attach and send on the next — 44px of thumb each, rather than three
       controls fighting over 340px. */
    .composer-row { flex-wrap: wrap; }
    .composer-row input[type="text"] { flex: 1 1 100%; }
    .composer-row .picker { flex: 1; }
    .composer-row .btn { flex: none; }

    .msg-edit { flex-wrap: wrap; }
    .msg-edit input[type="text"] { flex: 1 1 100%; }
}

/* ---- touch ----
   Keyed on the pointer rather than on the width, because a 900px tablet is still something you
   poke with a finger and a 700px browser window on a desktop is not.

   Reply, edit and delete live on the name line and appear on hover. A touch screen has no hover,
   so on one they were unreachable — there was no way to reply to or delete your own message from
   a phone at all. Here they are simply always there, sized to be hit. */
@media (hover: none) {
    /* Written as .msg-by .msg-tools, not .msg-tools, because that is what the desktop rule that
       hides them is written as. A media query adds no specificity, so the shorter selector lost
       and the row opened to make space for buttons that were still invisible — the worst of both
       behaviours, and not something the numbers would have shown. */
    .msg-by .msg-tools { opacity: 1; margin-left: 6px; gap: 16px; }
    .msg-by-quiet { height: auto; overflow: visible; }
    .msg-run { margin-top: -7px; }
    .msg-tools button { font-size: 12.5px; padding: 6px 2px; }

    .btn { padding: 10px 15px; }
    .btn-sm { padding: 8px 12px; }
    .vote button { padding: 8px 11px; font-size: 14px; }
    .comment-tools { gap: 16px; }
    .comment-tools button, .comment-tools .linkish { padding: 6px 0; }
    .picker-btn { padding: 9px 14px; }
    .picker-clear { padding: 6px 2px; }

    /* Links that stand on their own get room around them. Links inside a sentence keep the
       line height of the sentence — padding them out would space the prose instead. */
    .thinfoot a { padding: 8px 6px; }
    .crumb a { display: inline-block; padding: 5px 0; }
    .fpost-foot a { padding: 5px 0; }
    .mast-who { padding: 6px 0; }
    .fpost h2 a { display: inline-block; padding: 3px 0; }
    .field-hint a { display: inline-block; padding: 5px 0; }
    .field.check input[type="checkbox"] { width: 20px; height: 20px; }
}

/* ---- the privacy table ----
   Four columns of prose do not fit across a phone. Each row becomes its own small card with the
   column names as labels, so it reads as a list of facts rather than a scrolling grid. */
@media (max-width: 700px) {
    .legal-table thead { display: none; }

    .legal-table tr {
        display: block;
        border: 1px solid var(--rule);
        border-radius: var(--r);
        background: var(--card);
        padding: 11px 13px;
        margin-bottom: 10px;
    }

    .legal-table td { display: block; border: 0; padding: 4px 0; }

    .legal-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 10.5px;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--ink-faint);
    }

    .legal-table td:first-child::before { content: none; }
    .legal { font-size: 14.5px; }
}

/* ---------------- the profile picture panel ---------------- */

/* Shown at 64px here and 32 everywhere else, because this is the one page where the picture is
   the subject rather than a label on something else. */
.avatar-edit {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin: 4px 0 12px;
    flex-wrap: wrap;
}

.avatar-edit .av {
    width: 64px;
    height: 64px;
    font-size: 22px;
}

.avatar-edit-forms {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.avatar-edit form { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* A plain file input, deliberately. The composers' picker hides theirs behind a styled label and
   writes the chosen filename back with script; there is nothing to write it back with here, and
   a styled button that cannot tell you which file you picked is worse than an unstyled one that
   can. */
.avatar-edit input[type="file"] {
    font-family: var(--f-body);
    font-size: 12.5px;
    color: var(--ink-soft);
    max-width: 100%;
}

/* The browser's own button inside the input. color-scheme darkens most form controls on its
   own and leaves this one a pale slab in the middle of a dark panel, so it is dressed to match
   the rest — without replacing the control, which is what keeps the chosen filename visible. */
.avatar-edit input[type="file"]::file-selector-button {
    font-family: var(--f-body);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    padding: 6px 12px;
    margin-right: 10px;
    cursor: pointer;
}

.avatar-edit input[type="file"]::file-selector-button:hover {
    border-color: var(--green-bright);
    color: var(--green);
}

@media (max-width: 620px) {
    .avatar-edit input[type="file"] { flex-basis: 100%; }
}
/* ---------------- testing instance banner ---------------- */

/* Deliberately loud, deliberately not dismissible, and at the very top of the document so it
   is the first thing on the page rather than something you scroll past. It appears only when
   Testing:Enabled is on, which is the same switch that removes email confirmation -- the two
   cannot be separated, so the site can never be quietly weakened. */
.testing-banner {
    background: #7f1d1d;
    color: #fff;
    padding: 10px 18px;
    font-size: 13.5px;
    line-height: 1.5;
    text-align: center;
    border-bottom: 2px solid #450a0a;
}

.testing-banner b { color: #fff; }
.testing-banner a { color: #fecaca; text-decoration: underline; }
.testing-banner a:hover { color: #fff; }
