/* Slice 9 — Presentation (§18).
 *
 * Replaces the operator chrome from slice 1. Three structural changes:
 *   1. Fixed banner header with UO panoramic image + search bar
 *   2. Fixed sidebar styled as a UO skill scroll (parchment)
 *   3. Main content area with warmer parchment-inspired text tones
 *
 * All class names from the previous file are preserved: the editor JS,
 * sort.js, listing_filter.js and pagepicker.js target them. */

/* ---------------------------------------------------------------
   Design tokens
   --------------------------------------------------------------- */

:root {
  /* Page structure.
     One band since §37: the banner IS the header, and the 50px strip
     that used to sit under it -- holding the nav links and the search
     box -- gave its height back to the artwork. The search box moved
     onto the image. `--bar-height` is kept at 0 rather than deleted
     because `--header-height` is what every fixed offset in this sheet
     is measured from, and splitting the two again should be a value
     change here rather than a hunt through `top` and `scroll-margin`. */
  --header-height: 160px;     /* the whole fixed header */
  --banner-height: 160px;     /* ...which is all banner now */
  --bar-height: 0px;
  /* Wide enough for scroll.png (908x1731) to read as a scroll rather
     than a strip. The image is sized on width alone, so this is what
     sets how large the artwork draws. */
  --sidebar-width: 17rem;

  /* The strip at the foot of the sidebar that the menu may not enter.
     `.account-bar` is `position: fixed` and therefore out of the menu's
     flow, so on a window short enough to scroll the tree the last entries
     slid UNDERNEATH it -- readable only by scrolling past a block that
     never moves. The menu's scroll box is padded by this instead, which
     reserves the space rather than overlapping it.

     Its value is the block's own height plus the 64px bottom roller it
     clears (see `.account-bar`). Kept as a token because three rules now
     depend on the same number, and the failure it prevents is invisible
     until the viewport is short. */
  --account-zone: 118px;

  /* The reading measure -- the same on every page, with or without a
     contents list. See the note on `main`: this is the cap that used to
     sit on the column, moved to where reading actually happens.

     48rem is about 85 characters at 16px Lora. That is above the 60-75
     the typographers ask for, and deliberately: much of this corpus is
     not paragraphs but nested bullets and stat lines, where a tighter
     column wraps short items onto two lines and reads worse than the
     wide version. It is a compromise between the measure and the
     content the corpus actually holds. */
  --measure: 48rem;
  /* The contents column and its gutter. Sized so `--measure` plus these
     clears the sidebar on a 1280px laptop before the grid collapses. */
  --toc-width: 15rem;
  --toc-gap: 2.5rem;
  /* How wide the page's FURNITURE may get -- the infobox, the monster
     hero and its tab panels, listings, search results.
     `--measure` governs prose and is deliberately narrower.

     Two numbers because they answer different questions. Prose has a
     measure beyond which a line is hard to track back from; a table of
     stats has no such limit but still must not run to the edge of a
     27" display, which is what removing `main`'s cap let it do. This is
     the old 60rem cap, kept for everything that is not a sentence, and
     `--measure` is the part that got its own tighter number.

     The value is not free: `main` includes its own 4rem of padding, and
     a contents page needs `--measure` + `--toc-gap` + `--toc-width` =
     65.5rem of content inside that. So 70rem is the smallest cap that
     does not squeeze the contents column back out of the layout -- the
     exact bug this whole pass started from. Raising `--measure` or
     `--toc-width` means raising this too. */
  --content-width: 70rem;

  /* Backgrounds */
  --bg: #1a1410;              /* deep warm charcoal */
  --bg-surface: #211c15;      /* elevated panels */
  --bg-overlay: #2a231a;      /* cards, infobox */

  /* Borders */
  --line: #3d3428;            /* subtle warm border */
  --line-light: #4a3f30;

  /* Text — parchment-inspired warm tones */
  --ink: #d4c5a9;             /* primary: warm parchment */
  --ink-bright: #e8dcc4;      /* headings, emphasis */
  --muted: #9b8e76;           /* secondary text */

  /* Accents */
  --accent: #c9a84c;          /* gold — UO's signature */
  --accent-hover: #d9bb63;
  --accent-dim: rgba(201, 168, 76, 0.15);
  --danger: #c44;
  --ok: #5a9e5a;

  /* A typed reference (§1, §6.1) -- an id-backed pointer at another page
     in this corpus. It was gold like everything else, which made the
     relation the whole system exists for look like the breadcrumb above
     it and the contents list beside it. Separated by HUE rather than
     brightness: a lighter or deeper gold reads as "the same thing,
     emphasised", where a cool tone reads as a different kind of thing.
     Aged copper, kept muted so a paragraph with a dozen references is
     not a field of colour. This is the dial. */
  --ref: #7fa88a;
  --ref-hover: #9cc4a6;
  --ref-underline: rgba(127, 168, 138, 0.45);

  /* An external link (§45) -- a URL out of the corpus, which is a
     different KIND of destination from a reference, not a weaker one.
     The reader is being told they will leave the site, so the two must
     not be told apart by brightness alone: a dimmer green would read as
     "a reference, de-emphasised".

     A muted blue is the one hue left. It sits 76deg from `--ref` green
     and 168deg from gold, clear of both, and it is the web's own
     convention for "this goes elsewhere" -- the one place in this
     palette where borrowing an outside convention is right, because the
     destination is outside too. Kept desaturated so it belongs to the
     parchment page rather than glowing out of it. */
  --link-ext: #8aa3c4;
  --link-ext-hover: #a6bcd9;
  --link-ext-underline: rgba(138, 163, 196, 0.45);

  /* The contents list's edge (§41). It was `--accent`, the same gold as
     the shard block a few hundred pixels away on the same screen, and
     the two panels read as the same kind of thing.

     The TOC is the one that moved, not the block. Gold belongs to the
     shard logo, which sits inside a shard block; furniture yields to
     content. This is a muted warm stone -- present enough to keep the
     list's left edge, quiet enough not to compete with a heading. */
  --toc-edge: #6b5c46;

  /* Body headings (§42.14). **Hue, not brightness** -- the thing that
     separates a heading from the prose under it.

     The reference is UOGuide itself: dark red headings on a white page,
     against near-black body text. The heading colour is not a shade of
     the text colour, it is a different colour, and that is why its
     structure reads at a glance from across the room. Inverted for a
     dark page, that means a warm light tone against `--ink` parchment.

     Three shades of ONE hue rather than three hues: the levels are the
     same kind of thing at different depths, so they share a colour and
     differ in how much of it they have. Against the prose they are all
     obviously not-prose, which is the distinction that was missing.

     Copper, reusing the hue §41.6 measured for the contents list -- it
     sits only 14deg from `--ink` and still reads apart because the two
     differ in SATURATION (50% against 20%). `--ink` is a near-grey
     parchment and copper is not. That measurement is why this works at
     0.9rem, where a brightness step of 1.25 does not. */
  --h2-ink: #e0a877;
  --h3-ink: #cf9166;
  --h4-ink: #b98055;

  /* The contents list's top-level rows. Copper rather than gold: gold
     belongs to the shard block (§41) and to the page's structural
     furniture, and a column of it here made the two panels look alike.

     This is the hue measured for §41 and then not used, so it is already
     known to sit clear of both gold (44deg) and `--ref` green (136deg).
     Against `--ink` the gap is only 14deg of hue but the two differ in
     SATURATION -- `--ink` is a near-grey parchment and this is not --
     which is what separates the levels at 0.9rem. 7.08 on the panel. */
  --toc-h2: #d99a6c;

  /* The plate behind an item sprite. A real light surface, not a
     lifted dark one: the art is cut out against the client's pale
     background, so the only ground that gives every sprite an edge is
     one in the range it was drawn for. `--bg-overlay` was tried first
     and is barely above the page -- it framed the icon without lighting
     it, which is the failure it was meant to fix.

     Warm and muted rather than white: it belongs to the parchment
     family below, so a page of these reads as tiles cut from the same
     material as the sidebar rather than as holes punched in the page.
     This is the dial -- raise towards `--parchment-light` if the
     darkest sprites still sink, drop if the tables glare. */
  --icon-plate: #b9a887;
  --icon-plate-edge: #8a7450;

  /* Parchment sidebar — extracted from the UO skill scroll */
  --parchment: #c4a872;
  --parchment-light: #d4bc8e;
  --parchment-dark: #8a7450;
  --parchment-edge: #6b5a3e;
  --parchment-ink: #2c1e0e;
  --parchment-muted: #5a4832;
}

/* ---------------------------------------------------------------
   Reset and base
   --------------------------------------------------------------- */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  /* 17px, not 16 (§37). Lora sets small for its nominal size -- its
     x-height is modest and the corpus is long-form reading, so the extra
     pixel buys legibility at no layout cost. Every width in this sheet
     is in `rem`, so the whole page scales with it rather than the text
     growing inside fixed boxes. */
  font: 17px/1.6 'Lora', Georgia, 'Times New Roman', serif;
  /* iOS (every browser there is WebKit) enlarges text in any block it
     judges wider than the screen, and in landscape regardless. The
     sizes here are already chosen per breakpoint; desktop ignores it. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

/* Page to page as a cross-fade, not a cut. Every click here is a full
   page load -- the sidebar's `?open=` and reading pages' no-JS rule (§2)
   make it so -- and when the new page drew before its big background
   pictures were ready, the banner and scroll flashed empty for a frame.
   Seen as "some pages blink", worst a few seconds after a visit, once
   the browser has dropped the decoded pictures. This asks the browser to
   hold the old page and fade to the new one once it is drawn. CSS only;
   a browser without it (Firefox today) loads exactly as before. */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ---------------------------------------------------------------
   Fixed banner header
   --------------------------------------------------------------- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
}

/* The panoramic UO banner image */
/* The whole header (§37): artwork, with the search box sitting on it.

   **The source is 2152x331 -- 6.50:1**, measured. (This comment said
   2152x486 / 4.43:1 for several slices; the file is not that shape, and
   the arithmetic below only works with the real number.)

   `cover` scales the image to fill the box in BOTH directions and crops
   the overflow, so the band shows a 160px slice of an image whose
   rendered height grows with the window. The crossover is exact:
   160 x 6.50 = **1040px**. Below that the whole artwork is visible;
   above it, every extra pixel of width scales the image up and pushes
   more of it out of the band. At 1440px the image renders 222px tall and
   62px are lost; at 2000px it is 308px and 148px are gone -- which is
   the foreground path, the bottom of the dragon, and the base of the
   wordmark.

   `background-position` chooses WHICH slice survives; it cannot stop the
   cropping. `bottom` is the deliberate choice here rather than `center`:
   the top of the frame is sky and rigging, the bottom is the row of
   creatures and warriors the banner exists to show, and the wordmark
   sits low-left. Losing sky is losing the least.

   The permanent fix for wide screens is to stop the image scaling past
   the width where it still fits -- see `.banner` in the max-width block
   below, which is off until it is judged. Changing `--banner-height`
   instead is the expensive route: §38.8 records that `--header-height`
   is what every fixed offset in this sheet is measured from. */
/* `banner.webp` is `banner.png` re-encoded, nothing else: WebP at
   quality 85 with lossless alpha, same 2172x724 so every number in this
   note still holds -- 1.75MB to 255KB. A 1.75MB background was being
   decoded on page loads and drew a frame late, part of the blink between
   pages. The PNG stays as the master; re-export from it if the art
   changes. `scroll-frame.webp` is the same treatment (350KB to 16KB) and
   so is `shard-logo-256.png` (1024px master, never shown above 180px). */
.banner {
  height: var(--banner-height);
  background: url('/static/banner.webp') center bottom / cover no-repeat;
  background-color: #1a1410;
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  padding: 0 1.5rem 0.9rem;
}

/* ---------------------------------------------------------------
   OPTION 3, not yet on: stop the artwork scaling past the width where
   it still fits.

   `--banner-max` is the whole switch. `none` (below) is today's
   behaviour: the band spans the window and crops as computed above.
   Set it to **1040px** -- the measured crossover for a 6.50:1 image in a
   160px band -- and the artwork is never cropped at any window width:
   the banner centres at its natural size and the page's own background
   shows either side of it on a wider screen.

   The trade is stated rather than hidden, because it is a real one and
   it is what makes this a judgement call rather than a fix. Below
   1040px nothing changes at all. Above it, the choice is between losing
   part of the picture (now) and showing bands of empty ground beside it
   (then) -- and on a 2366px monitor those bands are 663px each, which
   can read as a broken layout rather than a deliberate frame. The
   background-color behind them is already `#1a1410`, so they will at
   least be the page's own dark ground rather than white.

   `--header-height` does NOT change either way, which is the point of
   doing it as a width cap: §38.8 records that every fixed offset in
   this sheet -- `scroll-margin-top`, the sidebar, the wordmark -- is
   measured from it, so a variable-height banner is the expensive
   version of this fix.

   **Re-check `.banner-home` if this goes on.** It is positioned from
   the banner's left edge, and a centred band moves that edge inward on
   a wide screen -- the click target would drift off the logo it is
   meant to cover. That is the same class of bug §38.6 records, where an
   element resolved against an ancestor nobody expected. */
/* Two values, read together. `--banner-max` caps how wide the artwork
 * may scale; `--banner-pos` chooses which slice survives whatever crop
 * is left over. The arithmetic that ties them, for the 2152x331
 * (6.50:1) source in a 160px band:
 *
 *   cap      renders   hidden   what a position can still reach
 *   1040px   160px       0px    nothing hidden -- the whole picture
 *   1200px   185px      25px    13% -- `top` keeps the wings and most ground
 *   1440px   221px      61px    28% -- no position holds both ends
 *   none     grows      grows   56% gone at a 2366px window
 *
 * **1040 is the only value that crops nothing** (160 x 6.50). Every
 * larger cap trades picture for width, which is why the position beside
 * it stops being cosmetic the moment the cap goes above 1040.
 *
 * The subject is what forces the choice: the dragon's wingtips are at
 * row ~30 and the figures' feet are at row 331, so the content spans
 * nearly the full height of the source. At a 1440 cap there is no
 * vertical position that holds both -- `top` cuts the legs, `bottom`
 * cuts the wings, which is what made the first 1440 attempt look worse
 * than no cap at all. 1200 with `top` loses only the bottom strip of
 * path, the emptiest band in the frame.
 *
 * Tune by editing these two and nothing else. */
:root {
  --banner-max: none;
  --banner-pos: center;
}

.banner {
  max-width: var(--banner-max);
  margin: 0 auto;
  /* Overrides the `center bottom` in the shorthand above -- a longhand
     after a shorthand wins, so the position lives here with the cap it
     is chosen against rather than two hundred lines away. */
  background-position: center var(--banner-pos);
}

/* The home link is a defined zone at the top left, not the whole banner
   (§37). A full-bleed overlay makes every pixel of the artwork a
   navigation control, so a stray click anywhere in the header leaves
   the page -- and it has to sit under the search box to keep that
   usable, which is fragile. A stated rectangle over the logo is the
   honest version: it is where a reader already expects home to be.

   200px wide and the full height of the banner -- roughly the column
   the shard logo occupies in the artwork. Height is
   `--banner-height` rather than a number so it follows the banner if
   that value changes, including in the narrow-screen block where it
   drops to 120px.

   Worth re-measuring after the banner is cropped: the logo's position
   moves with the crop, and this rectangle is stated in CSS pixels
   against an image that `cover` scales to the window's width. */
.banner-home {
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  height: var(--banner-height);
  z-index: 1;
}

/* The dark gradient over the artwork is OFF, to see the banner at full
   strength (§38). Not a blur -- it was a linear fade to the page colour,
   0 at the top through 0.35 at 62% to 0.92 at the bottom edge.

   Two things it was doing, so watch for both coming back:
     * the search box sits ON the artwork, and its text needs a dark
       ground under it wherever the image happens to be bright;
     * it faded the image into the page, which is what replaced the old
       50px brown stripe. Without it the banner ends on a hard edge.

   Restore by deleting the `background: none` line. */
.banner::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: none;
}

/* The two nav groups (§37). Reader-facing domain links first, operator
   links after the search box and quieter -- see base.html for why the
   split is editorial and explicitly not an auth seam.

   BOTH ARE HIDDEN while the banner is being judged (§37) -- see the
   `display: none` after these two rules, which is the one line to
   delete to bring them back. The markup, the routes and the DOMAINS
   loop are all untouched. */
/* ONE FULL-WIDTH BAND, not per-link plates (§40.8).

   The plates were tried first and read as a row of separate buttons
   floating on the artwork. What the header had before §37 merged the two
   bands was a solid strip under the panorama, and that is what this
   restores -- with the difference that the strip is now part of the
   banner rather than a second 50px band, so `--header-height` does not
   change and nothing downstream (every heading's `scroll-margin-top`,
   the sidebar's `top`, the wordmark's) has to move.

   The band is painted by `.banner-nav`, which spans the banner's full
   width at its bottom edge. Both link groups sit inside it. */
.banner-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0.45rem 1.5rem;
  /* FULLY opaque, not a tint (§40.10). At 0.93 the panorama still read
     through the band and it looked like a shadow over the artwork rather
     than a bar -- an author reported not finding the menu at all. The
     search box beside it made the same call for the same reason (§37):
     on artwork, a control needs its own solid ground, not a veil.

     `--panel` is the page's own surface colour, so the band reads as the
     page beginning rather than as part of the picture. */
  background: #16100a;
  border-top: 1px solid rgba(201, 168, 76, 0.55);
  /* Lifts the band off the artwork above it -- without this the top edge
     is a hairline on a busy image and the eye slides past it. */
  box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.5);
}

.banner-nav .domain-links { display: flex; gap: 0.1rem; flex-wrap: wrap; }

.banner-nav .admin-links {
  display: flex;
  gap: 0.1rem;
  flex-wrap: wrap;
  margin-left: auto;      /* operator set to the right of the band */
  padding-left: 1rem;
  border-left: 1px solid rgba(201, 168, 76, 0.3);
}

/* ONE size for both groups. The admin links were 0.72rem against the
   domain links' inherited size, from §37's judgement that they were the
   quieter set. That distinction is gone: both groups are behind
   `can_write` now, so everything in this bar is an author's tool and
   there is no louder half to be quiet against. */
.banner-nav a {
  color: #d8cbb0;
  font-family: 'Cinzel', serif;
  font-size: 0.82rem;
  font-variant: small-caps;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.55rem;
  border-radius: 2px;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.banner-nav a:hover {
  color: var(--accent);
  background: rgba(201, 168, 76, 0.12);
}

/* SHOWN AGAIN as of slice 5 (§40.8), and the reasoning changed rather
   than reverted. §37 hid both groups because the domain listings are a
   raw alphabetical index -- 1,890 items -- which is close to useless to
   the newcomer the sidebar serves, so it was noise on a reader's page.

   That argument does not reach an *author*. The listings are how someone
   editing gets to a page fast, and they are now behind `can_write` in
   the template: a reader never sees them, which is what §37 wanted, and
   an author always does, which is what §37 was costing. The admin links
   are folded into the same bar rather than sitting in a second group.

   A reader still sees no navigation here -- the sidebar's authored tree
   (§8.1) is their way in, unchanged. */
.banner .domain-links,
.banner .admin-links { display: flex; }

/* The account block was tried on the banner first and MOVED to the foot
   of the sidebar (§40.8). On the banner it sat over the artwork at the
   top right, where a muted 0.72rem link on a painted background is
   invisible in practice -- the operator could not find the way in to
   their own admin screens, which is the one job this control has. The
   rule is kept as a no-op so a cached page does not draw the old
   position; the live rule is `.account-bar` below. */
.banner .account-links { display: none; }

/* A button that reads as a link. The logout control has to be a <form>
   (a GET logout fires from any URL on the page), but it should not look
   like a submit button sitting in the banner. */
.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.8;
  cursor: pointer;
  text-decoration: underline;
}
.linklike:hover { opacity: 1; }

