/* Hearth root rules (253.1, Tom 15 Nov 17:04 / 17:15; Lumi's brief). Loaded LAST, after every screen's own CSS.
   Each rule is written once here; a screen opts in by using the shared component class, never by a patch of its own.
   Sizes come from ui/root-tokens.css; colours from the theme tokens. Signed layouts (digital sheet, Fold L, GM big screen,
   the 253 Fold-open arch portrait) keep their own sizes: the rules only take effect where a component opts in, plus the
   one rule marked GLOBAL (headings balance their lines).

   Specificity: a screen's own rule (".gmx .gmx-card") outranks one class, so the components double their class
   (".r-panel.r-panel") and, loaded last, win without !important.
   Shared components:
     .r-panel   a flex column that scrolls as ONE box (rule 2); its parts never squash below their content
     .r-scroll  a list box that scrolls on its own (rule 2); inside an .r-panel it grows instead (one scroller only)
     .r-sheet   a pop-up / bottom sheet (rule 3): fits the window between the bars and above the keyboard; .r-sheet-head
                and its Done / x stay put, .r-sheet-body scrolls, and starts below a corner x (.r-sheet-x)
     .r-grid    a grid of cells (rule 5): as many columns of at least --cell as fit the box, rows sized to content
     .r-card    a card (rules 4, 8, 12): wraps words, never spills; a container for container queries
     .r-toolbar a one-row toolbar that never scrolls sideways: what does not fit goes under More (ui/root-rules.js);
                with data-r-labels="hold" it shows icons, and a button's name on press-and-hold or hover (.r-tip)
     .r-media   a picture box (rule 7): keeps its aspect ratio, the picture covers it
     .r-chip    a coloured chip (rule 6): its text is light or dark to suit its colour (--chip)
     .r-pill / .r-seg   a pill, a chip or a segmented group of options (253.1 fix-back rule 1): its text is on one line,
                never narrower than its words, never broken mid-word, never clipped
     .r-chip-row  a row of pills / chips / filters (fix-back rule 2): wraps inside its panel's content box; with
                .r-chip-scroll (or .r-chip-short on a short screen) it scrolls sideways instead, with an edge fade and snap
     .r-card-line  one line of a card (fix-back rule 3): .r-card-text keeps --card-text-min; in a card narrower than the
                step (26rem) the actions sit under the text; a .r-seg-line (a segmented group) always has its own line
   Rule 1 (keyboard), rule 6 (automatic readable ink) and rule 8 (48 dp touch areas) also have a part in ui/root-rules.js. */

/* ---------- rule 4: text fits its box. In the shared components (cards, panels, sheets, text) a word too long for its
   line breaks rather than running out ("anywhere" is not used: Tom 14:33, no mid-word breaks such as "Advantag-e"; a
   break inside a word gets a hyphen where the language allows). Not set on the whole page: on the signed digital sheet
   at Fold-shut width it broke "one-handed" mid-word in the weapon card, and signed layouts stay exactly as they are.
   Headings (GLOBAL) balance their lines. ---------- */
:where(h1, h2, h3, .r-title) { text-wrap: balance; }
.r-card, .r-text, .r-panel, .r-sheet-body { overflow-wrap: break-word; }
.r-card, .r-text { min-width: 0; }
.r-clamp-2.r-clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* ---------- rule 2: panels and lists that must scroll ---------- */
.r-panel.r-panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow-y: auto; overscroll-behavior: contain; container-type: inline-size; }
.r-panel.r-panel > * { flex-shrink: 0; }
.r-scroll.r-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.r-panel.r-panel .r-scroll.r-scroll { flex: 0 0 auto; min-height: auto; overflow: visible; }

/* ---------- rule 3: pop-ups and sheets ---------- */
.r-sheet.r-sheet { display: flex; flex-direction: column; min-height: 0;
  max-height: calc(100dvh - var(--hearth-safe-top, 0px) - var(--hearth-safe-bottom, 0px) - var(--kb-h)); }
.r-sheet > .r-sheet-head { flex: none; }
.r-sheet.r-sheet > .r-sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.r-sheet.r-sheet:has(> .r-sheet-x) > .r-sheet-body { margin-top: calc(var(--tap-visual) - var(--sp-1)); }

/* A pop-up that sits inside a screen's own stage (not the window): it also stays inside that stage, so nothing of it
   is under a bar below the stage (253.1 fix-back rule 4: the map builder's Map size). */
.r-sheet.r-sheet-in { max-height: min(calc(100% - 2 * var(--sp-3)), calc(100dvh - var(--hearth-safe-top, 0px) - var(--hearth-safe-bottom, 0px) - var(--kb-h))); box-sizing: border-box; }

