/* The whole palette is here: change a color in one place.
   Dark colors are the default. The light ones are below, twice: once for
   devices set to light (unless the visitor picked dark with the ◐ button),
   once for visitors who picked light. data-theme on <html> is that pick. */
:root {
    color-scheme: dark;   /* scrollbars and form fields match */
    /* "Night workshop": warm violet-black, amber, neon cyan and pink. */
    --bg: #17141a;
    --bg-raised: #1f1a23;
    --nav-bg: #1b171f;
    --chip-bg: #231d29;       /* behind Dump/Feed/Forum */
    --comment-bg: var(--bg-raised);   /* the frame of each comment */
    --comment-line: var(--line);
    --text: #ece4d8;
    /* Names by role: users white, moderators purple, the admin red. */
    --name-user: #ffffff;
    --name-mod: #b98cf0;
    --name-admin: #ff5a6a;
    --muted: #a99fb0;
    --accent: #ffb347;
    --accent-dim: #3a3140;    /* the frame around Dump/Feed/Forum */
    --accent-glow: transparent;
    --cyan: #2ee6d6;
    --pink: #ff3d8b;
    --line: #352d3b;
    --danger: #ff6b6b;
    --shadow: rgba(0, 0, 0, 0.6);
    /* The admin's announcement: neon cyan, apart from the amber links. */
    --notice: #2ee6d6;
    --notice-bg: #13201f;
    --notice-line: #1f5c57;
    --notice-glow: rgba(46, 230, 214, 0.08);
    /* Fonts (static/fonts): text, small labels and headings. */
    --font-body: "IBM Plex Sans", system-ui, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, monospace;
    --font-pixel: "Silkscreen", "IBM Plex Mono", monospace;
    --body-size: 17px;
    --radius: 8px;
    /* The big heading: light letters with a hard violet shadow. */
    --h1-color: #ece4d8;
    --h1-shadow: 3px 3px 0 #3a3140;
    /* Titles people write: the plain font, as typed (the pixel font has no
       Cyrillic and long titles in it are hard to read). */
    --title-font: var(--font-body);
    --title-transform: none;
    --title-spacing: 0;
    --title-weight: 600;
    /* "+ New" in the header: a filled amber button. */
    --new-bg: #ffb347;
    --new-color: #17141a;

    /* Directions: the color is taken by the value of the field through a CSS
       class (dir-organs...), it isn't stored in the database. */
    --dir-organs: #d0849a;
    --dir-functions: #7fa8e0;
    --dir-surgical: #d2b06a;
    --dir-soft: #86c99a;
    --dir-accessories: #5fc4d4;

    /* The scalpel is always steel, whatever its direction color is. */
    --silver: #c4ccd4;

    /* The home page picture: the night street (the light theme swaps in
       the beach by day). Parts of only one of them hide with
       display: var(--night-off, ...) or var(--day-off, ...). */
    --day-off: none;
    --hero-bg: #120f17;
    --hero-border: #3a3140;
    --hero-road: #0d0b10;
    --hero-road-edge: #2a2330;
    --hero-lane: #ffb347;
    --hero-h1: #ece4d8;
    --hero-h1-shadow: 4px 4px 0 #3a3140;
    --hero-sub: #2ee6d6;
    --cat-sprite: url("/static/hero/cat.png?v=30");
}

/* Light: the same style as the dark theme (fonts, shapes, the pixel
   heading), in the colors of a seventies beach day. Text and links have
   about 7:1 contrast with the background, like the dark theme, not the
   bare minimum. Keep the two copies the same. */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        color-scheme: light;
        /* "Beach day": warm cream paper, brown ink, burnt orange, mustard and
           sea teal. */
        --bg: #f6efe2;
        --bg-raised: #fffaf2;
        --nav-bg: #fbf3e6;
        --chip-bg: #f1e4cf;
        --comment-bg: #e0dfdc;    /* light gray, a shade darker than the page */
        --comment-line: #cfc6b8;
        --text: #2b1d14;
        --name-user: #2b1d14;
        --name-mod: #6c2bb0;
        --name-admin: #9c1e25;
        --muted: #5e4a3c;
        --accent: #843506;
        --accent-dim: #e0c8a4;
        --accent-glow: transparent;
        --cyan: #0a5754;
        --pink: #932250;
        --line: #e5d5bc;
        --danger: #941f18;
        --shadow: rgba(80, 50, 20, 0.18);
        --notice: #0a5754;
        --notice-bg: #e3f4ef;
        --notice-line: #8fcfc2;
        --notice-glow: rgba(10, 87, 84, 0.08);
        --h1-color: #2b1d14;
        --h1-shadow: 3px 3px 0 #f0a03a;
        --new-bg: #f0a03a;
        --new-color: #2b1d14;
        --dir-organs: #8f2d4c;
        --dir-functions: #244b85;
        --dir-surgical: #624809;
        --dir-soft: #175530;
        --dir-accessories: #0c5a68;
        --silver: #524d48;
        /* The home page: the beach by day instead of the night street. */
        --night-off: none;
        --day-off: initial;
        --hero-bg: linear-gradient(#8fd3e8, #c9eef2 45%, #ffe6bf 75%);
        --hero-border: #e0c8a4;
        --hero-road: #514b4a;
        --hero-road-edge: #e8d3a6;
        --hero-lane: #fff1cc;
        --hero-h1: #2b1d14;
        --hero-h1-shadow: 4px 4px 0 #f0a03a;
        --hero-sub: #0a5754;
        --cat-sprite: url("/static/hero/cat-orange.png?v=1");
    }
}

:root[data-theme="light"] {
    color-scheme: light;
    /* "Beach day": warm cream paper, brown ink, burnt orange, mustard and
       sea teal. */
    --bg: #f6efe2;
    --bg-raised: #fffaf2;
    --nav-bg: #fbf3e6;
    --chip-bg: #f1e4cf;
    --comment-bg: #e0dfdc;    /* light gray, a shade darker than the page */
    --comment-line: #cfc6b8;
    --text: #2b1d14;
    --name-user: #2b1d14;
    --name-mod: #6c2bb0;
    --name-admin: #9c1e25;
    --muted: #5e4a3c;
    --accent: #843506;
    --accent-dim: #e0c8a4;
    --accent-glow: transparent;
    --cyan: #0a5754;
    --pink: #932250;
    --line: #e5d5bc;
    --danger: #941f18;
    --shadow: rgba(80, 50, 20, 0.18);
    --notice: #0a5754;
    --notice-bg: #e3f4ef;
    --notice-line: #8fcfc2;
    --notice-glow: rgba(10, 87, 84, 0.08);
    --h1-color: #2b1d14;
    --h1-shadow: 3px 3px 0 #f0a03a;
    --new-bg: #f0a03a;
    --new-color: #2b1d14;
    --dir-organs: #8f2d4c;
    --dir-functions: #244b85;
    --dir-surgical: #624809;
    --dir-soft: #175530;
    --dir-accessories: #0c5a68;
    --silver: #524d48;
    /* The home page: the beach by day instead of the night street. */
    --night-off: none;
    --day-off: initial;
    --hero-bg: linear-gradient(#8fd3e8, #c9eef2 45%, #ffe6bf 75%);
    --hero-border: #e0c8a4;
    --hero-road: #514b4a;
    --hero-road-edge: #e8d3a6;
    --hero-lane: #fff1cc;
    --hero-h1: #2b1d14;
    --hero-h1-shadow: 4px 4px 0 #f0a03a;
    --hero-sub: #0a5754;
    --cat-sprite: url("/static/hero/cat-orange.png?v=1");
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--body-size);
    line-height: 1.6;
}

/* Labels, dates, buttons and the header are in the monospace font, the text
   people write in the plain one. */
nav, small, .meta, .hint, .crumbs, .pager, .tags, button, .dropdown summary,
code, .score, .post-no {
    font-family: var(--font-mono);
}

nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 12px 24px;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--line);
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

nav ul {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 24px;
}

/* Dump, feed and forum in one frame, apart from Learn. */
nav ul.levels-nav {
    gap: 8px 20px;
    padding: 4px 14px;
    background: var(--chip-bg);
    border: 1px solid var(--accent-dim);
    border-radius: var(--radius);
    box-shadow: 0 0 6px var(--accent-glow);
}