/* The account block, at the foot of the sidebar column (§40.8).

   `fixed`, mirroring `.wordmark` at the other end of the scroll and for
   the same two reasons (§38.6): `.sidebar` carries a `filter`, which
   makes it the containing block for any fixed DESCENDANT -- so this has
   to be a sibling to pin to the viewport at all -- and its
   `overflow-y: auto` would otherwise scroll the block away with the
   menu instead of holding it at the bottom.

   `bottom: 64px` clears the border-image's bottom roller, which is drawn
   at that height. Sitting ON the roller was tried and reads as a caption
   for the ornament; just above it, the block sits on the parchment where
   the menu ends. */
.account-bar {
  position: fixed;
  bottom: 64px;
  left: 0;
  width: var(--sidebar-width);
  z-index: 51;                /* the sidebar is 50, as .wordmark is */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.7rem;
  /* Inside the parchment band, which the scroll frame insets from the
     column's edges. */
  padding: 0.5rem 1.6rem 0.5rem 1rem;
  /* The parchment is light and busy at the edges; a rule above the block
     separates it from the last menu entry without needing a fill. */
  border-top: 1px solid rgba(61, 52, 40, 0.25);
}

/* Sized and weighted as a TOP-LEVEL MENU ENTRY, not as fine print
   (§40.8). At 0.72-0.78rem in a muted brown it was legible in the markup
   and invisible on the page -- and for a logged-out visitor this is the
   only operator control anywhere, since the banner's links are behind
   `can_write`. It matches `.sidebar .entry > a`: same inherited size,
   same 600 weight, same near-black ink. */
.account-bar a,
.account-bar .linklike {
  color: #1a0f05;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(26, 15, 5, 0.35);
  transition: color 0.15s;
}
.account-bar a:hover,
.account-bar .linklike:hover {
  color: #4a2d0a;
  border-bottom-color: currentColor;
}
.account-bar form { margin: 0; }

/* The signed-in address, which is also the link to the account page
   (§40.10). Truncated rather than wrapped: an address long enough to
   wrap would push the block up over the menu, and the full value is on
   the element's `title`.

   Quieter than the Log out button beside it -- it is an identity first
   and a control second -- but it takes the link colour rather than the
   muted grey it had as plain text, or nothing suggests it is clickable. */
.account-who {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 500;
}

/* The logout button is a <form> submit (a GET logout fires from any URL
   on the page), so it needs the base `.linklike` reset -- background,
   border and padding stripped -- while taking its colour and size from
   the shared rule above rather than the banner-tuned one. */
.account-bar .linklike {
  opacity: 1;
  cursor: pointer;
}

/* Shown only while reading is closed, and only to an admin. A private
   corpus looks exactly like a public one from every page, so this is the
   only thing that says otherwise. */
.gate-badge {
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* The navigation + search bar below the banner */
/* `.header-bar` is gone from the markup (§37) -- its contents moved onto
   the banner and its 50px went back to the artwork. The rule is kept as
   a no-op so a stale template or a cached page does not draw the old
   brown stripe; delete it once nothing references the class. */
.header-bar { display: contents; }

.banner nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem;
  overflow-x: auto;
  min-width: 0;
}
.banner nav a {
  color: var(--muted);
  text-decoration: none;
  font: 500 0.75rem/1 'Cinzel', serif;
  padding: 0.3rem 0.5rem;
  border-radius: 3px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.banner nav a:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

/* Search form in the header bar.

   `margin-left: auto` pushes it off the domain links; the admin group
   that follows keeps its own right-hand position, so the box floats in
   the gap between reader navigation and operator navigation rather than
   being pinned to either. */
/* On the banner now (§37), bottom-right, above the gradient and the
   home zone -- `z-index` because both of those are positioned layers in
   the same stacking context and the input has to stay clickable. */
.banner .searchform {
  margin-left: auto;
  display: flex;
  position: relative;
  z-index: 2;
  align-self: flex-start;
  margin-top: 1.8rem;
}
.banner .searchform input {
  width: 16rem;
  padding: 0.4rem 0.8rem;
  /* Opaque, not a tint (§37): this sits on artwork rather than on a flat
     strip, and a translucent field let whatever the crop put behind it
     -- sky, a dragon's wing -- read straight through the box, so the
     input was barely findable. Its own solid ground, and a gold border
     bright enough to state the edge. */
  background: #120e0a;
  color: var(--ink-bright);
  border: 1px solid rgba(201, 168, 76, 0.55);
  box-shadow: 0 2px 10px rgba(0,0,0,0.55);
  border-radius: 4px;
  font: inherit;
  font-size: 0.85rem;
  transition: border-color 0.15s, background 0.15s;
}
.banner .searchform input::placeholder { color: var(--muted); }
.banner .searchform input:focus {
  outline: none;
  border-color: var(--accent);
  /* Solid, like the resting state. This used to be `rgba(0,0,0,0.5)`,
     which made the field *more* see-through the moment it was clicked
     into -- the artwork came back through the box exactly while someone
     was typing in it. Focus should read as more present, not less. */
  background: #0d0a07;
}

/* The live-search dropdown (§58), hung from the search box. Absolute
   inside `.searchform` (already `position: relative`), right-aligned to
   the box and wider than it: titles like `Kaelynna the Magery
   Instructor` would wrap to three lines in 16rem. The same solid ground
   and gold edge as the input it belongs to -- it sits over artwork and
   then over the page, and a tint would let both read through. */
.live-results {
  position: absolute;
  top: calc(100% + 0.3rem);
  right: 0;
  width: 26rem;
  max-width: calc(100vw - 2rem);
  margin: 0;
  padding: 0.3rem 0;
  list-style: none;
  background: #120e0a;
  border: 1px solid rgba(201, 168, 76, 0.55);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
  font-size: 0.85rem;
  z-index: 20;
}
.live-results[hidden] { display: none; }
.live-results a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0.8rem;
  color: var(--ink);
  text-decoration: none;
}
.live-results a:hover,
.live-results a.is-active { background: var(--accent-dim); color: var(--ink-bright); }
.live-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-kind { color: var(--muted); font-size: 0.75rem; flex-shrink: 0; }
.live-note,
.live-none { padding: 0.35rem 0.8rem; color: var(--muted); font-style: italic; }
.live-footer { border-top: 1px solid var(--line); margin-top: 0.3rem; padding-top: 0.2rem; }
.live-results a.live-all { color: var(--accent); font-size: 0.8rem; }

/* Legacy compat: old header selectors that may still appear */
header nav { display: flex; gap: 1rem; }
header nav a { color: var(--muted); text-decoration: none; }
header nav a:hover { color: var(--ink); }
header .env { display: none; }
header .searchform { margin-left: auto; display: flex; }

/* ---------------------------------------------------------------
   Layout shell — fixed sidebar, scrolling main
   --------------------------------------------------------------- */

.shell {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

/* The width budget (§36.8).
 *
 * `--measure` is the reading column and it is the SAME on every page,
 * with or without a contents list. 60-75 characters is the typographic
 * measure; at 16px Lora that is about 40rem, and a page whose prose is
 * wider is harder to read no matter how much window is spare.
 *
 * So the cap belongs on the prose, NOT on `main`. The old
 * `max-width: 60rem` here was a slice-1 default doing the job at the
 * wrong level: it capped the whole column, which meant a contents list
 * had to be cut OUT of the reading width (39rem of prose against 56rem
 * on a page without one) while ~13rem of window sat empty beside it.
 * Same page, two measures, and the one with more to navigate got less
 * to read.
 *
 * `main` now caps at `--content-width` instead, which is furniture's
 * limit rather than prose's: the contents list sits in margin the old
 * 60rem was wasting, so adding one costs the prose nothing, while a
 * monster's tab panels still stop somewhere instead of following a wide
 * window to the edge of the screen. */
main {
  flex: 1;
  min-width: 0;
  max-width: var(--content-width);
  padding: 2rem 2rem 4rem;
}

/* ---------------------------------------------------------------
   Fixed sidebar — UO skill scroll / parchment style
   --------------------------------------------------------------- */

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  z-index: 50;

  /* The scroll is a NINE-SLICE, not a background image, because the two
     requirements conflict under `background-size`: full width, full
     height, and no distortion cannot all hold for one bitmap in a box
     whose ratio is not the artwork's. The source is 1:1.9 and the
     sidebar is about 1:3, so `100% 100%` squeezed it, `100% auto` left
     it short, and `repeat-y` tiled a second pair of rollers down the bar.

     `border-image` decouples the axes: the two rollers are fixed-height
     slices that never scale, and only the parchment band between them
     stretches to whatever the viewport is. Any sidebar height works and
     nothing distorts.

     `scroll-frame.png` is `scroll.png` prepared for this: 96px of dead
     margin cropped off each side (21% of the source width was empty, and
     that margin is what read as "padding" no CSS could remove), and the
     tall uniform middle collapsed to a 160px band since border-image
     stretches it anyway -- 1.5MB to 523KB. `scroll.png` is kept as the
     master. Regenerate rather than hand-edit if the artwork changes. */
  /* Two different units, and mixing them is what inflates the rollers:
     `border-image-slice` counts IMAGE pixels (130/127 in a 544-wide
     bitmap), while the widths after the slash are CSS pixels -- the
     height each slice is DRAWN at. The artwork is 2x for retina (544
     image px over a 272px sidebar), so the CSS numbers are the image
     numbers halved. Carrying the slice values through unscaled stretches
     a 65px roller to 130px and it reads as a different image.
     If scroll.png is redrawn: reslice, then divide by 544/272. */
  border-image: url('/static/scroll-frame.webp') 130 0 127 0 fill / 65px 0 64px 0 stretch;
  border-width: 65px 0 64px 0;
  border-style: solid;
  background-color: transparent;

  border-right: none;
  /* The black edge was in the ARTWORK, not in CSS (§37).
     Chased through the stylesheet first and it was never here: decoding
     `scroll-frame.png` showed 369 of 377 pixels in its left column, and
     372 in its right, were opaque near-black (RGB 0,0,1 at alpha 255).
     The scroll had been exported onto a black background instead of
     transparency, so it carried its own frame and no rule could remove
     it. The PNG was regenerated with that surround flooded to alpha 0 --
     a flood from the edges inward rather than a threshold over the whole
     image, so the dark outlines INSIDE the ornament and the gem clasps
     survive. `scroll.png` is still the master to regenerate from.
     The shadow is the page's own colour rather than black: over bright
     parchment on a near-black page, a black drop shadow has nothing to
     darken and just draws a line. */
  box-shadow: 4px 0 12px rgba(26, 20, 16, 0.55);

  /* The border-image's top slice already IS the roller and its ornament,
     so the old 5.3rem top padding that used to clear them would push the
     menu that far below the ornament again. What is left is a little
     breathing room under the ornament and enough at the sides to sit the
     text on the parchment, clear of its curled edges.

     The RIGHT padding is cut to 0.6rem (§37): the parchment's curl is on
     the left edge, where the scroll is bound, so the right side never
     needed the same clearance. The symmetric version cost 1.4rem of the
     usable width and wrapped "Getting Started" onto two lines.

     The BOTTOM padding reserves `--account-zone` for the account block.
     That block is `position: fixed` (it has to be -- see its own note),
     so it takes no space in this scroll box and the menu ran underneath
     it on any window short enough to scroll: the last entries were
     reachable only by scrolling behind a thing that never moves. Padding
     the scroll box is what turns the overlap into a floor, and it must be
     padding rather than a shorter `bottom` on `.sidebar` -- the scroll
     frame's bottom roller is drawn by this element's border-image, so
     ending the element early would cut the ornament off. */
  padding: 0.9rem 0.6rem var(--account-zone) 1.6rem;
  box-sizing: border-box;

  /* Softened against the page (§37). The artwork is a bright parchment
     scan and the site around it is near-black, so at full strength the
     sidebar read as a lit panel rather than part of the page.

     A `filter` rather than `opacity`: opacity would fade the menu TEXT
     with the parchment, and the text is the one thing that has to stay
     legible. This dims and desaturates the artwork; the ink on top is
     restored to full strength below. */
  filter: brightness(0.82) saturate(0.88);

  /* Medieval serif — Cinzel matches the UO scroll lettering style. */
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  color: #1a0f05;
}

/* Scrollbar styling for the sidebar */
/* The phone's open and close controls (the 50rem block). A wide screen
   always draws the scroll, so it has nothing to open. */
.nav-target,
.nav-toggle,
.nav-close { display: none; }

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: var(--parchment-dark); }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--parchment-edge);
  border-radius: 3px;
}

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

.sidebar .entry {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}
.sidebar .entry > a {
  /* Sized from its own words and NOT allowed to grow (§37).

     Two bugs, one after the other. `flex: 1` is `flex: 1 1 0%` -- a zero
     basis, so the label was a *share* of the row rather than its text,
     which put the twist at the midpoint and wrapped "Getting Started"
     onto two lines beside empty parchment. Then `flex: 1 1 auto` fixed
     the wrap but kept the growth: the label absorbed all the slack, so
     `margin-left: auto` on the twist had nothing left to push against
     and each `+` sat wherever its own label ended, ragged down the bar.

     `0 1 auto` -- shrink if it must, never grow -- leaves the spare
     width unclaimed for the twist's auto margin to take, so every `+`
     lands on the same right edge. */
  flex: 0 1 auto;
  color: #1a0f05;
  text-decoration: none;
  padding: 0.3rem 0;
  font-weight: 600;
  transition: color 0.15s;
}
.sidebar .entry > a:hover {
  color: #4a2d0a;
}

.sidebar .twist {
  /* Never squeezed by a long label, and lined up down the bar -- but
     held off the edge (§37). `margin-left: auto` alone pushed every `+`
     hard against the sidebar's right boundary, where the parchment
     curls and the artwork clips it. The right margin is the inset that
     keeps the control on the flat part of the scroll. */
  flex: 0 0 auto;
  margin-left: auto;
  margin-right: 1.5rem;
  color: #3a2815;
  text-decoration: none;
  font-family: ui-monospace, monospace;
  padding: 0 0.3rem;
  line-height: 1;
  font-size: 0.9em;
}
.sidebar .twist:hover { color: #4a2d0a; }

/* Open branch highlight */
.sidebar li.open > .entry > a {
  color: #0f0800;
  font-weight: 700;
}

/* Blackletter, and ONLY here (§38). This is the UO client's gump-chrome
   face and it earns its place on one line seen once per page -- it does
   NOT go on `h1`, where `Gargish Platemail Arms` and `A Small Piece of
   Blackrock` are long, unfamiliar strings a reader is trying to match
   against a half-memory. Blackletter is where that gets slow. The
   client splits it the same way: gothic on a gump's title, a plain face
   on the skill list under it.

   Sat on the scroll's TOP ROLLER -- the 65px slice the border-image
   draws. It is NOT positioned onto it: `.sidebar` is `overflow-y: auto`,
   and an overflow container clips a negative offset, so the obvious
   `top: -65px` would hide the wordmark completely rather than lift it
   onto the roller. It is the first item in normal flow instead, pulled
   up by its own negative margin, which overflow does not clip.

   The margin is the sidebar's top `border-width` and its top `padding`
   together, so the label lands centred on the roller. Both are stated
   above; if either changes this number follows them.

   The parchment is bright and the ink dark, so this is the one place in
   the sheet using a dark text colour -- `--parchment-ink`, the same the
   menu links use. The light shadow lifts it off the roller's shading
   without the glow a dark shadow would need. */
/* NOT `.sidebar .wordmark` -- it is the sidebar's SIBLING, for the
   reason `_sidebar.html` records: `.sidebar` has a `filter`, and a
   filtered element is the containing block for any `position: fixed`
   inside it. Nested, this rule resolved against the sidebar instead of
   the viewport and put the label 160px down the parchment, in the
   middle of the menu. Two cuts failed there before the cause was found;
   both looked like a wrong offset and neither was.

   `fixed` rather than flow or `absolute`: it pins to the viewport at
   the same `top` the sidebar uses, so it lands on the roller painted at
   the top of that box -- and stays put while the menu scrolls under it,
   which is what a label on a roller should do. */
.wordmark {
  position: fixed;
  /* +2px: the roller's highlight sits just under the scroll's top edge,
     so matching `--header-height` exactly set the text a touch high
     against the curl. */
  top: calc(var(--header-height) + 2px);
  left: 0;
  width: var(--sidebar-width);
  z-index: 51;                /* the sidebar is 50 */
  /* 58px, not the roller's full 65: the artwork paints a decorative
     flourish across the lower third of the slice, so centring on the
     whole height sets the text on the ornament. Sitting it in the
     upper part puts it on the clean curl of the parchment with the
     flourish reading as a rule beneath it. */
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.2rem 0 0.6rem;
  font-family: 'UnifrakturMaguntia', 'Cinzel', serif;
  /* Fits "Tome of Knowledge" on one line in a ~15rem roller. Blackletter
     sets wide, so this is smaller than it looks on the page. */
  font-size: 1.05rem;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  color: var(--parchment-ink);
  text-shadow: 0 1px 0 rgba(255, 246, 225, 0.5);
}
.wordmark:hover { color: #5a3d12; }

/* Sub-entries — indented with a dark rule */
.sidebar ul.sub {
  margin: 0.15rem 0 0.5rem 0.6rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--parchment-dark);
}
.sidebar ul.sub a {
  display: block;
  padding: 0.2rem 0 0.2rem 0.2rem;
  color: #2a1a0a;
  text-decoration: none;
  font-size: 0.92em;
  transition: color 0.15s;
}
.sidebar ul.sub a:hover { color: #0f0800; }

/* Current entry in the branch */
.sidebar ul.sub li.current > a {
  color: #0f0800;
  font-weight: 700;
}

/* The News section under the authored tree (§69.4). Set apart by a rule
   and a small-caps heading rather than by indentation: it is a second
   list, not a branch of the first, and indenting it would read as a
   sub-menu of whatever entry happens to sit last above it. */
.sidebar .nav-section {
  margin-top: 1rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--parchment-dark);
}
.sidebar .nav-heading {
  margin: 0 0 0.2rem;
  font-family: 'Cinzel', serif;
  font-size: 0.78em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--parchment-muted);
}

/* When sidebar exists, push main content to the right */
.sidebar ~ main {
  margin-left: var(--sidebar-width);
}

