/* /talk, shared by both layouts and written for the narrow one.

   There are no *width* media queries in this file or in talk-wide.css, and
   that is the point of choosing the layout on the server: a phone downloads
   the phone rules and nothing else. talk-wide.css carries the desktop chrome
   and is linked only when the document is the desktop one. The queries that
   are here answer the device, not its width -- the dark palette below and the
   coarse-pointer vote target -- and reach either layout.

   The safe-browse gate lives here rather than in the wide file, because it
   has to work on a phone.

   The palette is the main site's -- its reds, on warm neutrals -- so /talk
   reads as the same site. The furniture is not: the tiled backgrounds, the
   hard 5px drop shadows, the serif body text and the pink-filled inputs in
   /css/ws_cream_nocache.css are of 2015 and are deliberately not copied. Any
   colour here that is shared names the legacy value it came from. */

:root {
  --accent: #e64545;       /* a:link */
  --accent-dark: #bf3d3d;  /* a:hover */
  --accent-bar: #db4f4f;   /* .navbar */
  --accent-ink: #a33131;
  --accent-tint: #fad2d2;  /* #page */
  --accent-wash: #fdeeee;

  --bg: #faf8f8;
  --surface: #fff;
  --surface-sunk: #f6f2f2;
  --line: #ece4e4;
  --line-strong: #dccfcf;

  --ink: #1d1a1a;
  --ink-soft: #6f6666;

  --spicy: #a66200;
  --spicy-wash: #fdf3e5;
  --nsfw: #c0392f;
  --nsfw-wash: #fdecea;

  /* Text painted on a filled accent (a button, the active pager page, a cast
     vote) and in a text selection, plus the gate's veil over blurred content.
     Pinned to tokens so the dark palette below can re-pair them -- white on
     the light-mode red, dark ink on the lighter dark-mode one. */
  --on-accent: #fff;
  --selection-ink: #4a1a1a;
  --gate-veil: rgba(255, 255, 255, 0.76);

  /* Both schemes: the light tokens are above and the dark ones override them
     below. This also hands the native UI -- scrollbars, form controls, the
     canvas painted before the page does -- to the browser, to match whichever
     scheme is in use. It stays `light dark` so nothing here needs script: the
     two rules after this block narrow it when a reader has pinned one. */
  color-scheme: light dark;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(29, 26, 26, 0.05);
  --shadow-lift: 0 2px 10px rgba(29, 26, 26, 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --gap: 12px;
}

/* A reader's pinned scheme, read off the meta tag the inline script in <head>
   rewrote. The property has to be re-declared because the one above outranks
   the tag on its own, and it is read from the document rather than a class on
   <html>: the rating buttons rewrite that className wholesale and would carry
   a theme token away with them. */
:root:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }

/* The dark palette. It re-points the colour tokens above, so nearly the whole
   surface re-themes from here -- every rule already reads these names. No
   light-dark() and no per-component query: one override on :root, which is
   also the widest-supported way to do it. The neutrals warm the same way the
   light ones do, so /talk still reads as the main site after dark.

   The red the links and filled controls use is lifted to clear 4.5:1 on these
   dark surfaces, which the light-mode red does not; in exchange a filled
   accent carries dark ink rather than white (see --on-accent), because white
   on the lighter red would not.

   It applies in two cases -- the system asks for dark and the reader has not
   pinned light, or the reader pinned dark -- and one @media cannot express
   both, so the list is written twice. The copies are adjacent on purpose:
   they are one palette and have to move together. */
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) {
    --accent: #ff6b6b;
    --accent-dark: #ff9090;
    /* --accent-bar is left alone: the bar is a red surface under white in
       either scheme, so it keeps the brand red rather than going dark. */
    --accent-ink: #ff9d9d;
    --accent-tint: #5a2a2a;
    --accent-wash: #352322;

    --bg: #181615;
    --surface: #201d1d;
    --surface-sunk: #2a2626;
    --line: #332e2e;
    --line-strong: #453e3e;

    --ink: #ece8e8;
    --ink-soft: #a89f9f;

    --spicy: #f0b860;
    --spicy-wash: #33291a;
    --nsfw: #ff6b5e;
    --nsfw-wash: #3a2320;

    --on-accent: #1a1413;
    --selection-ink: #ffe8e8;
    --gate-veil: rgba(20, 18, 18, 0.78);

    /* Depth off near-black: the warm light-mode shadows all but vanish here,
       so these are plain black and a touch deeper. The borders carry most of
       the separation in the dark regardless. */
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lift: 0 2px 10px rgba(0, 0, 0, 0.5);
  }

  /* The bar stays the brand red, so its white "New topic" button keeps the
     dark-red ink and pale hover wash it has in light mode -- the dark tokens
     above would otherwise paint light ink on that white fill. Scoped to the
     bar's subtree, so only its button is affected. */
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .bar {
    --accent-ink: #a33131;
    --accent-wash: #fdeeee;
  }
}