main {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* The only glow on the site. */
a:hover {
    text-shadow: 0 0 8px var(--accent);
}

a:focus-visible, button:focus-visible {
    outline: 1px solid var(--accent);
}

h1 {
    color: var(--h1-color);
    font-family: var(--font-pixel);
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-shadow: var(--h1-shadow);
}

h2 {
    font-size: 1.05em;
    font-weight: 400;
    margin: 0;
}

small, .meta, .hint, .empty, .crumbs {
    color: var(--muted);
}

.banner {
    margin: 0;
    padding: 8px 24px;
    color: var(--danger);
    border-bottom: 1px solid var(--line);
}

/* ---------- forms ---------- */

input, textarea, select, button {
    font: inherit;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 6px 8px;
    max-width: 100%;
    box-sizing: border-box;
}

select option {
    background: var(--bg);
}

input:focus, textarea:focus, select:focus {
    outline: 1px solid var(--accent);
}

button {
    color: var(--accent);
    border-color: var(--accent);
    cursor: pointer;
}

button.pressed {
    background: var(--accent);
    color: var(--bg);
}

button.danger, .danger {
    color: var(--danger);
    border-color: var(--danger);
}

/* A button that looks like a link, for forms inside text (log out, delete). */
button.link {
    border: none;
    padding: 0;
}

form.inline {
    display: inline;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.stack label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stack button {
    align-self: flex-start;
}

/* New post form: no image field when the type "question" is chosen.
   :has() asks "does the form contain a chosen question button?", so it works
   without JavaScript. */
.stack:has(input[name="kind"][value="question"]:checked) .image-field {
    display: none;
}

/* The subsection only matters for the forum: hidden while another "Where" is
   chosen. Also :has(), no JavaScript. */
.stack:has(select[name="level"]):not(:has(select[name="level"] option[value="forum"]:checked)) .subsection-field {
    display: none;
}

.narrow {
    max-width: 360px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.error {
    color: var(--danger);
    margin: 0;
}

/* ---------- expanding lists and pages ---------- */

/* Expanding list (dump: kind and sort, feed: direction). position: relative lets the opened list
   float over the posts instead of pushing them down. */
.dropdown {
    position: relative;
    display: inline-block;
    margin: 12px 0;
}

/* Lists next to each other (kind and sort in the dump). */
.dropdown + .dropdown {
    margin-left: 12px;
}

.dropdown summary {
    cursor: pointer;
    color: var(--accent);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 4px 10px;
    list-style: none;
}

.dropdown summary::-webkit-details-marker {
    display: none;
}

.dropdown summary::after {
    content: " ▾";
}

.dropdown[open] summary::after {
    content: " ▴";
}

/* Closing on a click outside, without JavaScript: while the list is open, the summary gets an
   invisible layer over the whole screen. The layer is part of the summary, so a click anywhere
   on it counts as a click on the summary, and that closes the list. The list itself (z-index 10)
   stays above the layer, so its links still work. */
.dropdown[open] summary::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9;
    cursor: default;
}

.dropdown ul {
    position: absolute;
    z-index: 10;
    min-width: 100%;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 4px 0;
}

.dropdown li a {
    display: block;
    padding: 4px 10px;
    white-space: nowrap;
}

.dropdown li a.active {
    color: var(--text);
}

.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 16px 0;
}

/* ---------- directions and pictures ---------- */

.dir-icon {
    display: inline-block;
    width: 1.2em;
    text-align: center;
}

/* An icon made of rows of tiny characters, one under another (soft: 01 / 10).
   The rows together are about as tall as one normal letter. */
.icon-rows {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    font-size: 0.5em;
    line-height: 1;
    font-weight: 700;
    width: auto;
    min-width: 2.4em;
}

/* A drawn icon (surgical scalpel, accessories chip), the size of one letter. */
.icon-svg {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
}

/* The font draws the gear smaller than the heart, so it is enlarged a bit.
   line-height: 1 keeps the bigger icon from making the line taller. */
.dir-icon.dir-functions {
    font-size: 1.3em;
    line-height: 1;
    width: 0.95em;
    vertical-align: -0.05em;
}

.icon-silver {
    color: var(--silver);
}

.dir-organs { color: var(--dir-organs); }
.dir-functions { color: var(--dir-functions); }
.dir-surgical { color: var(--dir-surgical); }
.dir-soft { color: var(--dir-soft); }
.dir-accessories { color: var(--dir-accessories); }

/* Each forum card keeps its direction color in --dir: the top border, the
   name, the hover frame and the corner icon all take it from there. */
.forum-part.dir-border-organs { --dir: var(--dir-organs); }
.forum-part.dir-border-functions { --dir: var(--dir-functions); }
.forum-part.dir-border-surgical { --dir: var(--dir-surgical); }
.forum-part.dir-border-soft { --dir: var(--dir-soft); }
.forum-part.dir-border-accessories { --dir: var(--dir-accessories); }

/* About 1 x 1.5 cm. */
/* Post pictures are 16:9 everywhere, in both sizes. object-fit: cover cuts
   pictures uploaded before that rule to the same shape. */
.pic-small {
    width: 64px;
    height: 36px;
    object-fit: cover;
    flex: none;
}

.pic-large {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--bg-raised);
}

/* The stylized question sign used instead of a picture. */
.qmark {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: 1px solid var(--accent);
    color: var(--accent);
    background: var(--bg-raised);
    text-shadow: 0 0 10px var(--accent);
}

.qmark.pic-small {
    font-size: 24px;
}

.qmark.pic-large {
    font-size: min(140px, 30vw);
}

.label-q {
    font-size: 0.75em;
    padding: 0 6px;
    border: 1px solid var(--accent);
    color: var(--accent);
    vertical-align: middle;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    color: var(--muted);
    font-size: 0.9em;
}

/* ---------- lists of posts ---------- */

.dump-item {
    display: flex;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.dump-item > div {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* The picture takes --feed-pic of the width, the text sits next to it.
   Change --feed-pic to try other sizes. */
.feed-item {
    --feed-pic: 40%;
    padding: 20px 0;
    border-top: 1px solid var(--line);
}

.feed-row {
    display: flex;
    gap: 16px;
}

.feed-pic {
    flex: 0 0 var(--feed-pic);
}

.feed-body {
    flex: 1;
    min-width: 0;   /* lets long titles wrap instead of pushing the picture */
}

/* The line above the picture: the author on the left, the direction and the
   date on the right. When there is no room, the right part goes to the next line. */
.feed-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px 12px;
    margin-bottom: 8px;
}

.feed-author {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.feed-when {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 0 auto;
    white-space: nowrap;
}

.feed-item h2 {
    margin: 0 0 6px;
    font-size: 1.1em;
    overflow-wrap: anywhere;
}

/* The score and comments under everything. */
.feed-bottom {
    display: block;
    margin-top: 10px;
}

.feed-item .qmark.pic-large {
    font-size: min(70px, 15vw);
}

/* The first sentences of the post, right under the title. */
.feed-excerpt {
    margin: 0;
    overflow-wrap: anywhere;
}

/* Narrow screens: the picture on top across the whole width, text under it. */
@media (max-width: 560px) {
    .feed-row {
        flex-direction: column;
    }

    .feed-pic {
        flex-basis: auto;
        width: 100%;
    }
}

/* The forum page: four cards, one per part. Each card has its own color on top
   and a "Ready to use" box inside it, so the box reads as part of the card. */
/* All four parts in one row; two by two on a narrow screen, one under
   another on a phone. */
.forum-parts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 900px) {
    .forum-parts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .forum-parts {
        grid-template-columns: 1fr;
    }
}

.forum-part {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-top: 3px solid var(--dir, var(--line));
    transition: border-color 0.2s;
}

.forum-part:hover {
    border-color: var(--dir);
}

/* The big faint icon in the top right corner, behind everything. */
.forum-part .part-mark {
    position: absolute;
    right: 0.05em;
    top: 0.1em;
    font-size: 9em;
    line-height: 1;
    opacity: 0.07;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* Icons normally sit in a fixed-width box; here it would push the big one
   away from the corner. */
.forum-part .part-mark .dir-icon {
    width: auto;
}

.forum-part:hover .part-mark {
    opacity: 0.12;
}

/* The name on the left, the counts on the right. */
.forum-part .part-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
}

.forum-part h2 {
    font-size: 1.35em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dir);
}

.forum-part h2 a {
    color: inherit;
}

/* The longest name: a bit smaller and tighter, so it stays on the icon's
   line in a narrow card like the others. */