/* ---------------------------------------------------------------
   Typography — headings use Cinzel (medieval), body uses Lora
   --------------------------------------------------------------- */

/* The scale is roughly 1.3x per level (2 / 1.5 / 1.15 / 0.95 against a
   1rem body), where it used to be 1.5 / 1.15 / 1.0 / 0.9 -- four levels
   inside a 0.6rem span, with h4 set SMALLER than the prose under it.
   At those sizes the only thing separating a section from a subsection
   was Cinzel versus Lora, so a reader flicking down one of the 111
   articles with 9+ headings had almost no structural signal.

   This is what the table of contents was compensating for (§36.7). The
   list is still right for a 31-heading page, but the page body should
   not depend on it to be navigable. */
h1 {
  font: 700 2rem/1.25 'Cinzel', serif;
  color: var(--ink-bright);
  margin: 0 0 0.5rem;
  letter-spacing: 0.01em;
}
h2 {
  font: 600 1.35rem/1.3 'Cinzel', serif;
  color: var(--ink-bright);
  margin: 2rem 0 0.6rem;
}

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
.crumb { margin: 0 0 0.5rem; font-size: 0.85rem; }

/* ---------------------------------------------------------------
   Cards — dashboard / domain listing
   --------------------------------------------------------------- */

.cards { display: flex; gap: 1rem; flex-wrap: wrap; }
.card {
  flex: 1 1 14rem;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.1rem 1.2rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover {
  border-color: var(--line-light);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}
.card h2 { margin: 0 0 0.4rem; font-size: 1rem; }
.card h2 a { text-decoration: none; }
.card .count { font-size: 1.8rem; margin: 0; color: var(--ink-bright); }
.card .count span { font-size: 0.8rem; color: var(--muted); }
.card .draft-count { color: var(--accent); font-size: 0.85rem; margin: 0.2rem 0; }

.card.choice { display: block; text-decoration: none; color: var(--ink); }
.card.choice:hover { border-color: var(--accent); }

/* ---------------------------------------------------------------
   Tables — listings, search results, infobox
   --------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
th {
  color: var(--muted);
  font: 500 0.8rem/1.3 'Cinzel', serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------
   Entity icon — the canonical infobox image (§9)
   --------------------------------------------------------------- */

/* The picture and the facts, side by side (§36.6).

   Everything used to stack: image, then a full-width infobox, then the
   prose -- which on a short page (a dungeon, a resource) pushed the
   first sentence below the fold and left a column of empty space beside
   a 200px thumbnail. Monsters already read side-by-side through their
   hero header; this is the same arrangement for the other nine domains,
   and it comes from the markup rather than from a per-domain rule.

   `align-items: flex-start` so a tall infobox does not stretch the
   image, and `wrap` so a narrow screen stacks them again. */
.entity-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Both children size to content and neither grows: an infobox of four
   rows should not stretch to fill the row just because the image is
   narrow. */
.entity-head > * { margin-bottom: 0; }

/* A fixed slot, the table icons' plate at page scale. Same reasoning
   (the sprite is cut out against the client's light ground, so it needs
   one here) and the same fixed square, so a 20px resource icon and a
   60px monster portrait both sit in an identically-sized box beside the
   infobox. It hugged the sprite before, which made the head's left
   column jump between domains and left a tiny 30px thumbnail floating
   against a tall fact card.

   Sized from the art, not chosen by eye: the median resource sprite
   measures 24x22 PIXELS (188 icons sampled, quartiles well under 40).
   The 8rem box tried first was 136px, so a typical icon floated in a
   square six times its size -- the opposite of the failure it fixed.
   4.5rem is ~76px, which frames the median with a margin and still
   holds the larger item art without shrinking it.

   The rare giant (287px wide) scales down to fit rather than setting
   the box: one outlier must not size a slot that appears on every
   page. */
.entity-icon {
  margin: 0 0 1rem;
  padding: 0;
  flex: 0 0 auto;
  width: 4.5rem;
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--icon-plate);
  border: 2px solid var(--icon-plate-edge);
  border-radius: 4px;
}

/* Moving the picture to the right of the infobox was tried and REVERTED
   (§37). `margin-left: auto` pushed it to the far edge of the content
   column, which on a thin domain left it stranded a long way from the
   facts it belongs to -- and the intent had been "beside the title",
   which is a different arrangement entirely. The picture stays on the
   left until the head is redesigned properly. */
/* The plate is on the figure above; the image carries no ground of its
   own and scales to fit the slot. */
.entity-icon img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  border: none;
  background: none;
}

/* ---------------------------------------------------------------
   Infobox — styled detail card
   --------------------------------------------------------------- */

/* A fact card, NOT a data grid -- and the two want opposite rules.
   This box is read one row at a time, label then value, so the division
   that matters is the VERTICAL one. It used to rule horizontally
   instead: a `border-bottom` between every pair of unrelated facts, and
   nothing at all in the label/value gutter the eye actually travels.
   The loud line was across the reading direction and the quiet one
   along it.

   So the rules come out and the label column does the dividing: one
   continuous band down the left, closed by a single `border-right`.
   Rows separate on whitespace, which is enough at four to eight rows
   and stops a short infobox looking like a spreadsheet. It also retires
   the `tr:last-child` pair that existed only to unpick the last rule. */
.infobox {
  max-width: 34rem;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.infobox th,
.infobox td {
  border-bottom: none;
  padding: 0.45rem 0.75rem;
  vertical-align: baseline;
}

/* The label gets its own voice rather than a dimmer shade of the
   value's. Both cells were Lora and the only difference was colour,
   which is why the box read as undesigned -- `th` had been given a
   label voice by the base rule (Cinzel, uppercase, tracked) and the
   infobox threw all three away without replacing them.

   Cinzel small and tracked is a caption face, not a reading face: it
   says "this word names the thing beside it" at a glance, so the muted
   colour is no longer carrying the distinction alone. Tracking rises as
   the size falls -- uppercase at 0.72rem sets tight without it. */
.infobox th {
  width: 11rem;
  font: 500 0.72rem/1.5 'Cinzel', serif;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: var(--bg-overlay);
  border-right: 1px solid var(--line);
}
.infobox td { font-size: 0.95rem; }

/* ---------------------------------------------------------------
   Misc page elements
   --------------------------------------------------------------- */

.ref-list { columns: 3; }

/* The domain listing's tabs: Live, Drafts, New, Archive. The bar is
   §36's `.tab-bar`; this adds the count each tab carries, so an author
   sees the size of a queue without opening it. The panel headings are
   for the no-script page, where tabs.js has not run and all four
   stack -- with the bar working they repeat the tab, so they shrink. */
.tab-bar .tab .tab-count {
  font: 600 0.75rem/1 var(--mono, monospace);
  opacity: 0.75;
  margin-left: 0.25rem;
}
.listing-tab-panel .panel-heading { margin: 0 0 0.25rem; font-size: 0.95rem; }
.listing-tab-panel .panel-heading .muted { font: 400 0.85rem/1.4 inherit; }

.notice {
  background: var(--bg-surface);
  border-left: 3px solid var(--accent);
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  border-radius: 0 4px 4px 0;
}

/* ---------------------------------------------------------------
   Forms — edit page
   --------------------------------------------------------------- */

form label, form .field { display: block; margin: 0.9rem 0; font-size: 0.85rem; color: var(--muted); }
form .field-label { display: block; }
form input, form select, form textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.45rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font: inherit;
}
form input[hidden], form select[hidden], form textarea[hidden], [hidden] {
  display: none !important;
}
form input:focus, form select:focus, form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
form textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
.hint { color: var(--muted); font-size: 0.78rem; font-weight: normal; }

/* ---------------------------------------------------------------
   Buttons
   --------------------------------------------------------------- */

button, .btn {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  background: var(--bg-surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary {
  background: linear-gradient(135deg, var(--accent), #b89530);
  color: #1a1410;
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
}
.actions { display: flex; gap: 0.6rem; margin-top: 1.5rem; align-items: center; }

/* The row id and legacy title, moved off the top of the page (§37).
   Pushed to the far end so the buttons keep the left edge. */
.actions .row-meta { margin-left: auto; font-size: 0.75rem; opacity: 0.6; }

/* The edit form's Save/Publish bar, pinned to the foot of the viewport.
   A monster is 69 fields and an article's body is longer, so at the end
   of the form these were a long scroll from wherever the author was
   typing.

   Fixed rather than sticky: sticky resolves against a scrolling ancestor
   and the form has none, so it would pin only after the page had already
   scrolled past the buttons -- precisely the case this is for.

   It spans from the sidebar's edge to the viewport's, not the content
   column's width: the bar is chrome, and a floating panel that stops at
   `--content-width` leaves a gap on a wide screen that reads as a
   rendering fault. `--sidebar-width` is 0 under the 50rem breakpoint, so
   this expression needs no separate mobile rule.

   z-index sits below the fixed header (which is 100): scrolling content
   goes under both, but if they ever meet on a short viewport the header
   is the one that should win, since it holds the search box. */
.actions-pinned {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 90;
  margin-top: 0;
  padding: 0.85rem 2rem;
  /* Fully opaque, and `--bg-surface` because the bar is an elevated panel
     over the page's own `--bg`. §40.8 made this call for the nav band: at
     0.93 it read as a shadow rather than a control, and text scrolling
     underneath a Save button is worse than that. An undefined token would
     be transparent, which is the same failure with no visible cause. */
  background: var(--bg-surface);
  border-top: 1px solid var(--line);
  /* Upward, since the bar's edge faces up. Enough to separate it from
     prose scrolling underneath without reading as a raised card. */
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.35);
}

.actions-hint { margin-left: auto; }

/* Discard sits in the bar but must not read as a third equal choice --
   it destroys work, where the other two save it. Muted until hovered,
   which is `form.danger button`'s treatment carried onto a button that
   is no longer inside that form (it reaches it by `form=` instead). */
.btn-discard { color: var(--muted); border-color: var(--line); }
.btn-discard:hover { color: var(--danger); border-color: var(--danger); }

/* The discard form holds no controls now -- its button is in the bar --
   so its top border would draw as a stray rule across the page. */
form.danger:empty { margin: 0; padding: 0; border: 0; }

/* The bar covers the foot of the page, so the form needs room to scroll
   past it -- otherwise "Discard draft" sits permanently underneath and
   cannot be clicked. Applied to the whole page rather than the form
   because the discard form is a sibling of the one holding the bar. */
body.has-pinned-actions main { padding-bottom: 7rem; }
form.danger { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
form.danger button { color: var(--danger); border-color: var(--danger); }

.btn.subtle { color: var(--muted); }
.btn.subtle:hover { color: var(--danger); border-color: var(--danger); }
form.danger .btn { color: var(--muted); border-color: var(--line); }

/* ---------------------------------------------------------------
   Body source / JSON viewer
   --------------------------------------------------------------- */

.body-json {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.8rem;
  overflow-x: auto;
  font-size: 0.8rem;
  color: var(--muted);
}

.body-source { display: none !important; margin-top: 2.5rem; }
.body-source summary { cursor: pointer; font-size: 0.85rem; }
.body-source .body-json { margin-top: 0.5rem; max-height: 30rem; overflow: auto; }

.ref-list-block { margin: 0.6rem 0 0; padding-left: 1.1rem; }
.ref-list-block li { margin: 0.25rem 0; }
.ref-list-block .muted { font-size: 0.85em; }

/* ---------------------------------------------------------------
   Error handling
   --------------------------------------------------------------- */

.error-box {
  background: var(--bg-surface);
  border-left: 3px solid var(--danger);
  padding: 1rem 1.2rem;
  border-radius: 0 4px 4px 0;
}
.error-box h2 { margin-top: 0; font-size: 1rem; }
.error-box .message { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }

/* ---------------------------------------------------------------
   Rendered body content (§5.4)

   The reading surface. Everything below styles output from
   cms/render.py, so class names here and there move together.
   --------------------------------------------------------------- */

/* Separates the prose from whatever precedes it -- an `.entity-head`, a
   byline, or the title itself. Was 1.5rem, which was measured against a
   head that is no longer drawn on a page without facts: with the byline's
   margin on top of it the first sentence sat ~2.9rem below a one-line
   title, a hole big enough to read as a missing element. */
.body { margin-top: 0.6rem; }
.body::after { content: ""; display: block; clear: both; }
/* A heading opening the body (no lead paragraph before it, e.g. Welcome)
   still carries its own 2.6rem top margin on top of this one, reading as
   a hole under the byline. Same fix already applied to the editor host
   (`.tiptap-host .ProseMirror > *:first-child`) and table cells. */
.body > *:first-child { margin-top: 0; }

/* The measure, applied to the text flow and NOT to `.body` itself.
 *
 * Capping the container would cap the tables with it, and a crafting
 * spec or a craftables listing is 5-7 columns of data that wants every
 * pixel the window has -- `.table-wrap` already gives it a horizontal
 * scrollbar as a last resort, and squeezing it to 42rem would make that
 * scrollbar the normal case rather than the fallback. Images are the
 * same: a dungeon map is a picture, not a sentence.
 *
 * So prose is capped and the wide things are not. A page whose body is
 * one long table therefore uses the full column while its paragraphs
 * stay readable, which is what the corpus actually contains. */
.body {
  max-width: var(--measure);
}

/* The wide things opt back out, because they are not prose.
 *
 * A crafting spec or a craftables listing is 5-7 columns of data that
 * wants every pixel the window has; `.table-wrap` already gives it a
 * horizontal scrollbar as a last resort, and holding it to `--measure`
 * would make that scrollbar the normal case rather than the fallback.
 * Images are the same -- a dungeon map is a picture, not a sentence.
 *
 * Selecting the article's children rather than capping only top-level
 * `p`/`ul` is what makes the cap actually hold: this corpus nests most
 * of its text (`<li><p>`, and prose inside table cells), so a `>` list
 * of block types left the deepest paragraphs uncapped and the page ran
 * full width anyway. */
.body > .table-wrap,
.body > .fig,
.body > figure,
.body > img,
.body > .gallery {
  max-width: none;
  width: max-content;
  max-width: min(100%, calc(100vw - var(--sidebar-width) - 6rem));
}

.body p { margin: 0 0 0.9rem; }
/* The margins matter as much as the sizes: each level's space ABOVE is
   roughly three times its space below, so a heading binds to the text it
   introduces rather than floating between two blocks. That grouping is
   most of what makes a long page skimmable -- more than the point size
   on its own. */
.body h2 {
  font: 600 1.5rem/1.25 'Cinzel', serif;
  margin: 2.6rem 0 0.7rem;
  padding-bottom: 0.35rem;
  /* The rule takes the heading's own hue at low alpha rather than the
     page's grey `--line`, so it reads as part of the heading rather than
     as a divider that happens to sit under it. */
  border-bottom: 1px solid rgba(224, 168, 119, 0.28);
  color: var(--h2-ink);
}
/* h3 and h4 are LORA, not Cinzel (§42.13) -- one loud level, two quiet.
 *
 * The three levels were the same face at the same weight, separated by
 * size alone, and the page read as heavy and wordy long before it read
 * as unclear. Cinzel is the cause: it is a display face with high stroke
 * contrast and wide letterforms, built for one line on a gump. `Arms
 * Lore` sets `Training`, then `Active`, `Active Use` and `Passive`, all
 * in that voice, in half a screen.
 *
 * So the hierarchy moves from SIZE onto VOICE. h2 keeps Cinzel and its
 * rule and means "a section starts here"; h3 and h4 are the body's own
 * Lora at 600, which says "part of the thing above" without shouting it.
 * That is §38.2's finding in another place -- a fact card and a data grid
 * want opposite rules -- and §36.7's note that blackletter earns its
 * place on one line seen once per page, not on every subheading.
 *
 * **Brightness was NOT used to separate them**, and §41.6 is why: the
 * TOC's levels were moved onto `--ink-bright`/`--ink`/`--muted` and the
 * hierarchy collapsed, because an h2-to-h3 step of 1.25 contrast is
 * measurable and invisible at 0.9rem. h3 keeps the bright ink; h4 drops
 * to `--ink` and earns its distinction from uppercase and tracking,
 * which is a change of KIND rather than of degree. */
/* h3 needed COLOUR, not a mark and not more weight (§42.14).
 *
 * Two cuts failed before this. Weight could not do it -- Lora is loaded
 * at 400/500/600 and stops, so h3 at 600 sat one step from the 400 prose
 * beneath it, same face, near-same size, SAME COLOUR. On `Pet training`,
 * `Wrestling, Tactics & Anatomy` sitting directly above a paragraph did
 * not read as a heading at all.
 *
 * Then a copper bar in the left margin, which worked and was still the
 * wrong device: it marks the line as special without saying what kind of
 * special, and it puts furniture in the gutter on 1,693 headings.
 *
 * What settled it was looking at UOGuide, which solves this with hue
 * alone -- dark red headings on white against near-black text, no rules,
 * no marks, no extra weight. The heading colour is not a shade of the
 * body colour; it is a different colour. Inverted for a dark page that
 * is copper against parchment, and it needs nothing else.
 *
 * **An underline was considered and rejected.** In this corpus an
 * underline already means LINK -- `a.ref` carries one (§38.8) -- and an
 * underlined heading beside `Wrestle` and `Anatomy`, which ARE links,
 * would invite a click on a word that does nothing. A mark has to be one
 * the reader has not already been taught to read as something else. */
.body h3 {
  font: 600 1.1rem/1.35 'Lora', Georgia, serif;
  margin: 1.9rem 0 0.5rem;
  color: var(--h3-ink);
  letter-spacing: 0.015em;
}
/* h4 was 0.9rem -- SMALLER than the 1rem prose beneath it, so the
   deepest heading read as a caption rather than as a heading. Uppercase
   and tracked keeps it distinct from h3 without needing more size, and
   now also without needing a second display face. */
.body h4 {
  font: 600 0.9rem/1.3 'Lora', Georgia, serif;
  margin: 1.4rem 0 0.4rem;
  /* The deepest step of the same hue (§42.14), not `--ink`. It was the
     prose's own colour, which is exactly the failure h3 had: at 0.9rem,
     uppercase and tracking alone left it reading as emphasised prose
     rather than as a heading. */
  color: var(--h4-ink);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.body ul, .body ol { margin: 0 0 0.9rem; padding-left: 1.4rem; }
.body li { margin: 0.2rem 0; }
.body li > ul, .body li > ol { margin: 0.2rem 0 0.3rem; }
.body li > p { margin: 0; }

/* Inline references (§5.2). Distinguished from external links.

   NOT scoped to `.body`: `render._reference` is the only thing that
   emits `a.ref`, so an infobox row's references -- a spell's reagents,
   a monster's slayer, a quest's giver -- are the same anchor and were
   inheriting bare gold with no underline at all. Styling the class
   covers every place a reference can appear, which is the point of
   there being one emitter. */
a.ref { color: var(--ref); text-decoration: none; border-bottom: 1px solid var(--ref-underline); }
a.ref:hover { color: var(--ref-hover); border-bottom-color: var(--ref-hover); }

/* External links (§45), the other half of the distinction above.

   Selected by `rel~="nofollow"` and NOT scoped to `.body`, for exactly
   the reason `a.ref` is not: `render._apply_marks` is the only thing in
   the app that emits that rel, so the attribute already means "an author
   typed this URL" wherever it appears. A summary or a block field
   rendering into an infobox row is the same anchor, and scoping to
   `.body` would leave those inheriting bare gold with no underline --
   which is the bug the comment above records having already been fixed
   once for references.

   The arrow is generated content rather than a character in the text: it
   must not enter the document (an author would have to delete it on
   every edit) and must not be selectable with the words. It is what
   tells a reader the click leaves the site BEFORE they make it -- colour
   alone does that only for a reader who has learnt this palette, and a
   first-time visitor has not. */
a[rel~="nofollow"] {
  color: var(--link-ext);
  text-decoration: none;
  border-bottom: 1px solid var(--link-ext-underline);
}
a[rel~="nofollow"]:hover {
  color: var(--link-ext-hover);
  border-bottom-color: var(--link-ext-hover);
}
a[rel~="nofollow"]::after {
  content: "↗";
  font-size: 0.8em;
  /* Superscript by baseline shift rather than <sup>: the arrow is
     decoration and must not change the line's height, which a real
     vertical-align on an inline box would. */
  vertical-align: 0.25em;
  margin-left: 0.12em;
  opacity: 0.7;
}

/* Unresolvable reference */
.ref-broken {
  color: var(--danger);
  border-bottom: 1px dotted var(--danger);
  cursor: help;
}
/* An author's copy links to the draft (render.Resolver.draft_url). It
   stays red: the colour is what says "unpublished". */
a.ref-broken { text-decoration: none; cursor: pointer; }
a.ref-broken:hover { border-bottom-style: solid; }

/* Figures. */
.body .fig { margin: 1rem 0; padding: 0; }
.body .fig img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-surface);
  display: block;
}
.body .fig figcaption {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.35rem;
  max-width: 24rem;
}
@media (min-width: 45rem) {
  .body .fig-left { float: left; margin: 0.3rem 1.2rem 0.8rem 0; max-width: 40%; }
  .body .fig-right { float: right; margin: 0.3rem 0 0.8rem 1.2rem; max-width: 40%; }
}

/* Icons inside table cells.

   The plate is a FIXED square on the figure, not a wrapper hugging the
   image. It sat on the `<img>` first, which meant its size was the
   sprite's size -- and UO item art runs from a 20px amulet to a 60px
   tunic, so a materials column came out as seven different rectangles
   down one line, none of them aligned. The client's own container grid
   is the reference: every item occupies an identical slot whatever is
   drawn on it, and the eye reads down the column instead of tracking a
   ragged edge.

   `flex` centres a sprite of any size in the slot; `max-width/height`
   on the image keeps an oversized one inside it. */
.body .content-table .fig {
  margin: 0;
  float: none;
  max-width: none;
  width: 3.4rem;
  height: 3.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--icon-plate);
  border: 1px solid var(--icon-plate-edge);
  border-radius: 3px;
}

/* A CSS-generated stone texture was tried here and REVERTED. Four
   repeating gradients at coprime periods do produce mottling, but at
   3.4rem it reads as faint noise rather than as the client's coarse
   stone -- the grain in a gump is painted at a scale CSS gradients
   cannot imitate without an actual texture image. Flat tan is honest
   about being a plate; fake stone just looked dirty. */
/* The sprite sits ON the plate above and carries no ground of its own.

   The plate exists because the art was not drawn for this page: UO item
   icons are cut out against the client's LIGHT background, so a dark
   sprite on `--bg` (#1a1410) has almost no edge. That is luminance, not
   the brown -- no adjustment to the hue recovers contrast the source
   art never had against a dark ground.

   NOTE the mixed corpus: some sprites are genuinely transparent and
   take the plate's colour, while others ship a near-white ground baked
   into the PNG (Gargish Platemail Arms). A uniform slot makes that
   difference MORE visible, not less, since the odd fills no longer hide
   behind a ragged edge. Not corrected here -- it is a property of the
   images, and a display-time filter would misreport what is stored. */
.body .content-table .fig img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border: none;
  background: none;
  border-radius: 0;
  display: block;
}
.body .content-table .fig figcaption { margin-top: 0.2rem; font-size: 0.75rem; }