/* ---------- fix-back rule 1: one-line controls never wrap ----------
   A pill, a chip and each option of a segmented group is one line of text and never narrower than its words. A row that
   cannot hold them wraps (.r-chip-row), and a segmented group drops onto its own line under the card's content
   (.r-seg-line in a .r-card-line). */
.r-pill.r-pill, .r-seg.r-seg > * { white-space: nowrap; flex: 1 0 auto; min-width: max-content; overflow: visible; text-overflow: clip; hyphens: none; overflow-wrap: normal; word-break: normal; }
.r-seg.r-seg { display: flex; flex-wrap: wrap; max-width: 100%; box-sizing: border-box; }
/* ---------- fix-back rule 2: chip and filter rows wrap inside their panel ---------- */
:where(.r-chip-row) { gap: var(--sp-1) var(--r-gap, var(--sp-1)); }
.r-chip-row.r-chip-row { display: flex; flex-wrap: wrap; min-width: 0; max-width: 100%; box-sizing: border-box; }
/* .r-scroll-x: any row that scrolls sideways shows it: its far edge fades out and its items snap, so an item cut at the
   edge reads as "more this way", not as a broken layout (.r-chip-scroll is a chip row that scrolls this way) */
.r-scroll-x.r-scroll-x, .r-chip-row.r-chip-scroll { overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(90deg, var(--c-black) calc(100% - var(--sp-5)), transparent 100%); mask-image: linear-gradient(90deg, var(--c-black) calc(100% - var(--sp-5)), transparent 100%); }
.r-chip-row.r-chip-scroll { flex-wrap: nowrap; overflow-y: hidden; }
.r-scroll-x > *, .r-chip-row.r-chip-scroll > * { scroll-snap-align: start; flex: none; }
/* .r-chip-short: on a short screen (a phone on its side) the chip row scrolls sideways the same way rather than taking
   three of the few lines there are */
@media (max-height: 29.99em) { .r-chip-row.r-chip-short { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(90deg, var(--c-black) calc(100% - var(--sp-5)), transparent 100%); mask-image: linear-gradient(90deg, var(--c-black) calc(100% - var(--sp-5)), transparent 100%); }
  .r-chip-row.r-chip-short > * { scroll-snap-align: start; flex: none; } }
/* the same cue where a row only scrolls sideways on a narrow screen (the map builder's category icons on a phone) */
@media (max-width: 37.49em) { .r-scroll-x-phone { scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(90deg, var(--c-black) calc(100% - var(--sp-5)), transparent 100%); mask-image: linear-gradient(90deg, var(--c-black) calc(100% - var(--sp-5)), transparent 100%); }
  .r-scroll-x-phone > * { scroll-snap-align: start; } }
/* ---------- fix-back rule 3: a card's text column keeps its least width ----------
   .r-card-line (on the .r-card itself, which is the query container): lead, text, actions on one line while the card
   is at least the step wide (26rem = --card-text-min + the widest set of actions); narrower, the text has the first line
   to itself and the actions sit under it. The same step for every card. */
.r-card-line.r-card-line { display: flex; flex-wrap: wrap; align-items: center; }
.r-card-line.r-card-line > .r-card-text { flex: 1 1 var(--card-text-min); min-width: 0; }
.r-card-line.r-card-line > .r-seg-line { flex: 0 0 100%; order: 9; width: 100%; max-width: none; margin: var(--sp-1) 0 0; }
.r-card-line.r-card-line > .r-seg-line > .r-seg { width: 100%; }
@container (max-width: 26rem) {
  .r-card-line.r-card-line > .r-card-text { flex-basis: 100%; }
  .r-card-line.r-card-line:has(> .r-card-lead) > .r-card-text { flex-basis: calc(100% - var(--card-lead)); }
}

/* ---------- rule 5: grids (the double class outranks a screen's own column template, which the component replaces) ---------- */
.r-grid.r-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--cell, var(--cell-default))), 1fr));
  grid-auto-rows: min-content; align-items: stretch; gap: var(--sp-2); }
.r-grid.r-tiles { --cell: var(--cell-tile); }
.r-grid.r-cards { --cell: var(--cell-card); }
.r-grid.r-skills { --cell: var(--cell-skill); }
.r-grid.r-portraits { --cell: var(--cell-portrait); }
/* tiles (icon over a name): every tile at least as tall as one with a two-line name (--tile-h, in em so it grows with the
   font), so a palette's tiles are one height; a name that needs three lines makes its row taller rather than being cut.
   (Not "grid-auto-rows: 1fr": in a scrolling box of limited height that splits the box among the rows and squeezes them.) */