.forum-part.dir-border-accessories h2 {
    font-size: 1.15em;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.forum-part .part-about {
    margin: 4px 0 12px;
    color: var(--muted);
    font-size: 0.9em;
}

.forum-part ul {
    position: relative;
    margin: 0 0 12px;
}

.forum-part li {
    margin: 4px 0;
}

/* A line like in a table of contents: title ... comments · date. A long
   title is cut with "…", so the numbers always stay on the same line. */
.toc-line {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.toc-line a {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.toc-dots {
    flex: 1 0 12px;
    border-bottom: 1px dotted var(--muted);
    opacity: 0.5;
}

.forum-part .empty {
    font-size: 0.9em;
}

.toc-line small {
    white-space: nowrap;
}

/* The question mark in front of a question, in the direction color. */
.toc-q {
    color: var(--dir);
    font-weight: bold;
}

.forum-part .ready-box {
    position: relative;
    margin-top: auto;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px dashed var(--line);
    font-size: 0.9em;
}

/* "Discussions" right under "Ready to use". */
.forum-part .ready-box + .ready-box {
    margin-top: 6px;
}

.forum-part .ready-box a {
    font-size: 0.85em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* The whole card is a link to the part, without JavaScript: the part's
   name link gets an invisible layer over the whole card. The subsection
   lines and the two boxes lie above that layer, each with its own invisible
   layer over its whole line, so a click there opens that one instead. */
.forum-part h2 a::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

.forum-part li,
.forum-part .ready-box {
    position: relative;
}

.forum-part li a::after,
.forum-part .ready-box a::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
}

.forum-part li:hover a,
.forum-part .ready-box:hover a {
    text-decoration: underline;
}

/* A forum part's own page: its subsections as a table of contents, with a
   line in the part's color on the left. */
.part-index {
    max-width: 640px;
    margin: 16px 0 24px;
    padding: 4px 0 4px 16px;
    border-left: 3px solid var(--dir, var(--line));
}

.part-index li {
    margin: 6px 0;
}

.part-index.dir-border-organs { --dir: var(--dir-organs); }
.part-index.dir-border-functions { --dir: var(--dir-functions); }
.part-index.dir-border-surgical { --dir: var(--dir-surgical); }
.part-index.dir-border-soft { --dir: var(--dir-soft); }
.part-index.dir-border-accessories { --dir: var(--dir-accessories); }

/* "Ready to use" closes the list, a little apart from the subsections. */
.part-index .part-index-ready {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
}

.unfiled-head {
    margin: 28px 0 4px;
    color: var(--muted);
}

.forum-item {
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

/* The subsection picker (moderators): one line, opens into buttons. */
.picker {
    flex-basis: 100%;
    margin-top: 6px;
    font-size: 0.9em;
}

.picker summary {
    cursor: pointer;
    color: var(--muted);
    list-style: none;
}

.picker summary::-webkit-details-marker {
    display: none;
}

.picker .picker-open {
    color: var(--accent);
}

.picker .picker-open::after {
    content: " ▸";
}

.picker[open] .picker-open::after {
    content: " ▾";
}

.picker form {
    margin-top: 6px;
    padding: 8px 12px;
    border: 1px dashed var(--line);
}

.picker .hint {
    margin: 0 0 6px;
}

.picker-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 6px 0;
}

.picker-row button {
    padding: 2px 8px;
}

.picker-part {
    min-width: 7em;
    color: var(--muted);
}

.picker-here {
    padding: 2px 8px;
    border: 1px solid var(--line);
    color: var(--muted);
}

.level {
    border: 1px solid var(--line);
    padding: 0 4px;
}

/* ---------- one post and comments ---------- */

.post-full .text, .comment .text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 12px 0;
}

.post-full .pic-large {
    margin-top: 12px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.score {
    padding: 0 6px;
}

.related {
    margin: 20px 0;
}

.related h2 {
    margin-top: 12px;
    color: var(--muted);
}

.comments {
    margin-top: 28px;
}

/* Each comment in its own frame, a small gap between them: easier to see
   where one ends and the next begins. */
.comment {
    margin: 8px 0;
    padding: 10px 14px;
    background: var(--comment-bg);
    border: 1px solid var(--comment-line);
    border-radius: var(--radius);
}

.comment header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
}

/* The comment the address points to (#c12) is highlighted, no JavaScript. */
.comment:target {
    background: var(--bg-raised);
    outline: 1px solid var(--accent);
}

.answers {
    margin: 6px 0;
    color: var(--muted);
    font-size: 0.9em;
}

.deleted {
    color: var(--muted);
    font-style: italic;
    margin: 0;
}

/* After an emoji click the page comes back scrolled to the form. The emoji
   panel is open above it, so leave room for the panel (its max-height). */
#comment-form {
    margin-top: 20px;
    scroll-margin-top: 320px;
}

/* ---------- avatars ---------- */

.avatar {
    display: inline-block;
    box-sizing: border-box;
    object-fit: cover;
    vertical-align: middle;
    border: 1px solid var(--line);
    flex: none;
}

.avatar-s { width: 20px; height: 20px; }
.avatar-m { width: 64px; height: 64px; }
/* Next to comments: bigger on computers, the usual small size on phones. */
.avatar-c { width: 36px; height: 36px; }
.avatar-l { width: 96px; height: 96px; }

/* Picking a generated avatar: the radio button is hidden (but still works
   with the keyboard), the picture itself shows which one is chosen. */
.avatar-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.stack label.avatar-choice {
    position: relative;
    cursor: pointer;
}

.avatar-choice input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.avatar-choice:hover img {
    border-color: var(--muted);
}

.avatar-choice input:checked + img {
    border-color: var(--accent);
    outline: 2px solid var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.avatar-choice input:focus-visible + img {
    outline: 2px dashed var(--accent);
    outline-offset: 3px;
}

.with-avatar {
    white-space: nowrap;
}

.profile-head, .avatar-edit {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.avatar-edit {
    align-items: flex-start;
    margin-bottom: 24px;
}

/* ---------- the profile page (how others see a user) ---------- */

/* Everything about the user in one frame, the posts below it. */
.profile-card {
    padding: 20px;
    border: 1px solid var(--line);
    background: var(--bg-raised);
}

.profile-who h1 {
    margin: 0;
    overflow-wrap: anywhere;
}

/* The sphere tag next to the name: not shouting like the name. */
.profile-who h1 .sphere {
    font-size: 0.4em;
    letter-spacing: 0;
    text-transform: none;
}

.profile-who .status {
    margin: 2px 0;
}

.profile-who .meta {
    margin: 2px 0 0;
}

/* The role as a small badge, in the same colors as the names. */
.role {
    padding: 0 6px;
    border: 1px solid currentColor;
    border-radius: 3px;
    font-size: 0.85em;
}

.role-curious { color: var(--muted); }
.role-moderator { color: var(--name-mod); }
.role-admin { color: var(--name-admin); }

/* A name colored by role, everywhere names are shown (macro "name"):
   users white (dark text in the light theme), moderators purple, the admin red. */
.name-curious { color: var(--name-user); }
.name-moderator { color: var(--name-mod); }
.name-admin { color: var(--name-admin); }

/* The numbers: a row of cells, big number over a small word. They wrap on
   phones. */
.profile-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    margin: 20px 0 0;
    background: var(--line);
    border: 1px solid var(--line);
}

.profile-stats div {
    flex: 1 1 90px;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    padding: 8px 4px;
    background: var(--bg);
}

.profile-stats dd {
    margin: 0;
    color: var(--accent);
    font-size: 1.4em;
    line-height: 1.2;
}

.profile-stats dt {
    color: var(--muted);
    font-size: 0.8em;
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.profile-actions form, .profile-actions p {
    margin: 0;
}

.profile-card > .hint:last-child {
    margin: 20px 0 0;
}

.profile-posts-head {
    margin: 28px 0 8px;
}

/* Everything / only posts / only blog. For logged in visitors the tabs are
   buttons of a form (the choice is saved), so they get the look of the links. */
.profile-show {
    margin: 28px 0 8px;
}

.tabs button.link {
    padding: 8px 14px;
    background: none;
    font: inherit;
    margin-bottom: -1px;
    color: var(--muted);
    border: 1px solid transparent;
    border-bottom: none;
    text-decoration: none;
}

.tabs button.link:hover {
    color: var(--accent);
}

.tabs button.link.active {
    color: var(--accent);
    background: var(--bg-raised);
    border-color: var(--line);
    border-bottom: 1px solid var(--bg-raised);
}

/* A blog entry in the profile list: the whole text, the picture after it,
   then the line with the number, date and comments. */
.blog-entry {
    padding: 16px 0;
    border-top: 1px solid var(--line);
    overflow-wrap: anywhere;
}

.blog-entry .meta {
    margin: 8px 0 0;
}

/* ---------- complaints ---------- */

/* The "complain" links are quiet: they are for the rare bad post. */
.complain-link {
    color: var(--muted);
    font-size: 0.9em;
}

.complain-link:hover {
    color: var(--danger);
}

/* What the complaint is about, quoted on the complaint page. */
.complaint-target {
    margin: 0 0 16px;
    padding: 8px 14px;
    border-left: 3px solid var(--line);
    background: var(--bg-raised);
    overflow-wrap: anywhere;
}

.complaint-target p {
    margin: 4px 0;
}

/* One post or comment on the admin's Complaints tab. */
.complaint {
    padding: 16px 0;
    border-top: 1px solid var(--line);
    overflow-wrap: anywhere;
}

.complaint h2 {
    margin: 0 0 6px;
    font-size: 1.1em;
}

.complaint-quote {
    margin: 0 0 8px;
    color: var(--muted);
}

.complaint-reasons {
    margin: 0 0 10px;
    padding-left: 20px;
}

.complaint-reasons li {
    margin: 4px 0;
}

/* ---------- account and admin ---------- */

.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 16px;
}

.facts dt {
    color: var(--muted);
}

.facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.users {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    display: block;
    overflow-x: auto;
}

.users th, .users td {
    text-align: left;
    padding: 6px 8px;
    border-top: 1px solid var(--line);
}

/* ---------- donate page ---------- */
.wallet {
    display: block;
    padding: 8px 12px;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    overflow-wrap: anywhere;
    user-select: all;
}

/* ---------- posts waiting for changes ---------- */
section.on-hold {
    margin: 16px 0;
    padding: 12px 16px;
    border: 1px solid var(--danger);
    background: var(--bg-raised);
}

section.on-hold h2 {
    margin-top: 0;
    color: var(--danger);
}

section.on-hold .text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

section.on-hold .actions {
    border: none;
    padding-bottom: 0;
}

small.on-hold {
    color: var(--danger);
}

.ask-changes {
    margin: 12px 0;
}

.ask-changes summary {
    cursor: pointer;
    color: var(--muted);
}

/* ---------- hidden users ---------- */
.hidden-users li {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 6px 0;
}

/* ---------- ready to use ---------- */
.stack label.check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.ready-link {
    margin: 0 0 16px;
}

/* ---------- learn page ---------- */
.soon {
    display: inline-block;
    margin: 0 0 16px;
    padding: 2px 10px;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 0.85em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.learn-list {
    list-style: disc;
    padding-left: 24px;
}

.learn-list li {
    margin: 8px 0;
}

.learn-head {
    margin: 28px 0 8px;
    color: var(--accent);
    font-size: 1.15em;
}

/* ---------- announcement ---------- */
/* As wide as the page text (main's content is 960px wide). */
.announcement {
    max-width: 960px;
    margin: 20px auto 0;
    padding: 0 16px 14px;
    box-sizing: border-box;
    background: var(--notice-bg);
    border: 1px solid var(--notice-line);
    border-left: 4px solid var(--notice);
    box-shadow: 0 0 24px var(--notice-glow);
}

/* On a phone the box keeps a 16px gap to the screen edges like the page text. */
@media (max-width: 992px) {
    .announcement {
        margin: 16px 16px 0;
    }
}

.announcement-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 -16px 12px;
    padding: 6px 16px;
    border-bottom: 1px solid var(--notice-line);
    color: var(--notice);
    font-size: 0.8em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.announcement-bar button.link {
    color: var(--notice);
    letter-spacing: 0.05em;
    text-transform: none;
    opacity: 0.8;
}

.announcement-bar button.link:hover,
.announcement-bar button.link:focus-visible {
    opacity: 1;
    text-shadow: 0 0 8px var(--notice);
}

.announcement h2 {
    color: var(--notice);
    font-size: 1.15em;
}

.announcement .text {
    margin-top: 6px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.announcement-list li {
    margin: 6px 0;
}

/* ---------- admin tabs ---------- */
/* nav.tabs, not just .tabs: the tabs are a <nav> too, and the rules of the top
   menu (nav) would otherwise spread them across the whole width. */
nav.tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
    margin: 0 0 24px;
    padding: 0;
    border-bottom: 1px solid var(--line);
}

.tabs a {
    padding: 8px 14px;
    margin-bottom: -1px;
    color: var(--muted);
    border: 1px solid transparent;
    border-bottom: none;
}

.tabs a:hover {
    color: var(--accent);
}

.tabs a.active {
    color: var(--accent);
    background: var(--bg-raised);
    border-color: var(--line);
    border-bottom: 1px solid var(--bg-raised);
}

.tabs .count {
    display: inline-block;
    min-width: 1.4em;
    padding: 0 5px;
    margin-left: 4px;
    border-radius: 9px;
    background: var(--danger);
    color: var(--bg);
    font-size: 0.8em;
    text-align: center;
}

/* ---------- recovery key ---------- */
.done {
    color: var(--dir-soft);
    margin: 0;
}

.key-box {
    margin: 20px 0;
    padding: 16px;
    background: var(--notice-bg);
    border: 1px solid var(--notice-line);
    border-left: 4px solid var(--notice);
}

.key-box h2 {
    color: var(--notice);
}

/* Big and easy to copy: one click selects the whole key. */
.recovery-key {
    display: block;
    margin: 12px 0;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--notice-line);
    color: var(--notice);
    font-size: 1.25em;
    letter-spacing: 0.08em;
    text-align: center;
    overflow-wrap: anywhere;
    user-select: all;
}

/* A page made of several sections (the account page): each heading starts a
   new block with a line above it. */
.section-head {
    margin: 36px 0 12px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--accent);
    font-size: 1.15em;
}

/* The avatar choice on the register page: a group of fields with a title. */
fieldset {
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    min-width: 0;
}

legend {
    padding: 0 6px;
}

/* Several buttons of one form in a row. */
.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.avatar-more {
    margin-top: 14px;
}

/* ---------- private messages ---------- */

nav a.unread {
    font-weight: bold;
}

.conversations {
    list-style: none;
    padding: 0;
    margin: 0;
}

.conversations li {
    border-top: 1px solid var(--line);
}

.conversations a {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    padding: 10px 4px;
    color: var(--text);
}

.conversations a:hover {
    text-shadow: none;
    background: var(--line);
}

.conversations .when {
    margin-left: auto;
}

.conversations .preview {
    flex-basis: 100%;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.conversations li.unread .preview {
    color: var(--text);
}

.badge {
    color: var(--accent);
    font-weight: normal;
}

.conversation {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

/* The other person's messages on the left, yours on the right. */
.message {
    max-width: 80%;
    align-self: flex-start;
    padding: 8px 12px;
    border: 1px solid var(--line);
}

.message.mine {
    align-self: flex-end;
    border-color: var(--accent);
}

.message header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    margin-bottom: 4px;
}

.message .text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message:target {
    outline: 1px dashed var(--accent);
}

/* A heading with a button right after it (the account page). */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

a.button.small {
    padding: 0 5px;
    font-size: 0.8em;
    line-height: 1.5;
}

a.button {
    display: inline-block;
    padding: 6px 8px;
    border: 1px solid var(--accent);
}

@media (max-width: 600px) {
    .avatar-c {
        width: 20px;
        height: 20px;
    }

    .message {
        max-width: 92%;
    }
}

/* ---------- new post: "New post / question" in the heading ---------- */

.new-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    margin-bottom: 4px;
}

.kind-switch {
    display: inline-flex;
    gap: 8px;
}

.stack .kind-switch label {
    display: inline-block;
    cursor: pointer;
}

/* The radio button itself is hidden, but still works with the keyboard. */
.kind-switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.kind-switch span {
    display: inline-block;
    padding: 0 10px;
    border: 1px dashed var(--line);
    color: var(--muted);
}

.kind-switch label:hover span {
    color: var(--text);
}

.kind-switch input:checked + span {
    border: 1px solid var(--accent);
    color: var(--accent);
    text-shadow: 0 0 8px var(--accent);
}

.kind-switch input:focus-visible + span {
    outline: 1px dashed var(--accent);
    outline-offset: 3px;
}

/* The title of a post with its number on the right. */
.post-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 16px;
    font-family: var(--title-font);
    font-weight: var(--title-weight);
    text-transform: var(--title-transform);
    letter-spacing: var(--title-spacing);
    text-shadow: none;
}