/* Content tables */
.body .table-wrap { overflow-x: auto; margin: 1rem 0 1.4rem; }
.body .content-table {
  width: auto;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.body .content-table caption {
  caption-side: top;
  text-align: left;
  color: var(--muted);
  font-size: 0.85rem;
  padding-bottom: 0.4rem;
}
/* `middle`, not `top`: a 3.4rem icon plate beside a one-line name left
   the name stranded at the top of the cell, and every table in this
   corpus that carries icons pairs them with short labels. A cell whose
   content is genuinely tall (the crafting spec's three skill lines)
   centres against its neighbours rather than against nothing, which is
   what the eye wants when scanning across a row.

   Horizontal alignment stays LEFT deliberately. Centring reads well on
   the two-row Special Moves box and badly everywhere else -- the
   crafting spec's `100 skill: 50% (5% exceptional)` rows are scanned
   down the column, and a ragged left edge is what makes that hard. */
.body .content-table th,
.body .content-table td {
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  vertical-align: middle;
  text-align: left;
}
/* A header WRAPS (§43.10). It was `white-space: nowrap`, which forced
   every heading onto one line and let the longest one set its column's
   width -- on a wide table that is taken from whichever column holds
   the prose. `Bard Masteries` is the case that showed it: seven
   columns, four of them two words ("Minimum Skill", "Intone Cost",
   "Upkeep Cost"), each claiming its full single-line width, leaving
   Description a gutter to wrap 60 words in.

   **156 tables in the corpus have 5+ columns and 2+ multi-word
   headers**, and 951 have a multi-word header at all, so this was
   never one article -- it was one article an author happened to read.

   The editor never had the rule, which is why the same table is
   legible under `/edit` and not on the page. Two views of one document
   disagreeing on layout is the defect; the editor's version was right.

   `balance` tells the browser to even the lines out rather than
   leaving one word stranded, and is ignored where unsupported. */
.body .content-table th {
  background: var(--bg-overlay);
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: normal;
  text-wrap: balance;
}
.body .content-table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.body .content-table td > *:last-child,
.body .content-table th > *:last-child { margin-bottom: 0; }
.body .content-table td > *:first-child,
.body .content-table th > *:first-child { margin-top: 0; }
/* No indent and no marker: the flex row below makes the marker box
   vanish anyway, so the padding was reserving space for nothing and
   pushing every material off the cell's left edge. */
.body .content-table ul { padding-left: 0; list-style: none; }

/* A material in a crafting spec is an icon and its name, and the icon
   is a BLOCK node (§19.3) -- so the name wrapped UNDERNEATH the plate
   rather than sitting beside it, with a bullet marker off to the left
   of both. Three things nobody wants: the marker says nothing when
   every row is one material, the stacking makes a two-material cell
   twice as tall as it needs to be, and the quantity ("18 Ingots") ends
   up detached from the picture it counts.

   The row is laid out here rather than in the importer because it is
   presentation: `import_items.py` writes the icon and the name as the
   two things they are, and how they sit is the stylesheet's call. */
.body .content-table li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.3rem 0;
}
.body .content-table li > p { margin: 0; }

/* Sortable headers (§5.4) */
.body .content-table th.sortable { cursor: pointer; user-select: none; }
.body .content-table th.sortable:hover { color: var(--accent); }
/* `inline-block` keeps the arrow attached to the last word now that a
   header wraps (§43.10). As a bare inline ::after it became a wrap
   opportunity, so "Minimum Skill ↕" could break to three lines with
   the glyph alone on the third. */
.body .content-table th.sortable::after {
  content: "\2195";
  display: inline-block;
  color: var(--muted);
  font-size: 0.8em;
  margin-left: 0.35em;
  opacity: 0.5;
}
.body .content-table th.sort-asc::after { content: "\2191"; color: var(--accent); opacity: 1; }
.body .content-table th.sort-desc::after { content: "\2193"; color: var(--accent); opacity: 1; }

.body .code {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.7rem 0.9rem;
  overflow-x: auto;
  font-size: 0.85em;
}

.render-error {
  background: var(--bg-surface);
  border-left: 3px solid var(--danger);
  padding: 0.8rem 1rem;
  border-radius: 0 4px 4px 0;
  margin: 1rem 0;
}

/* ---------------------------------------------------------------
   The editor (slice 3 part 2)
   --------------------------------------------------------------- */

.tiptap-host .ProseMirror {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.7rem 0.9rem;
  min-height: 18rem;
  max-height: 40rem;
  overflow-y: auto;
  color: var(--ink);
  line-height: 1.55;
}
.tiptap-host .ProseMirror:focus { outline: none; border-color: var(--accent); }
.tiptap-host .ProseMirror > *:first-child { margin-top: 0; }

.tiptap-host table {
  border-collapse: collapse;
  width: auto;
  max-width: 100%;
  margin: 0.9rem 0;
}
.tiptap-host th, .tiptap-host td {
  border: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
  vertical-align: top;
}
.tiptap-host th { background: var(--bg-overlay); font-weight: 600; color: var(--ink); }
.tiptap-host .selectedCell { background: var(--accent-dim); }

.tiptap-host img { max-width: 100%; min-width: 16px; border-radius: 2px; }
.tiptap-host img.ProseMirror-selectednode { outline: 2px solid var(--accent); }

.editor-fallback {
  background: var(--bg-surface);
  border-left: 3px solid var(--danger);
  padding: 0.6rem 0.8rem;
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}

/* Toolbar (§19) */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.4rem;
  background: var(--bg-overlay);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}
.toolbar-group { display: flex; gap: 0.15rem; }
.toolbar-group + .toolbar-group {
  padding-left: 0.5rem;
  border-left: 1px solid var(--line);
}
.toolbar-button {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  line-height: 1.2;
  background: var(--bg);
  min-width: 1.9rem;
}
.toolbar-button.is-active {
  background: var(--accent);
  color: #1a1410;
  border-color: var(--accent);
  font-weight: 600;
}
.toolbar-button:disabled { opacity: 0.35; cursor: default; }
.toolbar-button:disabled:hover { border-color: var(--line); }

.editor-toolbar + .tiptap-host .ProseMirror { border-radius: 0 0 4px 4px; }

.image-picker {
  flex-basis: 100%;
  margin-top: 0.4rem;
  padding: 0.6rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.image-picker-head { display: flex; gap: 0.5rem; align-items: center; }
.image-picker-search { flex: 1; }
.image-picker-status { margin: 0.4rem 0; }
.image-picker-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: 0.4rem;
  max-height: 18rem;
  overflow-y: auto;
}
.image-picker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--muted);
}
.image-picker-item:hover { border-color: var(--accent); }
.image-picker-item img { max-width: 100%; max-height: 4rem; object-fit: contain; }
.image-picker-item span { word-break: break-all; text-align: center; }

.image-picker-file { display: none; }
.image-picker-upload { cursor: pointer; display: inline-block; }
.toolbar-button.is-disabled { opacity: 0.35; cursor: default; }

/* The `icon` column's picker on the edit form (§51).
 *
 * Reuses `.image-picker` above unchanged -- the panel is the body
 * toolbar's, mounted against a text input instead of an editor -- so
 * everything here styles only the row of controls that opens it.
 *
 * `align-items: center` and NOT `stretch`: the buttons sit beside a
 * thumbnail whose height varies with the sprite, and stretching them to
 * a 4.5rem monster portrait makes two tall thin buttons. */
.icon-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.4rem 0 1rem;
}

/* A fixed box for the same reason `.entity-icon` is one (§38.3): the
 * three icon populations differ by a factor of seven (resources 24x22,
 * items 47x50, monsters 166x141), so a slot that hugs the art makes the
 * form jump between domains. Smaller than the reading page's plate --
 * this is a confirmation that the right file is named, not the picture
 * as a reader will see it.
 *
 * The plate is deliberately here, unlike §48.5's gallery: a lone sprite
 * against the form's dark ground has the same cut-out problem the
 * reading page has, and this is exactly the lone-sprite case. */