.r-grid.r-tiles > :not(.r-wide) { min-height: var(--tile-h); }
.r-grid > * { min-width: 0; }
.r-grid > .r-wide { grid-column: 1 / -1; }

/* ---------- rules 4 and 12: cards ---------- */
.r-card { container-type: inline-size; }

/* ---------- the one-row toolbar (fix 8): ui/root-rules.js moves what does not fit under More ---------- */
.r-toolbar { display: flex; align-items: center; min-width: 0; position: relative; }
.r-toolbar.r-toolbar { overflow: visible; }
.r-toolbar > .r-toolbar-items { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: var(--r-gap, var(--sp-half)); overflow: hidden; }
.r-toolbar [data-r-off] { display: none !important; }
.r-toolbar > .r-more { display: none; flex: none; }
.r-toolbar.r-over > .r-more { display: flex; align-items: center; justify-content: center; }
.r-toolbar > .r-more-list { position: absolute; right: var(--sp-1); top: calc(100% + var(--sp-1)); z-index: 60; min-width: var(--menu-w-min); max-width: min(var(--menu-w-max), 90vw);
  max-height: min(70dvh, var(--menu-h-max)); overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: var(--sp-half); padding: var(--menu-pad);
  border-radius: var(--rad-3); border: var(--sp-hair) solid var(--c-umber-19); background: var(--x-pane, var(--c-night-09)); box-shadow: var(--shadow-pop) rgb(from var(--c-black) r g b / 0.55); }
.r-toolbar > .r-more-list[hidden] { display: none; }
/* More shows that something chosen is inside it */
.r-toolbar > .r-more.r-has-on { border-color: var(--gold, var(--c-gold-65)); color: var(--gold, var(--c-gold-65)); }
/* .r-more-wrap: a More list of short chips (numbers) wraps them in rows instead of one per line, and opens in the flow
   under its row (not over the page), so the panel it is in scrolls to its end and nothing is covered or cut off */
.r-toolbar:has(> .r-more-wrap:not([hidden])) { flex-wrap: wrap; height: auto; }
.r-toolbar:has(> .r-more-wrap) > .r-toolbar-items { flex: 1 1 0%; }
.r-toolbar > .r-more-list.r-more-wrap { position: static; flex: 0 0 100%; box-sizing: border-box; max-width: none; max-height: none; overflow: visible; margin-top: var(--sp-1); box-shadow: none; flex-direction: row; flex-wrap: wrap; gap: var(--sp-1); }
.r-more-list.r-more-wrap > * { width: auto; min-width: var(--tap) !important; justify-content: center !important; padding: 0 var(--sp-3) !important; border: var(--sp-hair) solid var(--c-umber-19) !important; border-radius: var(--rad-pill); }
.r-more-list.r-more-wrap > *.on { border-color: var(--gold, var(--c-gold-65)) !important; }
.r-more-list > * { display: flex !important; flex-direction: row !important; align-items: center; justify-content: flex-start !important; gap: var(--sp-3) !important;
  min-height: var(--tap) !important; height: auto !important; width: 100%; padding: 0 var(--sp-3) !important; border: 0 !important; background: transparent !important; text-align: left; }
.r-more-list > * svg { width: var(--icon-md); height: var(--icon-md); flex: none; }
.r-more-list > * span { font-size: var(--fs-md) !important; }
.r-more-list > *:hover, .r-more-list > *.open { background: rgb(from var(--gold, var(--c-gold-65)) r g b / 0.12) !important; }

/* A toolbar of icons (data-r-labels="hold"): each button's word is kept for screen readers and for the More list, not shown
   in the row. Press and hold a button (or point at it with a mouse) and its name shows in .r-tip; let go without moving
   and nothing happens; a tap opens it (ui/root-rules.js). */