/* The second copy, for a reader who pinned dark. Same values, same order, and
   the comments are above rather than repeated here. */
:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  --accent: #ff6b6b;
  --accent-dark: #ff9090;
  --accent-ink: #ff9d9d;
  --accent-tint: #5a2a2a;
  --accent-wash: #352322;

  --bg: #181615;
  --surface: #201d1d;
  --surface-sunk: #2a2626;
  --line: #332e2e;
  --line-strong: #453e3e;

  --ink: #ece8e8;
  --ink-soft: #a89f9f;

  --spicy: #f0b860;
  --spicy-wash: #33291a;
  --nsfw: #ff6b5e;
  --nsfw-wash: #3a2320;

  --on-accent: #1a1413;
  --selection-ink: #ffe8e8;
  --gate-veil: rgba(20, 18, 18, 0.78);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 2px 10px rgba(0, 0, 0, 0.5);
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .bar {
  --accent-ink: #a33131;
  --accent-wash: #fdeeee;
}

* { box-sizing: border-box; }

/* The tab bar is fixed over the end of the page, so anything scrolled to --
   a `#comments` link, or a field being tabbed into -- can land underneath it.
   This is the bar's height plus air; talk-wide.css gives it back, having no
   bottom bar and a sticky top one instead. */
html { scroll-padding-bottom: 56px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  -webkit-text-size-adjust: 100%;
  /* Room for the bottom tab bar on mobile; harmless on desktop, where the
     bar is not fixed. */
  padding-bottom: 64px;
  /* A column so the footer can be held at the bottom of a short page: see
     `.wrap` below. A near-empty community -- one topic, no sidebar card --
     otherwise leaves the footer floating in the middle of the window with a
     stretch of background under it. The fixed `.tabs` is out of flow and so
     is not a column item. */
  display: flex;
  flex-direction: column;
  min-block-size: 100dvh;
}

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

::selection { background: var(--accent-tint); color: var(--selection-ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--ink-soft); font-size: 14px; }

/* A relative timestamp in a meta line. Plain muted text and not a pill: the
   row already carries badges for flair and rating, and a date is not one of
   them. Unbroken, because a flex-wrapped meta line will otherwise put "3" at
   the end of one line and "hours ago" at the start of the next. */
.ago { color: var(--ink-soft); white-space: nowrap; }

.empty {
  padding: 20px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-align: center;
}

/* -- chrome -------------------------------------------------------------- */

.bar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 10px 14px;
  background: var(--accent-bar);
  color: #fff;
}