.icon-field-preview {
  width: 3.5rem;
  height: 3.5rem;
  object-fit: contain;
  padding: 0.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.icon-field-empty { margin: 0; }

/* The picker panel is a sibling of the controls, not a child of the flex
 * row: it is full width and must break to its own line rather than
 * competing with the buttons for horizontal space. */
.icon-field .image-picker { flex-basis: 100%; margin-top: 0.2rem; }

/* Summary editor */
.tiptap-summary .ProseMirror { min-height: 4rem; }
.editor-toolbar-summary { margin-bottom: 0; }

/* Scan panel (§6.2) */
.scan-panel {
  flex-basis: 100%;
  margin-top: 0.4rem;
  padding: 0.6rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.scan-head { display: flex; gap: 0.5rem; align-items: center; }
.scan-status { margin: 0.4rem 0; }
.scan-results { display: flex; flex-direction: column; gap: 0.25rem; max-height: 22rem; overflow-y: auto; }

.scan-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 0.8rem;
}
.scan-raw { font-family: ui-monospace, monospace; color: var(--muted); }
.scan-target { color: var(--ink); }
.scan-row .toolbar-button { margin-left: auto; }
.scan-choice { margin-left: 0.25rem; }

.scan-unmatched { opacity: 0.55; }
.scan-ambiguous { border-color: var(--accent); }
.scan-anchor { font-style: italic; }

/* Reference chip in the editor. Takes `--ref` for the same reason the
   reading page does: it is the same relation, and an author inserting
   one should see what the reader will get. */
.ref-chip {
  padding: 0 0.15rem;
  border-radius: 3px;
  background: rgba(127, 168, 138, 0.15);
  border-bottom: 1px solid var(--ref);
  color: var(--ref);
  cursor: default;
}
.ref-chip-unresolved {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  color: var(--muted);
}

/* ---------------------------------------------------------------
   Fieldsets on the edit form (§25.1)
   --------------------------------------------------------------- */

.fieldgroup { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldgroup:has(legend) {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1.25rem;
}
.fieldgroup legend {
  color: var(--accent);
  font: 600 0.8rem/1 'Cinzel', serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 0.4rem;
}

/* ---------------------------------------------------------------
   Tags (slice 12)
   --------------------------------------------------------------- */

.page-tags { margin: 1.5rem 0 0; }
.tag-chip {
  display: inline-block;
  margin: 0 0.3rem 0.3rem 0;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.85em;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.tag-chip:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.tag-picker .tag-check {
  display: block;
  margin: 0.15rem 0;
  font-weight: normal;
}
.tag-picker .tag-check input { margin-right: 0.4rem; }

.inline-form { display: flex; gap: 0.4rem; }
.inline-form input { margin: 0; }

/* ---------------------------------------------------------------
   Admin: category tree
   --------------------------------------------------------------- */

.cat-tree, .cat-tree ul { list-style: none; margin: 0; padding: 0; }
.cat-tree > li { border-bottom: 1px solid var(--line); padding: 0.15rem 0; }
.cat-tree ul.sub { margin-left: 1.5rem; }
.cat-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.35rem 0; }
.cat-name { font-weight: 500; min-width: 10rem; }
.cat-target { flex: 1; font-size: 0.85rem; }
.cat-target .generated { font-style: italic; }
.cat-target .broken { color: var(--danger); }
.cat-actions { display: flex; gap: 0.3rem; align-items: center; }
.cat-actions form { display: inline; margin: 0; }
.cat-actions button { padding: 0.15rem 0.45rem; font-size: 0.8rem; }

/* Page picker */
.page-picker { border: 1px solid var(--line); padding: 0.75rem 1rem; border-radius: 4px; position: relative; }
.pp-box { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.pp-input { flex: 1; }
.pp-chosen { margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.pp-chosen.has-target { color: var(--ok); }
.pp-results {
  list-style: none; margin: 0.35rem 0 0; padding: 0;
  border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg-surface); max-height: 16rem; overflow-y: auto;
  position: absolute; left: 1rem; right: 1rem; z-index: 20;
}
.pp-results li { border-bottom: 1px solid var(--line); }
.pp-results li:last-child { border-bottom: 0; }
.pp-hit {
  display: flex; justify-content: space-between; align-items: baseline;
  width: 100%; text-align: left; border: 0; border-radius: 0;
  background: none; padding: 0.45rem 0.7rem; color: var(--ink);
}
.pp-hit:hover { background: var(--bg); color: var(--accent); }
.pp-kind { color: var(--muted); font-size: 0.75rem; margin-left: 1rem; }
.pp-none { padding: 0.45rem 0.7rem; color: var(--muted); font-size: 0.85rem; }

/* The `@` picker (§47). Deliberately the same furniture as .pp-* above:
   it is the same job -- turn a name into an id -- and an author who has
   used one should recognise the other.

   Two differences, both forced by where it appears. It is anchored to
   the CARET rather than stretched between a field's edges, so `left`
   and `top` are set from `coordsAtPos` and the width is content-driven
   with a floor and a ceiling. And its z-index clears the sticky editor
   toolbar, which the menu picker never had to sit under. */
.mention-list {
  list-style: none; margin: 0; padding: 0;
  border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg-surface); max-height: 15rem; overflow-y: auto;
  position: absolute; z-index: 40;
  min-width: 14rem; max-width: 24rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.mention-list[hidden] { display: none; }
.mention-list li { border-bottom: 1px solid var(--line); }
.mention-list li:last-child { border-bottom: 0; }
.mention-hit {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem;
  width: 100%; text-align: left; border: 0; border-radius: 0;
  background: none; padding: 0.4rem 0.65rem; color: var(--ink);
  font: inherit; cursor: pointer;
}
/* Hover and keyboard selection paint the SAME way. The arrow keys move
   `is-active` and the mouse moves `:hover`; if the two looked different
   an author switching between them would see two highlights at once and
   have to work out which one Enter would take. */
.mention-hit:hover, .mention-hit.is-active {
  background: var(--bg); color: var(--accent);
}
.mention-kind { color: var(--muted); font-size: 0.75rem; }
.mention-none {
  padding: 0.4rem 0.65rem; color: var(--muted); font-size: 0.85rem;
}

/* ---------------------------------------------------------------
   Search (slice 8)
   --------------------------------------------------------------- */

/* Results page form */
.searchform-page { display: flex; gap: 0.5rem; margin: 0 0 1.5rem; position: relative; }
/* The results page's box gets the dropdown too (§58) -- live_search.js
   binds every `form.searchform`. Hung from its left edge, where the
   field starts, rather than the banner box's right. */
.searchform-page .live-results { left: 0; right: auto; }
.searchform-page input {
  flex: 1;
  max-width: 30rem;
  padding: 0.5rem 0.7rem;
  background: var(--bg-surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
}
.searchform-page input:focus { outline: none; border-color: var(--accent); }

/* Search result hover (search_preview.js): the page rendered at desktop width in
   embed mode, scaled to a thumbnail. Look only, so it takes no pointer. */
.page-preview {
  position: fixed;
  z-index: 30;
  width: 480px;
  height: 520px;
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid rgba(201, 168, 76, 0.55);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
  pointer-events: none;
}
.page-preview[hidden] { display: none; }
.page-preview iframe {
  width: 1100px;
  height: 1300px;
  border: 0;
  transform: scale(0.7);
  transform-origin: 0 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.page-preview.loaded iframe { opacity: 1; }

/* Embed mode (`?embed=1`): no banner above, so no room reserved for it. */
.shell.embed { padding-top: 0; }

/* Listing filter */
.listing-filter { display: flex; align-items: baseline; gap: 0.75rem; margin: 0.75rem 0 0; }
.listing-filter[hidden] { display: none; }
.listing-filter input {
  width: 18rem;
  padding: 0.35rem 0.6rem;
  background: var(--bg-surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  font-size: 0.9rem;
}
.listing-filter input:focus { outline: none; border-color: var(--accent); }
.filter-status { font-size: 0.85rem; }

tr.filtered-out { display: none !important; }
/* A row the filter found by close spelling rather than by its words
   (listing_filter.js's rescue pass). Marked, not hidden: it is offered,
   and the reader should see it is a guess. */
tr.near-miss td:first-child { font-style: italic; }

/* ---------------------------------------------------------------
   Monster Page: Hero Header & 6-Tab Dossier Layout
   --------------------------------------------------------------- */

.monster-hero-header {
  display: flex;
  align-items: stretch;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* Monsters are a different population and take a different slot. Their
   portraits measure 166x141 at the median and 236x264 at p90 (275
   sampled), against 47x50 for items and 24x22 for resources -- so the
   4.5rem slot that frames an item's sprite would scale a monster's
   portrait down to a thumbnail. It sizes to the art here instead of
   holding a fixed square, which is why the plate is off: a box that
   fits its contents is already the right shape, and the tan would be a
   frame around a picture that fills it rather than a ground under a
   sprite that does not. */
.monster-big-portrait {
  margin: 0 !important;
  flex: 0 0 auto;
  width: auto;
  height: auto;
  background: none;
  border: none;
  border-radius: 0;
}

.monster-big-portrait img {
  max-width: 220px;
  max-height: 240px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-surface);
  padding: 0.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: block;
}

.monster-hero-card {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 1.2rem 1.4rem;
  min-height: 5rem;
}

.monster-summary {
  flex: 1;
  font-size: 0.95rem;
  color: var(--ink);
}

.monster-summary p {
  margin: 0;
}

.monster-summary-fallback {
  transition: opacity 0.15s;
}

.monster-summary-fallback:hover {
  opacity: 0.85;
}

.monster-summary-fallback .read-more-link {
  color: var(--accent);
  font-size: 0.85em;
  font-weight: 600;
  text-decoration: underline;
  margin-left: 0.3rem;
}

.monster-hp-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem 1.1rem;
  min-width: 8rem;
  text-align: center;
  flex-shrink: 0;
}

.monster-hp-badge .hp-label {
  font: 600 0.72rem/1.2 'Cinzel', serif;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.monster-hp-badge .hp-val {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.2rem;
}

/* Hide figure images in the Guide & Notes tab */
#m-tab-guide .monster-guide-body .fig {
  display: none !important;
}

/* Pictures Tab: Gallery Layout
 *
 * `auto-fit`, not `auto-fill`. Both lay out the same number of pictures;
 * they differ in what happens to the LEFTOVER tracks, and that is the
 * whole difference here. `auto-fill` keeps the empty columns it could
 * have made, so three pictures in a row that fits five sat in 13rem
 * cells with the spare width held by tracks holding nothing -- a wide
 * 455x109 sprite sheet was squeezed into 13rem while empty columns sat
 * beside it. `auto-fit` collapses the empties and gives their width back
 * to the real pictures.
 *
 * The floor drops to 11rem for the same reason: it is a MINIMUM, and the
 * pictures now grow past it on their own. A high floor was doing work
 * that `max-width` on the image should do, which is how a cell ended up
 * narrower than its contents (§48.4: a declared size that silently does
 * not apply is the failure).
 *
 * `align-items: start` so a short picture does not stretch its figure to
 * the height of the tallest in the row -- these are three unrelated
 * pictures, not a set that should share a baseline box.
 *
 * The track's upper bound is `1fr` and NOT `max-content`: max-content
 * sizes a track to its widest item with nothing above it, so one 900px
 * screenshot would push the row wider than the panel and reintroduce
 * the overflow from the other direction. `1fr` divides the space that
 * exists. The picture then takes its stored width or the cell, whichever
 * is smaller (see `.fig img` below), so a narrow picture no longer
 * stretches and a wide one no longer escapes. */
.monster-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  justify-content: start;
  align-items: start;
  gap: 1.25rem;
  margin-top: 0.5rem;
}

.monster-gallery .body-gallery-extract {
  display: contents;
}

.monster-gallery .body-gallery-extract > *:not(.fig) {
  display: none !important;
}

.monster-gallery .fig {
  margin: 0 !important;
  float: none !important;
  max-width: 100% !important;
  background: var(--bg-overlay);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem;
  text-align: center;
}

/* The cell bounds the picture; the picture does not bound the cell.
 *
 * This had `max-height: 14rem; width: auto` and NO `max-width`, which
 * works only for art that is taller than it is wide. The corpus is not:
 * Phoenix.png is 455x109, so a 14rem height cap never binds, `auto`
 * resolved to the full 455px, and the image ran straight out of its
 * ~13rem grid track and under the figure beside it. Tall art was
 * constrained and wide art was not, which is why the panel looked
 * correct until a sprite sheet arrived.
 *
 * `max-width: 100%` is the missing half. It is on the `.fig` wrapper
 * above but a wrapper's cap does not travel to its child -- the box was
 * the right size all along with the picture overflowing it.
 *
 * `height: auto` rather than `width: auto`: with both dimensions capped
 * the aspect ratio has to be preserved explicitly, and letting HEIGHT be
 * the derived one is what makes the author's stored `width` attribute
 * meaningful. `width: auto` overrode it -- §5.1 stores a width per image
 * node and render.py emits it, and a CSS `width` beats an HTML width
 * attribute, so every author-set width was being silently discarded in
 * this panel. Now a picture renders at its stored width, or at the
 * cell's width if that is narrower, whichever is smaller.
 *
 * NOT `object-fit`, which was here and did nothing: it only applies to a
 * replaced element with BOTH dimensions fixed, and neither is. Left in
 * place it would letterbox the moment someone added a fixed height --
 * §48.5's trap, where a plate sized for a lone sprite crops a
 * screenshot. */
.monster-gallery .fig img {
  max-width: 100%;
  max-height: 14rem;
  height: auto;
  margin: 0 auto;
  border-radius: 4px;
}

.monster-gallery figcaption {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Tabs (§36). Named for the mechanism, not for monsters: the same bar
   is the reading page's dossier and the edit form's panels, and a
   second domain that declares `layout="tabs"` gets it without a rule.
   The `.monster-*` names these replaced were the stylesheet half of
   §35's hardcoding. */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  border-bottom: 2px solid var(--line);
  margin-bottom: 1.25rem;
}

.edit-tab-panel > fieldset {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.5rem;
}

.edit-tab-panel > fieldset > label:first-child,
.edit-tab-panel > fieldset > .field:first-child {
  margin-top: 0;
}

/* `raw_fields` used to be hidden here entirely: its two editable keys
   (taming difficulty, pack instinct) have their own inputs in Attributes
   and Identity, so the blob looked like operator plumbing.
   **No longer hidden** (§36.2) -- it is the only column in the "Guide &
   Notes" group, so the rule emptied a whole tab, and a `display: none`
   in the stylesheet is exactly the shape that hid a real column in §34.
   It renders as what it is: a JSON bag with a hint saying the two keys
   an author edits are above.

   `special_skills` was never hidden and still is not -- hiding it is
   what made it look like the empty duplicate of `specialskill`. */
input[name="raw_fields"],
input[name="special_skills"] {
  font-family: var(--mono, monospace);
  font-size: 0.8rem;
}

.tab-bar .tab {
  background: var(--bg-surface);
  color: var(--muted);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  padding: 0.55rem 1rem;
  font: 600 0.85rem/1 'Cinzel', serif;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: all 0.15s ease;
}

.tab-bar .tab:hover {
  color: var(--ink-bright);
  background: var(--bg-overlay);
}

.tab-bar .tab.active {
  color: #1a1410;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

/* The panels are NOT hidden here, deliberately -- tabs.js does it on
   load. A `display: none` in the stylesheet would hide seven eighths of
   a monster page for a reader whose JavaScript failed, with nothing to
   bring it back; done in JS, a failure degrades to one long page. */
.monster-tab-panel,
.edit-tab-panel {
  margin-bottom: 1.5rem;
}

.monster-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1.25rem;
}

.monster-card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem 1.2rem;
}

.monster-card h3 {
  font: 600 1rem/1.2 'Cinzel', serif;
  color: var(--accent);
  margin: 0 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}

.monster-mini-table {
  width: 100%;
  border-collapse: collapse;
}

/* The same fact card as `.infobox`, so the same rules -- it is a
   label/value pair list inside a tab panel, not a grid. It was a fourth
   copy of the "undo the base `th`" override; keeping it in step with
   the infobox is the point, or the two boxes drift apart again. No
   background band here: it sits inside an already-panelled tab, and a
   second fill inside a fill reads as a box in a box. */
.monster-mini-table th {
  font: 500 0.72rem/1.5 'Cinzel', serif;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  width: 42%;
  padding: 0.4rem 0.6rem 0.4rem 0;
  border-bottom: none;
  vertical-align: baseline;
}

.monster-mini-table td {
  font-size: 0.92rem;
  padding: 0.4rem 0.5rem;
  border-bottom: none;
  vertical-align: baseline;
}

/* 5-Column Elemental Matrix */
.elemental-matrix {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
}

.elemental-matrix th,
.elemental-matrix td {
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--line);
  font-size: 0.9rem;
}

.elemental-matrix th {
  font: 600 0.82rem/1.2 'Cinzel', serif;
  letter-spacing: 0.03em;
}

.elem-phys { color: #b0b8c0; }
.elem-fire { color: #ff6b6b; }
.elem-cold { color: #4dadf7; }
.elem-poison { color: #51cf66; }
.elem-energy { color: #cc5de8; }

.elemental-matrix tbody th {
  text-align: left;
  background: var(--bg-overlay);
  color: var(--muted);
}

/* ---------------------------------------------------------------
   Key-value bag display
   --------------------------------------------------------------- */

.kv { margin: 0; }
.kv dt { font-weight: 500; color: var(--muted); font-size: 0.85em; }
.kv dd { margin: 0 0 0.4rem; }

/* ---------------------------------------------------------------
   Responsive — collapse sidebar on narrow screens
   --------------------------------------------------------------- */

@media (max-width: 50rem) {
  :root {
    --sidebar-width: 0px;
    /* One band on a phone too (§37): the two must stay equal or the
       banner draws short of the fixed header and leaves a strip of page
       background showing through under the artwork.
       80px, anchored left with the search box centred, was tried for
       the screen it saves and reverted: the 120px band looked better. */
    --header-height: 120px;
    --banner-height: 120px;
  }
  .sidebar { display: none; }
  .sidebar ~ main { margin-left: 0; }
  main { padding: 1.5rem 1rem 3rem; }

  /* The sidebar's two fixed SIBLINGS (§38.6) are sized by
     `--sidebar-width`, so hiding the sidebar alone left them at zero
     width: a one-word-wide column of "Tome of / Knowledge" and "Log /
     out" painted over the article. The wordmark labels a scroll that is
     not drawn here, so it goes. The account block cannot -- for a
     logged-out reader it is the only way in -- so it drops into the
     shell's flow after <main>, a footer line on the dark page, where the
     parchment's near-black ink would vanish. */
  .wordmark { display: none; }
  .shell { flex-wrap: wrap; }

  /* The menu, closed until `Menu` targets it (_sidebar.html says why
     `:target`). Open, it is the same scroll in the page's flow rather
     than pinned beside it, kept at its desktop width and centred: the
     rollers are border-image slices drawn for ~17rem, and stretched
     across a whole phone they read as a different picture. */
  .nav-toggle {
    display: block;
    order: -2;
    flex: 1 0 100%;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--line-light);
    font: 600 0.9rem/1.4 'Cinzel', serif;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
  }
  .nav-toggle::before { content: "☰  "; }
  .nav-target:target ~ .sidebar {
    display: block;
    order: -1;
    position: static;
    width: min(100%, 17rem);
    margin: 1rem auto 0;
    overflow: visible;
    /* The account block is not pinned on a phone, so the floor
       `--account-zone` reserves for it is not needed here. */
    padding-bottom: 0.9rem;
  }
  .nav-target:target ~ .nav-toggle { display: none; }
  .nav-close {
    display: block;
    margin: 0 0 0.6rem;
    font-size: 0.8rem;
    color: #2a1a0a;
  }
  .account-bar {
    position: static;
    order: 1;
    flex: 1 0 100%;
    width: auto;
    justify-content: flex-start;
    padding: 0.9rem 1rem 1.5rem;
    border-top: 1px solid var(--line-light);
  }
  .account-bar a,
  .account-bar .linklike {
    color: var(--accent);
    border-bottom-color: currentColor;
  }
  .account-who { max-width: 60vw; }

  .banner nav a { font-size: 0.7rem; padding: 0.25rem 0.4rem; }
  .banner .searchform input { width: 10rem; }
  .ref-list { columns: 1; }
}


/* ---------------------------------------------------------------
   The in-game item tooltip (§36.6)

   The shape a player already reads in the UO client: a dark box, the
   item's name in gold at the top, then one line per property with the
   value right of its label. Deliberately close to the client rather
   than to the rest of this stylesheet -- recognition is the point, and
   it is why the tooltip exists instead of a fifteen-row infobox.

   Floated beside the body like `.entity-icon`, so an item page reads
   name, picture, tooltip, prose -- the order a wiki page uses.
   --------------------------------------------------------------- */
.tooltip-box {
  /* A flex child of `.entity-head` (§36.6), not a float: it sits beside
     the item's picture the way the infobox does on every other domain.
     It was floated when it was the only thing beside the body. */
  flex: 0 0 auto;
  width: 15rem;
  max-width: 100%;
  margin: 0;
  padding: 0.75rem 0.9rem 0.85rem;
  background: #14100c;
  border: 1px solid var(--line-light);
  border-radius: 4px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.tooltip-name {
  margin: 0 0 0.5rem;
  text-align: center;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tooltip-props {
  margin: 0;
}

/* Label left, value right, on one line each. A grid rather than a
   float pair so a long label wraps without dragging its value with it. */
.tooltip-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: baseline;
}

.tooltip-row dt,
.tooltip-row dd {
  margin: 0;
  color: var(--ink);
}

.tooltip-row dd {
  text-align: right;
  white-space: nowrap;
}

/* A valueless flag ("Blessed", "One-Handed Weapon") is one centred
   line -- it names what the item IS, so it has no label to sit beside. */
.tooltip-flag {
  grid-template-columns: 1fr;
  margin-top: 0.35rem;
}

.tooltip-flag dd {
  text-align: center;
  color: var(--ink-bright);
  white-space: normal;
}

@media (max-width: 40rem) {
  /* `.entity-head` already wraps; this just stops the box keeping a
     fixed 15rem when it is the full width of a phone. */
  .tooltip-box { width: 100%; }
}

/* ---------------------------------------------------------------
   Table of contents (§36.7)

   For `layout="toc"` domains -- articles and skills, the body-heavy
   half of the corpus. A sticky panel floated beside the prose, so it
   stays reachable as the reader scrolls; see the note on `.toc` for
   why the first cut's plain block was wrong.

   Indentation carries the hierarchy the heading levels already
   express (10,511 H2s, 1,690 H3s, 362 H4s), which is the thing tabs
   would have flattened.
   --------------------------------------------------------------- */
.toc {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  /* Not gold -- see `--toc-edge`. A shard block (§41) is a panel with a
     gold left border and the two were indistinguishable side by side. */
  border-left: 3px solid var(--toc-edge);
  border-radius: 4px;
  padding: 0.9rem 1.2rem 1rem;

  /* Sticky, in a column of its own (§36.7).

     Two earlier cuts were wrong and both are worth recording:

     1. A plain block above the body. A contents list is *not* read once
        on arrival -- `Pet training` lists 31 entries, taller than the
        viewport, so the reader scrolls past a wall of links and cannot
        see it again without going back to the top. Text, not
        navigation. uoguide.com's own TOC has the same fault.

     2. `float: right` plus `position: sticky`. **These do not compose.**
        A float reserves space at its position in the normal flow, and
        sticky takes the box out of that flow the moment it detaches --
        so the paragraphs below reclaimed the full column width and the
        list sat on top of the text.

     A grid column reserves the space for real, and the box sticks
     inside its own track. `top` must clear the fixed 160px banner or
     the list slides underneath it. */
  position: sticky;
  top: calc(var(--header-height) + 1rem);
  margin: 0;

  /* A list still too tall to fit gets its own scrollbar rather than
     pushing itself off screen. Two pages in the corpus need this --
     `List of Quest NPCs` is 35 flat H2s with no depth to trim. */
  max-height: calc(100vh - var(--header-height) - 3rem);
  overflow-y: auto;
}

/* Prose left, contents RIGHT, and the prose column is `--measure` --
   exactly what a page with no contents list gets. That is the whole
   point of the change: a contents list must not narrow the reading
   column, so it goes in the margin beside it rather than taking a cut
   of it.

   Right rather than left keeps the prose starting at the same
   x-position whether or not the page has a list, so moving between an
   article and a spell does not shift the text sideways. It also keeps
   the reading column against the sidebar rather than pushing it into
   the middle of the window behind a second navigation band.

   The <nav> comes after the <article> in the source, which is both the
   reading order a screen reader wants and the visual order here -- so
   the grid places it with no `order` override.

   `minmax(0, var(--measure))` is a CEILING, not a fixed width: the
   prose never sets wider than the measure -- which is the whole point,
   and what keeps a contents page and a plain page agreeing -- but it
   may shrink below it when the window is tight. A fixed track would
   have forced the collapse to a single column on any laptop narrower
   than 86.5rem, which cost the sticky list on almost every real screen
   (§37). Losing a few rem of measure is much cheaper than losing the
   navigation entirely.

   `justify-content: start` pins the pair left so the prose starts at
   the same x-position as on a page with no list. */
.with-toc {
  display: grid;
  grid-template-columns: minmax(0, var(--measure)) var(--toc-width);
  gap: var(--toc-gap);
  align-items: start;
  justify-content: start;
}

.toc-title {
  margin: 0 0 0.6rem;
  padding-bottom: 0.45rem;
  font: 700 0.8rem/1 'Cinzel', serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  /* It labels the panel, so it must not be the DIMMEST thing in it --
     which `--muted` made it, quieter than every row it introduces. A
     label that recedes behind its own list reads as an artefact rather
     than as a heading.

     `--ink-bright` and not the rows' copper: the label is not a row and
     should not look like the brightest one. It is the only bright NEUTRAL
     in the panel, which is what makes it read as chrome while the copper
     reads as content. The rule under it does the separating, so the
     colour does not have to shout. Deliberately not gold -- that is the
     shard block's now (§41), and this panel yielded it. */
  color: var(--ink-bright);
  border-bottom: 1px solid var(--line);
}

/* Numbering is deliberately off: these are named sections, not steps,
   and a nested ordered list would print "1.2.3" against headings the
   page itself does not number. */
.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc li { margin: 0.15rem 0; line-height: 1.4; }

/* Not the global gold every other anchor inherits -- that was a column of
   gold beside a gold-edged shard block (§41) and the two panels read
   alike. But the first cut of that fix set every level to `--ink`, which
   **collapsed the hierarchy**: `Pet training` lists sections three deep,
   and with one colour the only thing separating an H2 from its H3s was
   indentation. That is a real loss, not a simplification -- the levels
   are what make a 31-entry list scannable.

   Brightness alone was tried for that and is NOT enough: `--ink-bright`
   over `--ink` is a 1.25 contrast step, measurable but far below what
   reads as "a different kind of row" at 0.9rem. The original gold/white
   pairing worked because it differed in HUE, and hue is the stronger
   signal -- §38.8 records the same finding about references, that a
   lighter or deeper shade reads as "the same thing, emphasised" where a
   different tone reads as a different thing.

   So the top level takes copper (`--toc-h2`) and the levels under it
   stay on the ink ladder. Copper is free here precisely because the
   shard block kept gold: it is the hue that was measured for §41 and
   then not used. Gold returns on hover at every level, where it means
   "you can click this". */
.toc li a { text-decoration: none; color: var(--toc-h2); }
.toc li a:hover { text-decoration: underline; color: var(--accent); }

.toc-l3 { padding-left: 1.1rem; font-size: 0.92rem; }
.toc-l4 { padding-left: 2.2rem; font-size: 0.86rem; }

/* `.toc li.toc-l3 a`, not `.toc-l3 a` -- SPECIFICITY, not source order.
   `.toc li a` above scores (0,2,1) and `.toc-l3 a` only (0,1,1), so the
   deeper levels lost and every row rendered copper however far down the
   file these sat. The bug is invisible in the rule itself: the colours
   are all declared and each one looks right on its own line.

   Matching `li` here brings both to (0,3,1), and the later rule wins on
   order as intended. */
.toc li.toc-l3 a { color: var(--ink); }
.toc li.toc-l4 a { color: var(--muted); }
.toc li.toc-l3 a:hover, .toc li.toc-l4 a:hover { color: var(--accent); }

/* Narrow screens: one column, contents first.

   Collapsing costs the reader the sticky list entirely -- it becomes a
   static block above the prose, scrolls away with the text, and is
   unreachable after that. So the bar for collapsing has to be that the
   two columns genuinely do not fit, not that they fit less than
   perfectly.

   The full budget is:

     17.0  sidebar
      4.0  main's padding
     48.0  --measure
      2.5  --toc-gap
     15.0  --toc-width
     ----
     86.5rem

   and requiring all of it was wrong (§37): a 1440px laptop is 90rem and
   a 1280px one only 80, so every normal window fell through and the
   sticky column was something almost nobody saw. Prose flexing a few
   rem below its ideal measure is a far smaller loss than losing the
   navigation, which is why `--measure` is a `minmax` ceiling in the
   grid rather than a fixed track.

   64rem is where the two columns stop fitting for real: below it the
   prose track would be under ~30rem and the list would be crowding the
   text rather than sitting beside it. */
@media (max-width: 64rem) {
  /* Source order is article-then-nav, so a plain block layout would put
     the contents at the bottom. `column-reverse` puts it back on top
     without touching the markup. */
  /* `stretch` overrides the grid's `align-items: start`, which in a
     flex COLUMN stops the article filling the width and lets it size to
     its content instead -- and a body picture is `width: max-content`,
     so the article took the picture's width (up to `--measure`, 816px)
     on a 400px phone. The prose ran off the right edge, and iOS then
     enlarged it as text wider than the screen. */
  .with-toc {
    display: flex;
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .with-toc > * { min-width: 0; }
  .toc {
    position: static;
    margin: 0 0 1.5rem;
    max-height: 22rem;
  }
}

/* The banner is `position: fixed` and 160px tall, so an anchor jump
   lands the heading *underneath* it -- the reader arrives at a section
   whose title is hidden behind the header. `scroll-margin-top` is what
   offsets that, and it has to be the header's height plus breathing
   room, not a token 1rem. Applies to every heading with an id, not only
   the ones a TOC lists: the ids are emitted corpus-wide, so any
   #anchor link a reader shares has the same problem. */
/* ---------------------------------------------------------------
   Shard-specific content — the gump (§41)
   --------------------------------------------------------------- */

/* The corpus documents Ultima Online; this shard changes some of its
   rules, and a reader has to see which is which without reading closely.

   Built from borders and gradients rather than a bitmap frame, and that
   is the load-bearing decision: these blocks hold anything from one
   sentence to a table, so the frame has to stretch in both directions. A
   scroll graphic has fixed end-caps that do not (the sidebar's scroll
   gets away with it because its height is the viewport's). The corner
   ornaments below are the only image, and they sit at fixed size in the
   corners where nothing needs to stretch.

   Deliberately NOT parchment. The sidebar is already a parchment scroll
   and a second one in the reading column competes with it for the same
   role -- §37 dimmed the sidebar for exactly this reason. This is the
   grey stone gump instead: a panel, in the page's own warm dark tones so
   the prose inside it reads exactly as prose outside it does. The frame
   says "shard-specific"; the text is not made harder to read to say it. */
.shard-block {
  position: relative;
  margin: 2rem 0;
  /* Starts BELOW a floated picture, never beside it. A float displaces
     line boxes only: without this the panel's fill, frame and logo ran
     underneath a `.fig-left` while its words were pushed out to the
     right of it -- logo at the column edge, title 40% across. Clearing
     rather than `display: flow-root` (which would sit the panel beside
     the float): a framed note squeezed into the 60% beside a picture
     reads as a sidebar, and the frame's corner brackets would collide
     with the figure. */
  clear: both;
  /* Extra left padding for the accent bar and the logo above it. */
  padding: 1.3rem 1.6rem 1.3rem 1.9rem;

  /* **Not `--bg-overlay`, and not gold on the left.** Both were tried and
     both collided with `.toc`, which is `--bg-surface` + a 3px gold
     left border a few hundred pixels away on the same screen. Two panels
     with the same fill and the same coloured edge read as the same KIND
     of thing, so a shard note looked like a second contents box. The
     collision is the finding: on a palette this narrow, "a panel with an
     accent edge" is a shape that is already taken.

     So the fill is its own value rather than a surface token -- warmer
     and slightly deeper than `--bg-overlay`, which keeps it a panel
     without being the panel the TOC already is. */
  background-color: #2b2116;
  border: 1px solid var(--line-light);
  border-radius: 2px;

  /* Gold, and the block is what KEEPS it -- the TOC was moved off it
     instead (see `.toc`). This was decided the other way round first, on
     the reasoning that gold already means "structure" so the newcomer
     should take a different hue. That was backwards: the shard logo sitting
     inside this panel is gold, so a copper bar beside a gold emblem put
     two colours on one meaning. The right question is not which element
     arrived last but which one owns the colour -- a shard block is
     CONTENT and the contents list is FURNITURE, so furniture yields.

     Wider than the TOC's 3px as well. */
  border-left: 5px solid var(--accent);

  /* A gump's bevel, as light from above: a faint highlight inside the
     top edge, a dark hairline inside the bottom. Cheaper than a bevel
     image and it scales to any height. The direction follows the fill --
     these were the other way round while the panel was darker than the
     page, which is what a raised edge looks like on a recessed panel. */
  box-shadow: inset 0 1px 0 rgba(232, 220, 196, 0.05),
              inset 0 -1px 0 rgba(0, 0, 0, 0.35),
              0 2px 12px rgba(0, 0, 0, 0.3);
}

/* The logo, top left, as the gump's own corner ornament. A background
   rather than an <img>: it is decoration and must not be read out as
   content, nor selected when an author drags across the block.

   Sized in rem so it tracks the type scale. If shard-logo.png is missing
   this simply draws nothing -- the frame still reads as a frame, which
   is why the padding below does not depend on the image existing. */
.shard-block::before {
  content: "";
  position: absolute;
  top: 1.2rem;
  left: 1.9rem;
  width: 2rem;
  height: 2rem;
  background: url('/static/shard-logo-256.png') center / contain no-repeat;
  opacity: 0.95;
  pointer-events: none;
}

/* Room for the logo. Applied to the block's first child rather than as
   padding on the block, so a block WITHOUT a title indents its opening
   paragraph past the logo just the same. */
.shard-block > :first-child { padding-left: 2.2rem; min-height: 1.6rem; }

/* The title is a real <h2> -- it takes an anchor and appears in the table
   of contents (§36.7), because shard content is content, not an aside.
   Restyled rather than reformatted: it keeps the body's Cinzel and its
   colour, and loses the full-width rule underneath, which inside a framed
   panel would read as a second frame. */
.shard-block .shard-title {
  font: 600 1.05rem/1.6rem 'Cinzel', serif;
  margin: 0 0 0.9rem;
  padding: 0 0 0 2.2rem;
  border-bottom: none;
  /* Gold, with the edge and the logo. */
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* The first child rule above would otherwise indent the paragraph that
   follows a title, leaving a second gap under the logo. */
.shard-block .shard-title + * { padding-left: 0; }

/* The gump's corner brackets (§41).

   They must sit OUTSIDE the frame, straddling it the way a real gump's
   corner ornaments do. The first cut used four background layers with
   `background-origin: border-box`, which puts them just inside the
   border -- and inside a panel they read as four specks floating in the
   fill rather than as corners of anything.

   A background cannot paint outside its own box, so this is an overlay
   element instead: one `::after`, inset by negative margins so its box
   is larger than the block's, carrying all four corners as background
   layers. `pointer-events: none` because it covers the text.

   One pseudo-element rather than four: `::before` is already the logo,
   and there is no third. Four layers on one element cost nothing and
   cannot be selected or read out as content.

   They are the one part of this that is artwork rather than CSS, and
   they earn it -- on a page this dark a fill can only separate from the
   page by ~1.16, so edges and marks are what carry the signal. */
.shard-block::after {
  content: "";
  position: absolute;
  /* Half the 16px art, so each corner straddles the border rather than
     sitting beside it. */
  top: -8px;
  right: -8px;
  bottom: -8px;
  left: -8px;
  background-image:
    url('/static/top-left.png'),
    url('/static/top-right.png'),
    url('/static/bottom-left.png'),
    url('/static/bottom-right.png');
  background-position: left top, right top, left bottom, right bottom;
  background-repeat: no-repeat;
  background-size: 16px 16px;
  pointer-events: none;
}

/* Inside the panel, prose keeps its own spacing but must not push against
   the frame -- a paragraph's top margin at the panel's edge reads as a
   broken border rather than as space. */
.shard-block > :first-child { margin-top: 0; }
.shard-block > :last-child { margin-bottom: 0; }

/* In the EDITOR the same block is an <aside class="shard-block"> with the
   title in an attribute rather than an <h2> -- ProseMirror renders the
   node, and the title is not editable content. Shown through a pseudo
   element so an author sees the name they set without it becoming text
   they can put a cursor in. */
/* In the editor the title lives in an attribute rather than an <h2> --
   ProseMirror renders the node and the title is not editable content --
   so it is drawn by CSS. On `::before`, WITH the logo, because `::after`
   is the corner-bracket overlay and a second rule setting `content`
   there would replace the brackets with the title text. That is a real
   collision, not a hypothetical: it silently removed the corners inside
   the editor while the reading page kept them.

   Two backgrounds and the text on one pseudo-element: the logo is drawn
   as the background, the title as the content beside it. */
.tiptap-host .shard-block[data-title]::before {
  content: attr(data-title);
  width: auto;
  height: auto;
  padding-left: 2.2rem;
  font: 600 1.05rem/1.6rem 'Cinzel', serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background-position: left center;
  background-size: 1.6rem 1.6rem;
}
.tiptap-host .shard-block[data-title] { padding-top: 3.2rem; }

.body h2[id],
.body h3[id],
.body h4[id],
/* A shard block's title carries an id like any other heading, so an
   anchor jump must clear the fixed header the same way. */
.shard-block .shard-title[id],
/* The monster hero's "read guide" link targets a tab panel by id and
   lands the same way when JS is off. */
.monster-tab-panel[id] {
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

/* ---------------------------------------------------------------
   Auth screens (slice 5, §10)

   Login, register, the approval queue and the access toggle. These are
   operator chrome in the sense §18.1 means: enough to read and act on,
   not a designed surface. The forms reuse `.cat-form` from the category
   admin rather than growing a second form idiom.
   --------------------------------------------------------------- */

/* A refused login or a rejected registration. Shares `.notice`'s shape
   and swaps the accent for the danger tone, so the two read as the same
   kind of object in different states. */
.notice.error {
  border-left-color: var(--danger);
  color: var(--text);
}

/* Account status, in the queue and on the access screen. A word, not a
   colour alone -- the three states have to be distinguishable without
   relying on hue. */
.badge {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge-active   { color: var(--ok);     border-color: var(--ok); }
.badge-pending  { color: var(--accent); border-color: var(--accent); }
.badge-disabled { color: var(--danger); border-color: var(--danger); }

/* The row awaiting a decision. The queue's whole purpose is that these
   are findable at a glance, so the tint is on the row rather than only
   on the badge. */
tr.pending { background: rgba(201, 168, 76, 0.06); }

/* The access gate's two positions. Radio rather than a checkbox or a
   single toggle button: the positions have consequences worth reading
   before choosing, and each needs a sentence next to it -- which a
   toggle has nowhere to put. */
.gate-choice {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
}
.gate-choice legend { padding: 0 0.4rem; }
.gate-choice .radio {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin: 0.8rem 0;
  font-size: 0.9rem;
  color: var(--text);
}
.gate-choice .radio input { margin-top: 0.25rem; width: auto; }
.gate-choice .radio .muted { display: block; margin-top: 0.2rem; }

/* Between the two halves of the merged admin screen (§40.8) -- the fixed
   access setting above, the growing account queue below. */
.admin-sep {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0 1.5rem;
}

/* /admin/settings folds each section, so the page reads as a list of headings. */
.settings-section { border-top: 1px solid var(--line); }
.settings-section:last-of-type { border-bottom: 1px solid var(--line); }
.settings-section > summary { cursor: pointer; list-style: none; padding: 0.7rem 0; }
.settings-section > summary::-webkit-details-marker { display: none; }
.settings-section > summary h2 { display: inline; margin: 0; }
.settings-section > summary::before {
  content: "▸"; display: inline-block; width: 1.2rem; color: var(--muted);
}
.settings-section[open] > summary::before { content: "▾"; }
.settings-section[open] { padding-bottom: 1.5rem; }

/* The reader disclaimer (§42), printed at the foot of every page from a
   settings row. Quiet by construction: it is a standing notice rather
   than content, so it takes muted ink at a small size and a rule above
   to separate it from whatever the page ended on.

   No top margin collapse to worry about -- it is the last child of
   <main>, and the pinned action bar authors get is `position: fixed`, so
   this never sits under it. */
.site-disclaimer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}
/* A link inside it stays quiet too. `render_summary` emits real anchors
   (which is why the disclaimer is a block tree and not a string), and
   the page's default link colour is gold -- far too loud for a footer
   nobody is meant to read twice. */
.site-disclaimer a { color: var(--muted); text-decoration: underline; }
.site-disclaimer a:hover { color: var(--ink); }

/* What the admin screen shows under the editor: the same text as a
   reader gets, so an unresolved link or a stray mark is visible before
   it reaches 7,040 pages. */
.disclaimer-preview {
  padding: 0.8rem 1rem;
  border-left: 2px solid var(--line-light);
  color: var(--muted);
  font-size: 0.82rem;
}

/* The shard badge beside a page title (§42): this page carries a shard
   block, so some of what it documents is this shard's rules rather than
   Ultima Online's.

   Derived from the body at render time, never stored -- §41.1 made shard
   content a *node* precisely so this question is a tree walk rather than
   a string match, and a column would be a second copy to keep honest.

   Sized in `em` so it tracks the h1 rather than fixing a pixel height
   the type scale would drift away from. `vertical-align` on the cap
   height, not the baseline: the logo is a square badge and sitting it on
   the baseline leaves it hanging below the letters. */
.shard-badge {
  height: 0.92em;
  width: auto;
  margin-left: 0.4em;
  /* Optically centred on the title's x-height rather than sat on its
     baseline. The mark is a square with its weight in the middle, so
     baseline alignment leaves it riding high against a line of capitals
     -- which is what the type does here (`.entity-head h1` is a small-caps
     serif). Negative, i.e. pushed DOWN from the baseline. */
  vertical-align: -0.1em;
  /* The mark is gold on transparent and the page is near-black, so it
     needs no plate -- unlike the item icons in §38.3, which are cut out
     against the client's light background. */
  opacity: 0.9;
}

/* Who last edited a page, under its title (§42). Quiet: it qualifies the
   content rather than being content, and it sits directly under an <h1>
   where anything loud competes with the title.

   The name is slightly brighter than the sentence around it -- it is the
   part a reader is actually looking for, and "UOGuide" on 7,040 pages is
   a provenance claim worth being able to pick out. */
/* The bottom margin is small because it is NOT the whole gap: `.body`
   adds its own 1.5rem above the first paragraph, and the two stack --
   these are siblings with an element boundary between them, so nothing
   collapses. 1.4rem here read as ~2.9rem on screen, which is where the
   "big gap under the title" came from once the empty `.entity-head`
   spacer was removed above. Left with something rather than zero so the
   byline does not touch the prose on a page that has no head at all. */
.byline {
  margin: -0.4rem 0 0.4rem;
  font-size: 0.78rem;
}
.byline-who { color: var(--ink); }

/* The tag ticks on the edit form (§42.9).
 *
 * They were inheriting `form input { display: block; width: 100% }`,
 * which turns a checkbox into a full-width block: each box rendered on
 * its own line, stretched, pushed to the right of the label it belongs
 * to. The rule is right for text inputs and wrong for the one control
 * whose natural size IS its size -- `.gate-choice .radio` had already
 * had to undo it for the access radios, which is the tell that this is
 * a generic rule reaching too far.
 *
 * A row per tag: box, then name, on one baseline. */
.tag-check {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  /* Overrides `form label`'s 0.9rem, which spaced a list of ticks like
     a column of separate fields. */
  margin: 0.3rem 0;
  color: var(--text);
  cursor: pointer;
}
.tag-check input[type="checkbox"] {
  /* The three that undo the block rule above. `flex: none` keeps the box
     from being stretched by the flex row it now sits in. */
  display: inline-block;
  width: auto;
  flex: none;
  margin: 0;
  /* A checkbox has no baseline of its own, so it aligns by its bottom
     edge and sits low against the text. Nudged up to match. */
  transform: translateY(0.15em);
}
.tag-check .mono { font-size: 0.78rem; }
/* The whole block reads as one control, not as N fields. */
.tag-picker .hint { margin-bottom: 0.5rem; }

/* Centred content in a body (§42.10).
 *
 * A class rather than an inline style, so what "centred" looks like stays
 * in the stylesheet -- the same separation §41.5 kept for the shard block.
 *
 * `.fig-center` was already being STORED on 168 imported images and
 * rendered by nothing: cms/render.py tested for left and right only, so
 * the attribute survived every round trip and did nothing. */
.body .fig-center {
  /* Not a float, unlike its two siblings -- that is the whole difference.
     margin auto is what centres a block whose width is its content's. */
  margin-left: auto;
  margin-right: auto;
  /* `width: fit-content` so the auto margins have something to centre;
     without it the figure is full-width and the margins do nothing while
     looking like they should. */
  width: fit-content;
  max-width: 100%;
}
.body .fig-center img { display: block; margin: 0 auto; }
.body .fig-center figcaption { text-align: center; }

/* A centred PARAGRAPH -- the standfirst under an article title, a line
   an author wants set apart (§42.10). The toolbar's `≡` sets it.
 *
 * This rule went missing between the feature being reverted and being
 * restored: the button set the attribute, `render.py` emitted the class
 * and nothing styled it, so centring silently did nothing. A class with
 * no rule is invisible in exactly the way a wrong rule is not -- there
 * is no declaration to read and find wrong.
 *
 * Not scoped away from `--measure`: a centred line is still prose and
 * belongs in the reading column, unlike a figure. */
.body p.align-center { text-align: center; }
/* Right (§48). Declared in the same place as centre and at the same
   specificity, because the failure this pairs with is the one recorded
   just above: the class was emitted and nothing styled it, so the button
   silently did nothing. A second alignment with no rule would repeat
   that exactly. */
.body p.align-right { text-align: right; }
/* And in the editor, so the author sees it while typing rather than
   after publishing. `.ProseMirror` is the live surface; the bare
   `.tiptap-host` selector covers the static preview. */
.tiptap-host p.align-center,
.tiptap-host .ProseMirror p.align-center { text-align: center; }
.tiptap-host p.align-right,
.tiptap-host .ProseMirror p.align-right { text-align: right; }
/* And in the editor, so the author sees the layout they are choosing
   rather than having to publish to find out. */
.tiptap-host .fig-center { margin-left: auto; margin-right: auto; display: block; }

/* An icon that is a SCREENSHOT, not a sprite (§42.11).
 *
 * §38.3's plate exists because UO art is cut out against the client's
 * light background: on a near-black page a sprite has no edge, and a
 * fixed square gives it one. A dungeon map (199x200), an NPC portrait
 * (235x190) or a quest screenshot is already a rectangle of its own
 * ground, so the plate frames a photo in a picture-frame and shrinks it
 * into a 4.5rem box on the way.
 *
 * `.monster-big-portrait` solved this for monsters by hand and this is
 * the general form -- chosen by the picture's measured size rather than
 * by its domain, because quests hold both kinds (26 sprites, 16
 * screenshots).
 *
 * The thin border and surface padding stay: they separate the image from
 * the page without claiming it needs a plate to be visible, which is the
 * same treatment the monster portrait settled on. */
.entity-icon-bare {
  width: auto;
  height: auto;
  max-width: 260px;
  background: none;
  border: none;
  border-radius: 0;
}
.entity-icon-bare img {
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-surface);
  padding: 0.4rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ====================================================================
 * The spell card (§43)
 *
 * A written-out reading panel for one domain, on §36.2's precedent --
 * the same reason detail.html kept a monster branch after edit.html
 * lost its own. The generic infobox prints eleven equal rows and a
 * spell is not eleven equal facts: `words_of_power` and the effect
 * carried identical weight, so the answer the reader came for sat
 * eleventh in a table.
 *
 * **The frame is structural, not painted.** A double keyline with
 * corner brackets. §38.3 measured that gradients cannot imitate
 * painted grain -- a CSS stone texture was tried and REVERTED -- so
 * this does not attempt a bevelled wooden border, it draws a frame and
 * is honest about being one. When a real border asset arrives it
 * becomes a `border-image` on `.spellcard` alone and these keylines
 * are its fallback; nothing inside the card is positioned against the
 * frame, so the swap moves nothing. */
.spellcard {
  position: relative;
  /* Not the full content column (§43.5). `main`'s 60rem is a slice-1
     default carried by prose, and a fact panel set to a prose measure
     reads as a wall -- the cost cells stretched to 12rem each with the
     numbers marooned at the left. 44rem holds four cells at a
     comfortable width and leaves the card looking like an object on
     the page rather than a band across it. `margin-right: auto` keeps
     it left-aligned with the heading above it, not centred. */
  max-width: 44rem;
  margin: 0 auto 1.75rem 0;
  /* The padding clears the frame's ornament: `border-width` reserves
     the space the art occupies and the padding sits inside that. */
  padding: 1.4rem 1.5rem 1.5rem;
  /* The interior sampled from the art itself (#191512), not
     `--bg-surface`. The frame is painted around a near-black ground,
     so the panel's own fill must match it or a seam shows where the
     border-image's inner edge meets the card. */
  background: #191512;

  /* The painted frame (§43.7). §38.3 established that CSS cannot
     imitate painted grain -- this is the other half of that finding:
     when the art EXISTS, use it, and stop drawing a pastiche.
     `border-image` is what puts it there without an extra element and
     without the picture being content.

     **Served as a cropped 9-slice, not the source PNG.** The original
     is 1131x944 and 712 KB, nearly all of it a dead black centre that
     `border-image` discards anyway -- the card's own background fills
     that. `spell_box_9slice.png` keeps 76px of every edge and collapses
     the middle to two pixels: 154x154 and 45 KB, a 94% saving on
     furniture that appears on 143 pages.

     The slice is 76px because the corner ornament measures ~48px in
     from the opaque edge, plus the 6px of soft outer shadow kept when
     cropping. `fill` is NOT set: the middle of the slice is the
     collapsed 2px strip and painting it would stretch that over the
     whole card. */
  border: 22px solid transparent;
  border-image: url('/static/spell_box_9slice.png') 76 stretch;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}

/* The CSS corner brackets are GONE (§43.7). They were the stand-in
   for a frame that did not exist yet; the art has its own carved
   corners, and drawing gold right-angles on top of them was two
   ornaments competing at the same four points. Deleting them is the
   swap §43.2 promised -- nothing inside the card was positioned
   against the frame, so nothing else moved. */

/* ---- Head: sigil, school, words of power ---- */
.spellcard-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 1.25rem;
}

/* The plate again (§38.3/§42.11), at the size the spell art actually
   is. Spell icons are a uniform population -- the client draws them as
   round sigils at one size -- so unlike `.entity-icon` this slot does
   not have to serve a 24px resource and a 287px monster at once. */
.spell-sigil {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  width: 5rem;
  height: 5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--icon-plate);
  border: 2px solid var(--icon-plate-edge);
  border-radius: 50%;
  overflow: hidden;
}
.spell-sigil img {
  max-width: 88%;
  max-height: 88%;
  object-fit: contain;
}

.spell-ident { flex: 1 1 12rem; min-width: 0; }

.spell-school {
  margin: 0 0 0.3rem;
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  color: var(--ink-bright);
}
/* The circle is a qualifier on the school, so it is quieter than the
   school and not a link -- it points at nothing. Printed as stored
   ("Second"), never rewritten to "2nd": §36.5's rule. */
.spell-circle { color: var(--muted); font-size: 0.9rem; font-family: 'Lora', Georgia, serif; }

.spell-words { margin: 0; font-size: 0.95rem; color: var(--ink); }
.spell-words em { color: var(--ink-bright); font-style: italic; }
/* Uppercase micro-label, the same treatment `.infobox th` gives a
   field name -- this is a label band, just laid out inline. */
.spell-words-label,
.spell-section-label {
  font: 500 0.7rem/1 'Cinzel', serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- The cost strip ----
 *
 * `auto-fit` with a min track, NOT a fixed four columns: the template
 * emits only the cells whose columns are FILLED (§43.1), which is
 * between two and six depending on the spell -- casting_delay is on
 * 113 of 143, magery_circle 64, tithing_points 10. A fixed grid would
 * leave holes on a third of the corpus. */
.spell-costs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

/* A fact card, so it divides the way §38.2 says a fact card divides --
 * a quiet surface and no rules between cells. The label sits above the
 * value because these are read as a row of small facts, not as a
 * label/value table. */
.cost {
  /* One column since §43.3 dropped the two stat icons -- two cells with
     art and two without read as two MISSING pictures rather than as a
     deliberate pair, and neither an animated hourglass nor a
     non-existent target sprite could complete the set. */
  padding: 0.55rem 0.7rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 3px;
}
/* Two icons exist and two are used (§43.3). A cell with no art simply
   has no grid item in the `icon` area and the text takes the row --
   which is why the areas are declared rather than the columns counted:
   an absent icon must not shift the label. */
.cost-label {
  display: block;
  font: 500 0.65rem/1.3 'Cinzel', serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.cost-value {
  display: block;
  font-size: 1.15rem;
  line-height: 1.2;
  color: var(--ink-bright);
}
/* A value that is words rather than a number ("Single target") must not
   be set at numeral size -- it wraps and breaks the strip's rhythm. */
.cost-value:not(:empty) { overflow-wrap: break-word; }

/* Target: a phrase on its own line (§43.6), not a stat cell. The
   longest value is 73 characters and 35 of 136 exceed 24 -- in the
   grid above, one of those set the height of all four cells. */
.spell-target {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  color: var(--ink);
}
.spell-target .spell-section-label { margin-right: 0.4rem; }

/* ---- Reagents ---- */
.spell-reagents {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
/* The comma-run fallback, for a tree that resolved to no chips. */
.spell-reagent-list p { margin: 0; }

/* The reagent chips (§43.3) -- the page's one source of colour, which
   is why the cost cells above give theirs up. The sprite does the
   recognising: a player knows Blood Moss by its shape long before
   reading the word.
 *
 * Still `a.ref`, so it keeps the reference colour and the hover: a
 * reagent is the same KIND of relation as any other typed reference
 * and must not read as a different one. What is added is the picture
 * and a plate to stand it on, not a new link style. */
.reagent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.reagent-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem 0.3rem 0.35rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 999px;
  /* `a.ref` sets a bottom border as its underline; a chip has a real
     border on all four sides, so that one would double up. */
  border-bottom-color: var(--line);
  font-size: 0.92rem;
  line-height: 1.3;
}
.reagent-chip:hover {
  border-color: var(--ref-underline);
  background: rgba(127, 168, 138, 0.09);
}
/* §38.3's plate at chip scale. A reagent sprite is a cut-out drawn
   against the client's LIGHT ground, so on this dark page it needs one
   -- the same reason `.entity-icon` has one, sized down. A chip with no
   icon (`Daemon Bone`) simply has no img and the padding closes up.
 *
 * **Sized from the art, not chosen by eye** (§38.3's rule, and the
 * first cut broke it): 13 of the 15 reagent sprites are 50x50 PIXELS
 * and the 22px circle was discarding more than half of that -- the
 * icons were present, uniform and too small to recognise, which is
 * the whole reason they are here. 34px shows the sprite at a size a
 * player reads as the pack icon it is.
 *
 * The two outliers (`Fertile_Dirt` 17x18, `Dragons_blood_pagan` 8x20)
 * are SMALLER than the slot and `object-fit: contain` leaves them at
 * their own size rather than upscaling them into mush -- one plate
 * with a small sprite centred in it, which is exactly what the plate
 * is for.
 *
 * **Round, by the author's eye, and it was tried square first.** The
 * argument for a square was §38.3's -- the plate is square because a
 * 50x50 sprite is -- and on this element it loses: a reagent sprite
 * does not fill its tile to the corners (the art sits in a
 * transparent margin), so nothing is actually clipped, and the round
 * plate reads as a pack slot next to `.spell-sigil`'s round frame a
 * few pixels above. Do not "correct" this back to a square on §38.3's
 * authority; the measurement it rests on does not hold here. */
.reagent-chip img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  padding: 3px;
  background: var(--icon-plate);
  border: 1px solid var(--icon-plate-edge);
  border-radius: 50%;
  flex: 0 0 auto;
}

/* ---- Quests (§43.9) ----
 *
 * The card itself is `.spellcard` -- same frame, same width, same
 * interior -- because it is the same object. What differs is what
 * sits inside it. */

/* A quest icon is not a spell sigil: 68 of 377 have one and they are
   a mixed population (§42.11 measured 26 sprites against 16
   screenshots), so this is the SQUARE plate `.entity-icon` uses, not
   the round sigil frame. `.entity-icon-bare` still overrides it for a
   screenshot, exactly as on the standard page. */
.quest-icon {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  width: 4.5rem;
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--icon-plate);
  border: 2px solid var(--icon-plate-edge);
  border-radius: 4px;
}
.quest-icon img { max-width: 88%; max-height: 88%; object-fit: contain; }

/* `Domain.flags` (§23.13): the word, printed only when the flag is
   set. "no longer available" is a warning a player wants before
   walking to the giver, so it reads as a notice rather than a field --
   which is also why it is not in the strip above. */
.quest-flags { margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.quest-flag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: rgba(196, 68, 68, 0.12);
  border: 1px solid rgba(196, 68, 68, 0.35);
  border-radius: 3px;
  font: 500 0.7rem/1.4 'Cinzel', serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #d98a8a;
}

/* The three block fields, stacked. Each is a panel rather than a table
   row because each holds a SENTENCE with references in it -- `5 Ogre,
   5 Ettin`, `Cloorne the Expeditionist` -- and a two-column table
   squeezed those into a narrow cell beside a label band. */
.quest-panels { display: flex; flex-direction: column; gap: 0.7rem; }
.quest-panel {
  padding: 0.75rem 0.95rem;
  background: rgba(201, 168, 76, 0.05);
  border: 1px solid var(--line-light);
  border-left: 2px solid var(--toc-edge);
  border-radius: 3px;
}
.quest-panel .spell-section-label { display: block; margin-bottom: 0.35rem; }
.quest-panel-body { font-size: 1rem; line-height: 1.5; color: var(--ink-bright); }
.quest-panel-body p { margin: 0; }

/* ---- The effect panel ----
 *
 * Last and largest: it is the answer to the question the reader
 * arrived with. A lighter surface than the cost cells so it reads as
 * the card's subject rather than another fact. */
.spell-effect {
  padding: 0.9rem 1.1rem;
  background: rgba(201, 168, 76, 0.05);
  border: 1px solid var(--line-light);
  border-left: 2px solid var(--toc-edge);
  border-radius: 3px;
}
.spell-effect-body {
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink-bright);
}
.spell-effect-body p { margin: 0 0 0.5rem; }
.spell-effect-body p:last-child { margin-bottom: 0; }

.spell-duration {
  margin: 0.7rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  color: var(--ink);
}

/* One column on a phone. The sigil keeps its size -- it is the page's
   identifying picture, not decoration to shrink away. */
@media (max-width: 34rem) {
  /* A 22px frame on a 320px screen eats a seventh of the width each
     side, so it thins with the card. `border-image-slice` is unchanged
     -- only the width the art is painted into. */
  .spellcard { padding: 1rem 0.9rem 1.1rem; border-width: 14px; }
  .spell-costs { grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); }
}

/* ---------------------------------------------------------------
   Batch delete and backups
   --------------------------------------------------------------- */

/* A notice whose consequence reaches beyond the page being acted on.
   Distinguished from `.notice` by hue rather than by weight or size, on
   §42.14's measurement: the plain notice is the accent edge, this one is
   the danger edge, and the two read apart at a glance without either
   shouting. Not `.error-box` -- nothing has gone wrong, the operator is
   being told what a button will do. */
.notice-warn {
  border-left-color: var(--danger);
}
.notice-warn h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

/* The list of pages a delete would unlink. Capped in the template at 40
   rows, so this only has to stay readable at that length. */
.unlink-list {
  max-height: 18rem;
  overflow-y: auto;
}

/* The tick column. Sized to its content so the title column keeps the
   width it had -- a checkbox column that takes a share of the table is
   one that pushes every listing's titles inward for a control most
   visits never use. */
.tick-col {
  width: 1.5rem;
  text-align: center;
}
/* §42.9 again: the generic `form input` rule makes every input a
   full-width block, which turns each tick into a row-height bar. The
   third element to need this override -- `.gate-choice .radio` and the
   tag ticks were the first two. */
.tick-col input[type="checkbox"] {
  width: auto;
  margin: 0;
  display: inline-block;
}

.listing-new {
  margin: 0.8rem 0;
}

/* A tab's batch buttons, one bar per tab panel. The buttons are outside
   the tick form and reach it with `form=`, so they are styled by their
   own class rather than by a descendant selector.

   STICKY, because the listings are long -- 1,890 items -- and the whole
   point of the ticks is choosing rows that are nowhere near the top. A
   selection made at row 900 with the button scrolled off screen means
   scrolling back up to act on it, and the count (which is the only thing
   telling you how many are ticked) is up there with it.

   `top` is the fixed banner's height, the same offset `scroll-margin-top`
   uses for heading anchors (§36.7): the header is `position: fixed` and
   160px tall, so a sticky element that stops at 0 parks underneath it.

   The background is opaque and NOT inherited -- rows scroll behind this
   bar, and at anything less than full opacity the table reads through it
   as a smear. That is the call `.searchform` made in §37 and the nav band
   made in §40.8. */
.listing-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0.8rem 0 1rem;
  flex-wrap: wrap;

  position: sticky;
  top: var(--header-height);
  z-index: 20;
  background: var(--bg);
  /* Pulled out to the measure's edges and padded back, so the opaque
     band spans the column rather than ending flush with the buttons and
     letting rows show through beside them. */
  margin-left: -1rem;
  margin-right: -1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
}
button.danger-btn {
  color: var(--danger);
  border-color: var(--danger);
}
/* A disabled batch button must not look like an enabled one. It is
   disabled whenever nothing is ticked, which is most of the time. */
button.danger-btn:disabled {
  color: var(--muted);
  border-color: var(--line);
  cursor: default;
}

/* Empty forms a listing's controls reach through `form=` (HTML forbids a
   nested form). They must occupy no space. */
.hidden-form {
  display: none;
}

/* Download / Restore / Delete sit on one row per backup. */
.backup-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

/* The accounts table on /admin.
   --------------------------------------------------------------- */

/* Wide by nature -- eight columns, four of them controls -- so it scrolls
   sideways inside the column on a narrow screen rather than squeezing
   every select to a letter. Only narrow: a scroll container would trap the
   sticky header below, which keeps the column names in view down the list. */
@media (max-width: 70rem) { .table-scroll { overflow-x: auto; } }
@media (min-width: 70.01rem) {
  .accounts-table th { position: sticky; top: var(--header-height); z-index: 10; background: var(--bg); }
}
.accounts-table td { vertical-align: middle; }
/* Eight columns fit the content width only with the cell padding tight:
   at the default 0.6rem a side the table overran by a few rem and the
   last column (Disable / Delete) sat behind a horizontal scroll. */
.accounts-table th,
.accounts-table td { padding-left: 0.4rem; padding-right: 0.4rem; }
.accounts-table .nowrap { white-space: nowrap; }
/* The email under the username: clipped, the full address in its tooltip, so one long address does not set the column. */
.accounts-table .acct-email { display: inline-block; max-width: 14rem; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: bottom; }
.accounts-table .unconfirmed { color: var(--accent); cursor: help; margin-left: 0.25rem; }

/* §42.9 for the fifth time: the generic `form select` rule is
   `width: 100%`, and 100% of a cell the table is busy shrinking is one
   character -- the role select read "a". Sized to the longest option
   instead, which is what a select in a row of controls wants. No floor:
   a yes/no select at a role select's width is space the table lacks. */
.accounts-table select {
  display: inline-block;
  width: auto;
  margin: 0;
}
/* The tool levels (§68): a word of two or three letters needs neither
   the generic padding nor the full font, and three of these sat at the
   width of "standard" each until the Delete column fell off the page. */
.accounts-table select.compact {
  padding: 0.2rem 0.25rem;
  font-size: 0.85rem;
}
/* Tool headers wrap onto two short lines rather than widening the column
   to "Quest editor". */
.accounts-table th { white-space: normal; }

/* Generate above, type-and-Set below, the hint under both. A <div>
   inside the cell, never `display: flex` on the <td>: that takes the cell
   out of table layout and the row's other cells pay for its width. */
.password-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}
.password-tools .inline-form { align-items: center; }
/* §42.9 for the fourth time: the generic `form input` rule makes every
   input a full-width block, which here would put the Set button on its
   own line under a stretched field. */
.password-set {
  width: 7.6rem;
  margin: 0;
}

/* Disable / Delete, stacked to one width so the column stays narrow. */
.account-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.account-actions .inline-form,
.account-actions button { width: 100%; }

/* The redirect after an account action lands on its row (`#account-N`)
   or the section (`#accounts`). The banner is `position: fixed`, so
   without the offset the target scrolls up underneath it (§36.7). */
.account-row,
.admin-anchor { scroll-margin-top: calc(var(--header-height) + 1rem); }
/* The row just acted on, so the eye finds it after the jump. */
tr.acted { background: rgba(201, 168, 76, 0.08); }
/* The band under it carries the outcome; the row's rule would otherwise
   cut it from its own result. */
tr.acted:has(+ .row-result) td { border-bottom-color: transparent; }
tr.acted + .row-result { background: rgba(201, 168, 76, 0.08); }
.row-result td { padding-top: 0; }
.row-result .notice { margin: 0.2rem 0 0.4rem; }

/* Shown once, meant to be read off the screen and typed. Large and
   selectable rather than styled as prose -- it is a credential being
   handed over, and the failure is misreading a character. */
.new-password {
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  user-select: all;
  padding: 0.4rem 0.6rem;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  display: inline-block;
}

/* The copy button copy_value.js puts beside it. Quiet until hovered,
   like the password eye: it is furniture beside the credential, and the
   credential is what the admin must read. */
.copy-value {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 0.4rem;
  padding: 0.35rem;
  line-height: 0;
  color: var(--muted);
}
.copy-value:hover { color: var(--accent); }
.copy-value.copied { color: var(--ok); border-color: var(--ok); }

/* ---------------------------------------------------------------
   "What links here" (§44)
   --------------------------------------------------------------- */

/* Collapsed by default and quiet: it sits above the content on every
   author's page load, so it must not compete with the title. The rule
   above it separates it from the byline without needing a fill. */
.inbound-panel {
  margin: 0.8rem 0 1.2rem;
  padding: 0.5rem 0 0;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}
.inbound-panel > summary {
  cursor: pointer;
  color: var(--muted);
  /* The marker stays -- it is the only thing saying this opens, and the
     panel is collapsed on arrival. */
  list-style: revert;
}
.inbound-panel > summary:hover { color: var(--ink); }
.inbound-panel[open] > summary { margin-bottom: 0.5rem; }

/* 534 entries on the corpus's most-linked page, so the list scrolls
   inside the panel rather than pushing the article off the screen. */
.inbound-list {
  max-height: 22rem;
  overflow-y: auto;
  margin: 0;
  columns: 2;
  column-gap: 2rem;
}
.inbound-list li {
  break-inside: avoid;
  margin-bottom: 0.15rem;
}
@media (max-width: 60rem) {
  .inbound-list { columns: 1; }
}

/* Edit and Unpublish share a cell. `white-space: nowrap` keeps the pair
   on one line so the actions column does not grow a second row per
   listing entry. */
/* `inline-flex` on a WRAPPER inside the cell, not `flex` on the <td>.
   A table cell's `display` is `table-cell` from the UA stylesheet, and
   overriding it to `flex` makes the element stop being a cell -- which
   drops it out of the table's column layout and lets the two controls
   stack. The cell stays a cell; the wrapper does the aligning.

   `align-items: center` because the pair is a <button> and an <a>: they
   are different elements with different baselines, so leaving them on
   the text baseline sits Unpublish a pixel or two below Edit. */
.row-actions-inner {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  white-space: nowrap;
}
.row-actions { white-space: nowrap; }
/* Unpublish and Archive are REVERSIBLE, so they must not borrow the
   delete affordance: `.btn.subtle` turns red on hover, which is the
   vocabulary for the one irreversible operation in the app. This keeps
   them muted throughout. Matched on the route rather than a class so a
   new reversible link cannot pick up red by forgetting one -- `*=` and
   not `$=`, because Archive's href carries `?then=archive`. */
.row-actions .btn.subtle:hover,
.actions-pinned .btn.subtle[href*="/unpublish"]:hover {
  color: var(--ink);
  border-color: var(--ink);
}

/* The inbound-link count in a listing (§44). Reference only -- it is not
   a link, so it takes no link colour. Right-aligned and narrow: a column
   of numbers is read by comparing magnitudes, and left-aligned digits of
   different widths do not line up to be compared. */
.links-col {
  text-align: right;
  width: 4rem;
  font-variant-numeric: tabular-nums;
}

/* Fixed layout takes column widths from the header row, so the browser draws the
   table without first measuring all ~2,000 rows. Title and Slug share what is left. */
#listing-table { table-layout: fixed; }
#listing-table .kind-col { width: 6rem; }
#listing-table .group-col { width: 7rem; }
#listing-table .actions-col { width: 17rem; }
#listing-table .slug-col { overflow-wrap: anywhere; }

/* The selected period on /recent (§45). A <span>, not a link -- it goes
   nowhere -- so it needs the button's shape without its affordance:
   filled rather than outlined, and no pointer cursor. */
.btn.current {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  cursor: default;
}

/* ---------------------------------------------------------------
   Picture grids (§48)
   ---------------------------------------------------------------

   A row of pictures laid out side by side -- the staff roster, five
   armour tooltips, a pair of tileset screenshots. The corpus's own pages
   are full of this shape and the body vocabulary had no way to say it.

   Deliberately NOT a table. §38.2 keeps a data grid's rules because a
   five-column crafting spec is where a lost row is a real error; using
   one for layout means turning those rules off per-instance and handing
   `data-sortable` plus screen-reader table semantics to something that
   is not tabular.

   `auto-fit` + `minmax` rather than a fixed column count is what makes
   this survive a narrow window: the row reflows to however many fit and
   the pictures stay legible, instead of a five-across grid becoming five
   unreadable slivers on a phone. An author's `columns` sets the ceiling
   through `--gallery-columns`; the wrap still happens underneath it. */
.body .gallery {
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(min(var(--gallery-min, 12rem), 100%), 1fr));
  gap: 1.4rem 1.2rem;
  margin: 1.4rem 0;
  align-items: start;
}

/* An author-set count is EXACT, not a ceiling `auto-fit` negotiates
   against.
 *
 * The first cut expressed it as a floor -- `max(12rem, 100%/N)` inside
 * the `minmax` above -- reasoning that a count could cap the track width
 * and let `auto-fit` do the rest. It cannot: at five columns each track
 * computes to about 7rem, the 12rem floor raises it back, and five
 * across silently renders as three then two. The author asked for five
 * and the stylesheet quietly disagreed, which is the failure mode a
 * declared value must never have.
 *
 * `repeat(N, 1fr)` obeys instead. The narrow-screen case is handled by
 * the media query below rather than by arithmetic, because those are two
 * different questions and folding them into one expression is what
 * produced the contradiction. */
.body .gallery[style*="--gallery-columns"] {
  grid-template-columns: repeat(var(--gallery-columns), 1fr);
}

/* Below the reading measure, an exact count stops being a service to the
   reader: five armour tooltips across a phone are five slivers. The
   count is dropped and the row reflows on the picture's own minimum --
   which is the unset gallery's behaviour, so a narrow screen renders
   every gallery the same way regardless of what was declared. */
@media (max-width: 48rem) {
  .body .gallery[style*="--gallery-columns"] {
    grid-template-columns: repeat(
      auto-fit,
      minmax(min(var(--gallery-min, 12rem), 100%), 1fr));
  }
}

/* The figures inside lose the margins and floats they carry as ordinary
   body images -- the grid owns the spacing now, and a float inside a grid
   cell does nothing except confuse the next rule that reads it.
   Specificity has to beat `.body .fig-left`/`.fig-right` (0,2,0), which
   is why these are written at (0,3,0) rather than as a bare `.fig`. */
.body .gallery .fig,
.body .gallery .fig-left,
.body .gallery .fig-right,
.body .gallery .fig-center {
  float: none;
  margin: 0;
  width: auto;
  max-width: 100%;
}

/* Pictures align on a common baseline, and this is the rule that makes a
   gallery read as a ROW rather than as scattered pieces.
 *
 * UO art runs from a 20px amulet to a 200px map -- §38.3's three
 * measured populations -- so a row at natural size puts every caption at
 * a different height and the eye has nothing to track along. That is not
 * a hypothetical: the first cut of this shipped with `height: auto` and
 * the five armour tooltips came out on five different baselines, which
 * is the same ragged-column problem §38.3 solved for table icons with a
 * fixed slot.
 *
 * The figure is a flex column with a fixed-height picture area, so the
 * caption starts at the same y in every cell whatever is drawn above it.
 * `object-fit: contain` keeps each sprite's proportions inside that
 * area -- nothing is cropped or stretched, it is centred in a slot. */
.body .gallery .fig {
  display: flex;
  flex-direction: column;
}
.body .gallery .fig img {
  /* No plate: no border, no fill, no radius, overriding the ones
     `.body .fig img` gives an ordinary body picture.
   *
   * §38.3's plate exists because UO art is cut out against the client's
   * LIGHT background, so a sprite has no edge on a dark page. That
   * reasoning is about a lone sprite in a table cell. It works against a
   * gallery: the plate is a fixed box the picture must fit INSIDE, so a
   * tooltip screenshot -- which is already a framed, opaque image with
   * its own dark ground -- gets letterboxed into a slot smaller than the
   * cell and reads as a stamp rather than as the picture. The grid
   * already supplies the alignment the plate was giving.
   *
   * Reverting is restoring these three declarations. */
  border: none;
  background: none;
  border-radius: 0;

  /* Sized to the cell rather than to a fixed slot. `height: auto` with a
     max is what lets a tall tooltip use the room a short sprite does not
     need, instead of every picture being letterboxed into the same box.
     The captions no longer share a baseline as exactly as they did --
     that was the plate's doing, and it is the trade being tested here. */
  width: 100%;
  height: auto;
  max-height: var(--gallery-height, 20rem);
  object-fit: contain;
  display: block;
}
/* An author who set a width on a picture meant it, so that one opts out
   of the shared slot rather than being stretched to fill it. */
.body .gallery .fig img[width] {
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}

/* The caption is the label under each picture -- the staff member's name,
   what the tooltip is showing. Centred under its own image rather than
   set to the reading measure: it belongs to the picture above it, not to
   the prose flow, and `.body .fig figcaption`'s 24rem cap would otherwise
   run one caption wider than the slot it sits in. */
.body .gallery .fig figcaption {
  max-width: 100%;
  text-align: center;
  margin-top: 0.45rem;
  /* Aligns the TOP of every caption, which is what a reader scanning the
     row actually follows. A two-line name (`Vallymar — Administrator /
     Dev`) then grows downwards and leaves its neighbours where they are,
     instead of pushing its own picture up out of line. */
  align-self: stretch;
}

/* And in the editor, so the author sees the grid while typing rather
   than a vertical stack that rearranges itself on save. `.ProseMirror`
   is the live surface; the bare `.tiptap-host` covers the static
   preview -- the same pairing `.align-center` uses above. */
.tiptap-host .gallery,
.tiptap-host .ProseMirror .gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(10rem, 100%), 1fr));
  gap: 1rem;
  padding: 0.6rem;
  /* A dashed edge only in the editor: a gallery is invisible as a
     container once its pictures are in place, and an author needs to see
     what they are adding a picture to. Nothing dashed reaches the
     reading page. */
  border: 1px dashed var(--line);
  border-radius: 4px;
}
.tiptap-host .gallery img { width: 100%; height: auto; }