.r-toolbar[data-r-labels="hold"] > .r-toolbar-items [data-r-name] > span,
.r-toolbar[data-r-labels="hold"] > .r-more > span { position: absolute; width: var(--sp-hair); height: var(--sp-hair); overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.r-toolbar[data-r-labels] [data-r-name] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
/* data-r-labels="under" (253.1 fix-back, Tom 16 Nov 07:48): the small name sits under each icon, on one line, never cut
   (a button is as wide as its word; what does not fit the row is under More). Hold and hover still show the full name. */
.r-toolbar[data-r-labels="under"] > .r-toolbar-items [data-r-name], .r-toolbar[data-r-labels="under"] > .r-more { flex-direction: column; gap: var(--sp-hair); flex: none; }
.r-toolbar[data-r-labels="under"] > .r-toolbar-items [data-r-name] > span, .r-toolbar[data-r-labels="under"] > .r-more > span { font-size: var(--fs-xs); line-height: 1; white-space: nowrap; overflow: visible; }
.r-toolbar[data-r-labels="under"] > .r-toolbar-items [data-r-name] > svg, .r-toolbar[data-r-labels="under"] > .r-more > svg { width: var(--icon-sm); height: var(--icon-sm); flex: none; }
.r-tip { position: fixed; z-index: 9990; left: 0; top: 0; max-width: min(var(--menu-w-max), 90vw); padding: var(--sp-2) var(--sp-3); border-radius: var(--rad-2);
  border: var(--sp-hair) solid var(--gold, var(--c-gold-65)); background: var(--x-pane, var(--c-night-09)); color: var(--ink, var(--auto-ink));
  font: 600 var(--fs-md)/var(--lh-tight) var(--sans, Roboto, system-ui, sans-serif); box-shadow: var(--shadow-pop) rgb(from var(--c-black) r g b / 0.55); pointer-events: none; white-space: nowrap; }
.r-tip[hidden] { display: none; }

/* The top edge of a full-window screen (fix 13's one inset rule): whatever sits there keeps clear of the status bar. In
   the Android app the window itself stops at the bars (HearthInsetsPlugin: the inset is 0); in a browser or an installed
   web app the inset arrives as --hearth-safe-top (--safe-t, ui/root-tokens.css) and this adds it above the content; a
   component with a fixed height adds --safe-t to that height. */
.r-safe-top.r-safe-top { padding-top: var(--safe-t); }

/* ---------- rule 7: pictures ---------- */
.r-media { aspect-ratio: var(--ar, 1); overflow: hidden; }
.r-media > img, img.r-media-img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- rule 8: touch areas. ui/root-rules.js marks the controls under --tap; the area grows from the control's own
   size to --tap (top/bottom % are of the control's height, left/right % of its width), but no further on a side than
   --r-ht/--r-hb/--r-hl/--r-hr, half the gap to a neighbouring control (--r-kt/--r-kb/--r-kl/--r-kr: a side that makes up for an
   opposite side held back by a neighbour). Nothing visible changes size. ---------- */
[data-r-rel] { position: relative; }
[data-r-hit="a"]::after, [data-r-hit="b"]::before { content: ""; position: absolute; pointer-events: auto; background: transparent;
  top: var(--r-kt, max(min(0px, calc((100% - var(--tap) / var(--r-sc, 1)) / 2)), calc(-1 * var(--r-ht, 100vmax))));
  bottom: var(--r-kb, max(min(0px, calc((100% - var(--tap) / var(--r-sc, 1)) / 2)), calc(-1 * var(--r-hb, 100vmax))));
  left: var(--r-kl, max(min(0px, calc((100% - var(--tap) / var(--r-sc, 1)) / 2)), calc(-1 * var(--r-hl, 100vmax))));
  right: var(--r-kr, max(min(0px, calc((100% - var(--tap) / var(--r-sc, 1)) / 2)), calc(-1 * var(--r-hr, 100vmax)))); }

/* ---------- rule 1: the keyboard (ui/root-rules.js sets --r-lift on a pop-up the keyboard would cover) ---------- */
.r-lifted { translate: 0 calc(-1 * var(--r-lift, 0px)); transition: translate .12s ease-out; }
@media (prefers-reduced-motion: reduce) { .r-lifted { transition: none; } }

/* ---------- rule 6: readable text on every theme. --auto-ink is the page's own readable text colour (contrast-color()
   where the browser has it; otherwise ui/root-rules.js picks light or dark from the page's luminance). The shared
   components use it where a theme's ink would read poorly; ui/root-rules.js also corrects --ink itself when a theme's
   ink fails 4.5:1 on its page. ---------- */
@supports (color: contrast-color(white)) { :root { --auto-ink: contrast-color(var(--page)); } }
/* .r-chip: a coloured chip or pill (set --chip to its colour). Its text is light or dark, whichever reads on the chip:
   contrast-color() where the browser has it, else black when the chip's OKLCH lightness is above 0.57 (where black and white read equally well), white below */
.r-chip { background: var(--chip); color: oklch(from var(--chip) clamp(0, (0.57 - l) * 1000, 1) 0 0); }
@supports (color: contrast-color(white)) { .r-chip { color: contrast-color(var(--chip)); } }

/* ---------- (Addendum 11, 17 Nov) shared pieces, first used by the map builder; any screen can use them ----------
   --r-gilt / --r-floor-tex / --r-lift / --r-bevel   the look's own surfaces under one name (--r-gilt-fill and --r-on-gilt:
              a control filled with gilt and the ink that reads on it, in every look) (Dark v2's black leather and
              gilt, Light v2's parchment; a Hearth+ frame colour tints the gilt; no look: the palette's gold)
   .r-dock    a bar of labelled icon buttons (bottom of a phone screen); .r-dock-col stands it up as a rail
   .r-split   two panes that share the height 50/50, with an optional bar between them
   .r-tilegrid a grid with a set number of columns (--r-cols), for picture tiles (.r-tile: picture, name under it,
              a corner star .r-tile-star)
   .r-sec-label a small section heading with a count at its end
   .r-pillbar a compact pill: a little picture, a name, and a close x (48 dp)
   .r-strip   a slim row of labelled buttons (52 dp)
   .r-hint    a one-line note that fades out after 4 s
   .r-stroke-fade  what steps aside (15%, no touches) while [data-r-stroking] is set on an ancestor (a finger drawing) */
:root { --r-gilt: linear-gradient(160deg, var(--c-gold-81, var(--gold)), var(--gold) 40%, var(--gold-deep, var(--gold))); --r-gilt-h: var(--r-gilt); --r-gilt-fill: var(--r-gilt); --r-on-gilt: var(--on-gold, var(--ink)); --r-floor-tex: none; --r-lift: 0 0.25rem 0.75rem rgb(from var(--c-black, black) r g b / 0.5); --r-bevel: inset 0 0 0 var(--sp-hair) var(--rim); }
html[data-look="dark"] { --r-gilt: var(--dk-gilt); --r-gilt-h: var(--dk-gilt-h); --r-floor-tex: var(--dk-leather); --r-lift: var(--dk-lift); --r-bevel: var(--dk-bevel); }
html[data-look="light"] { --r-gilt: var(--pv-gilt); --r-gilt-h: var(--pv-gilt-h); --r-gilt-fill: var(--pv-gilt-h); --r-on-gilt: var(--pv-ink, var(--ink)); --r-floor-tex: var(--pv-parch); --r-lift: var(--pv-lift); --r-bevel: var(--pv-bevel); }
html[data-plus~="frame"] { --r-gilt: linear-gradient(160deg, var(--look-frame), var(--gold) 50%, var(--look-frame)); --r-gilt-h: var(--r-gilt); }

.r-dock.r-dock { display: flex; align-items: stretch; gap: var(--sp-half); padding: var(--sp-1) var(--sp-2) calc(var(--sp-1) + env(safe-area-inset-bottom, 0rem)); }
.r-dock > button, .r-dock > .r-dock-btn { flex: 1 1 0; min-width: var(--tap); min-height: 4rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-half);
  border: 0; background: none; border-radius: var(--rad-2); padding: var(--sp-1) 0; font: 600 var(--fs-xs)/1.1 var(--sans); color: var(--ink-soft, var(--ink)); cursor: pointer; }
.r-dock > button svg { width: var(--icon-md); height: var(--icon-md); flex: none; }
.r-dock > button.on, .r-dock > button[aria-pressed="true"] { color: var(--gold); background: rgb(from var(--gold) r g b / 0.14); box-shadow: inset 0 0 0 var(--sp-hair) rgb(from var(--gold) r g b / 0.55); }
.r-dock > button:disabled { opacity: 0.5; cursor: default; }
.r-dock.r-dock-col { flex-direction: column; padding: var(--sp-2) var(--sp-1); }
.r-dock.r-dock-col > button { flex: 0 0 auto; min-height: 3.75rem; }
.r-dock > .r-dock-sep { flex: 0 0 var(--sp-hair); align-self: stretch; margin: var(--sp-2) 0; background: var(--rim); }
.r-dock.r-dock-col > .r-dock-sep { height: var(--sp-hair); margin: var(--sp-1) var(--sp-2); }
.r-dock kbd { font: 600 0.62rem/1 var(--sans); opacity: 0.75; border: var(--sp-hair) solid var(--rim); border-radius: var(--sp-1); padding: 0.0625rem 0.25rem; }

.r-split.r-split { display: grid; grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); min-height: 0; }
.r-split.r-split > * { min-height: 0; min-width: 0; }