.bar a { color: #fff; }
.bar a:hover { color: #fff; text-decoration: none; }
/* Talk leads, because it is where the reader is; SoundSip follows as the way
   back out. The weight goes with the position -- a second word heavier than
   the first reads as the real title and sends the eye to the wrong one. */
.bar__brand { font-weight: 700; letter-spacing: -0.01em; }
.bar__home { font-weight: 600; opacity: 0.9; }
.bar__acct { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.bar__acct form { margin: 0; }
.bar__who { font-size: 14px; opacity: 0.95; }

/* Signing out is a form post, so it has to be a button; it is the quietest
   thing in the bar, so it is painted as the text it sits next to rather than
   as a second white button competing with "New topic". Padding rather than a
   size carries the 24px target. */
.bar__out {
  padding: 5px 2px;
  min-block-size: 24px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  color: #fff;
  opacity: 0.8;
  cursor: pointer;
}

.bar__out:hover { opacity: 1; text-decoration: underline; }

/* The global ring is `--accent` on white, which is all but invisible on the
   bar's own red. White carries the 3:1 this needs. */
.bar :focus-visible { outline-color: #fff; }

/* White on the red bar rather than the pale pink fill the main site uses,
   which has too little contrast against it to read as a button. */
.bar .btn {
  background: #fff;
  border-color: #fff;
  color: var(--accent-ink);
  font-weight: 600;
}

/* Keeps its ink on hover: `.bar a:hover` is white, which the pale fill below
   cannot carry. */
.bar .btn:hover { background: var(--accent-wash); border-color: var(--accent-wash);
  color: var(--accent-ink); }

/* `flex: 1 0 auto` rather than `margin-block-start: auto` on the footer:
   auto margins eat the free space but collapse to nothing once the page is
   long enough to scroll, which would drop the footer's own 18px of air. The
   content column takes the slack instead and the footer keeps its margin. */
/* `inline-size: 100%` because the `auto` inline margins that centre this
   beat a flex item's default stretch: without it the column shrinks to its
   own content and the centring has nothing to centre. */
.wrap { padding: 14px; max-width: 920px; margin: 0 auto; inline-size: 100%; flex: 1 0 auto; }

.tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.tabs__item {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  font-size: 13px;
  color: var(--ink-soft);
}

.tabs__item:hover { text-decoration: none; }
.tabs__item.is-active { color: var(--accent); font-weight: 600; }

.foot {
  margin-top: 18px;
  padding: 16px 14px 24px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 14px;
}

.foot__links { display: flex; gap: 14px; flex-wrap: wrap; }

/* Safe browsing sits in the footer itself rather than in the sheet below it,
   so it reads as part of the page: name and control on one line, wrapping to
   two on a narrow phone. */
.foot__show { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin-top: 14px; }

/* -- the settings sheet -------------------------------------------------- *\
   The preferences a reader sets once, folded into one <details>. The marker
   is kept, as on `.editor`: a disclosure with no triangle gives a reader
   nothing to tell "this opens" from "this does something". The summary
   carries the link-ish look by hand because nesting a <button> in a
   <summary> breaks the toggle.
\* ----------------------------------------------------------------------- */

.prefs { margin-top: 12px; }

.prefs__open {
  display: list-item;
  width: fit-content;
  color: var(--ink-soft);
  cursor: pointer;
}

.prefs__open:hover { color: var(--accent); text-decoration: underline; }
.prefs[open] .prefs__open { color: var(--accent); }

/* Name beside control, so the four rows share one pair of columns and the
   labels line up. `fit-content` keeps the panel as narrow as its widest row
   rather than running the width of the footer, and the cap is what stops
   that from overflowing a phone. */
.prefs__sheet {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px 16px;
  width: fit-content;
  max-width: 100%;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.prefs__name { font-size: 14px; }

/* One segmented control per preference. `flex-wrap`, because "System (dark)"
   plus Light and Dark is wider than a narrow phone and a clipped pill group
   would hide the third choice entirely. */
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-sunk);
  justify-self: start;
}

.seg > button {
  border: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
}

.seg > button:hover { color: var(--accent); }

/* Inside the pill. The global ring sits 2px out, which on a 2px-padded group
   lands exactly on its border and all but disappears. */
.seg > button:focus-visible { outline-offset: -1px; }

/* Which one is in force: a raised pill rather than a filled accent, which
   `--accent` under white does not carry to 4.5:1 at this size. Weight and a
   lift as well as colour, because these sit in a row of near-identical text
   and colour alone is not a cue everybody has. */
.seg > button[aria-pressed=true] {
  background: var(--surface);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: var(--shadow);
  cursor: default;
}

/* Autoplay is one state rather than a choice between named ones, so a track
   and a knob rather than a pill group. Both colours are tokens that invert
   with the palette, so there is no second rule for the dark one. */
.switch {
  position: relative;
  inline-size: 40px;
  block-size: 24px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-sunk);
  cursor: pointer;
  justify-self: start;
}

.switch::after {
  content: "";
  position: absolute;
  inset-block-start: 3px;
  inset-inline-start: 3px;
  inline-size: 16px;
  block-size: 16px;
  border-radius: 50%;
  background: var(--ink-soft);
}

.switch[aria-pressed=true] { background: var(--accent); border-color: var(--accent); }
.switch[aria-pressed=true]::after { background: var(--on-accent); translate: 16px 0; }

/* Which system setting the "System" button would follow. Both readings are in
   the markup and the wrong one is removed, so no script decides it and an
   assistive technology reads one label rather than two. This answers
   prefers-color-scheme on its own, deliberately: it reports the system
   setting, not the scheme the page is currently painted in. */
.if-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .if-light { display: none; }
  .if-dark { display: inline; }
}

/* -- type and bits ------------------------------------------------------- */

.page__title { font-size: 22px; line-height: 1.25; margin: 6px 0 4px; letter-spacing: -0.01em; }
.page__head { margin-bottom: 12px; }

/* A page-level row of links under the sorts -- `New topic`, `Flairs`. It
   borrows `.form__row`'s layout but is not inside a `.form`, so nothing else
   gives it the air before the listing that a form's fields would. */
.page__actions { margin-bottom: 14px; }
.crumbs { font-size: 14px; color: var(--ink-soft); margin-bottom: 10px; }

/* Titles are short enough for `balance` to be worth its layout cost; bodies
   get `pretty`, which only tidies the last few lines. Named rather than put
   on `*`, where both would be paid for on every element. */
.page__title, .topic__title, .thread__title { text-wrap: balance; }
.post__text, .comment__body, .empty { text-wrap: pretty; }
.crumbs a { color: var(--ink-soft); }
.crumbs a:hover { color: var(--accent); }

.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
}

.btn:hover { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink);
  text-decoration: none; }

.btn--small { padding: 5px 10px; font-size: 13px; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.btn--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--on-accent); }

.linkish {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink-soft);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.linkish:hover { color: var(--accent); text-decoration: underline; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-sunk);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

a.tag:hover { background: var(--accent-wash); color: var(--accent-ink); text-decoration: none; }
.tag--flair { background: var(--accent-wash); color: var(--accent-ink); }
.tag--spicy { background: var(--spicy-wash); color: var(--spicy); }
.tag--nsfw { background: var(--nsfw-wash); color: var(--nsfw); }
.tag--ip { font-family: ui-monospace, SFMono-Regular, monospace; }
/* The reach badge next to a community's name when it is unlisted or private.
   Kept muted on purpose -- it marks a state, it is not a call to action. */