/* The draft-preview banner (§49).
 *
 * This page is byte-for-byte what publishing will produce -- that is the
 * point of rendering a preview through `detail.html` rather than through
 * a template of its own. It is also the hazard: without a marker there is
 * nothing on screen to distinguish a preview tab from the live page, and
 * an author who leaves one open comes back to it later believing the
 * change is published.
 *
 * `sticky` rather than `fixed`: a body can run past the viewport many
 * times over and the marker has to survive scrolling, but a fixed bar
 * would need `--header-height` accounting on a page that already pins an
 * action bar at the foot (§38.8's warning about moving that number).
 * Sticky costs nothing and needs no offset.
 *
 * The danger tone, not the accent: this is a state the author needs to
 * leave, not a feature of the page. */
.preview-banner {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-surface);
  border-left: 3px solid var(--danger);
  border-radius: 0 4px 4px 0;
  padding: 0.6rem 0.8rem;
  margin: 0 0 1rem;
  font-size: 0.9rem;
  /* Fully opaque, for §40.8's reason: a translucent bar over body text
     reads as a shadow rather than as a control, and this one is the only
     thing telling an author the page is not live. */
  opacity: 1;
}
.preview-banner a { margin-left: 0.6rem; }

/* The link backlog (§62). Each ambiguous target is its own form, boxed
   so the choice and the ticks it applies to read as one unit -- a
   stray click on the next group's button would otherwise look like it
   belonged to this one. The page list is a flat column of ticks, not a
   table: there is nothing to compare across rows. */