.post-title > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.post-no {
    flex: none;
    color: var(--muted);
    font-size: 0.6em;
    letter-spacing: normal;
}

/* "delete" left of "Post №n". When clicked it opens into
   "Are you sure? yes, delete · cancel"; only "yes, delete" deletes. */
.confirm-delete {
    display: inline-flex;
    gap: 8px;
    margin-right: 8px;
}

.confirm-delete summary {
    cursor: pointer;
    color: var(--danger);
    list-style: none;
}

.confirm-delete summary::-webkit-details-marker {
    display: none;
}

.confirm-delete[open] summary {
    order: 1;
    color: var(--muted);
}

.confirm-delete .when-open,
.confirm-delete[open] .when-closed {
    display: none;
}

.confirm-delete[open] .when-open {
    display: inline;
}

/* ---------- account page: tabs on the left ---------- */

.account-layout {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 24px;
    margin-top: 16px;
}

.account-tabs {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-self: start;
    gap: 0;
    padding: 0;
    border-bottom: none;
    border-right: 1px solid var(--line);
}

.account-tabs a {
    padding: 8px 12px;
    color: var(--muted);
    border-left: 2px solid transparent;
}

.account-tabs a:hover {
    color: var(--text);
    text-shadow: none;
}

.account-tabs a.current {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--bg-raised);
}

.account-tabs a.tab-danger {
    margin-top: 16px;
    color: var(--danger);
}

.account-tabs a.tab-danger.current {
    border-left-color: var(--danger);
}

.account-body {
    min-width: 0;
}