.r-tilegrid.r-tilegrid { display: grid; grid-template-columns: repeat(var(--r-cols, 3), minmax(0, 1fr)); gap: var(--r-gap, var(--sp-2)); }
.r-tile.r-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: var(--sp-1); min-width: 0; min-height: var(--tap);
  padding: var(--sp-2) var(--sp-1) var(--sp-1); border-radius: var(--rad-2); border: var(--sp-hair) solid var(--rim); background: var(--u-surface); color: var(--ink); cursor: pointer;
  font: 600 var(--fs-xs)/1.15 var(--sans); text-align: center; }
.r-tile.r-tile > .r-tile-pic { width: var(--r-pic, 3.875rem); height: var(--r-pic, 3.875rem); display: grid; place-items: center; flex: none; }
.r-tile.r-tile > .r-tile-pic > svg, .r-tile.r-tile > .r-tile-pic > img { width: 100%; height: 100%; object-fit: contain; }
.r-tile.r-tile > .r-tile-name { display: block; max-width: 100%; overflow-wrap: normal; word-break: normal; hyphens: manual; }
.r-tile.r-tile.on, .r-tile.r-tile[aria-pressed="true"] { border-color: transparent; background: linear-gradient(var(--u-surface), var(--u-surface)) padding-box, var(--r-gilt) border-box; border-width: var(--sp-half); box-shadow: 0 0 0.75rem rgb(from var(--gold) r g b / 0.4); }
/* .r-tile-wrap: a tile plus its corner star (the star is a sibling button, so the wrap is the positioned box) */
.r-tile-wrap { position: relative; min-width: 0; }
.r-tile-star.r-tile-star { position: absolute; top: 0; right: 0; width: var(--tap); height: var(--tap); display: grid; place-items: start end; padding: var(--sp-1); border: 0; background: none; color: var(--ink-soft, var(--ink)); cursor: pointer; }
.r-tile-star.r-tile-star svg { width: 1rem; height: 1rem; }
.r-tile-star.r-tile-star[aria-pressed="true"] { color: var(--gold); }