.backlog-tabs { margin: 0 0 0.6rem; }
.ambiguous-group {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem 1rem 0.9rem;
  margin: 1rem 0;
  background: var(--bg-surface);
}
.ambiguous-group h2 { margin: 0 0 0.4rem; font-size: 1rem; }
.ambiguous-group .gate-choice { margin: 0 0 0.5rem; }
.ambiguous-pages { list-style: none; margin: 0 0 0.6rem; padding: 0;
                   columns: 2; column-gap: 2rem; }
.ambiguous-pages li { break-inside: avoid; padding: 0.1rem 0; }
.ambiguous-pages input { width: auto; margin-right: 0.35rem; }
@media (max-width: 700px) { .ambiguous-pages { columns: 1; } }

/* The show/hide eye (password_reveal.js). The wrapper is created by the
   script, so these rules only ever apply to a page where the button
   works. The input keeps whatever width its form gives it; the eye sits
   inside its right edge, with padding so a long password never runs
   under the icon -- which is exactly where the typo would be. */
.password-wrap { position: relative; display: block; margin-top: 0.25rem; }
.inline-form .password-wrap { display: inline-block; margin-top: 0; }
/* The field's own top margin moves to the wrapper, or the eye -- centred
   on the wrapper -- sits a few pixels below the field's centre. */