.tag--quiet { vertical-align: middle; margin-inline-start: 8px; font-weight: 400; }

/* A segmented control: one sunk track, the chosen one raised out of it. */
.sorts {
  display: inline-flex;
  gap: 2px;
  margin: 10px 0 14px;
  padding: 3px;
  background: var(--surface-sunk);
  border-radius: 999px;
}

.sorts__item {
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-soft);
}

.sorts__item:hover { color: var(--accent-ink); text-decoration: none; }
.sorts__item.is-active {
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--accent-ink);
  font-weight: 600;
}

/* The links inside are the paginator's own `.button` / `.active` /
   `.disabled`, from app/paginator.py. */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 18px 0; }

.pager a, .pager .disabled {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 14px;
}

.pager a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager .active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.pager .active:hover { color: var(--on-accent); }
.pager .disabled { opacity: 0.5; }

/* Where the numbers stop, Next is the control for the list rather than one
   step through a strip, so it takes the width a thumb needs. */
.pager--more[data-more] .pager__next { flex: 1; min-width: 7rem; text-align: center; font-weight: 600; }
/* A fetch in flight. Not `disabled`: an anchor has no such state, and a
   second press while the first is loading would append the page twice. */
.pager a[aria-busy="true"] { opacity: 0.6; pointer-events: none; }

/* -- listings ------------------------------------------------------------ */

.topics { display: flex; flex-direction: column; gap: 8px; }