.r-sec-label.r-sec-label { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-3) 0 var(--sp-2); font: 700 var(--fs-xs)/1.2 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.r-sec-label.r-sec-label::after { content: ""; flex: 1 1 auto; height: var(--sp-hair); background: var(--rim); order: 1; }
.r-sec-label.r-sec-label > .r-sec-n { order: 2; color: var(--ink-soft, var(--ink)); letter-spacing: 0; }

.r-pillbar.r-pillbar { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--tap); max-width: 100%; padding: 0 0 0 var(--sp-1); border-radius: var(--rad-pill);
  border: var(--sp-hair) solid transparent; background: linear-gradient(var(--u-surface), var(--u-surface)) padding-box, var(--r-gilt) border-box; box-shadow: var(--r-lift); color: var(--ink); }
.r-pillbar > .r-pill-pic { width: 2.25rem; height: 2.25rem; flex: none; display: grid; place-items: center; }
.r-pillbar > .r-pill-pic > svg, .r-pillbar > .r-pill-pic > img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.r-pillbar > .r-pill-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 var(--fs-sm)/1.2 var(--serif); }
.r-pillbar > .r-pill-name small { display: block; font: 500 var(--fs-xs)/1.2 var(--sans); color: var(--ink-soft, var(--ink)); }
.r-pillbar > .r-pill-x { flex: none; width: var(--tap); height: var(--tap); border: 0; border-radius: 50%; background: none; color: var(--ink); font: 600 1.15rem/1 var(--sans); cursor: pointer; }

.r-strip.r-strip { display: flex; align-items: center; gap: var(--sp-1); padding: var(--sp-1) var(--sp-2); min-height: 3.25rem; }
.r-strip > button { min-width: var(--tap); min-height: 3.25rem; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.125rem; padding: 0 var(--sp-2);
  border: var(--sp-hair) solid var(--rim); border-radius: var(--rad-2); background: var(--u-surface); color: var(--ink); font: 600 var(--fs-xs)/1.1 var(--sans); cursor: pointer; }