/* The first heading of a tab: no line and no big gap above it. */
.section-head.first {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* Phones: the tabs become a row above the content. */
@media (max-width: 600px) {
    .account-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .account-tabs {
        flex-direction: row;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .account-tabs a {
        border-left: none;
        border-bottom: 2px solid transparent;
    }

    .account-tabs a.current {
        border-bottom-color: var(--accent);
    }

    .account-tabs a.tab-danger {
        margin-top: 0;
    }

    .account-tabs a.tab-danger.current {
        border-bottom-color: var(--danger);
    }
}

/* ---------- the header: support | sections | account ---------- */

/* Two equal side columns keep the middle one exactly in the center, whatever
   the width of the sides. */
.site-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.site-nav .nav-right {
    justify-self: end;
}

.support {
    padding: 2px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 0.9em;
    white-space: nowrap;
}

/* A heart before "Support the project": a letter, not a picture. */
.support::before {
    content: "♥\fe0e  ";
    color: var(--pink);
}

/* The name of the site on the left of the header, back to the home page. */
.site-nav .brand {
    margin-right: 16px;
    color: var(--text);
    font-family: var(--font-pixel);
    font-size: 1.05em;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.site-nav .nav-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    justify-self: start;
}

/* "+ New": filled in the dark colors, a plain link in the light ones. */
.site-nav .new-button {
    padding: 4px 12px;
    background: var(--new-bg);
    color: var(--new-color);
    border-radius: var(--radius);
}

.site-nav .new-button:hover {
    text-shadow: none;
    filter: brightness(1.1);
}

.support:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* Not enough room for three columns: the sections go to a row of their own
   under support and the account links. */
@media (max-width: 1000px) {
    .site-nav {
        grid-template-columns: auto 1fr;
    }

    .site-nav .nav-center {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: center;
    }
}

/* ---------- my posts ---------- */

/* Posts per level; each one is also a filter link. */
.my-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    color: var(--muted);
}

.my-counts a {
    color: var(--muted);
}

.my-counts a.active, .my-counts a:hover {
    color: var(--accent);
}

.my-counts strong {
    color: var(--text);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 8px;
}

.my-status {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    margin: 4px 0;
}

/* ---------- the user menu in the header ---------- */

.user-menu {
    margin: 0;
}

/* The list opens under the button, aligned to its right edge (it's at the
   right side of the screen), one item per line: "nav ul" makes lists in the
   header a row, this one isn't. */
.site-nav .user-menu ul {
    display: block;
    right: 0;
    min-width: 160px;
    margin-top: 4px;
}

.user-menu li button.link {
    display: block;
    width: 100%;
    padding: 4px 10px;
    text-align: left;
    color: var(--muted);
}

.user-menu li button.link:hover {
    color: var(--danger);
}

.user-menu summary .badge {
    margin-left: 4px;
}

/* "light dark" in the menu: one row of small buttons, the chosen one in
   plain text color. */
.user-menu li.menu-theme {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    padding: 4px 10px;
    font-size: 0.9em;
}

.user-menu li.menu-theme button.link {
    display: inline;
    width: auto;
    padding: 0;
    color: var(--accent);
}

.user-menu li.menu-theme button.link:hover {
    color: var(--text);
}

.user-menu li.menu-theme button.active {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Guests have no menu: the ◐ button opens the same choices. */
.theme-menu {
    margin: 0;
}

.theme-menu summary::after {
    content: none;
}

.theme-menu[open] summary::after {
    content: none;
}

.site-nav .theme-menu ul {
    display: block;
    right: 0;
    min-width: 200px;
    margin-top: 4px;
}

.theme-menu li button.link {
    display: block;
    width: 100%;
    padding: 4px 10px;
    text-align: left;
    white-space: nowrap;
}

.theme-menu li button.active {
    color: var(--text);
}

.theme-menu li button.active::before {
    content: "• ";
}

/* Scripts on/off under the colors, split by a line. */
.theme-menu li.menu-split {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--line);
}

/* The user's status line under the name on the profile. */
.status {
    margin: 4px 0 8px;
    color: var(--text);
    font-style: italic;
    overflow-wrap: anywhere;
}

/* A user's signature under their comments: clearly apart from the comment. */
.signature {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed var(--line);
    color: var(--muted);
    font-size: 0.8em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ---------- popups over links to comments (no JavaScript) ---------- */

/* The text is already in the page next to the link, hidden; hovering the link
   (or reaching it with Tab) shows it. A popup lists the replies to its
   comment, each with its own popup inside: ">" opens only the next level. */
.ref-wrap {
    position: relative;
}

.ref-preview {
    display: none;
    position: absolute;
    z-index: 20;
    left: 0;
    top: 100%;
    width: max-content;
    max-width: min(420px, 80vw);
    margin-top: 4px;
    padding: 8px 10px;
    background: var(--bg-raised);
    border: 1px solid var(--accent);
    color: var(--text);
    font-size: 0.85rem;
    font-style: normal;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    box-shadow: 0 4px 16px var(--shadow);
}

.ref-wrap:hover > .ref-preview,
.ref-wrap:focus-within > .ref-preview {
    display: block;
}

/* An invisible strip over the gap between the link and its popup: the mouse
   crosses it on the way into the popup, and the popup stays open. */
.ref-preview::before {
    content: "";
    position: absolute;
    left: -1px;
    right: -1px;
    bottom: 100%;
    height: 6px;
}

/* The replies at the bottom of a popup, as links with their own popups. */
.ref-replies {
    display: block;
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    white-space: normal;
}

.ref-author {
    display: block;
    margin-bottom: 4px;
    color: var(--accent);
}

/* Phones have no mouse: a tap just follows the link. */
@media (hover: none) {
    .ref-wrap:hover > .ref-preview {
        display: none;
    }
}

/* ---------- comment formatting and the comment editor ---------- */

/* Emojis: pixel art drawn on a 16x16 grid inside an 18x18 frame, so the
   sizes are 1.5x or 2x of 18 (27px, 36px): sharp on phones and HiDPI
   screens. Each picture is a strip of 4 frames side by side (see
   tools/make_emojis.py). object-fit: cover makes the frame fill the square
   and cuts the rest of the strip off, so the first frame shows. The PNG has
   one pixel per grid pixel: pixelated keeps them sharp squares when made
   bigger, instead of blurring them. */
img.emoji {
    height: 27px;
    width: 27px;
    vertical-align: -7px;
}

img.emoji, .emoji-button img, .tool-square img {
    object-fit: cover;
    object-position: 0 0;
    image-rendering: pixelated;
}

/* Under the mouse the strip slides frame by frame: 4 stops from the left
   end (0) to the right end (100%), jumping, not sliding smoothly. */
@keyframes emoji-play {
    from { object-position: 0 0; }
    to { object-position: 100% 0; }
}

img.emoji:hover,
.emoji-button:hover img, .emoji-button:focus-visible img,
.tool-square:hover img {
    animation: emoji-play 0.8s steps(4, jump-none) infinite;
}

/* For people who turned off animations in their system: still pictures. */
@media (prefers-reduced-motion: reduce) {
    img.emoji:hover,
    .emoji-button:hover img, .emoji-button:focus-visible img,
    .tool-square:hover img {
        animation: none;
    }
}

.text code, .format-help code {
    padding: 0 4px;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    font-size: 0.9em;
}

/* A spoiler is a gray bar until the mouse is over it or a tap focuses it
   (it has tabindex). The bar is a layer on top of the text, made of 5px
   squares split into 6 random groups (a mask of 6 small pictures, in
   static/spoiler/; inline data: pictures would be blocked by our CSP). They
   are PNG, exactly 40px like the mask size, not SVG: Tor Browser on "Safest"
   shows no SVG, and a mask that doesn't load would show the text. On
   hover the groups vanish one after another, so the bar falls apart into
   pixels and the text shows through. The layer also catches clicks, so a
   hidden link can't be clicked by accident.
   It is an inline-block, so a long spoiler is a rectangle, not a strip of
   lines: the layer can only cover a rectangle. */
.spoiler {
    position: relative;
    display: inline-block;
    max-width: 100%;
    vertical-align: bottom;
    cursor: pointer;
}

.spoiler::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: var(--line);
    -webkit-mask-image: url("spoiler/1.png"),
        url("spoiler/2.png"),
        url("spoiler/3.png"),
        url("spoiler/4.png"),
        url("spoiler/5.png"),
        url("spoiler/6.png");
    mask-image: url("spoiler/1.png"),
        url("spoiler/2.png"),
        url("spoiler/3.png"),
        url("spoiler/4.png"),
        url("spoiler/5.png"),
        url("spoiler/6.png");
    -webkit-mask-size: 40px 40px, 40px 40px, 40px 40px, 40px 40px, 40px 40px, 40px 40px;
    mask-size: 40px 40px, 40px 40px, 40px 40px, 40px 40px, 40px 40px, 40px 40px;
}

.spoiler:hover, .spoiler:focus {
    outline: none;
}

.spoiler:hover::after, .spoiler:focus::after {
    pointer-events: none;
    animation: spoiler-dissolve 0.5s steps(1, end) forwards;
}

/* Each step drops one more group of squares. The last step also hides the
   layer completely, for browsers that don't know masks. */
@keyframes spoiler-dissolve {
    0% { mask-size: 40px 40px, 40px 40px, 40px 40px, 40px 40px, 40px 40px, 40px 40px; -webkit-mask-size: 40px 40px, 40px 40px, 40px 40px, 40px 40px, 40px 40px, 40px 40px; }
    16.7% { mask-size: 0 0, 40px 40px, 40px 40px, 40px 40px, 40px 40px, 40px 40px; -webkit-mask-size: 0 0, 40px 40px, 40px 40px, 40px 40px, 40px 40px, 40px 40px; }
    33.3% { mask-size: 0 0, 0 0, 40px 40px, 40px 40px, 40px 40px, 40px 40px; -webkit-mask-size: 0 0, 0 0, 40px 40px, 40px 40px, 40px 40px, 40px 40px; }
    50% { mask-size: 0 0, 0 0, 0 0, 40px 40px, 40px 40px, 40px 40px; -webkit-mask-size: 0 0, 0 0, 0 0, 40px 40px, 40px 40px, 40px 40px; }
    66.7% { mask-size: 0 0, 0 0, 0 0, 0 0, 40px 40px, 40px 40px; -webkit-mask-size: 0 0, 0 0, 0 0, 0 0, 40px 40px, 40px 40px; }
    83.3% { mask-size: 0 0, 0 0, 0 0, 0 0, 0 0, 40px 40px; -webkit-mask-size: 0 0, 0 0, 0 0, 0 0, 0 0, 40px 40px; }
    100% { mask-size: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; -webkit-mask-size: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; visibility: hidden; }
}

/* For people who turned off animations in their system: the bar just goes. */
@media (prefers-reduced-motion: reduce) {
    .spoiler:hover::after, .spoiler:focus::after {
        animation: none;
        visibility: hidden;
    }
}

/* The comment field: a frame around the toolbar and the textarea, which has
   no border of its own. The frame lights up while you type in it. */
.editor-box {
    position: relative;
    border: 1px solid var(--line);
}

.editor-box:focus-within {
    outline: 1px solid var(--accent);
}

.editor-box textarea {
    display: block;
    width: 100%;
    border: none;
    outline: none;
}

.editor-toolbar {
    display: flex;
    gap: 6px;
    padding: 6px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-raised);
}