.topic {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topic:hover { border-color: var(--line-strong); }

.topic__score {
  min-width: 38px;
  height: fit-content;
  padding: 4px 0;
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* A fixed square, so 25 rows line up and a tall picture does not make one
   row twice the height of its neighbours. `cover` crops rather than
   letterboxes, and it is what keeps a row square on the posts whose
   thumbnail is still the full picture. */
.topic__thumb {
  flex: none;
  display: block;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
}
.topic__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

.topic__main { flex: 1; min-width: 0; }
.topic__title { font-size: 16px; line-height: 1.35; margin: 0 0 5px; font-weight: 600; }
.topic__title a { color: var(--ink); }
.topic__title a:hover { color: var(--accent); text-decoration: none; }
.topic__meta { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-size: 13px; color: var(--ink-soft); }
.topic__comments { color: var(--ink-soft); }

.cards { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.card {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card__title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.card .card__title a { color: inherit; }
.cards .card__title { font-size: 16px; letter-spacing: normal; text-transform: none; color: var(--ink); }
.cards .card__title a { color: var(--ink); }
.cards .card__title a:hover { color: var(--accent); text-decoration: none; }

.list { list-style: none; margin: 0 0 12px; padding: 0; }
.list li { display: flex; gap: 8px; align-items: baseline; padding: 6px 0;
  border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li a { color: var(--ink); flex: 1; }
.list li a:hover { color: var(--accent); text-decoration: none; }

.card__more { margin: 0 0 12px; font-size: 14px; }
/* The Communities card closes with a link and a button; the recents card ends
   with the list, so the room the list leaves for one is given back. */
.card .list:last-child { margin-bottom: 0; }

/* Recently visited, filled by talk.js and hidden until it has something in
   it. On a phone it is the last thing in the content column, so it needs
   separating from the page above it -- in the desktop sidebar the column's
   own gap does that, which is why the margin is on `main`'s copy alone. */
main > .recents { margin-top: 14px; }

/* -- a topic and its thread --------------------------------------------- */

.post {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.post__head .page__title { margin-top: 0; }
.post__head .muted { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.post__source { margin: 8px 0 0; font-size: 14px; color: var(--ink-soft); }

.post__body { margin: 12px 0; }
/* Only the text runs wrap on their own whitespace; an embed sits between them
   as a block, so the newline that set it apart does not print as a blank line. */
.post__text { white-space: pre-wrap; overflow-wrap: anywhere; }
.post__text + .post__text { margin-top: 0; }

/* Both kinds claim their box before loading, so the thread below is not pushed
   down the page as each arrives. A player has a ratio of its own; a gif is on
   another host at an unknown size, with no stored dimensions to write as
   `width`/`height` the way `_images.html` does -- so it takes the same 16/9
   box and is contained inside it, letterboxed when its shape differs. */
.embed { margin: 12px 0; }
.embed--video .embed__frame { position: relative; aspect-ratio: 16 / 9;
  background: #000; border-radius: 8px; overflow: hidden; }
.embed--video iframe { position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; }
.embed--gif { aspect-ratio: 16 / 9; background: var(--surface-sunk);
  border-radius: 8px; overflow: hidden; }
.embed--gif img, .embed--gif video { display: block; width: 100%; height: 100%;
  object-fit: contain; }

/* The listing facade: what a row shows instead of a player it has not been
   asked to load. Same 16/9 box as the real thing, so clicking it swaps one
   block for another of the same height and the rows below do not jump.

   A link, not a button -- with no script it goes to the thread, which is
   where the player is. `contain` on the poster for the reason the gif above
   uses it: a provider still is whatever shape it is, and cropping somebody's
   video to fit is worse than letterboxing it. */
.embed--facade { margin: 10px 0 0; max-width: 420px; }
.embed__play { position: relative; display: block; aspect-ratio: 16 / 9;
  background: var(--surface-sunk); border-radius: 8px; overflow: hidden;
  text-decoration: none; }
.embed__poster { display: block; width: 100%; height: 100%; object-fit: contain; }

/* The badge is drawn rather than an image: one less request on a listing, and
   it inherits the palette. `::after` is the triangle, nudged right of centre
   by a quarter of its own width because a triangle's visual centre is not its
   bounding box's. */
.embed__badge { position: absolute; inset: 0; margin: auto; width: 56px; height: 56px;
  border-radius: 50%; background: rgb(0 0 0 / 0.55); }
.embed__badge::after { content: ""; position: absolute; inset: 0; margin: auto;
  width: 0; height: 0; transform: translateX(2px);
  border-left: 18px solid #fff; border-top: 11px solid transparent;
  border-bottom: 11px solid transparent; }
.embed__play:hover .embed__badge, .embed__play:focus-visible .embed__badge {
  background: rgb(0 0 0 / 0.75); }

/* What it will load, for a provider with no still to show -- and a label
   under the poster where there is one. Not `aria-hidden`: the link's own
   name already says "Play YouTube video", so this is the visible half of
   the same sentence. */
.embed__what { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px;
  font-size: 12px; color: #fff; background: rgb(0 0 0 / 0.55); }

.post__actions, .comment__actions { display: flex; align-items: center; gap: 8px; margin: 12px 0 0;
  flex-wrap: wrap; }
.comment__actions { margin-top: 8px; }
.modform { display: flex; align-items: center; gap: 8px; }

.vote {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12px;
  cursor: pointer;
}

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

/* The box stays 30x28 -- six 44x44 buttons would not fit the row on a phone
   -- and the touch target is grown past it instead, on touch screens only,
   where a fingertip is less precise than a pointer. 8px and 7px are what
   bring 28 and 30 to 44. */
@media (pointer: coarse) {
  .vote { position: relative; }
  .vote::after { content: ""; position: absolute; inset: -8px -7px; }
}
.vote.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.vote__score { min-width: 24px; text-align: center; font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums; }

.thread { margin-top: 22px; }
.thread__title { font-size: 17px; margin: 0 0 10px; }

.comments, .replies { list-style: none; margin: 0; padding: 0; }

/* The thread is one surface with its comments ruled off inside it, rather
   than a card each -- a card per comment turns a reply into a sibling of
   what it replies to. `:empty` because topic.html always renders the list,
   so talk.js has somewhere to put the first comment. */
.comments {
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.comments:empty { display: none; }
.replies { margin: 6px 0 0 6px; padding-left: 14px; border-left: 2px solid var(--line); }

.comment { padding: 12px 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; }
.comment--reply { padding: 10px 0; }

.comment__meta { margin: 0 0 4px; font-size: 13px; color: var(--ink-soft);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.comment__who { font-weight: 600; color: var(--ink); }
/* A name that leads to a profile is underlined on hover and nothing else: an
   always-underlined name in a meta line turns a thread into a page of links. */
a.comment__who, a.topic__who, a.post__by { color: inherit; text-decoration: none; }
a.comment__who:hover, a.topic__who:hover, a.post__by:hover {
  color: var(--accent);
  text-decoration: underline;
}
.comment__body { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment.is-pending { opacity: 0.75; }
.comment.is-removed .comment__body { font-style: italic; color: var(--ink-soft); }

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

.form { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 18px; }
/* `.form` sets `display`, which beats the user-agent rule behind the `hidden`
   attribute -- so the reply form stayed on screen after it had been hidden by
   script, with no error anywhere. */
[hidden] { display: none !important; }

.form > label, .form .field > label { display: block; font-size: 14px; color: var(--ink-soft); }
.form > label.form__row { display: flex; }

.form input[type=text], .form input[type=password], .form input[type=email],
.form input[type=search], .form textarea, .form select, .modform select {
  display: block;
  width: 100%;
  max-width: 540px;
  margin-top: 4px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.modform select { display: inline-block; width: auto; margin-top: 0; padding: 5px 8px;
  font-size: 13px; }
.form select { width: auto; min-width: 200px; }
.form textarea { min-height: 96px; resize: vertical; }

.form input:focus, .form textarea:focus, .form select:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(230, 69, 69, 0.15);
}

/* `:user-invalid`, not `:invalid`: the latter paints an untouched form red on
   arrival, since a required field starts out empty. This waits until the
   visitor has had a go at the field, or has tried to submit. talk.js writes
   `aria-invalid` from the same selector, so the two audiences agree. */
.form :is(input, textarea, select):user-invalid {
  border-color: var(--nsfw);
  background: var(--nsfw-wash);
}

.form input[type=checkbox] { width: auto; margin: 0 8px 0 0; accent-color: var(--accent); }
.form__row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form__error { color: var(--nsfw); font-size: 14px; }
/* The same line used to report where a search has got to rather than that
   something is wrong. Red is for wrong. */
.form__error.is-quiet { color: var(--ink-soft); }
.form__note { color: var(--ink-soft); font-size: 13px; margin: 0; }
.reply-form { margin: 10px 0 10px 14px; }

/* A group of exclusive choices -- the community's visibility. A fieldset so
   the legend names the group for a screen reader; the radios keep their native
   look, branded with `accent-color` as the checkboxes are. Each row is the
   radio, its label and the line describing what the choice does. */
.choices { border: 0; margin: 0; padding: 0; min-inline-size: 0;
  display: flex; flex-direction: column; gap: 12px; }
.choices > legend { padding: 0; font-size: 14px; color: var(--ink-soft); }
.choice { display: grid; grid-template-columns: auto 1fr; align-items: baseline;
  column-gap: 8px; }
.choice input[type=radio] { width: auto; margin: 0; accent-color: var(--accent); }
.choice > .hint { grid-column: 2; margin-top: 2px; }

/* -- editing in place ---------------------------------------------------- *\
   A <details>, so it opens with no script at all -- the form inside is a
   plain POST that redirects back to the thread, which is how the rest of
   /talk's forms work.

   The marker is kept rather than hidden: a disclosure with no triangle and
   no other directional cue gives a reader nothing to tell "this opens" from
   "this does something". The summary carries the `.linkish` look by hand
   because it is not a <button> -- nesting one inside a <summary> breaks the
   toggle.
\* ----------------------------------------------------------------------- */

.editor { font-size: 14px; }

.editor__open {
  display: list-item;
  width: fit-content;
  color: var(--ink-soft);
  cursor: pointer;
}

.editor__open:hover { color: var(--accent); text-decoration: underline; }
.editor[open] .editor__open { color: var(--accent); }

/* Open, it takes the whole row: the actions line is a flex row of small
   controls that wraps, and a textarea is not one of those. The <details> is
   the flex item, so the width has to be claimed here rather than on the form
   inside it. */
.editor[open] { flex-basis: 100%; }
.editor__form { margin: 10px 0 2px; }
.editor__form textarea { min-height: 72px; }

/* -- safe browsing ------------------------------------------------------- */
/*
   The whole gate, and it is CSS rather than JS so there is no flash: the
   class on <html> is written by an inline script in <head> before this file
   is parsed, and the server renders the same class into the attribute, so a
   visitor with scripting off still gets the default.

   `.gate__ask` is the overlay and `.gate__body` is the content. A visitor who
   has opted in to everything (`r-nsfw`) sees neither rule apply.
*/

/* A minimum height so the overlay has somewhere to sit: a two-line body
   would otherwise leave the question floating over almost nothing. */
.gate { position: relative; min-height: 104px; display: flex; }
.gate__body { flex: 1; }
.gate__ask { display: none; }

.gate__ask {
  position: absolute;
  inset: 0;
  z-index: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  background: var(--gate-veil);
}

/*
   `:not(.is-shown)` rather than a second rule undoing the first: talk.js adds
   `is-shown` to reveal one item without changing the preference, and an
   override would have to out-specify a four-part selector -- which the
   obvious `.gate.is-shown > .gate__body` does not, so the reveal silently did
   nothing. Putting the state in the selector means there is one rule and
   nothing to out-rank.
*/
.r-safe [data-rating="spicy"] > .gate:not(.is-shown) > .gate__body,
.r-safe [data-rating="nsfw"] > .gate:not(.is-shown) > .gate__body,
.r-spicy [data-rating="nsfw"] > .gate:not(.is-shown) > .gate__body {
  filter: blur(18px);
  pointer-events: none;
  user-select: none;
}

.r-safe [data-rating="spicy"] > .gate:not(.is-shown) > .gate__ask,
.r-safe [data-rating="nsfw"] > .gate:not(.is-shown) > .gate__ask,
.r-spicy [data-rating="nsfw"] > .gate:not(.is-shown) > .gate__ask {
  display: flex;
}

/* -- a post's images ----------------------------------------------------- *\
   A list, because that is what it is: one to four pictures in upload order.
\* ----------------------------------------------------------------------- */

.shots {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--gap);
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.shots__item { max-width: 100%; }
.shots__link { display: block; }

/* Never stretched: `width` and `height` stay `auto` under two maxima, which
   is how a replaced element fits both and keeps its aspect ratio. The
   `width`/`height` attributes the template writes still do their job --
   they give the browser the ratio to reserve the box with before a byte
   arrives, so the thread below does not jump as each picture loads. */
.shots img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
}

/* More than one, and they line up on a common height. Left to themselves a
   portrait beside a landscape takes four times the room and the post becomes
   a scroll, which is what the first version of this did. */
.shots:not(:has(.shots__item:only-child)) img { max-height: 300px; }

.shots__link:focus-visible img { outline: 3px solid var(--accent); outline-offset: 2px; }

/* -- picking images ------------------------------------------------------ */

.field { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }

/* -- the community picker ------------------------------------------------
   A text field with a list under it. The list is absolute inside a box
   holding nothing but the input, so it hangs off the input rather than off
   the field -- which also carries the hint and the error line -- and so the
   options sit over whatever follows rather than pushing the rest of the form
   down the page every time somebody types. On a phone that would move the
   field out from under the thumb using it. */
.combo { width: 100%; max-width: 540px; }
.combo__box { position: relative; width: 100%; }
/* `appearance: none` because Safari gives `type=search` its own rounded box
   and ignores half of the border and padding every other field here has. */
.combo .combo__input { max-width: none; appearance: none; }

.combo__list {
  position: absolute;
  z-index: 5;
  inset-inline: 0;
  top: 100%;
  /* `dvh`, not `vh`: on a phone this list opens with the keyboard up, and
     `vh` is the viewport as if it were not. */
  max-height: 46dvh;
  overflow-y: auto;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lift);
  overscroll-behavior: contain;
}

.combo__option {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  /* 48px of target, which is what a thumb needs and what the rows of a list
     this long are most likely to be missed on. */
  min-height: 48px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.combo__option:first-child { border-top: 0; }
.combo__name { color: var(--ink); }
.combo__slug { color: var(--ink-soft); font-size: 13px; }

/* Arrowed to or hovered. Both, because the pointer and the keyboard are
   pointing at the same row and there is no second highlight to spend. */
.combo__option:hover, .combo__option.is-active { background: var(--accent-wash); }
.combo__option.is-active .combo__name { color: var(--accent-ink); font-weight: 600; }

/* Stacked under its label like every other control here, rather than inline
   after the label text, which is where a file input sits by default. */
.field--images input[type=file] {
  display: block;
  width: auto;
  max-width: 100%;
  margin-top: 4px;
  font-size: 14px;
}

.hint { color: var(--ink-soft); font-size: 13px; margin: 0; max-width: 540px; }

/* The removal list inside the edit form: a checkbox and the picture it
   removes, so the thing being ticked is the thing being seen. */
.field--shots { border: 0; margin: 10px 0; padding: 0; }
.field--shots legend { padding: 0; color: var(--ink-soft); font-size: 13px; }

.shots__drop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 10px 0 0;
  cursor: pointer;
}

.shots__drop img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* Ticked, the picture it belongs to is shown as going: the checkbox alone is
   a small target to read a decision off when there are four of them. */
.shots__drop:has(:checked) img { opacity: 0.45; outline: 2px solid var(--nsfw); }

/* Taken off the screen but left in the accessibility tree, which `display:
   none` would not be: the flairs table labels each control this way, because
   its column headers say what the field is and the row says which flair.

   `clip-path: inset(50%)` with 1px dimensions rather than a negative
   text-indent, and the `:focus-within` exception so anything focusable
   wrapped in it can still be seen by the person who tabbed to it. */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

/* -- picking flairs ------------------------------------------------------ *\
   A checkbox group, not a `<select multiple>`: a listbox hides its own size,
   wants a modifier key nobody is told about, and is a scrolling overlay on a
   phone. Twelve short labels are twelve tap targets instead.

   Each one looks like the badge it produces, so what is being ticked is what
   will appear on the topic. The native checkbox stays visible beside it --
   `accent-color` brands it, and a box replaced by a styled label is a control
   that disagrees with the forced-colors palette.
\* ----------------------------------------------------------------------- */

.field--flairs { border: 0; margin: 4px 0; padding: 0; }
.field--flairs legend { padding: 0; color: var(--ink-soft); font-size: 14px; }
.flair-picks { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }

/* The padding is the tap target and the negative margin gives the space back,
   so a row of these is 44px high to the finger and 24px to the layout. */
.flair-pick { display: inline-flex; align-items: center; }

.flair-pick label {
  padding: 11px 0;
  margin: -11px 0;
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.flair-pick input[type=checkbox] { margin: 0 6px 0 0; accent-color: var(--accent); }
.flair-pick:has(:checked) label { color: var(--accent-ink); font-weight: 600; }
.flair-pick:has(:focus-visible) label { outline: 2px solid var(--accent); outline-offset: 3px; }

/* -- the owner's flair list ---------------------------------------------- */

.flairs { width: 100%; max-width: 540px; border-collapse: collapse; font-size: 14px; }
.flairs th { text-align: left; padding: 0 8px 6px 0; color: var(--ink-soft); font-weight: 600; }
.flairs td { padding: 4px 8px 4px 0; vertical-align: middle; }
.flairs td:last-child, .flairs th:last-child { padding-right: 0; text-align: center; }
.flairs input[type=number] { width: 5.5ch; }
/* The label column takes what is left; the other two are as wide as they need. */
.flairs th:first-child { width: auto; }
.flairs th:not(:first-child) { width: 1%; white-space: nowrap; }

/* -- what the picker has picked ------------------------------------------ *\
   Thumbnails of the files chosen but not yet sent, each one clickable to
   cross it out. Written by talk.js; with no scripting none of this exists and
   the file input is the whole control, which is what it was before.

   Crossing out rather than removing: a picker that forgets a file the moment
   it is clicked punishes a misclick with the file dialog again. A crossed-out
   pick stays on screen and comes back when clicked a second time.
\* ----------------------------------------------------------------------- */

.picks { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }

.pick { line-height: 1; }

/* A button, because it does something and takes a press -- `aria-pressed`
   carries the crossed-out state, which is the half a strikethrough cannot
   tell anybody. `relative`, so the cross drawn in `::after` covers the
   thumbnail and not the size caption underneath it. */
.pick__toggle {
  display: block;
  position: relative;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
  cursor: pointer;
  line-height: 0;
}

.pick__toggle img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.pick__toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* The cross itself, drawn over the thumbnail with two gradients rather than a
   glyph: a character would be a font-dependent size over a 64px box. Not
   colour alone -- the opacity drops and the border changes with it. */
.pick__toggle[aria-pressed=true] { border-color: var(--nsfw); }
.pick__toggle[aria-pressed=true] img { opacity: 0.35; }

.pick__toggle[aria-pressed=true]::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background:
    linear-gradient(to bottom right, transparent calc(50% - 1.5px),
      var(--nsfw) calc(50% - 1.5px) calc(50% + 1.5px), transparent calc(50% + 1.5px)),
    linear-gradient(to bottom left, transparent calc(50% - 1.5px),
      var(--nsfw) calc(50% - 1.5px) calc(50% + 1.5px), transparent calc(50% + 1.5px));
}

.pick__size { display: block; margin-top: 2px; font-size: 11px; color: var(--ink-soft);
  text-align: center; }
.pick__toggle[aria-pressed=true] + .pick__size { text-decoration: line-through; }

/* A drop target, and the one state it has. `is-over` is written by talk.js on
   dragenter and taken off on dragleave and drop -- a dashed box that is
   always there is furniture, and one that appears when something is being
   dragged is an answer to "can I let go here". */
.field--images.is-drop { width: 100%; max-width: 540px; }

.field--images.is-over {
  outline: 2px dashed var(--accent);
  outline-offset: 6px;
  border-radius: var(--radius-sm);
}

/* -- the cookie notice ---------------------------------------------------
   In the flow at the top of the document, not pinned over it: this surface
   already has a sticky header on a desktop and a fixed tab bar on a phone,
   and a third bar over the reading area would be the one in the way. One
   row, and it scrolls off with the rest of the page.

   Hidden by the attribute the inline script in <head> sets from the cookie,
   so a visitor who has read it never sees it painted. `display` rather than
   `visibility`, because the bar must take no room either. */
.cookiebar {
  display: flex;
  gap: 12px 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--accent-wash);
  border-bottom: 1px solid var(--line-strong);
  font-size: 14px;
}

.cookiebar__text { margin: 0; max-width: 72ch; text-wrap: pretty; }
html[data-ck] .cookiebar { display: none; }

/* -- joining a community -------------------------------------------------
   Rendered only for a signed-in reader, so it is absent from every cached
   page rather than present and wrong. `is-on` is "you are in this one": the
   same wash the active sort pill uses, because it is the same statement. */
.join { display: inline-flex; }
.cards .join { margin-top: 10px; }

.join__btn.is-on {
  background: var(--accent-wash);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

/* While the fetch is out. Not hidden and not resized -- a button that
   changes width mid-press moves the next one under the thumb. */
.join__btn[disabled] { opacity: 0.6; cursor: progress; }

/* The feed group sits in the same pill track as the three sorts, because
   they are one row of choices about one list. The rule between the groups is
   what stops five near-identical pills reading as five sorts: these two
   answer "which list", the three after them answer "in what order". */
.sorts__item--feed + .sorts__item:not(.sorts__item--feed) {
  margin-left: 6px;
  padding-left: 16px;
  border-left: 1px solid var(--line-strong);
}

/* -- the privacy page ----------------------------------------------------
   A definition list, because that is what "here is a thing, here is what is
   kept about it" is. The term carries the weight; the detail is indented
   under it so the page can be read by skimming the terms alone. */
.facts { margin: 0 0 18px; }
.facts dt { font-weight: 600; margin-top: 12px; }
.facts dd { margin: 4px 0 0 14px; color: var(--ink-soft); max-width: 72ch; text-wrap: pretty; }
.facts dd a { color: var(--accent-ink); }

/* The rights list reads as prose, not as a card's row of links, so it drops
   the rules and the flex row `.list` gives its items. */
.list--plain { margin-bottom: 18px; max-width: 72ch; }
.list--plain li { display: list-item; list-style: disc; margin-left: 20px; border-top: 0;
  padding: 3px 0; color: var(--ink-soft); }