.password-wrap input { padding-right: 2.2rem; margin-top: 0; }
.password-reveal {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  display: flex;
  padding: 0.2rem;
  margin: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  line-height: 0;
}
.password-reveal:hover,
.password-reveal[aria-pressed="true"] { color: var(--accent); }
.password-reveal:focus-visible { outline: 1px solid var(--accent); border-radius: 3px; }


/* ---------------------------------------------------------------
   The Chronicle (§69.3)
   ---------------------------------------------------------------

   A week reads as a paper, not a log: the lead set large, four stories
   as the front page, then the rest under their kind of deed, headline
   only. The scale does that work, so no box or card is drawn round any
   of it -- the stories are prose on the page like an article's. */
.chronicle-masthead { margin-bottom: 1.5rem; }
.chronicle-masthead h1 { margin-bottom: 0.2rem; }
.chronicle-masthead p { margin: 0; }

.chronicle-lead {
  padding-bottom: 1.2rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--line-light);
}
.chronicle-lead h2 { font-size: 1.7rem; margin-top: 0; }
.chronicle-lead p { font-size: 1.08rem; }

/* Two columns where there is room for two: four short stories side by
   side are a front page; stacked they are a list. */
.chronicle-front {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem 2rem;
  margin-bottom: 1rem;
}
.chronicle-story h3 { margin-top: 0.4rem; }
@media (max-width: 50rem) {
  .chronicle-front { grid-template-columns: 1fr; }
}

.chronicle-section ul { list-style: none; padding: 0; margin: 0; }
.chronicle-section li { margin: 0.35rem 0; }
.chronicle-section summary { cursor: pointer; color: var(--ink-bright); }
.chronicle-section details p { margin: 0.3rem 0 0.2rem 1.1rem; }
.chronicle-section .chronicle-byline { margin-left: 1.1rem; }
.chronicle-headline { margin: 0; color: var(--ink-bright); }
.chronicle-city-mark { display: inline-block; width: 1em; color: var(--muted); }
.chronicle-cities .is-rose .chronicle-city-mark { color: var(--ok); }
.chronicle-cities .is-fell .chronicle-city-mark { color: var(--danger); }
.chronicle-city-story { margin: 0.2rem 0 0.2rem 1.1rem; }

.chronicle-byline { font-size: 0.82rem; margin: 0.2rem 0 0.6rem; }
.chronicle-byline time { border-bottom: 1px dotted var(--muted); cursor: help; }

/* A first or a record: the gold that means "this is the shard's" (§41.6),
   small, so a week of firsts does not shout. */
.chronicle-legend {
  font-family: 'Cinzel', serif;
  font-size: 0.62em;
  letter-spacing: 0.05em;
  color: var(--accent);
  white-space: nowrap;
  vertical-align: middle;
}
.chronicle-repeat {
  font-size: 0.7em;
  font-style: italic;
  color: var(--muted);
  white-space: nowrap;
}
.chronicle-quiet { font-style: italic; color: var(--muted); }

.chronicle-pager {
  display: flex;
  gap: 1.5rem;
  margin-top: 2rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.chronicle-archive { list-style: none; padding: 0; }
.chronicle-archive li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.chronicle-archive a { display: flex; gap: 1rem; align-items: baseline; flex: 1; }
.chronicle-archive-week {
  flex: 0 0 13rem;
  color: var(--muted);
  font-size: 0.9rem;
}
@media (max-width: 50rem) {
  .chronicle-archive a { flex-direction: column; gap: 0.1rem; }
  .chronicle-archive-week { flex: none; }
}