.tool summary {
    list-style: none;
}

.tool summary::-webkit-details-marker {
    display: none;
}

.tool-square {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    box-sizing: border-box;
    border: 1px solid var(--line);
    color: var(--muted);
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, color 0.15s;
}

.tool-square img {
    width: 27px;
    height: 27px;
}

.tool-square:hover, .tool[open] .tool-square {
    border-color: var(--accent);
    color: var(--accent);
}

/* Closing on a click outside, the same way as .dropdown above. */
.tool[open] .tool-square::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9;
    cursor: default;
}

/* The panel opens above the comment field, right over the toolbar, so it
   covers the comments above and not the text you are writing. If it is
   taller than max-height, it scrolls inside. */
.tool-panel {
    position: absolute;
    z-index: 10;
    left: 0;
    right: 0;
    bottom: 100%;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px 12px 12px;
    background: var(--bg-raised);
    border-top: 1px solid var(--accent);
    box-shadow: 0 -8px 16px var(--shadow);
}

.format-help {
    margin-top: 8px;
    border-collapse: collapse;
}

.format-help td {
    padding: 4px 16px 4px 0;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 6px;
    max-width: 520px;
}

.emoji-grid .emoji-button {
    align-self: stretch;
    display: grid;
    place-items: center;
    padding: 6px;
    border-color: var(--line);
    transition: border-color 0.15s, transform 0.15s;
}

.emoji-button:hover, .emoji-button:focus-visible {
    border-color: var(--accent);
    transform: scale(1.12);
}

.emoji-button img {
    width: 36px;
    height: 36px;
}

/* ---------- main sphere and interests ---------- */

/* A small tag next to a name. */
.sphere {
    display: inline-block;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: 3px;
    font-size: 0.75em;
    line-height: 1.6;
    color: var(--muted);
    white-space: nowrap;
    vertical-align: middle;
}

.interests-head {
    font-size: 1em;
    margin: 16px 0 4px;
}