.r-strip > button svg { width: var(--icon-sm); height: var(--icon-sm); }
.r-strip > button.r-strip-wide { flex-direction: row; gap: var(--sp-2); padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.r-strip > button.on, .r-strip > button[aria-pressed="true"] { color: var(--gold); border-color: var(--gold); }
.r-strip > button.r-strip-gold { color: var(--r-on-gilt); background: var(--r-gilt-fill); border-color: transparent; }
.r-strip > button:disabled { opacity: 0.5; cursor: default; }
.r-strip > .r-strip-gap { flex: 1 1 auto; }

.r-hint.r-hint { margin: 0; padding: var(--sp-2) var(--sp-3); border-radius: var(--rad-2); background: rgb(from var(--gold) r g b / 0.12); border: var(--sp-hair) solid var(--rim);
  color: var(--ink); font: 500 var(--fs-sm)/var(--lh-body, 1.35) var(--sans); animation: rHintFade 4s ease-in forwards; }
@keyframes rHintFade { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

[data-r-stroking] .r-stroke-fade { opacity: 0.15 !important; pointer-events: none !important; transition: opacity 0.12s; }
@media (prefers-reduced-motion: reduce) { .r-hint.r-hint { animation-duration: 0.01s; animation-delay: 4s; } }

/* (A15 A3, Tom 20 Nov) every drop-cap name (the Home hero card, the sheet's name, the look picker's titles): the big first
   letter sits inside its own line, so the top of it is never cut off by the name's overflow and nothing above overlaps it.
   It was drawn 1.42x with line-height 0, so it stood out above the line box. */
:is(.hv-nm, .u-cs3-nm, .u-lkp-page .u-t-h1, .u-lkp-hero .u-nm)::first-letter { line-height: 1 !important; }

/* (A15 A8) a disabled picker action ("Full" when Learned is full): the theme's muted text on no fill, never gold, and it
   does not look tappable (Dark, Light, Blue and the wheels: --sh-muted follows the look) */
html:root[data-palette][data-palette][data-palette][data-palette][data-palette] body .pk-sheet .spb-acts .browse-action-btn:disabled {
  background: transparent !important; color: var(--sh-muted, var(--ink-soft)) !important; border: var(--sp-hair) dashed rgb(from var(--sh-muted, var(--ink-soft)) r g b / 0.45) !important;
  box-shadow: none !important; font-weight: 600 !important; cursor: default !important; opacity: 1;
}
/* (A15 B6) Browse spells: a level header over each level with the All filter, in the themed small-caps picker style; it
   sticks to the top of the list while its level scrolls past */
html:root[data-palette] body .pk-sheet .pk-list > .pk-sec {
  position: sticky; top: 0; z-index: 2; margin: .5rem 0 .25rem; padding: .4rem .25rem .3rem;
  font: 700 .8125rem/1.2 var(--sans); font-variant: small-caps; letter-spacing: .1em; text-transform: lowercase;
  color: var(--sh-title-accent, var(--gold)); background: var(--sh-bg-solid, var(--navy2));
  border-bottom: var(--sp-hair) solid rgb(from var(--sh-title-accent, var(--gold)) r g b / 0.35);
}
html:root[data-palette] body .pk-sheet .pk-list > .pk-sec[hidden] { display: none; }

/* (A15 B4) the one remove-x: every x that removes or deletes something (a weapon's extra damage row, a companion, an
   item, a game or encounter, a creature from the fight, an area, an invite, a list row, a sheet tile) carries .h-rmx and
   is red, the danger token, in every look. An x that only closes stays neutral (it never carries .h-rmx). */
html:root[data-palette][data-palette][data-palette][data-palette][data-palette] body :is(.h-rmx, .u-h-rmx) { color: var(--crimson-ink) !important; fill: var(--crimson-ink) !important; }
html:root[data-palette][data-palette][data-palette][data-palette][data-palette] body :is(.h-rmx, .u-h-rmx) svg { stroke: currentColor; }
html:root[data-palette][data-palette][data-palette][data-palette][data-palette] body button:is(.h-rmx, .u-h-rmx):is(:hover, :focus-visible) { border-color: rgb(from var(--crimson-ink) r g b / 0.6) !important; }

/* (A15 B5) the pop-up close x, in the shared pop-up host (ui/ui.js pinX): one corner for every themed pop-up, the same
   gap from the top edge and the right edge, a 44 px target; pinned while the body scrolls (it takes the pop-up's own
   background once there is content under it). Neutral: a close x is never the danger colour. */
html:root[data-palette][data-palette][data-palette][data-palette][data-palette] body [data-hpop] :is(.hpop-x, .hpop-own-x).hpop-pin {
  position: absolute !important; top: var(--sp-2) !important; right: var(--sp-2) !important; left: auto !important; bottom: auto !important;
  z-index: 5; width: var(--tap-visual) !important; height: var(--tap-visual) !important; min-width: var(--tap-visual) !important; min-height: var(--tap-visual) !important;
  margin: 0 !important; padding: 0 !important; display: inline-grid !important; place-items: center; border-radius: 50% !important;
}
html:root[data-palette][data-palette][data-palette][data-palette][data-palette] body [data-hpop] :is(.hpop-x, .hpop-own-x).hpop-pin.hpop-pin-up { background: var(--sh-bg-solid, var(--c-night-07)) !important; box-shadow: 0 0 0 var(--sp-1) var(--sh-bg-solid, var(--c-night-07)) !important; }
html:root[data-palette][data-palette][data-palette][data-palette][data-palette] body [data-hpop] > :has(> .hpop-own-x.hpop-pin) { padding-right: calc(var(--tap-visual) + var(--sp-2)) !important; }

/* (A15 B11) no visible scroll bars on the themed screens (the character sheet at Fold and laptop sizes, its columns,
   pop-ups, drawers): touch, wheel and keyboard scrolling are unchanged. The long picker lists keep a thin bar, the one
   place a list really needs one to show how far it runs. */
html:root body, html:root body *:not(.pk-list):not(.u-pk-list) { scrollbar-width: none; }
html:root body ::-webkit-scrollbar { width: 0; height: 0; background: transparent; }
html:root body :is(.pk-list, .u-pk-list) { scrollbar-width: thin; scrollbar-color: rgb(from var(--gold) r g b / 0.4) transparent; }
html:root body :is(.pk-list, .u-pk-list)::-webkit-scrollbar { width: var(--sp-1); }
html:root body :is(.pk-list, .u-pk-list)::-webkit-scrollbar-thumb { background: rgb(from var(--gold) r g b / 0.4); border-radius: var(--sp-1); }
html:root { scrollbar-width: none; }
/* (A15 B11, Tom's sheet-scrollbar.jpg) the gold bar on the sheet's right edge is Hearth's own page scroll strip (.hss,
   30 Oct), not a browser bar: its handle is not drawn. The 20 px strip still drags the whole page, and touch, wheel and
   keyboard scrolling are unchanged. */
html:root body .hss .hss-thumb { opacity: 0 !important; box-shadow: none !important; }

/* (A15 B15) GM card size: the GM screen's creature, initiative and stat cards scale by one GM token, --gm-card-scale
   (Settings > GM table: Small 0.85, Medium 1, Large 1.25). Type, spacing, faces and buttons scale together (zoom on the
   card's own contents); the map and the tools row are never inside these, so they keep their size. A card that grows
   past its pane scrolls inside it. */
html:root body .gm2 :is(.gmx-faces, .gm2-faces, .gmx-card > *, .gm2-enclist > *, .gmxB-init, .gmx-L .gmx-card > *) { zoom: var(--gm-card-scale, 1); }
html:root[data-gm-card="m"] body .gm2 :is(.gmx-faces, .gm2-faces, .gmx-card > *, .gm2-enclist > *, .gmxB-init) { zoom: normal; }
/* (B15, Lee 21 Nov) the card head's one-line layout (gm-v2e.css, from 27.5rem of card) is measured before the zoom.
   At Large a busy head (name, Shown, a light, + Condition, then - HP +) needs about 47.5rem of card, so below that the
   chips wrap onto their own row under the name and the HP buttons, as on a narrow card. */
@container gmxcard (max-width: 47.5rem) {
  html:root[data-gm-card="l"] body .gmx .gmx-chead { flex-wrap: wrap; }
  html:root[data-gm-card="l"] body .gmx .gmx-cname { order: 1; flex: 1 1 0; min-width: 0; }
  html:root[data-gm-card="l"] body .gmx .gmx-hp { order: 2; }
  html:root[data-gm-card="l"] body .gmx .gmx-cchips { order: 3; flex: 1 1 100%; flex-wrap: wrap; overflow: visible; margin: 0; }
}

/* (A15 C4) the first-crit question: the shared pop-up, over the roll card (.rr), three equal buttons with none picked */
html:root body .u-layer.hcrit-layer { z-index: 100001; }
html:root body :is(.hcrit-opts, .u-hcrit-opts) { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-2); margin-top: var(--sp-3); }
html:root body :is(.hcrit-opts, .u-hcrit-opts) :is(.hcrit-b, .u-hcrit-b) { min-height: var(--tap); width: 100%; margin: 0 !important; justify-content: center; }
html:root[data-palette][data-palette][data-palette][data-palette][data-palette] body :is(.hcrit-x, .u-hcrit-x) { background: transparent !important; border: 0 !important; box-shadow: none !important; color: var(--sh-muted, var(--ink-soft)) !important; font: 400 1.75rem/1 var(--sans) !important; }
html:root body :is(.hcrit-l, .u-hcrit-l) { margin-top: var(--sp-1); }