/* Written by the user: line breaks are kept, long words wrap. */
.interests {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ---------- the home page ---------- */

.home {
    display: flex;
    flex-direction: column;
    gap: 56px;
}

/* The night street (templates/index.html), or by the light theme's colors
   the beach by day: the parts of one picture hide in the other (--night-off,
   --day-off). Everything moves by CSS animations only. */
.hero {
    --wall: #120d17;
    --lights-amber: #7a5226;
    --lights-teal: #176a64;
    --lights-pink: #7a2150;
    --lights-dark: #1d1723;
    --neon-cyan: #2ee6d6;
    --neon-pink: #ff3d8b;
    position: relative;
    height: 420px;
    overflow: hidden;
    background: var(--hero-bg);
    border: 1px solid var(--hero-border);
    border-radius: 10px;
}

.hero-star {
    display: var(--night-off, block);
    position: absolute;
    width: 3px;
    height: 3px;
    background: #ece4d8;
    opacity: 0.6;
    animation: hero-twinkle 4s steps(1) infinite;
}

.hero-star:nth-child(3n) { animation-delay: -1.3s; }
.hero-star:nth-child(3n + 1) { animation-delay: -2.6s; }

/* A pixel moon: a square with its corners cut. */
.hero-moon {
    display: var(--night-off, block);
    position: absolute;
    right: 140px;
    top: 44px;
    width: 44px;
    height: 44px;
    background: #ffe2b0;
    clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
}

/* The houses slide slowly backwards: the car is driving. Each one has its own
   width; margin-right (not gap) keeps the two copies exactly one row apart. */
.hero-city {
    position: absolute;
    left: 0;
    bottom: 96px;
    display: var(--night-off, flex);
    align-items: flex-end;
    width: max-content;
    animation: hero-city 40s linear infinite;
}

/* Windows: two stripes of wall color over the color of the lights. Some
   houses have a neon edge on the roof (--neon), an antenna with a red light
   (::before) or a vertical neon sign on the wall (::after). Every pattern
   repeats every 15 houses, like the sizes, so both copies of the row match. */
.house {
    position: relative;
    flex: none;
    margin-right: 8px;
    border-top: 3px solid var(--neon, #241d2b);
    box-shadow: 0 -3px 10px -4px var(--neon, transparent);
    background:
        repeating-linear-gradient(90deg, var(--wall) 0 8px, transparent 8px 14px),
        repeating-linear-gradient(0deg, var(--wall) 0 10px, transparent 10px 16px),
        var(--lights);
}

.house:nth-child(5n + 2) { --neon: var(--neon-cyan); }
.house:nth-child(15n + 4),
.house:nth-child(15n + 11) { --neon: var(--neon-pink); }

.house:nth-child(5n + 1)::before {
    content: "";
    position: absolute;
    left: 30%;
    bottom: 100%;
    width: 2px;
    height: 26px;
    margin-bottom: 3px;
    background: #2a2231;
    box-shadow: 0 -2px 0 1px #ff3d4f;
}

.house:nth-child(15n + 3)::after,
.house:nth-child(15n + 9)::after,
.house:nth-child(15n + 5)::after,
.house:nth-child(15n + 13)::after {
    content: "";
    position: absolute;
    right: 6px;
    top: 18px;
    width: 8px;
    height: 46px;
    background: repeating-linear-gradient(0deg, var(--neon-pink) 0 6px, transparent 6px 9px);
    box-shadow: 0 0 10px rgba(255, 61, 139, 0.55);
    animation: hero-flicker 7s steps(1) infinite;
}

.house:nth-child(15n + 5)::after,
.house:nth-child(15n + 13)::after {
    background: repeating-linear-gradient(0deg, var(--neon-cyan) 0 6px, transparent 6px 9px);
    box-shadow: 0 0 10px rgba(46, 230, 214, 0.5);
    animation-delay: -3s;
}

.house:nth-child(15n + 1) { width: 70px; height: 150px; --lights: var(--lights-amber); }
.house:nth-child(15n + 2) { width: 54px; height: 210px; --lights: var(--lights-teal); }
.house:nth-child(15n + 3) { width: 90px; height: 120px; --lights: var(--lights-dark); }
.house:nth-child(15n + 4) { width: 62px; height: 260px; --lights: var(--lights-amber); }
.house:nth-child(15n + 5) { width: 80px; height: 180px; --lights: var(--lights-dark); }
.house:nth-child(15n + 6) { width: 48px; height: 140px; --lights: var(--lights-pink); }
.house:nth-child(15n + 7) { width: 100px; height: 230px; --lights: var(--lights-amber); }
.house:nth-child(15n + 8) { width: 58px; height: 170px; --lights: var(--lights-dark); }
.house:nth-child(15n + 9) { width: 76px; height: 280px; --lights: var(--lights-teal); }
.house:nth-child(15n + 10) { width: 64px; height: 150px; --lights: var(--lights-amber); }
.house:nth-child(15n + 11) { width: 88px; height: 200px; --lights: var(--lights-dark); }
.house:nth-child(15n + 12) { width: 52px; height: 240px; --lights: var(--lights-pink); }
.house:nth-child(15n + 13) { width: 70px; height: 130px; --lights: var(--lights-teal); }
.house:nth-child(15n + 14) { width: 84px; height: 190px; --lights: var(--lights-dark); }
.house:nth-child(15n + 15) { width: 60px; height: 220px; --lights: var(--lights-amber); }
.hero-star:nth-of-type(1) { left: 6%; top: 12px; }
.hero-star:nth-of-type(2) { left: 14%; top: 40px; }
.hero-star:nth-of-type(3) { left: 22%; top: 18px; }
.hero-star:nth-of-type(4) { left: 31%; top: 55px; }
.hero-star:nth-of-type(5) { left: 38%; top: 10px; }
.hero-star:nth-of-type(6) { left: 47%; top: 30px; }
.hero-star:nth-of-type(7) { left: 56%; top: 14px; }
.hero-star:nth-of-type(8) { left: 70%; top: 8px; }
.hero-star:nth-of-type(9) { left: 78%; top: 44px; }
.hero-star:nth-of-type(10) { left: 86%; top: 20px; }
.hero-star:nth-of-type(11) { left: 93%; top: 52px; }
.hero-star:nth-of-type(12) { left: 97%; top: 12px; }

.hero-road {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 96px;
    background: var(--hero-road);
    border-top: 3px solid var(--hero-road-edge);
}

.hero-lines {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 42px;
    height: 4px;
    background-image: repeating-linear-gradient(90deg, var(--hero-lane) 0 28px, transparent 28px 56px);
    opacity: 0.7;
    animation: hero-road 0.35s linear infinite;
}

/* The rats: a strip of 4 frames (tools/make_hero.py), each 132x60 pixels,
   shown 3 times bigger with sharp pixels. background-size 400% fits one frame
   in the box; the animation jumps from frame to frame. ?v= changes when the
   picture changes. */
/* The picture is 164x60 pixels per frame: 32 of fire behind the car, then
   the 132 of the car. margin-left keeps the car (not the fire) in the middle:
   -(32 + 66) pixels times the scale. */
.hero-car,
.hero-car-day {
    display: var(--night-off, block);
    position: absolute;
    left: 50%;
    bottom: 24px;
    width: 492px;
    height: 180px;
    margin-left: -294px;
    background: url("/static/hero/rats.png?v=4") 0 0 / 400% 100% no-repeat;
    image-rendering: pixelated;
    animation: hero-frames 0.4s steps(4, jump-none) infinite, hero-bob 0.5s steps(2) infinite;
}

/* By day: the rats cruising in the Impala (tools/make_hero_day.py), the
   same size of picture, a slower cruise. */
.hero-car-day {
    display: var(--day-off, block);
    background-image: url("/static/hero/rats-day.png?v=1");
    animation-duration: 0.6s, 0.9s;
}

/* A seventies sun: a round pixel sun, its lower half cut by stripes of
   sky. */
.hero-sun {
    display: var(--day-off, block);
    position: absolute;
    right: 110px;
    top: 34px;
    width: 120px;
    height: 120px;
    background: linear-gradient(#ffe36b, #ffb347 55%, #ff7a3d);
    clip-path: polygon(35% 0, 65% 0, 65% 4%, 80% 4%, 80% 10%, 90% 10%, 90% 20%, 96% 20%,
        96% 35%, 100% 35%, 100% 65%, 96% 65%, 96% 80%, 90% 80%, 90% 90%, 80% 90%, 80% 96%,
        65% 96%, 65% 100%, 35% 100%, 35% 96%, 20% 96%, 20% 90%, 10% 90%, 10% 80%, 4% 80%,
        4% 65%, 0 65%, 0 35%, 4% 35%, 4% 20%, 10% 20%, 10% 10%, 20% 10%, 20% 4%, 35% 4%);
    -webkit-mask: linear-gradient(#000 0 54%, transparent 54% 59%, #000 59% 68%, transparent 68% 72%,
        #000 72% 80%, transparent 80% 83%, #000 83%);
    mask: linear-gradient(#000 0 54%, transparent 54% 59%, #000 59% 68%, transparent 68% 72%,
        #000 72% 80%, transparent 80% 83%, #000 83%);
}

/* Two pixel clouds drifting slowly across the sky. */
.hero-cloud {
    display: var(--day-off, block);
    position: absolute;
    left: 100%;
    width: 84px;
    height: 24px;
    background: #fffaf2;
    clip-path: polygon(0 50%, 15% 50%, 15% 25%, 35% 25%, 35% 0, 65% 0, 65% 25%, 85% 25%,
        85% 50%, 100% 50%, 100% 100%, 0 100%);
    animation: hero-cloud 60s linear infinite;
}

.hero-cloud { top: 70px; }
.hero-cloud + .hero-cloud { top: 26px; width: 60px; height: 18px; animation-delay: -34s; }

/* The sea behind the beach, with rows of little waves running along it. */
.hero-sea {
    display: var(--day-off, block);
    position: absolute;
    left: 0;
    right: 0;
    bottom: 120px;
    height: 74px;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.75) 0 16px, transparent 16px) 0 14px / 52px 3px repeat-x,
        linear-gradient(90deg, rgba(255, 255, 255, 0.6) 0 10px, transparent 10px) 20px 38px / 40px 3px repeat-x,
        linear-gradient(90deg, rgba(255, 255, 255, 0.5) 0 22px, transparent 22px) 8px 58px / 64px 3px repeat-x,
        linear-gradient(#3cc3cf, #1f9db0);
    border-top: 3px solid #7fdde3;
    animation: hero-waves 3s steps(6) infinite;
}

.hero-sand {
    display: var(--day-off, block);
    position: absolute;
    left: 0;
    right: 0;
    bottom: 96px;
    height: 24px;
    background: #f3d9a4;
    border-top: 3px solid #ffe9bd;
}

/* Palms and small houses (tools/make_beach.py): one pixel tile, repeated
   along the beach 3 times bigger, sliding back as the car drives. */
.hero-beach {
    display: var(--day-off, block);
    position: absolute;
    left: 0;
    right: 0;
    bottom: 99px;
    height: 192px;
    background: url("/static/hero/beach.png?v=1") 0 100% / 720px 192px repeat-x;
    image-rendering: pixelated;
    animation: hero-beach 24s linear infinite;
}

.hero-rain {
    display: var(--night-off, block);
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: repeating-linear-gradient(105deg, transparent 0 22px, rgba(46, 230, 214, 0.12) 22px 23px);
    animation: hero-rain 0.7s linear infinite;
}

.hero-title {
    position: absolute;
    left: 36px;
    top: 30px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hero h1 {
    margin: 0;
    color: var(--hero-h1);
    font-family: "Silkscreen", monospace;
    font-weight: 700;
    font-size: 64px;
    line-height: 1;
    letter-spacing: 0.03em;
    text-shadow: var(--hero-h1-shadow);
}

.hero-title p {
    margin: 0;
    color: var(--hero-sub);
    font-family: "IBM Plex Mono", monospace;
    font-size: 15px;
}

@keyframes hero-frames { from { background-position: 0 0; } to { background-position: 100% 0; } }
@keyframes hero-bob { 50% { transform: translateY(-3px); } }
@keyframes hero-road { to { background-position: -56px 0; } }
@keyframes hero-rain { to { background-position: -80px 400px; } }
@keyframes hero-city { to { transform: translateX(-50%); } }
@keyframes hero-flicker { 0%, 90%, 100% { opacity: 1; } 92% { opacity: 0.3; } 94% { opacity: 0.9; } 96% { opacity: 0.4; } }
@keyframes hero-twinkle { 0%, 70%, 100% { opacity: 0.6; } 80% { opacity: 0.15; } }
@keyframes hero-beach { to { background-position: -720px 100%; } }
@keyframes hero-cloud { to { transform: translateX(calc(-100vw - 200px)); } }
@keyframes hero-waves { to { background-position: -52px 14px, -20px 38px, -56px 58px, 0 0; } }
@keyframes hero-beach-small { to { background-position: -480px 100%; } }

/* Wide screens: the car 4 times bigger, so the rats are easy to see. */
@media (min-width: 900px) {
    .hero-car,
    .hero-car-day {
        width: 656px;
        height: 240px;
        margin-left: -392px;
        bottom: 22px;
    }
}

/* Phones: a lower street, a smaller car (2x instead of 3x). */
@media (max-width: 640px) {
    .hero {
        height: 330px;
    }

    .hero h1 {
        font-size: 38px;
    }

    .hero-sun {
        right: 20px;
        top: 74px;
        width: 72px;
        height: 72px;
    }

    .hero-beach {
        height: 128px;
        background-size: 480px 128px;
        animation-name: hero-beach-small;
    }

    .hero-title {
        left: 18px;
        top: 20px;
    }

    .hero-car,
    .hero-car-day {
        width: 328px;
        height: 120px;
        margin-left: -196px;
        bottom: 26px;
    }
}

/* Visitors who asked their device for less motion get a still picture. */
@media (prefers-reduced-motion: reduce) {
    .hero * {
        animation: none !important;
    }
}

.home-about {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    align-items: flex-start;
}

.home-lead {
    flex: 999 1 480px;
    min-width: 0;
    margin: 0;
    font-size: 1.3em;
    line-height: 1.6;
}

.home-rules, .home-card, .home-principle {
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.home-rules {
    flex: 1 1 260px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px 22px;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 14px;
}

.home-rules-head {
    color: var(--accent);
}

.home-levels {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.home-intro {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 760px;
}

.home-intro h2 {
    font-size: 2em;
    font-weight: 600;
    line-height: 1.25;
}

.home-intro p {
    margin: 0;
    color: var(--muted);
}

.home-kicker {
    color: var(--cyan);
    font-family: var(--font-mono);
    font-size: 14px;
}

.home-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.home-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px;
    color: var(--muted);
}

a.home-card:hover {
    border-color: var(--accent);
    text-shadow: none;
}

.home-card-title {
    color: var(--accent);
    font-family: var(--font-pixel);
    font-size: 1.3em;
}

.home-card-go {
    margin-top: auto;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 14px;
}

.home-card-soon {
    background: transparent;
    border-style: dashed;
}

.home-card-soon .home-card-title {
    color: var(--muted);
}

.soon {
    padding: 2px 6px;
    border: 1px solid var(--cyan);
    color: var(--cyan);
    font-family: var(--font-mono);
    font-size: 12px;
    vertical-align: middle;
}

/* One under the other on phones; side by side on wider screens, where the
   anonymity block (the second, with more text) gets twice the room. */
.home-principles {
    display: grid;
    gap: 16px;
}

@media (min-width: 760px) {
    .home-principles {
        grid-template-columns: 1fr 2fr;
    }
}

/* The narrow column: its block only as tall as its text, and the cat in
   the middle of the room left under it. */
.home-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.home-cat {
    flex: 1;
    display: grid;
    place-items: center;
}

/* The cat chasing a drone, no background: 16 frames of 76x56 pixels,
   shown 3 times bigger with sharp pixels (smaller only if the column is
   narrower). */
.cat-face {
    width: min(228px, 100%);
    aspect-ratio: 76 / 56;
    background: var(--cat-sprite) 0 0 / 1600% 100% no-repeat;
    image-rendering: pixelated;
    animation: cat-frames 3.2s steps(16, jump-none) infinite;
}

@keyframes cat-frames { from { background-position: 0 0; } to { background-position: 100% 0; } }

/* On phones the blocks are one under the other: no room to fill. */
@media (max-width: 759px) {
    .home-cat {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cat-face {
        animation: none;
    }
}

/* The icon and the heading on the first line, the text under both, using
   the whole width. The inner <div> takes no part in the layout
   (display: contents), so its heading and text are placed by this grid. */
.home-principle {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 14px;
    align-items: baseline;
    padding: 26px;
    color: var(--muted);
}

.home-principle > div {
    display: contents;
}

.home-principle > div > * {
    grid-column: 1 / -1;
}

.home-principle > div > h3 {
    grid-column: 2;
}

.home-principle-icon {
    flex: none;
    color: var(--cyan);
    font-family: var(--font-mono);
    font-size: 22px;
    line-height: 1.2;
}

.home-principle h3 {
    margin: 0 0 6px;
    color: var(--cyan);
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 500;
}

.home-principle p {
    margin: 0 0 8px;
}

.home-principle ul {
    list-style: "– ";
    padding-left: 1.2em;
}

.home-principle li {
    margin: 4px 0;
}

/* ---------- extra images in a post ---------- */

/* A figure in the text: whole, as wide as the text at most, never cut.
   A click opens it alone at full size. */
.figure {
    margin: 16px 0;
}

.figure img {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 80vh;
    margin: 0 auto;
    border: 1px solid var(--line);
    background: var(--bg-raised);
}

.figure figcaption {
    margin-top: 6px;
    text-align: center;
    color: var(--muted);
    font-size: 0.9em;
    overflow-wrap: anywhere;
}

/* The image fields in the new post and edit forms. */
.figures summary {
    cursor: pointer;
    color: var(--accent);
}

.figures[open] summary {
    margin-bottom: 8px;
}

.figure-slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px 20px;
    margin-top: 10px;
}

.figure-slot {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border: 1px dashed var(--line);
}

.figure-slot img {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
    align-self: flex-start;
}

.figure-slots code, .figures .hint code {
    padding: 0 4px;
    background: var(--bg-raised);
    border: 1px solid var(--line);
}

/* A text box that grows while it's filled (field-sizing, no JavaScript).
   It starts at least as high as its rows and stops growing at the screen
   height, then scrolls inside. Browsers that don't know field-sizing show a
   normal box that can be made taller by dragging its corner. */
textarea.grow {
    field-sizing: content;
    min-height: 12lh;
    max-height: 85vh;
    resize: vertical;
}

/* ---------- ranks ---------- */
/* Each part's color, for the tags, the bars and the ladders. */
.rank-organs { --dir: var(--dir-organs); }
.rank-functions { --dir: var(--dir-functions); }
.rank-surgical { --dir: var(--dir-surgical); }
.rank-soft { --dir: var(--dir-soft); }
.rank-accessories { --dir: var(--dir-accessories); }

/* A rank next to a name: like the sphere tag, framed in the part's color. */
.rank {
    display: inline-block;
    padding: 0 6px;
    border: 1px solid var(--dir);
    border-radius: 3px;
    font-size: 0.75em;
    line-height: 1.6;
    color: var(--dir);
    white-space: nowrap;
    vertical-align: middle;
}

/* The profile: one bar per part. */
.rank-bars li {
    margin: 10px 0;
}

.rank-bar-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0 12px;
}

.rank-bar-head b {
    color: var(--dir);
}

.rank-bar progress {
    display: block;
    width: 100%;
    height: 8px;
    accent-color: var(--dir);
}

.rank-bar .hint {
    display: block;
}

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

/* The admin's Ranks tab: one line per rank, wraps on a phone. */
.rank-new {
    margin-bottom: 20px;
}

.rank-admin-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin: 8px 0;
}

.rank-edit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.rank-edit input[name="name"] {
    width: 12em;
}

.rank-edit .rank-points input {
    width: 6em;
}

.rank-edit input[name="description"] {
    flex: 1;
    min-width: 12em;
}

.rank-step {
    min-width: 1.5em;
    color: var(--muted);
}

/* ---------- the user's links ---------- */
/* Account page: a name and an address side by side; one under the other on a phone. */
.link-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.link-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 6px;
}

@media (max-width: 520px) {
    .link-row {
        grid-template-columns: 1fr;
        margin-bottom: 6px;
    }
}

/* Profile: the name, then the full address in small grey text. */
.profile-links li {
    margin: 2px 0;
    overflow-wrap: anywhere;
}

.profile-links .link-url {
    margin-left: 6px;
}

/* The ranks on a profile: the icon, the name, the part, the description. */
.profile-ranks li {
    margin: 4px 0;
}

.profile-ranks b {
    color: var(--dir);
}

.profile-ranks .hint {
    display: block;
    margin-left: 1.6em;
}

/* AI page summary: a collapsible box above the comments. Uses <details>, so
   it opens and closes with no JavaScript. */
.page-summary {
    border: 1px solid var(--notice-line);
    background: var(--notice-bg);
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    margin: 0 0 1.2rem;
}
.page-summary > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--notice);
    padding: 0.3rem 0;
}
.page-summary .summary-body {
    padding-top: 0.4rem;
}
.page-summary .summary-note {
    font-size: 0.85em;
    color: var(--muted);
    margin: 0 0 0.6rem;
}
.page-summary h3 {
    font-family: var(--font-mono);
    font-size: 0.8em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0.9rem 0 0.3rem;
}
.page-summary ul {
    margin: 0;
    padding-left: 1.2em;
}
.page-summary li {
    margin: 0.2rem 0;
}
.page-summary li .ref {
    font-size: 0.85em;
}

/* ---------- the optional scripts (static/enhance.js) ---------- */

/* Parts only the script uses come with the hidden attribute. Rules like
   display: grid would show them anyway, so hidden always wins. */
[hidden] {
    display: none !important;
}

/* B, I, S, || in the comment toolbar are buttons, not <details>. */
button.tool-square {
    padding: 0;
    font-weight: bold;
}

/* "123 / 5000" under a text box; it turns red near the limit. */
.char-count {
    align-self: flex-end;
    font-size: 0.85em;
}

.char-count.over {
    color: var(--danger);
}

/* The chosen picture before uploading, cut like the server will cut it. */
.file-preview {
    display: block;
    max-width: 100%;
    max-height: 160px;
    margin-top: 6px;
    border: 1px solid var(--line);
    object-fit: contain;
}

.file-preview.wide {
    width: 284px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.file-preview.square {
    width: 120px;
    height: 120px;
    object-fit: cover;
}

/* ---------- stories (What's new) ---------- */

/* The row of waiting stories: round pictures in a ring of the theme's colors,
   the name under each. On a narrow screen the row scrolls sideways. */
.story-row {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    padding: 8px 2px 14px;
    margin: 12px 0 28px;
}

.story-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 84px;
    color: var(--text);
    text-decoration: none;
}

.story-ring {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: conic-gradient(var(--accent), var(--pink), var(--cyan), var(--accent));
}

/* A gap of the page color between the ring and the picture. */
.story-ring .avatar,
.story-site {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    border: 3px solid var(--bg);
}

/* The site's news: the site's initials instead of someone's picture. */
.story-site {
    display: grid;
    place-items: center;
    box-sizing: border-box;
    background: var(--new-bg);
    color: var(--new-color);
    font-family: var(--font-pixel);
    font-weight: 700;
    font-size: 20px;
}

.story-who {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.8em;
}

.story-bubble:hover .story-who,
.story-bubble:focus-visible .story-who {
    color: var(--accent);
}

.story-form {
    max-width: 640px;
    margin-bottom: 28px;
}

.my-stories li,
.my-subscriptions li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    padding: 6px 0;
    border-top: 1px solid var(--line);
}

/* One story, full size: a card in the middle, the picture whole. */
.story {
    max-width: 560px;
    margin: 0 auto;
    padding: 16px 18px;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.story-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    margin-bottom: 12px;
}

.story-tag {
    padding: 0 6px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.75em;
}

.story-image {
    display: block;
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--radius);
    background: var(--bg);
}

/* The text as written: line breaks kept, long words wrapped. */
.story-text {
    margin: 12px 0 0;
    font-size: 1.1em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.story-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    margin-top: 16px;
}

/* "Next" is a link dressed as a button: rounded like "Close" next to it. */
.story-actions a.button {
    border-radius: var(--radius);
}

/* "What's new" in the menu: only there while something waits to be watched,
   so it has to be noticed. A pill in the theme's accent and pink with a soft
   glow pulsing round it, and the count of waiting stories. */
.site-nav a.whats-new-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 6px 2px 12px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--pink));
    color: var(--bg);
    font-weight: 700;
    text-decoration: none;
    animation: whats-new-glow 1.8s ease-out infinite;
}

.site-nav a.whats-new-button:hover,
.site-nav a.whats-new-button:focus-visible {
    filter: brightness(1.1);
}

.whats-new-button .count {
    min-width: 1.5em;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--pink);
    font-size: 0.8em;
    text-align: center;
}

@keyframes whats-new-glow {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pink) 55%, transparent); }
    70%, 100% { box-shadow: 0 0 0 9px transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .site-nav a.whats-new-button {
        animation: none;
    }
}
