/* D&D Theme - a Player's Handbook page in a certificate frame, on a leather desk */

/* Homebrewery's 5e fonts (Solbera's CC-BY-SA 4.0 remakes; see fonts/LICENSE.txt) */
@font-face {
    font-family: 'Bookinsanity';
    src: url('/fonts/Bookinsanity-acb5fbb3e14d67153802e0aa97998f44.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Bookinsanity';
    font-weight: bold;
    src: url('/fonts/BookinsanityBold-58f93fdce6614cbcbe59fb33ca5f6408.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Bookinsanity';
    font-style: italic;
    src: url('/fonts/BookinsanityItalic-737f59499c305e19e0fc176afa662e39.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Bookinsanity';
    font-style: italic;
    font-weight: bold;
    src: url('/fonts/BookinsanityBoldItalic-eb9f967395231d368aee1221afc547fd.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Kalam';
    src: url('/fonts/Kalam-3698184e9c630f266ae6b549165aa845.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Mr Eaves Small Caps';
    src: url('/fonts/MrEavesSmallCaps-0c5445af25ba106869283a13b2dd9335.woff2') format('woff2');
    font-display: swap;
}
/* The Campaign Sage's handwriting: Almendra by Ana Sanfelippo (SIL Open Font License 1.1; fonts/Almendra-OFL.txt) */
@font-face {
    font-family: 'Almendra';
    src: url('/fonts/Almendra-f9e602c4b25960cfd3e774c594d61171.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Almendra';
    font-weight: bold;
    src: url('/fonts/AlmendraBold-5f8bc943a579909b02abf99d55faefd4.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Almendra';
    font-style: italic;
    src: url('/fonts/AlmendraItalic-90e3a361f4e411220f7ea4ab706f2bb3.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Almendra';
    font-style: italic;
    font-weight: bold;
    src: url('/fonts/AlmendraBoldItalic-6adb567d9a4803dc4b21e0e65db717f1.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Solbera Imitation';
    src: url('/fonts/SolberaImitationTweak-0f3b6b970827ec69b6b53b021b3f9fbd.woff2') format('woff2');
    font-display: swap;
}

/* Color Palette */
/* Georgia sized to Bookinsanity, style by style (measured 2026-11-03: Georgia's bold is about 10% wider), so text
   drawn before Bookinsanity arrives takes the same room and nothing moves when it does; before, the breadcrumb's bold
   italic links wrapped in Georgia and unwrapped in Bookinsanity, moving the whole page up a line */
@font-face {
    font-family: 'Bookinsanity Fallback';
    font-style: normal;
    font-weight: normal;
    src: local('Georgia');
    size-adjust: 100.5%;
    ascent-override: 77.6%;
    descent-override: 22.9%;
}
@font-face {
    font-family: 'Bookinsanity Fallback';
    font-style: italic;
    font-weight: normal;
    src: local('Georgia Italic'), local('Georgia-Italic');
    size-adjust: 99.2%;
    ascent-override: 78.6%;
    descent-override: 23.2%;
}
@font-face {
    font-family: 'Bookinsanity Fallback';
    font-style: normal;
    font-weight: bold;
    src: local('Georgia Bold'), local('Georgia-Bold');
    size-adjust: 90.8%;
    ascent-override: 85.9%;
    descent-override: 25.3%;
}
@font-face {
    font-family: 'Bookinsanity Fallback';
    font-style: italic;
    font-weight: bold;
    src: local('Georgia Bold Italic'), local('Georgia-BoldItalic');
    size-adjust: 89.7%;
    ascent-override: 87.0%;
    descent-override: 25.6%;
}

:root {
    --font-body: 'Bookinsanity', 'Bookinsanity Fallback', Georgia, serif;
    --font-heading: 'Mr Eaves Small Caps', Georgia, serif;
    /* Player's Handbook heading red, and the gold rule under its headings */
    --oxblood: #58180d;
    --rule-gold: #c9ad6a;
    --parchment-light: #f4e8d0;
    --parchment-dark: #e8d5b7;
    --leather-brown: #8b4513;
    --leather-dark: #654321;
    --leather-darker: #2c1810;
    --gold: #d4af37;
    --gold-dark: #aa8c2c;
    --gold-light: #e5c048;
    /* Gold for small text on leather; --gold-light is too dark to read there */
    --gold-pale: #f5d76e;
    --text-dark: #2c1810;
    --text-light: #f4e8d0;
    --success: #556b2f;
    --warning: #b8860b;
    /* Crimson, kept well apart from the oxblood main button so a Delete never passes for a Save */
    --danger: #b3261e;
    --info: #2f5f8a;
    /* Warning-coloured small text; --warning itself is too light to read on parchment */
    --warning-text: #7a5a00;
    /* The empty parchment of the hearth picture (images/hearth), so the words around it sit on the same paper */
    --hearth-parchment: #ecc895;
    /* Firelight: the glow over the hearth, and the focus ring on the pages it lights */
    --ember: #f0a040;
    /* Polished brass, from its shine to the shadow in its grooves (the compass; the Sage's scroll case will share it) */
    --brass-shine: #fff0b0;
    --brass-light: #f3dc8a;
    --brass: #b8892e;
    --brass-dark: #6d4c10;
    --brass-shadow: #3a2604;
    /* Rust-brown tooled leather, redder than --leather-brown (the compass band; the Sage's wrap will share it) */
    --leather-rust: #8c4520;
    --leather-mid: #5c2a10;
    --leather-deep: #3a1808;
    /* Aged, yellowed paper (warmer than --parchment-*, which is the page) and the brown ink drawn on it */
    --paper-light: #f6e8c6;
    --paper: #e8d2a2;
    --paper-edge: #c9a86e;
    --ink-brown: #6b4a24;
    /* A map's north arrow */
    --needle: #a8321f;
    --needle-lit: #c8452d;
    /* Light catching the brass on hover */
    --glow-light: #fff4c0;
}

/* The certificate parchment every sheet, tile, and pop-up is cut from: WebP (117 KB) where the browser can choose a
   format, the JPEG (271 KB) otherwise. One picture, so a page fetches it once whatever uses it. */
:root {
    --frame-picture: url('/images/certificate-frame-683a3f897cb05a18b13ff17665cd1933.jpg');
}

/* Every scrolling box's scrollbar (a tile's list, a pop-up, the Sage's chat), set once: the parchment track and gold
   thumb the Sage's chat had. The window's own scrollbar is left as the browser draws it. Chrome, Edge, and Safari read
   the ::-webkit-scrollbar rules; Firefox, which has none, reads scrollbar-color (Chrome would drop the width and hover
   if it saw scrollbar-color, so it doesn't) */
@supports not selector(::-webkit-scrollbar) {
    body * {
        scrollbar-color: var(--rule-gold) var(--parchment-dark);
    }
}

body *::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body *::-webkit-scrollbar-track,
body *::-webkit-scrollbar-corner {
    background: var(--parchment-dark);
}

body *::-webkit-scrollbar-thumb {
    background: var(--rule-gold);
}

body *::-webkit-scrollbar-thumb:hover {
    background: var(--gold-dark);
}

@supports (background-image: image-set(url('/images/certificate-frame-a205bac3ae838c5348460ee7c36a0497.webp') type('image/webp'))) {
    :root {
        --frame-picture: image-set(url('/images/certificate-frame-a205bac3ae838c5348460ee7c36a0497.webp') type('image/webp'),
            url('/images/certificate-frame-683a3f897cb05a18b13ff17665cd1933.jpg') type('image/jpeg'));
    }
}


/* Between pages the browser shows the canvas, not the body: dark leather too, so a link (a tab, a breadcrumb) never
   flashes white */
html {
    background-color: var(--leather-darker);
}

/* Global Font */
/* Skip to content: hidden until a keyboard focuses it, then a brass tab over the navbar's top left corner */
.skip-link:focus {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 2000;
    padding: 0.5rem 1rem;
    background: var(--brass-light);
    color: var(--text-dark);
    border-radius: 4px;
    font-weight: bold;
}

/* The skip link's target: it takes the focus so the next Tab starts inside the page, without drawing a ring round
   the whole sheet */
main[tabindex="-1"]:focus {
    outline: none;
}

/* The page is a dark leather desk; each page's content lies on it as a framed parchment sheet (.page-frame). The desk
   is the canvas's (html): the body paints nothing (not even Bootstrap's white), or it would cover the notes' paper,
   which is drawn beneath the page */
body {
    font-family: var(--font-body);
    color: var(--text-dark);
    background-color: transparent;
    min-height: 100vh;
}

/* Every page's main container: the certificate sheet. border-image cuts the picture into nine pieces, so the
   ornamental corners keep their shape at any page size and only the edges and the middle stretch. The sheet is
   drawn underneath (its ::before, below the notes' paper and shadows; see the field notes) rather than as the frame's
   own background, which would cover them. */
.page-frame {
    --frame-border: 62px;
    position: relative;
    border: var(--frame-border) solid transparent;
    padding: 0.5rem 1rem 1rem;
    margin-bottom: 2rem;
}

.page-frame::before {
    content: "";
    position: absolute;
    inset: calc(-1 * var(--frame-border));
    z-index: -9;
    border: var(--frame-border) solid transparent;
    border-image: var(--frame-picture) 250 fill / var(--frame-border) stretch;
    /* Plain parchment, all covered by the picture once it arrives; until then the new page shows a sheet, not the
       dark desk through a hole */
    background-color: var(--parchment-dark);
    pointer-events: none;
}

@media (max-width: 768px) {
    .page-frame {
        --frame-border: 28px;
        padding: 0.25rem 0.25rem 0.75rem;
    }
}

/* Page footers lie on the dark desk, outside the sheet, so their muted text is lightened to stay readable */
body > footer,
body > footer .text-muted {
    color: var(--parchment-dark) !important;
    border-color: var(--leather-dark) !important;
    font-family: var(--font-heading);
    font-size: 1.1rem;
}

/* On a page with the Sage's and Notes' floating buttons, the footer ends with room for them, so they never sit over
   its last links once the page is scrolled to the bottom */
body:has(.chat-floating-fab) > footer {
    padding-bottom: 5rem;
}

/* Credit line for the fonts, on the desk under the page */
.font-credit {
    padding-bottom: 1rem;
    text-align: center;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    color: var(--parchment-dark);
}

.font-credit a {
    color: var(--gold-pale);
    font-weight: normal;
}

/* Inline icons (fragments/icons.html) sit on the text baseline like the icon font did */
.icon {
    vertical-align: -0.125em;
}

/* Typography */
/* Player's Handbook headings: oxblood small caps (Mr Eaves has one weight, so no faux bold) */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: normal;
    color: var(--oxblood);
}

h1 {
    font-size: 2.6rem;
}

.campaign-title {
    font-family: var(--font-heading);
    color: var(--oxblood);
}

/* The first letter of an opening paragraph, PHB style: a tall ornamental capital. The paragraph contains the
   floated capital, so a one-line paragraph grows to fit it instead of letting it spill out of its card.
   opening-cap is the same on a Markdown description (a record's page and pop-up), but only when the text opens with
   a plain paragraph: a list, heading or quote first is left as it is. */
.drop-cap, .opening-cap > p:first-child {
    display: flow-root;
}

.drop-cap::first-letter, .opening-cap > p:first-child::first-letter {
    float: left;
    font-family: 'Solbera Imitation', var(--font-heading);
    font-size: 4.2rem;
    line-height: 0.85;
    padding: 0.2rem 0.4rem 0 0;
    color: var(--oxblood);
}

/* A date the World State opens with, set on its own line above the capital: a quiet PHB heading */
.world-state-date {
    font-family: var(--font-heading);
    color: var(--oxblood);
    margin-bottom: 0.25rem;
}

/* In the pop-up the capital is smaller, to suit its shorter summary */
.entity-summary .opening-cap > p:first-child::first-letter {
    font-size: 3rem;
}

/* Navigation Bar */
.navbar-dark {
    background: linear-gradient(to bottom, var(--leather-brown), var(--leather-dark)) !important;
    border-bottom: 3px solid var(--leather-darker);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.navbar-brand, .nav-link {
    color: var(--parchment-light) !important;
    font-family: var(--font-heading);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

/* The site's name, not a link: lettered in the hearth headlines' Almendra, in pale gold, and still to the touch */
.navbar-brand {
    font-family: 'Almendra', Georgia, serif;
    font-weight: bold;
    font-size: 1.75rem;
    letter-spacing: 0.01em;
    color: var(--gold-pale) !important;
    cursor: default;
    user-select: none;
}

.navbar .nav-link {
    font-size: 1.25rem;
}

/* Laid out in one row (xl up; below that the links stack under the menu button and may wrap), no link's words wrap,
   and a long campaign or section name is cut short with "…" so the bar stays on one line; the whole name is still
   the link's text, so a screen reader reads it all, and its title shows it. The account menu is wide
   enough for the plan line on two lines */
@media (min-width: 1200px) {
    .navbar .nav-link {
        white-space: nowrap;
    }

    .navbar [data-account-menu] {
        min-width: 18rem;
    }

    .navbar .nav-link[data-nav-crumb] {
        max-width: 16rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.nav-link:hover {
    color: var(--gold) !important;
}

.nav-link:active {
    color: var(--gold-light) !important;
    transform: scale(0.95);
    transition: transform 0.05s;
}

/* Global click feedback for links */
a:active {
    opacity: 0.7;
    transition: opacity 0.05s;
}

/* Loading overlay — shown on page navigation */
.page-loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(244, 232, 208, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.page-loading-overlay.active {
    display: flex;
}

.page-loading-text {
    font-family: var(--font-body);
    font-style: italic;
    color: var(--oxblood);
    font-size: 1rem;
    margin-top: 12px;
}

.page-loading-d20 {
    width: 48px;
    height: 48px;
    position: relative;
    animation: d20-roll 1.2s ease-in-out infinite;
}

.page-loading-d20 svg {
    width: 100%;
    height: 100%;
}

@keyframes d20-roll {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(90deg) scale(1.05); }
    50% { transform: rotate(180deg) scale(1); }
    75% { transform: rotate(270deg) scale(0.95); }
    100% { transform: rotate(360deg) scale(1); }
}

/* A background import of a free-form document (fragments/import-job.html, static/js/import-job.js). The banner: a
   strip just under the navbar on every signed-in page while the GM has one, holding one note (one line on a desktop,
   wrapping on a phone). It sits in the page's flow, so it never covers the Sage's button */
.import-banner {
    padding-top: 0.75rem;
}

/* The plan notices (fragments/layout.html notices: read-only, a plan's refusal, the admin testing a plan): first on
   the page's sheet, inside <main> where "Skip to content" lands, with room before the page's own heading */
.read-only-banner {
    margin-bottom: 1rem;
}

/* How many of the import's parts are read: a thin bar, its fill set by the script (--progress, 0 to 1) */
.import-progress {
    --progress: 0;
    height: 6px;
    background: var(--parchment-dark);
    border: 1px solid var(--rule-gold);
    border-radius: 3px;
    overflow: hidden;
}

.import-progress::after {
    content: "";
    display: block;
    height: 100%;
    width: calc(var(--progress) * 100%);
    background: var(--gold-dark);
    transition: width 0.4s ease;
}

.import-banner .import-progress {
    flex: 0 0 6rem;
}

/* The page change's rolling d20, small, beside an import's progress line; it stands still with reduced motion */
.import-d20 {
    width: 24px;
    height: 24px;
    flex: none;
    color: var(--gold-dark);
}

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

    .import-progress::after {
        transition: none;
    }
}

/* The newest records an import has found, each with its kind as a tag */
.import-feed {
    font-size: 0.875rem;
}

.import-feed li {
    padding: 1px 0;
}

/* "+3" beside a count that rose since the script last looked */
.import-count-up {
    color: var(--success);
    font-weight: bold;
    margin-left: 0.35rem;
}

/* Breadcrumbs */
/* Breadcrumbs: an italic running head, ruled off from the page */
.breadcrumb {
    background: none;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--rule-gold);
    border-radius: 0;
    font-style: italic;
}

.breadcrumb-item a {
    color: var(--oxblood);
    font-weight: bold;
}

.breadcrumb-item.active {
    color: var(--leather-dark);
}

/* Every tile is a field note: the Sage's paper. The pop-ups' certificate parchment (the middle of the page's sheet)
   worn on all four sides by the Sage's uneven edge (the same strip, turned for the top and bottom),
   lifted off the page by a soft shadow. The paper is the tile's ::before and the shadow its ::after,
   both drawn behind the page's contents (negative z-index) rather than the tile being a layer of its own, so
   the mask that wears the paper doesn't cut the tile's contents, and nothing in a tile (a dropdown, a pop-up) is
   trapped inside it. So nothing between a tile and the page may paint a background of its own: the sheet is drawn
   underneath (.page-frame::before) and the body leaves the desk to the canvas. Neighbouring tiles wear their edges
   from different points of the strip, so they never tear alike. */
/* The paper is the look of every box in the app: tiles, story steps, the import callout and messages (pop-ups keep
   the full certificate, frame and all). A box
   may mark itself with a bar of colour down its left, inside the worn edge (--note-mark: a message's kind, a story
   step's place). */
.card, .dnd-card, .story-step, .import-format-callout, .alert {
    --worn-left: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='200'%3E%3Cpath d='M16 0 L3.4 0 L3.9 8 L1.9 14 L2.1 28 L1.8 42 L2.8 56 L4.1 62 L2.9 68 L4.0 82 L2.2 96 L5.3 104 L7.2 118 L5.0 132 L7.4 138 L4.8 144 L3.2 152 L4.7 160 L3.4 174 L2.1 182 L5.3 196 L3.4 200 L16 200 Z' fill='black'/%3E%3C/svg%3E");
    --worn-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='200'%3E%3Cpath d='M16 0 L3.4 0 L3.9 8 L1.9 14 L2.1 28 L1.8 42 L2.8 56 L4.1 62 L2.9 68 L4.0 82 L2.2 96 L5.3 104 L7.2 118 L5.0 132 L7.4 138 L4.8 144 L3.2 152 L4.7 160 L3.4 174 L2.1 182 L5.3 196 L3.4 200 L16 200 Z' fill='black' transform='translate(16 0) scale(-1 1)'/%3E%3C/svg%3E");
    --worn-top: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='16'%3E%3Cpath d='M0 16 L0 3.4 L8 3.9 L14 1.9 L28 2.1 L42 1.8 L56 2.8 L62 4.1 L68 2.9 L82 4.0 L96 2.2 L104 5.3 L118 7.2 L132 5.0 L138 7.4 L144 4.8 L152 3.2 L160 4.7 L174 3.4 L182 2.1 L196 5.3 L200 3.4 L200 16 Z' fill='black'/%3E%3C/svg%3E");
    --worn-bottom: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='16'%3E%3Cpath d='M0 16 L0 3.4 L8 3.9 L14 1.9 L28 2.1 L42 1.8 L56 2.8 L62 4.1 L68 2.9 L82 4.0 L96 2.2 L104 5.3 L118 7.2 L132 5.0 L138 7.4 L144 4.8 L152 3.2 L160 4.7 L174 3.4 L182 2.1 L196 5.3 L200 3.4 L200 16 Z' fill='black' transform='translate(0 16) scale(1 -1)'/%3E%3C/svg%3E");
    --worn-at: 0;
    /* How far the paper reaches past the box's contents */
    --note-border: 6px;
    --note-mark: transparent;
    --note-shadow: rgba(60, 35, 10, 0.4);
    --note-lift: 3px;
    /* Where its paper and shadow are drawn beneath the page's contents (deeper notes higher; see below) */
    --note-paper-z: -7;
    --note-shadow-z: -8;
    position: relative;
    border: var(--note-border) solid transparent;
    /* Its bar of colour (none unless it is marked), on the box itself, which is drawn over its paper */
    background: linear-gradient(var(--note-mark), var(--note-mark)) left 6px top 8px / 4px calc(100% - 16px) no-repeat;
    box-shadow: none;
    border-radius: 0;
    color: var(--leather-darker);
}

/* A theme card without Bootstrap's .card still spaces its body, footer, and header as one would: Bootstrap sets these
   on .card only, so a .dnd-card's .card-body otherwise sits flush against its edge */
.dnd-card {
    --bs-card-spacer-y: 1rem;
    --bs-card-spacer-x: 1rem;
}

.card::before, .dnd-card::before, .story-step::before, .import-format-callout::before, .alert::before {
    content: "";
    position: absolute;
    inset: calc(-1 * var(--note-border));
    z-index: var(--note-paper-z);
    /* The certificate's own parchment: only the middle of the picture (its 9-slice centre, no frame), stretched to the
       box however tall, so no piece of the frame ever shows. Plain parchment beneath until the picture arrives, as
       for the sheet; the picture's fill covers it all */
    border-image: var(--frame-picture) 250 fill / 0 stretch;
    background-color: var(--parchment-dark);
    box-shadow: inset 0 0 16px rgba(140, 69, 32, 0.55), inset 0 0 4px rgba(110, 50, 18, 0.5);
    -webkit-mask:
        var(--worn-left) left 0 top var(--worn-at) / 16px 200px repeat-y,
        var(--worn-right) right 0 top var(--worn-at) / 16px 200px repeat-y,
        linear-gradient(black, black) center / calc(100% - 32px) 100% no-repeat,
        var(--worn-top) left var(--worn-at) top 0 / 200px 16px repeat-x,
        var(--worn-bottom) left var(--worn-at) bottom 0 / 200px 16px repeat-x,
        linear-gradient(black, black) center / 100% calc(100% - 32px) no-repeat;
    -webkit-mask-composite: source-over, source-over, source-in, source-over, source-over;
    mask:
        var(--worn-left) left 0 top var(--worn-at) / 16px 200px repeat-y add,
        var(--worn-right) right 0 top var(--worn-at) / 16px 200px repeat-y add,
        linear-gradient(black, black) center / calc(100% - 32px) 100% no-repeat intersect,
        var(--worn-top) left var(--worn-at) top 0 / 200px 16px repeat-x add,
        var(--worn-bottom) left var(--worn-at) bottom 0 / 200px 16px repeat-x add,
        linear-gradient(black, black) center / 100% calc(100% - 32px) no-repeat;
    pointer-events: none;
}

.card::after, .dnd-card::after, .story-step::after, .import-format-callout::after, .alert::after {
    content: "";
    position: absolute;
    /* A plain rectangle just inside the paper's worn edge, its soft shadow showing past the edge (most where it is
       torn deepest), so the shadow follows the tears without a mask of its own */
    inset: calc(5px - var(--note-border));
    z-index: var(--note-shadow-z);
    box-shadow: 0 var(--note-lift) 9px 3px var(--note-shadow);
    pointer-events: none;
}

/* Notes lie on notes (a story's steps on its Steps tile, NPCs on a location's): every shadow must fall on the paper
   beneath it, so each depth of note is drawn a level up from the one it lies on, all still beneath the page's
   contents (and the sheet beneath them all) */
:is(.card, .dnd-card, .story-step, .import-format-callout, .alert) :is(.card, .dnd-card, .story-step, .import-format-callout, .alert) {
    --note-paper-z: -5;
    --note-shadow-z: -6;
}

:is(.card, .dnd-card, .story-step, .import-format-callout, .alert) :is(.card, .dnd-card, .story-step, .import-format-callout, .alert) :is(.card, .dnd-card, .story-step, .import-format-callout, .alert) {
    --note-paper-z: -3;
    --note-shadow-z: -4;
}

:is(.card, .dnd-card, .story-step, .import-format-callout, .alert) :is(.card, .dnd-card, .story-step, .import-format-callout, .alert) :is(.card, .dnd-card, .story-step, .import-format-callout, .alert) :is(.card, .dnd-card, .story-step, .import-format-callout, .alert) {
    --note-paper-z: -1;
    --note-shadow-z: -2;
}

:nth-child(4n+2) > .card, :nth-child(4n+2) > .dnd-card, .card:nth-child(4n+2), .dnd-card:nth-child(4n+2) {
    --worn-at: -57px;
}

:nth-child(4n+3) > .card, :nth-child(4n+3) > .dnd-card, .card:nth-child(4n+3), .dnd-card:nth-child(4n+3) {
    --worn-at: -113px;
}

:nth-child(4n+4) > .card, :nth-child(4n+4) > .dnd-card, .card:nth-child(4n+4), .dnd-card:nth-child(4n+4) {
    --worn-at: -161px;
}

/* A note's writing is a hand (Kalam). Tags keep their own type; buttons keep the heading face every button has; forms
   and stat blocks keep the print, so they read at a glance and fill in plainly */
.card-body,
.card-footer,
.card .list-group-item {
    font-family: 'Kalam', cursive;
}

.card .btn {
    font-family: var(--font-heading);
}

.card form,
.card .stat-block {
    font-family: var(--font-body);
}

.card .card-title,
.card .card-title a {
    font-family: var(--font-heading);
    color: var(--oxblood);
}

/* A label over a value in an info card (Calendar, Last Played …): a PHB stat-block entry, like a field label */
.info-label {
    color: var(--oxblood);
    font-family: var(--font-heading);
    font-size: 1.2rem;
    line-height: 1.2;
}

/* Campaign Info's calendar and in-game date: links to the calendar pop-up, a small pencil after each */
.calendar-edit-link .icon {
    font-size: 0.8em;
    margin-left: 0.35em;
}

/* A link in an info card kept to one line, cut with "…" (Campaign Info's planned session); its title shows it all */
.info-link-truncate {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* Campaign page: World State is its own tile that scrolls up and down only; long words wrap so the width
   never changes and nothing scrolls sideways */
.world-state-text {
    max-height: 15rem;
    overflow-y: auto;
    overflow-x: hidden;
    overflow-wrap: anywhere;
}

/* Wide screens: the side column (Campaign Info, World State) ends level with the bottom row of tiles
   (Rumors, Plot Threads); the tiles set the height and World State scrolls in whatever room is left */
@media (min-width: 768px) {
    .campaign-side {
        position: relative;
    }

    .campaign-side-fill {
        position: absolute;
        top: 0;
        bottom: 0;
        left: calc(var(--bs-gutter-x) * 0.5);
        right: calc(var(--bs-gutter-x) * 0.5);
        display: flex;
        flex-direction: column;
    }

    /* Campaign Info keeps its full height; only World State gives way */
    .campaign-info-card {
        flex: 0 0 auto;
    }

    .world-state-card {
        flex: 1 1 auto;
        min-height: 6rem;
    }

    .world-state-text {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
    }
}

/* The title of a campaign-page section tile (Sessions, Locations …): a larger, bolder PHB heading, no icon */
.dnd-card-header .section-tile-title {
    font-size: 1.9rem;
    font-weight: bold;
    letter-spacing: 0.03em;
    line-height: 1.1;
}

/* Card headers: a PHB section title, oxblood small caps over a gold rule */
.dnd-card-header {
    background: transparent;
    border-bottom: 2px solid var(--rule-gold);
    color: var(--oxblood);
    font-family: var(--font-heading);
    font-size: 1.2rem;
    padding: 0.5rem 1rem 0.2rem;
    border-radius: 0;
}

.dnd-card-header h1,
.dnd-card-header h2,
.dnd-card-header h3,
.dnd-card-header h4,
.dnd-card-header h5,
.dnd-card-header h6 {
    color: var(--oxblood);
}

.card-body {
    background: transparent;
}

/* Buttons - main action: solid oxblood, the Player's Handbook red */
.btn-primary {
    background: var(--oxblood) !important;
    border: 2px solid var(--leather-darker) !important;
    color: var(--parchment-light) !important;
    font-family: var(--font-heading);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    border-radius: 3px;
}

.btn-primary:hover {
    background: #74241a !important;
    color: #fff !important;
}

.btn-primary:active {
    background: var(--leather-darker) !important;
    box-shadow: inset 0 3px 6px rgba(0,0,0,0.4) !important;
    transform: translateY(1px);
    transition: transform 0.05s, box-shadow 0.05s;
}

/* Buttons - the five roles (STYLE_GUIDE.md). Each has its own look so a Delete never passes for a Cancel. */
.dnd-btn-add,
.btn-secondary,
.btn-danger,
.btn-outline-danger,
.btn-outline-secondary {
    font-family: var(--font-heading);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    border-radius: 3px;
}

/* Create / add: an oxblood outline on parchment, the main button's quieter twin */
.dnd-btn-add {
    background: var(--parchment-light) !important;
    border: 2px solid var(--oxblood) !important;
    color: var(--oxblood) !important;
}

/* Every button's menu (+ New homebrew, a player's Status): the pop-ups' paper under a gold rule, its choices in the
   heading face, lit gold when pointed at, like the Sage's @-mention list */
.dropdown-menu {
    --bs-dropdown-bg: var(--paper-light);
    --bs-dropdown-border-color: var(--rule-gold);
    --bs-dropdown-border-radius: 0;
    --bs-dropdown-link-color: var(--oxblood);
    --bs-dropdown-link-hover-color: var(--oxblood);
    --bs-dropdown-link-hover-bg: rgba(212, 175, 55, 0.25);
    --bs-dropdown-link-active-color: var(--parchment-light);
    --bs-dropdown-link-active-bg: var(--oxblood);
    --bs-dropdown-divider-bg: var(--rule-gold);
    box-shadow: 0 6px 16px rgba(44, 24, 16, 0.35);
}

.dropdown-item {
    font-family: var(--font-heading);
    font-size: 1.05rem;
}

/* Cancel / back: darker leather, a step down from Create */
.btn-secondary {
    background: linear-gradient(to bottom, var(--leather-dark), var(--leather-darker)) !important;
    border: 2px solid var(--leather-darker) !important;
    color: var(--parchment-dark) !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* Destructive: crimson */
.btn-danger {
    background: var(--danger) !important;
    border: 2px solid #7f1a14 !important;
    color: var(--parchment-light) !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* Destructive, quieter: crimson on parchment, dashed so it can't pass for the create outline */
.btn-outline-danger {
    background: var(--parchment-light) !important;
    border: 2px dashed var(--danger) !important;
    color: var(--danger) !important;
}

/* Low-key / utility: leather text on parchment, edged in dark gold so it stands as tall as a solid button */
.btn-outline-secondary {
    background: var(--parchment-light) !important;
    border: 2px solid var(--gold-dark) !important;
    color: var(--leather-dark) !important;
}

.dnd-btn-add:hover {
    background: var(--oxblood) !important;
    color: var(--parchment-light) !important;
}

.btn-secondary:hover {
    background: linear-gradient(to bottom, #9c5524, #765432) !important;
    color: #fff !important;
}

.btn-danger:hover,
.btn-outline-danger:hover {
    background: #c9342b !important;
    color: #fff !important;
}

.btn-outline-secondary:hover {
    background: var(--parchment-dark) !important;
    color: var(--leather-dark) !important;
}

.dnd-btn-add:active,
.btn-secondary:active,
.btn-danger:active,
.btn-outline-danger:active,
.btn-outline-secondary:active {
    box-shadow: inset 0 3px 6px rgba(0,0,0,0.5) !important;
    transform: translateY(1px);
    transition: transform 0.05s, box-shadow 0.05s;
}

/* Buttons are set in the PHB heading small caps, a size up because Mr Eaves runs small */
.btn {
    font-size: 1.15rem;
    line-height: 1.3;
}

/* Small Buttons */
.btn-sm {
    padding: 0.2rem 0.75rem;
    font-size: 1rem;
}

/* Badges */
/* Badges in the PHB heading small caps, one size wherever they sit (a heading or a card header no longer makes
   them bigger). Lower-cased, every letter is a small cap, so a stored ALIVE matches a written "Power: 7". */
.badge, .dnd-badge {
    font-size: 0.8rem;
    text-transform: lowercase;
    vertical-align: middle;
    font-weight: normal;
    background: var(--leather-brown);
    color: var(--parchment-light);
    border: 1px solid var(--leather-darker);
    font-family: var(--font-heading);
    border-radius: 0;
}

/* A badge that shows a name as it was typed (an account's plan name), not lower-cased */
.badge.badge-exact, .dnd-badge.badge-exact {
    text-transform: none;
}

/* Alternate badge colors maintain D&D theme */

/* A location's or a faction's type: every type the same width, so a Village and a Dungeon line up */
.badge.type-tag {
    min-width: 5.75em;
    text-align: center;
}

/* The import format guide (fragments/import-format-guide.html): a heading or key never breaks across lines */
.import-format-guide code {
    white-space: nowrap;
}

/* Every table lies on the page's parchment, never on Bootstrap's white rows, with the theme's text and gold rules,
   striped, hover, and active rows included. The theme doesn't use Bootstrap's coloured table classes (table-dark,
   table-warning ...), so there is nothing to keep apart; TablesOnParchmentTest fails if a template uses one. */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-dark);
    --bs-table-striped-color: var(--text-dark);
    --bs-table-hover-color: var(--text-dark);
    --bs-table-active-color: var(--text-dark);
    --bs-table-border-color: var(--rule-gold);
}

/* Table headings in the heading small caps on parchment, like every other label */
.table > thead th {
    color: var(--oxblood);
    font-family: var(--font-heading);
    font-weight: normal;
    border-bottom: 2px solid var(--rule-gold);
    background: transparent;
    white-space: nowrap;
}

/* A select waiting on another choice (e.g. Subclass before a class) stays parchment, only dimmed */
.form-select:disabled {
    background-color: var(--parchment-dark);
    opacity: 0.75;
}

/* A larger badge, for the one status a page is about */
.badge.badge-large {
    font-size: 0.95rem;
}

/* Badge tones: the only badge colours. Chosen by BadgeTones through fragments/badges.html. */
.badge.badge-success { background: var(--success); color: var(--text-light); }
.badge.badge-info { background: var(--info); color: var(--text-light); }
.badge.badge-warning { background: var(--warning); color: var(--text-dark); }
.badge.badge-danger { background: var(--danger); color: var(--text-light); }
.badge.badge-neutral { background: var(--leather-brown); color: var(--text-light); }

/* Forms */
/* Every text box can be dragged taller to read long text; never wider, since each already fills its column */
textarea {
    resize: vertical;
}

/* ...and from anywhere along the top or bottom edge (static/js/textarea-edge-resize.js) */
textarea.textarea-edge-hover {
    cursor: ns-resize;
}

.textarea-edge-resizing,
.textarea-edge-resizing * {
    cursor: ns-resize !important;
    user-select: none;
}

/* Fields: a pale writing space on the parchment, edged in the gold rule */
.form-control, .form-select {
    background-color: rgba(255, 250, 240, 0.65);
    border: 1px solid var(--rule-gold);
    color: var(--text-dark);
    font-family: var(--font-body);
    border-radius: 0;
}

.form-control:focus, .form-select:focus {
    background-color: #fffaf0;
    border-color: var(--gold);
    box-shadow: 0 0 0 0.2rem rgba(212, 175, 55, 0.25);
}

.form-label {
    color: var(--oxblood);
    font-family: var(--font-heading);
}

/* Every field's label reads like a stat-block entry in the Player's Handbook: oxblood small caps, no box */
label.form-label {
    display: block;
    margin-bottom: 0.15rem;
    background: none;
    color: var(--oxblood);
    font-size: 1.2rem;
    line-height: 1.2;
}

/* The required-field asterisk, crimson on the parchment */
label.form-label .text-danger {
    color: var(--danger) !important;
}

/* Alerts */
/* Messages are notes too, marked down their left in the colour of their kind */
.alert {
    --note-mark: var(--leather-brown);
    font-family: var(--font-body);
    padding-left: 1.4rem;
}

.alert-success { --note-mark: var(--success); }
.alert-danger { --note-mark: var(--danger); }
.alert-warning { --note-mark: var(--warning); }
.alert-info { --note-mark: var(--info); }

/* A group of fields is a section of the page, PHB style: no box, just a gold rule along the top */
.choice-panel {
    position: relative;
    padding: 0.25rem 0 0.75rem;
    border: none;
    border-top: 2px solid var(--rule-gold);
    border-radius: 0;
    background: none;
}

/* Section titles: oxblood PHB small caps sitting on the gold rule. A fieldset opens its border around the
   legend, so the rule runs into the title and out again. */
.choice-panel > legend {
    float: none;
    width: auto;
    padding: 0 0.4rem;
    margin-bottom: 0.25rem;
    background: none;
    color: var(--oxblood);
    font-family: var(--font-heading);
    font-size: 1.6rem;
    line-height: 1;
}

/* A Bonuses row's Adds to box is for extra damage: hidden while the row is anything else and it is empty, so a box
   with words in it always shows (and with no :has support, every box shows) */
.bonus-row:not(:has(option[value="EXTRA_DAMAGE"]:checked)) .rider-field:has(input:placeholder-shown) {
    display: none;
}

/* Its When box is for extra damage and for a resistance, immunity, or vulnerability: hidden, as Adds to is, while the
   row is anything else and the box is empty */
.bonus-row:not(:has(option[value="EXTRA_DAMAGE"]:checked, option[value="RESISTANCE"]:checked,
        option[value="IMMUNITY"]:checked, option[value="VULNERABILITY"]:checked,
        option[value="CONDITION_IMMUNITY"]:checked)) .when-field:has(input:placeholder-shown) {
    display: none;
}

/* Tick boxes: a parchment square in the gold rule; ticked, oxblood with a gold quill check */
.form-check-input {
    width: 1.2em;
    height: 1.2em;
    margin-top: 0.15em;
    background-color: var(--parchment-light);
    border: 1px solid var(--gold-dark);
    cursor: pointer;
}

.form-check-input[type="checkbox"] {
    border-radius: 3px;
}

.form-check-input:checked {
    background-color: var(--oxblood);
    border-color: var(--oxblood);
}

.form-check-input:checked[type="checkbox"] {
    --bs-form-check-bg-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 8.6c1.3.9 2.3 2.2 3.1 3.8 1.6-3.9 3.9-6.9 6.6-9.1' fill='none' stroke='%23e5c048' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.form-check-input:checked[type="radio"] {
    --bs-form-check-bg-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3E%3Ccircle r='2.2' fill='%23e5c048'/%3E%3C/svg%3E");
}

.form-check-input:focus {
    border-color: var(--gold-dark);
    box-shadow: 0 0 0 0.2rem rgba(212, 175, 55, 0.4);
}

.form-check-label {
    font-family: var(--font-body);
    color: var(--text-dark);
    cursor: pointer;
}

/* A place's or faction's type under its name in a pick list ("Town" under "Port Vell"): quieter and smaller */
.choice-type {
    color: var(--ink-brown);
    font-size: 0.85em;
}

/* A form row's columns stack on a phone; each but the last keeps the gap a row would have, so a label never sits on
   the field above it. Rows with their own gutters (g-*) and columns with their own margin already have one. */
@media (max-width: 767.98px) {
    form .row:not([class*="g-"]) > [class*="col-md"]:not(:last-child):not([class*="mb-"]) {
        margin-bottom: 1rem;
    }
}

/* The formatting toolbar above each long text box (static/js/text-format.js) */
.format-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fill, 5.25rem);
    gap: 4px;
    margin-top: 0.25rem;
    margin-bottom: 0.4rem;
}

.format-toolbar .btn {
    padding: 0 0.25rem;
    white-space: nowrap;
    font-size: 0.95rem;
    box-shadow: none;
}

/* A finger needs a taller button than a mouse pointer */
@media (pointer: coarse) {
    .format-toolbar .btn {
        min-height: 32px;
    }
}

/* A long text field shown formatted (Markdown through md.html): PHB spacing, oxblood bullets */
.md-text > :last-child {
    margin-bottom: 0;
}

.md-text p {
    margin-bottom: 0.5rem;
}

.md-text ul,
.md-text ol {
    margin-bottom: 0.5rem;
    padding-left: 1.4rem;
}

.md-text ul ul,
.md-text ol ol,
.md-text ul ol,
.md-text ol ul {
    margin-bottom: 0;
}

.md-text li::marker {
    color: var(--oxblood);
}

.md-text h1,
.md-text h2,
.md-text h3,
.md-text h4,
.md-text h5,
.md-text h6 {
    font-size: 1.3rem;
    margin: 0.5rem 0 0.25rem;
}

.md-text blockquote {
    margin: 0 0 0.5rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--rule-gold);
    font-style: italic;
}

/* Hidden until the page's script shows it (the script sets an inline display, which overrides this) */
.starts-hidden {
    display: none;
}

/* Previously imported documents, on their own line above the import box: the list takes the width, Remove beside it */
.import-history-row {
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.import-history-row .form-select {
    flex: 1 1 auto;
    min-width: 0;
}

/* The import box takes a dropped file; while one is dragged over it, it is outlined and says so */
.import-drop-zone {
    position: relative;
}

.import-drop-hint {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--bs-primary);
    border-radius: var(--bs-border-radius);
    background: rgba(var(--bs-body-bg-rgb), 0.85);
    font-weight: 600;
    pointer-events: none;
}

.import-drop-zone.dragging .import-drop-hint {
    display: flex;
}

/* A long tick-box list that scrolls up and down inside its panel, e.g. a faction's members; never sideways */
.scroll-choices {
    max-height: 14rem;
    overflow-x: hidden;
    overflow-y: auto;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    /* the last visible row fades out, so a row cut at the edge reads as "scroll for more" */
    mask-image: linear-gradient(to bottom, #000 calc(100% - 1.75rem), transparent);
}


/* A prepped session's quick reference: each kind (NPCs, monsters, places, items, factions) its own full-width tile,
   its records two side by side, scrolling inside one most height (fragments/quick-reference) */
.quick-ref-body {
    max-height: 26rem;
    overflow-y: auto;
}

/* A long pick list's search box (choice-search.js), between its title and its choices: the main pages' search box,
   small, so the list stays the thing on the page */
.choice-search {
    max-width: 22rem;
    margin-bottom: 0.5rem;
}

/* A pick list's columns follow the list's own width, not the window's (whatever col or row-cols classes a page gives
   them): as many of at least 9rem as fit, and never more than three, so a list in a side column gets two where one
   across the page gets three, and a name always has room to be read; narrower than 9rem, the one column shrinks to the
   box. (The third is a hair under a third, so rounding never drops it.) No side margins: a grid row's would make the
   list wider than its box */
.scroll-choices > .row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, max(9rem, calc((100% - 1px) / 3))), 1fr));
    row-gap: 0.25rem;
    margin: 0;
}

/* Each choice a grid cell: room on the left for its box's focus ring (the list never scrolls sideways, so it would be
   cut), and a gap before the next, so a name never runs into the next choice's box */
.scroll-choices > .row > * {
    width: auto;
    max-width: none;
    min-width: 0;
    margin-top: 0;
    padding-left: 0.25rem;
    padding-right: 1rem;
}

/* A pick list is a grid: each choice its column's width and the same height, room for its name and its type under
   it; a name too long for one line is cut with "…" (whole on hover, its title), never wrapped */
.scroll-choices .form-check {
    min-height: 2.75em;
}

/* The label keeps to its column (inline, as wide as its text, it would carry the name past it), so the name is cut */
.scroll-choices .form-check-label {
    display: block;
}

/* Only the name is cut to one line: what tells a choice apart under it, and anything else a label holds (the import
   review's lines), wraps */
.scroll-choices .choice-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scroll-choices .choice-type {
    display: block;
}

/* A scrollable block of sample text, e.g. the import format example */
.example-block {
    max-height: 20rem;
    overflow: auto;
    white-space: pre-wrap;
    padding: 0.5rem;
    border: 1px solid var(--rule-gold);
    border-radius: 4px;
}

/* A loot card whose loot has been taken: dimmed, still readable */
.loot-looted {
    opacity: 0.6;
}

/* A planned session already run: dimmed like looted loot, at the bottom of the Sessions page's list, still clickable */
.planned-run {
    opacity: 0.6;
}

/* A cautionary note under a field */
.warning-note {
    color: var(--warning-text);
}

/* Loading spinners in the theme's leather */
.spinner-theme {
    color: var(--leather-brown);
}

/* Text describing a good outcome */
.success-note {
    color: var(--success);
}

/* Faction power out of 10, coloured by band */
.power-meter {
    width: 100%;
    height: 25px;
    accent-color: var(--success);
}

.power-meter.power-mid {
    accent-color: var(--warning);
}

.power-meter.power-high {
    accent-color: var(--danger);
}

/* A creature's hit points in a planned session's Encounters (fragments/encounter-tracker): the power meter's bar,
   green above half, amber to a quarter, crimson at a quarter or below */
.hp-meter {
    flex: 1 1 auto;
    min-width: 6rem;
    height: 25px;
    accent-color: var(--success);
}

.hp-meter.hp-mid {
    accent-color: var(--warning);
}

.hp-meter.hp-low {
    accent-color: var(--danger);
}

/* One creature's row in the Encounters: its name and bar, its hit points under them, a dashed rule between creatures
   as between an Actions tile's lines */
.hp-row {
    padding: 0.5rem 0;
}

.hp-row + .hp-row {
    border-top: 1px dashed var(--rule-gold);
}

/* Story steps: numbered slips of the worn parchment with an oxblood edge; the current one is lit in gold, finished
   ones fade */
.story-step {
    --note-mark: var(--oxblood);
    padding: 12px 16px 12px 22px;
    margin-bottom: 10px;
}

.story-step.story-step-current {
    --note-mark: var(--gold);
    --note-shadow: var(--gold);
    --note-lift: 1px;
}

.story-step.story-step-done {
    opacity: 0.7;
}

/* On the story form, an involved NPC or faction that drives the story stays ticked and says why (story-form.js) */
.form-check[data-drives-story] .form-check-label::after {
    content: " · drives this story";
    font-size: 0.85em;
    font-style: italic;
    color: var(--ink-brown);
}

/* A story that has ended (resolved, failed or abandoned) sits back in the hub */
.story-card.story-ended {
    opacity: 0.75;
}

.step-number {
    display: inline-block;
    width: 32px;
    height: 32px;
    margin-right: 10px;
    line-height: 28px;
    text-align: center;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    background: var(--oxblood);
    color: var(--parchment-light);
    border: 2px solid var(--rule-gold);
    border-radius: 50%;
}

/* How far through its steps a story is */
.story-progress {
    width: 100%;
    height: 8px;
    accent-color: var(--gold-dark);
}

/* Colour swatches on the /style-guide page */
.swatch {
    width: 9rem;
    padding: 1.5rem 0.5rem 0.5rem;
    border: 2px solid var(--leather-darker);
    font-size: 0.75rem;
    color: var(--text-light);
}

.swatch-parchment { background: var(--parchment-light); color: var(--text-dark); }
.swatch-leather { background: var(--leather-brown); }
.swatch-gold { background: var(--gold); color: var(--text-dark); }
.swatch-oxblood { background: var(--oxblood); }
.swatch-rule-gold { background: var(--rule-gold); color: var(--text-dark); }
.swatch-success { background: var(--success); }
.swatch-warning { background: var(--warning); color: var(--text-dark); }
.swatch-danger { background: var(--danger); }
.swatch-info { background: var(--info); }

/* Text that keeps its own line breaks, e.g. AI-written prep */
.preserve-lines {
    white-space: pre-wrap;
    font-family: inherit;
}

/* Campaign list: field notes of a steady height, descriptions cut to two lines */
.campaign-row {
    min-height: 140px;
}

/* The world being imported, not built yet: dimmed, as a looted chest is */
.import-pending {
    opacity: 0.6;
}

/* One side of a difference on an update's review (the world's or the file's value): set in a little, under its
   choice, and scrolled within itself past 14rem so a long description never pushes the other choices away */
.update-value {
    max-height: 14rem;
    overflow-y: auto;
    margin-left: 1.5rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--rule-gold);
}

.clamp-2-lines {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* The edit pop-up while it fetches the item's form */
/* The pop-up's loading state: the same rolling d20 and phrase as a page change */
.edit-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 2rem;
}

.edit-modal-loading .page-loading-d20 {
    color: var(--gold-dark);
}

/* A record tile (fragments/note.html), on the paper every box has (see .card near the top): its name in the heading
   small caps over a gold rule with a diamond (note :: rule), its text in Kalam, tags in their own type, and the same
   footer on every tile (note :: footer): who it belongs to, and where. */
.field-note .card-body {
    padding: 0.6rem 0.75rem 0.4rem;
}

.field-note .text-muted {
    color: var(--ink-brown) !important;
}

/* Under the name: a gold rule broken by a small diamond */
.note-rule {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0.25rem 0 0.6rem;
}

.note-rule::before,
.note-rule::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--rule-gold);
}

.note-rule span {
    width: 7px;
    height: 7px;
    transform: rotate(45deg);
    background: var(--gold-dark);
}

/* A note's footer: who it belongs to on the left, where it is on the right, under a dashed rule */
.card-footer {
    background: none;
    border-top: 1px dashed var(--rule-gold);
    margin: 0 0.75rem;
    padding: 0.35rem 0 0.45rem;
}

.card-footer .icon {
    color: var(--ink-brown);
}

/* A list in a note (an Actions tile, a list of links): handwritten lines on the paper, dashed between */
.card .list-group-item {
    background: none;
    border: none;
    border-bottom: 1px dashed var(--rule-gold);
    /* Inset from the paper's edge: auto, not Bootstrap's 100% (an action's), so it doesn't run past it */
    width: auto;
    margin: 0 0.75rem;
    padding-left: 0;
    padding-right: 0;
}

.card .list-group-item:last-child {
    border-bottom: none;
}

.card .list-group-item-action:hover {
    background: none;
    color: var(--oxblood);
}

/* A note's heading sits inside its worn edge */
.card > .dnd-card-header,
.dnd-card > .dnd-card-header {
    margin: 0 0.75rem;
    padding-left: 0;
    padding-right: 0;
}

/* Registered, so the shadow's lift eases with the tile's */
@property --note-lift {
    syntax: '<length>';
    inherits: true;
    initial-value: 3px;
}

.card.note-link {
    transition: top 0.15s ease, --note-lift 0.15s ease;
}

.card.clickable-card:hover,
.card.clickable-card:focus-visible,
.card.note-link:hover,
.card.note-link:focus-within {
    top: -2px;
    box-shadow: none;
    --note-shadow: rgba(60, 35, 10, 0.5);
    --note-lift: 6px;
}

/* The same lift while a card's name has the keyboard; a rule of its own, as a browser without :has() drops a
   whole rule over one selector it can't read */
.card.clickable-card:has([data-card-link]:focus-visible) {
    top: -2px;
    box-shadow: none;
    --note-shadow: rgba(60, 35, 10, 0.5);
    --note-lift: 6px;
}

/* A card that opens something when clicked: lift it on hover and show keyboard focus */
.clickable-card {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, top 0.15s ease, --note-lift 0.15s ease;
}

/* A clickable chip lifts with a transform; a note lifts by moving (top), since a transform would make it a layer of
   its own (see the field notes) */
.clickable-card:not(.card):hover,
.clickable-card:not(.card):focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(44, 24, 16, 0.3);
}

.clickable-card:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

.clickable-card:has([data-card-link]:focus-visible),
.card.note-link:has(.stretched-link:focus-visible) {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

/* A card's name is its one control: with the keyboard on it, the whole card shows the focus (and lifts, as on hover,
   in the rules beside each hover); the name draws no ring of its own where the browser can draw the card's */
@supports selector(:has(*)) {
    .clickable-card [data-card-link]:focus-visible {
        outline: none;
    }
}

/* A row's title that is its name link (a rumor, a story, a prepped session's place) keeps the colour it had as plain
   text */
a.card-name {
    color: inherit;
}

/* A name that opens a pop-up with no page behind it (the dashboard's shared links) is a button that reads as the
   title it replaces */
.card-link-button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-align: start;
    text-decoration: none;
}

/* A note opened by its stretched name shows the focus on the whole note, not just the name */
.card.note-link .stretched-link:focus-visible {
    outline: none;
}

/* A planned session's row opens its page from anywhere on it; its Up, Down, and Set as current buttons sit above
   the stretched title, so they still do their own thing */
/* The Planned Sessions tile: its list starts right under the title however few there are (the card body doesn't
   stretch to fill the tile beside the Actions), and after about five sessions it scrolls instead of growing */
.planned-session-tile > .card-body {
    flex: 0 0 auto;
}

.planned-session-tile > .list-group {
    max-height: 17.5rem;
    overflow-y: auto;
}

.planned-row {
    cursor: pointer;
}

/* Lit when it is hovered or its title has the keyboard's focus, not when one of its buttons has */
.planned-row:hover,
.planned-row:has(.stretched-link:focus-visible) {
    background-color: rgba(212, 175, 55, 0.15);
}

.planned-row form {
    position: relative;
    z-index: 2;
}

.planned-row .stretched-link:focus-visible {
    outline: none;
}

.planned-row:has(.stretched-link:focus-visible) {
    outline: 3px solid var(--gold);
    outline-offset: -3px;
}

/* A planned session's places, NPCs, and factions under its Actions: rows like Actions' that open a pop-up, so they
   light up as Actions' rows do instead of lifting like a card */
.related-item.clickable-card:hover,
.related-item.clickable-card:focus-visible {
    transform: none;
    box-shadow: none;
}

.related-item.clickable-card:has([data-card-link]:focus-visible) {
    transform: none;
    box-shadow: none;
}

.related-item.clickable-card:focus-visible {
    outline-offset: -3px;
}

.related-item.clickable-card:has([data-card-link]:focus-visible) {
    outline-offset: -3px;
}

/* A planned session's Jump to tile links to the sections of its prep; a section lands clear of the top of the
   window */
.prep-section {
    scroll-margin-top: 5rem;
}

/* A row in a list (a location page's rumors and plot threads) that opens the edit pop-up: it lights up instead
   of lifting like a card */
.clickable-row {
    padding: 0.5rem;
    border-radius: 4px;
}

.clickable-row:hover,
.clickable-row:focus-visible {
    transform: none;
    box-shadow: none;
    background-color: rgba(212, 175, 55, 0.15);
}

.clickable-row:has([data-card-link]:focus-visible) {
    transform: none;
    box-shadow: none;
    background-color: rgba(212, 175, 55, 0.15);
}

/* A feature people should notice, not fine print: a note on the paper, its title an oxblood heading */
.import-format-callout {
    padding: 0.9rem 1rem;
}

.import-format-callout-title {
    color: var(--text-dark);
    font-family: var(--font-heading);
    font-size: 1.3rem;
    margin-bottom: 0.35rem;
}

code {
    color: var(--leather-brown);
    font-weight: bold;
}

.import-format-callout [aria-expanded="true"] .when-collapsed,
.import-format-callout [aria-expanded="false"] .when-expanded {
    display: none;
}

/* The bulk stat-block page's Back / count / Generate row: stays on screen while a long NPC list scrolls under it */
.stat-block-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
    margin: 0 -1rem;
    padding: 0.75rem 1rem;
    background: var(--parchment-light);
    border-top: 3px solid var(--rule-gold);
    box-shadow: 0 -4px 6px rgba(44, 24, 16, 0.2);
}

/* On a page with this bar the Campaign Sage and Session Notes buttons float just above it, so neither covers the
   other */
body:has(.stat-block-actions) .chat-floating-fab {
    bottom: 5.25rem;
}

/* There the Sage's question banner stays above the Session Notes button too */
body:has(.stat-block-actions) .sage-ask-banner {
    bottom: calc(5.25rem + 72px);
}

/* The bulk stat-block page's NPCs: past twenty, a box of twenty that scrolls (stat-block-bulk.js sets its height to
   end at the twenty-first, never taller than the screen above the actions bar), its header staying put, and room
   left under the header for whatever is scrolled into view. At either end a swipe carries on to the page. */
.stat-block-list {
    overflow-y: auto;
    scroll-padding-top: 3rem;
    margin-bottom: 1rem;
}

/* Its table has no margin below; the header, which rows scroll under, is the same paper's light tone, so it reads as
   part of the page (the shared .table rule makes the rows transparent) */
.stat-block-list .table {
    margin-bottom: 0;
}

.stat-block-list .table > tbody > tr > td {
    border-bottom: 1px dashed var(--rule-gold);
}

.stat-block-list .table > thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--paper-light);
    /* Its gold rule, drawn so it stays with the header (a collapsed border scrolls away), in place of the border */
    border-bottom: 0;
    box-shadow: inset 0 -2px 0 var(--rule-gold);
}

/* A scrolling box a keyboard reaches (tabindex="0"): the bulk stat-block list, and a .scroll-choices list of links
   (how NPCs feel about a player) */
.stat-block-list:focus-visible,
.scroll-choices:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

/* The −/+ control for an NPC's disposition (fragments/disposition-stepper.html): the change, or the score, between
   two square buttons, wide enough that "Indifferent (+1)" doesn't make the buttons jump as it changes */
.stepper-button {
    width: 2.25rem;
    font-family: var(--font-body);
    font-size: 1.25rem;
    font-weight: bold;
    line-height: 1;
}

.stepper-value {
    min-width: 2.5rem;
    text-align: center;
    font-weight: bold;
}

/* A value the AI filled in that the GM has not checked yet: gold, like the rule around a PHB note */
.form-control.cr-suggested {
    background-color: var(--gold-pale);
    border-color: var(--gold-dark);
}

/* Tables */

/* List Groups */
.list-group-item {
    background: rgba(244, 232, 208, 0.6);
    border: 1px solid var(--rule-gold);
    color: var(--text-dark);
    font-family: var(--font-body);
}

/* On a phone a record page's Actions tile sits under its title, minimized to its header line; tapping the line
   slides its list open or shut, slowly (static/js/actions-menu.js sets the heights). Only a tile the script has
   wired is minimized: without the script it stays open. */
@media (max-width: 767.98px) {
    [data-actions-wired] > .list-group {
        overflow: hidden;
        transition: max-height 0.6s ease;
    }

    [data-actions-wired]:not([data-actions-shown]) > .list-group {
        max-height: 0;
    }

    [data-actions-wired] [data-actions-toggle] {
        cursor: pointer;
    }
}

/* The caret beside "Actions" on a phone: down while minimized, turning up as the list opens */
.actions-caret .icon {
    transition: transform 0.6s ease;
}

[data-actions-shown] .actions-caret .icon {
    transform: rotate(180deg);
}

/* A folding card's title (fold.js: a planned session's prep sections): a button the width of the header that reads as
   the heading it sits in, its caret at the far end */
.fold-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.fold-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(212, 175, 55, 0.4);
}

/* Open, the caret turns up, as the Actions tile's does */
.fold-toggle[aria-expanded="true"] .actions-caret .icon {
    transform: rotate(180deg);
}

/* The body slides as the Actions tile's list does; folded, it is gone, padding and all */
[data-fold-wired] > .fold-body {
    overflow: hidden;
    transition: max-height 0.6s ease, padding 0.6s ease;
}

[data-fold-wired][data-folded] > .fold-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

@media (prefers-reduced-motion: reduce) {
    [data-actions-wired] > .list-group,
    [data-fold-wired] > .fold-body,
    .actions-caret .icon {
        transition: none;
    }
}

/* A row you can click is bold like every link, also when it is a button (an Actions tile's Share, Copy …) */
.list-group-item-action {
    font-weight: bold;
}

.list-group-item:hover, .list-group-item-action:hover {
    background: rgba(212, 175, 55, 0.2);
    color: var(--text-dark);
}

/* The row chosen in a list of results (an Add's search on the character sheet): gold, never Bootstrap's blue */
.list-group-item.active {
    background: rgba(212, 175, 55, 0.35);
    border-color: var(--rule-gold);
    box-shadow: inset 4px 0 0 var(--oxblood);
    color: var(--text-dark);
}

.list-group-item:active, .list-group-item-action:active {
    background: rgba(212, 175, 55, 0.35);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
    transform: scale(0.98);
    transition: transform 0.05s, background 0.05s;
}

/* Modals: the same certificate parchment as the page (a narrower frame, all the way round), its title a PHB heading
   over a gold rule */
.modal-content {
    /* Plain parchment until the picture arrives, as for the sheet */
    background: var(--parchment-dark);
    border: 28px solid transparent;
    border-image: var(--frame-picture) 250 fill / 28px stretch;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
    border-radius: 0;
}

.modal-header {
    border-bottom: 2px solid var(--rule-gold);
}

.modal-footer {
    border-top: 1px solid var(--rule-gold);
}

/* A row of tags that stays on one line (a pop-up's tags, a title's tags); a phone draws them a little smaller so they
   fit, and wraps a row that sits beside a title. In a tile (flex-wrap: an NPC's AC, HP, speed and disposition) it
   wraps instead of running past the paper */
.tag-row {
    white-space: nowrap;
}

.tag-row.flex-wrap {
    white-space: normal;
}

/* In a row that wraps, a tag too long for its card (a scene's whole name) wraps inside it, never past its edge */
.tag-row.flex-wrap .badge {
    white-space: normal;
    max-width: 100%;
    overflow-wrap: anywhere;
    text-align: left;
}

@media (max-width: 575.98px) {
    .tag-row .badge {
        font-size: 0.75rem;
    }

    /* Beside a title in a name-and-tags row (a story's stage, status, and impact; a faction's type and power), a
       phone wraps the tags onto more lines, right-aligned, rather than pushing the page wider than the screen */
    .justify-content-between > .tag-row:not(.flex-wrap) {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.25rem;
        white-space: normal;
        min-width: 0;
    }
}

@media (max-width: 379.98px) {
    .tag-row .badge {
        font-size: 0.68rem;
        padding-left: 0.4em;
        padding-right: 0.4em;
    }
}

/* The pop-up's buttons stay on one line; a phone gives them a little less padding so they fit */
.modal-footer .btn {
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .modal-footer {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .modal-footer .btn {
        padding-left: 0.6rem;
        padding-right: 0.6rem;
        font-size: 1.05rem;
    }
}

@media (max-width: 379.98px) {
    .modal-footer {
        gap: 0.25rem !important;
    }

    .modal-footer .btn {
        padding-left: 0.4rem;
        padding-right: 0.4rem;
        font-size: 0.95rem;
    }
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--oxblood);
}

/* Links */
a {
    color: var(--leather-brown);
    font-weight: bold;
}

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

/* Container */
.container {
    max-width: 1200px;
}

/* Specific Card Types */

/* Tabs: PHB small-caps labels in one row on a wide screen; every tab is edged in the gold rule, and the open one
   is parchment */
.nav-tabs {
    border-bottom: 2px solid var(--rule-gold);
    flex-wrap: nowrap;
}

.nav-tabs .nav-link {
    background: transparent;
    border: 1px solid var(--rule-gold);
    border-bottom: none;
    color: var(--leather-dark) !important;
    font-family: var(--font-heading);
    font-size: 1rem;
    text-shadow: none;
    white-space: nowrap;
    margin-right: 4px;
    border-radius: 0;
    padding: 5px 10px 3px;
}

.nav-tabs .nav-link:hover {
    background: rgba(212, 175, 55, 0.15);
    color: var(--oxblood) !important;
    border-color: var(--rule-gold);
}

.nav-tabs .nav-link.active {
    background: var(--parchment-light) !important;
    border: 1px solid var(--rule-gold);
    border-bottom: none;
    color: var(--oxblood) !important;
}

/* Narrower than a wide desktop, the tabs stack into an even grid three across, each a closed tile */
@media (max-width: 1199.98px) {
    .nav-tabs {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
        border-bottom: none;
    }

    .nav-tabs .tab-count {
        display: block;
    }

    .nav-tabs .nav-link,
    .nav-tabs .nav-link.active {
        height: 100%;
        margin: 0;
        border-bottom: 1px solid var(--rule-gold);
        text-align: center;
        white-space: normal;
    }
}

/* Tabs that are all one size (Homebrew's kinds): an even grid at every width, wrapping on a phone, each label cut with
   an ellipsis only where it cannot fit (its full name is the link's title). 6rem gives a phone three across and a laptop one row */
.nav-tabs.nav-tabs-even {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr));
    gap: 4px;
    border-bottom: none;
}

.nav-tabs-even .nav-item {
    min-width: 0;
}

.nav-tabs-even .nav-link,
.nav-tabs-even .nav-link.active {
    display: block;
    height: 100%;
    margin: 0;
    border-bottom: 1px solid var(--rule-gold);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== AI Chat Panel ===== */

/* Chat panel */
.chat-panel {
    position: sticky;
    top: 100px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    margin: 14px 0;
    border: 24px solid transparent;
    /* No shadow under the sheet: while it rolls, the clip that follows the roller would cut a shadow off in a straight
       line, a dark box behind the scroll. Its darker, worn edges set it off from the page instead. A stacking context
       of its own (isolation) keeps the paper layer, at z-index -1, behind its contents and in front of the page. */
    isolation: isolate;
    font-family: var(--font-body);
}

/* The Sage's sheet: aged, yellowed paper with soft stains and worn, uneven sides, behind the panel's contents. Its
   own layer (chat-panel.js puts it first in the panel), so the mask that wears its edges doesn't also cut off the
   rollers, which reach past the paper. The images are data URIs: the worn edges are a mask (shape only), the stains
   brown noise. */
.chat-paper {
    position: absolute;
    inset: -24px;
    z-index: -1;
    /* The pop-ups' certificate parchment (the page's sheet, its ornamental frame cut to a narrow 24px border), with
       its sides worn by the mask below */
    border: 24px solid transparent;
    border-image: var(--frame-picture) 250 fill / 24px stretch;
    /* Plain parchment until the picture arrives, as for the sheet */
    background-color: var(--parchment-dark);
    /* The worn sides: each a strip of uneven edge repeated down the paper (the right the left's shape mirrored), the
       middle solid */
    --sage-worn-left: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='200'%3E%3Cpath d='M16 0 L3.4 0 L3.9 8 L1.9 14 L2.1 28 L1.8 42 L2.8 56 L4.1 62 L2.9 68 L4.0 82 L2.2 96 L5.3 104 L7.2 118 L5.0 132 L7.4 138 L4.8 144 L3.2 152 L4.7 160 L3.4 174 L2.1 182 L5.3 196 L3.4 200 L16 200 Z' fill='black'/%3E%3C/svg%3E");
    --sage-worn-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='200'%3E%3Cpath d='M16 0 L3.4 0 L3.9 8 L1.9 14 L2.1 28 L1.8 42 L2.8 56 L4.1 62 L2.9 68 L4.0 82 L2.2 96 L5.3 104 L7.2 118 L5.0 132 L7.4 138 L4.8 144 L3.2 152 L4.7 160 L3.4 174 L2.1 182 L5.3 196 L3.4 200 L16 200 Z' fill='black' transform='translate(16 0) scale(-1 1)'/%3E%3C/svg%3E");
    -webkit-mask:
        var(--sage-worn-left) left top / 16px 200px repeat-y,
        var(--sage-worn-right) right top / 16px 200px repeat-y,
        linear-gradient(black, black) center / calc(100% - 32px) 100% no-repeat;
    mask:
        var(--sage-worn-left) left top / 16px 200px repeat-y,
        var(--sage-worn-right) right top / 16px 200px repeat-y,
        linear-gradient(black, black) center / calc(100% - 32px) 100% no-repeat;
    pointer-events: none;
}

/* The scroll's rollers, top and bottom, wider than the paper: the sheet rolled up, each end capped by the closed
   button's brass finial (the finial drawn as a data URI in the brass tokens' colours; SageColoursTest keeps them the
   tokens' own) */
.chat-panel::before,
.chat-panel::after {
    content: "";
    position: absolute;
    /* The rolled paper is exactly as wide as the sheet (its outer edge is 24px out, past the padding box); each 28px
       finial caps it just outside the sheet's side, its collar over the roll's end */
    left: -47px;
    right: -47px;
    height: 34px;
    z-index: 2;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 14 50 62'%3E%3Cdefs%3E%3ClinearGradient id='b' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%233a2604'/%3E%3Cstop offset='.18' stop-color='%236d4c10'/%3E%3Cstop offset='.34' stop-color='%23f3dc8a'/%3E%3Cstop offset='.5' stop-color='%23b8892e'/%3E%3Cstop offset='.78' stop-color='%236d4c10'/%3E%3Cstop offset='1' stop-color='%233a2604'/%3E%3C/linearGradient%3E%3CradialGradient id='k' cx='.38' cy='.32' r='.75'%3E%3Cstop offset='0' stop-color='%23fff0b0'/%3E%3Cstop offset='.3' stop-color='%23b8892e'/%3E%3Cstop offset='.75' stop-color='%236d4c10'/%3E%3Cstop offset='1' stop-color='%233a2604'/%3E%3C/radialGradient%3E%3C/defs%3E%3Cg%3E%3Crect x='40' y='14' width='10' height='62' rx='3' fill='url(%23b)'/%3E%3Crect x='35' y='19' width='6' height='52' rx='2' fill='url(%23b)'/%3E%3Cpath d='M35 24 C22 24 18 36 18 45 C18 54 22 66 35 66 Z' fill='url(%23b)'/%3E%3Cpath d='M33 27 C25 30 23 38 23 45 C23 52 25 60 33 63 M29 29 C24 34 24 40 24 45' fill='none' stroke='%233a2604' stroke-opacity='.6'/%3E%3Crect x='13' y='38' width='6' height='14' rx='2' fill='url(%23b)'/%3E%3Cellipse cx='10' cy='45' rx='7' ry='9' fill='url(%23k)'/%3E%3Cpath d='M4 40 C0 42 0 48 4 50 C2 47 2 43 4 40 Z' fill='%23b8892e'/%3E%3C/g%3E%3C/svg%3E") left center / 28px 34px no-repeat,
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 14 50 62'%3E%3Cdefs%3E%3ClinearGradient id='b' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%233a2604'/%3E%3Cstop offset='.18' stop-color='%236d4c10'/%3E%3Cstop offset='.34' stop-color='%23f3dc8a'/%3E%3Cstop offset='.5' stop-color='%23b8892e'/%3E%3Cstop offset='.78' stop-color='%236d4c10'/%3E%3Cstop offset='1' stop-color='%233a2604'/%3E%3C/linearGradient%3E%3CradialGradient id='k' cx='.38' cy='.32' r='.75'%3E%3Cstop offset='0' stop-color='%23fff0b0'/%3E%3Cstop offset='.3' stop-color='%23b8892e'/%3E%3Cstop offset='.75' stop-color='%236d4c10'/%3E%3Cstop offset='1' stop-color='%233a2604'/%3E%3C/radialGradient%3E%3C/defs%3E%3Cg transform='translate(50 0) scale(-1 1)'%3E%3Crect x='40' y='14' width='10' height='62' rx='3' fill='url(%23b)'/%3E%3Crect x='35' y='19' width='6' height='52' rx='2' fill='url(%23b)'/%3E%3Cpath d='M35 24 C22 24 18 36 18 45 C18 54 22 66 35 66 Z' fill='url(%23b)'/%3E%3Cpath d='M33 27 C25 30 23 38 23 45 C23 52 25 60 33 63 M29 29 C24 34 24 40 24 45' fill='none' stroke='%233a2604' stroke-opacity='.6'/%3E%3Crect x='13' y='38' width='6' height='14' rx='2' fill='url(%23b)'/%3E%3Cellipse cx='10' cy='45' rx='7' ry='9' fill='url(%23k)'/%3E%3Cpath d='M4 40 C0 42 0 48 4 50 C2 47 2 43 4 40 Z' fill='%23b8892e'/%3E%3C/g%3E%3C/svg%3E") right center / 28px 34px no-repeat,
        linear-gradient(to bottom, color-mix(in srgb, var(--leather-deep) 30%, transparent),
            color-mix(in srgb, var(--leather-deep) 0%, transparent) 22%,
            color-mix(in srgb, var(--paper-light) 45%, transparent) 42%,
            color-mix(in srgb, var(--leather-deep) 0%, transparent) 62%,
            color-mix(in srgb, var(--leather-deep) 32%, transparent)) content-box,
        linear-gradient(color-mix(in srgb, var(--leather-rust) 16%, transparent),
            color-mix(in srgb, var(--leather-rust) 16%, transparent)) content-box,
        var(--frame-picture) 50% 50% / 700px auto content-box var(--parchment-dark);
    /* The rolled paper fills the content box only, between the finials: the sheet's own certificate parchment,
       warmed to the reddish ageing of the sheet's edges and shaded as a cylinder */
    box-sizing: border-box;
    padding: 4px 23px;
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4));
    pointer-events: none;
}

.chat-panel::before {
    top: -42px;
}

.chat-panel::after {
    top: calc(100% + 6px);
}

.chat-header {
    padding: 0 0 4px;
    border-bottom: 2px solid var(--rule-gold);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--oxblood);
    font-family: var(--font-heading);
}

/* A help "i": a bold "i" in a circle, no button box. Every title's (a page's, a card's, a pop-up's, a tile's, the
   Sage's) sits just after the title, centred on its line, so the help is always in the same place and never off at
   the far right; anything else in the header goes to the right of it. The Sage's takes the place of .chat-info-slot
   (campaign-chat.html). */
.chat-info-button {
    align-self: center;
    margin: 0 auto 0 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.05rem;
    height: 1.05rem;
    padding: 0;
    flex-shrink: 0;
    border: 1.5px solid var(--oxblood);
    border-radius: 50%;
    background: transparent;
    color: var(--oxblood);
    font: bold 0.7rem/1 Georgia, serif;
}

/* The same mark just after a form field's label (a story step's Step order), raised a little like the header's */
.form-label + .chat-info-button {
    margin: 0 0 0 0.35rem;
    vertical-align: text-top;
}

/* A label with its "i" after it keeps to its own width, so the mark sits on the label's line */
label.form-label:has(+ .chat-info-button) {
    display: inline-block;
}

.chat-info-button:hover {
    background: var(--oxblood);
    color: var(--parchment-light);
}

/* A hint under a pick-one or tick-box list sits close under it, as a field's hint does */
fieldset.choice-panel + .form-text {
    display: block;
    margin-top: -0.75rem;
    margin-bottom: 1rem;
}

/* The in-game calendar (in-game-calendar.js): a month grid on aged paper that opens under its date's fields, in the
   campaign's own month and weekday names. Today is ringed in oxblood, the chosen day filled, a marked day (a step's
   Starts, on its Due calendar) underlined in gold */
.calendar-open {
    line-height: 1;
}

/* An in-game date's calendar button, day, month and year share one line, even on a phone: the boxes may shrink */
.in-game-date-row > * {
    min-width: 0;
}

/* A number box for a count or hit points, three or four digits wide: how many of a creature, and its hit points */
.count-box {
    width: 5.5rem;
}

/* An in-game date's day count, beside its label under the date: a few digits wide */
.in-game-days {
    width: 7rem;
}

.calendar-pop {
    /* Fixed to the window under its button (in-game-calendar.js places it), over any pop-up */
    position: fixed;
    z-index: 1070;
    width: min(20rem, calc(100vw - 1rem));
    padding: 0.6rem;
    border: 1px solid var(--rule-gold);
    background: var(--paper-light);
    box-shadow: 0 6px 16px rgba(44, 24, 16, 0.35);
}

.calendar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.calendar-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--oxblood);
}

.calendar-step {
    padding: 0 0.5rem;
    border: none;
    background: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--oxblood);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-weekday {
    text-align: center;
    font-size: 0.75rem;
    color: var(--ink-brown);
}

.calendar-day {
    padding: 0.3rem 0;
    border: 1px solid transparent;
    border-radius: 2px;
    background: none;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.calendar-day:hover:not(:disabled) {
    background: rgba(212, 175, 55, 0.25);
}

.calendar-day:focus-visible,
.calendar-step:focus-visible {
    outline: 3px solid var(--ember);
    outline-offset: 1px;
}

.calendar-day:disabled {
    color: var(--paper-edge);
}

.calendar-day.is-today {
    border-color: var(--oxblood);
}

.calendar-day.is-selected {
    background: var(--oxblood);
    color: var(--parchment-light);
}

.calendar-day.is-marked {
    box-shadow: inset 0 -3px 0 var(--gold);
}

.calendar-key {
    margin: 0.4rem 0 0;
    font-size: 0.8rem;
    color: var(--ink-brown);
}

/* A help note: an Actions tile's opens just below its row (a collapse); a field's is shown in the help pop-up, or a
   pop-over inside a pop-up (field-help-popover, below), and its own copy stays hidden */
.field-help {
    margin: 0.35rem 0 0.75rem;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--rule-gold);
    background: var(--paper-light);
    color: var(--text-dark);
    font-size: 0.9rem;
}

/* A note opened inside a row of fields spans the row, lined up with its columns rather than the row's gutters */
.row > .field-help {
    width: calc(100% - var(--bs-gutter-x));
    margin-left: calc(var(--bs-gutter-x) * 0.5);
    margin-right: calc(var(--bs-gutter-x) * 0.5);
}

/* A field's note in a pop-over beside its "i", inside a pop-up already (help-pop.js, Bootstrap's popover): the help's paper
   and gold rule, its title in oxblood */
.field-help-popover {
    --bs-popover-max-width: 24rem;
    --bs-popover-bg: var(--paper-light);
    --bs-popover-border-color: var(--rule-gold);
    --bs-popover-header-bg: var(--parchment-dark);
    --bs-popover-header-color: var(--oxblood);
    --bs-popover-body-color: var(--text-dark);
    font-size: 0.9rem;
    box-shadow: 0 6px 16px rgba(44, 24, 16, 0.35);
}

.field-help-popover .popover-header {
    font-family: var(--font-heading);
}

.field-help-popover ul {
    margin-bottom: 0.5rem;
    padding-left: 1.2rem;
}

/* A note's drawing shows only in the help pop-up; floating beside its "i" or open in an Actions tile, it's words only */
.field-help .help-figure {
    display: none;
}

/* Light words on a filled shape in a help drawing (a Resolved pill) */
.help-figure .hf-light-text {
    fill: var(--parchment-light);
}

/* Where the Sage is, last in a help note that sends the GM to it: set off under a thin gold rule */
.sage-open-hint {
    margin: 0.75rem 0 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--rule-gold);
    font-size: 0.9rem;
}

/* A help note's import-format example: the text to paste, set apart on darker paper behind a gold rule */
.quick-add-example {
    background: var(--parchment-dark);
    border-left: 3px solid var(--rule-gold);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

.field-help ul {
    margin-bottom: 0.5rem;
    padding-left: 1.2rem;
}

/* An action with its "i" (an Actions tile's less obvious ones): the action fills the row, the mark sits at its end,
   and its note opens under both */
/* The row holding an action and its note isn't itself an action: no hover tint or press on it, or on its open note */
.card .action-with-help:hover,
.card .action-with-help:active {
    background: none;
    box-shadow: none;
    transform: none;
}

/* The action inside the row is already inset by the row, so it takes no inset or rule of its own */
.card .action-with-help .list-group-item {
    margin: 0;
    border-bottom: none;
}

.action-with-help .chat-info-button {
    align-self: center;
    margin: 0 0.75rem 0 0.5rem;
}

.action-with-help .field-help {
    margin: 0 0.75rem 0.6rem;
}

/* The same mark after a big title (the campaign's name, Welcome back, a tile's, kept centred with it) or a button
   (Save and generate): a little more room, and big enough to tap on a touch screen */
.chat-info-beside {
    align-self: center;
    margin: 0 0 0 0.6rem;
}

@media (pointer: coarse) {
    .chat-info-beside {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 1rem;
    }
}

/* A help pop-up's section: a drawing beside its text, the drawing above it on a phone, a gold rule between sections */
.help-section {
    display: grid;
    gap: 0.75rem 1.5rem;
    padding: 1rem 0;
    border-top: 1px solid var(--rule-gold);
}

/* The first section sits straight under the header's own rule */
.modal-body > .help-section:first-child {
    padding-top: 0;
    border-top: none;
}

/* Side by side only where the pop-up is wide (modal-lg, from 992px); narrower, the drawing sits above its words */
@media (min-width: 992px) {
    .help-section {
        grid-template-columns: 17rem 1fr;
        align-items: start;
    }

    /* A help section with no drawing (the closing Getting started, any section without one): its words take the
       whole width, so no section has to remember a class for it */
    .help-section.help-section-text,
    .help-section:not(:has(.help-figure)) {
        grid-template-columns: 1fr;
    }
}

.help-section h3 {
    color: var(--oxblood);
    font-family: var(--font-heading);
    font-size: 1.15rem;
}

/* A help pop-up's drawing: an inline SVG on aged paper, coloured only by the hf- classes below */
.help-figure {
    margin: 0 auto;
    width: 100%;
    max-width: 20rem;
}

.help-figure svg {
    display: block;
    width: 100%;
    height: auto;
}

.help-figure figcaption {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    color: var(--ink-brown);
}

.help-figure text {
    font-family: var(--font-body);
    fill: var(--text-dark);
    text-anchor: middle;
}

.hf-label {
    font-size: 11px;
}

.hf-small {
    font-size: 9.5px;
}

.hf-start text,
.help-figure .hf-start {
    text-anchor: start;
}

.help-figure .hf-heading {
    font-family: var(--font-heading);
    font-size: 14px;
    fill: var(--oxblood);
    text-anchor: start;
}

.hf-paper {
    fill: var(--paper-light);
    stroke: var(--ink-brown);
    stroke-width: 1.2;
}

.hf-ink {
    fill: none;
    stroke: var(--ink-brown);
    stroke-width: 1.5;
}

/* The gold thread that links one record to another */
.hf-thread {
    fill: none;
    stroke: var(--gold-dark);
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
}

.hf-leather {
    fill: var(--leather-rust);
    stroke: var(--leather-deep);
    stroke-width: 1.5;
}

.hf-gold-line {
    fill: none;
    stroke: var(--gold);
}

.help-figure .hf-gold-text,
.help-figure .hf-gold-text text {
    font-family: var(--font-heading);
    font-size: 14px;
    fill: var(--gold-pale);
}

.hf-done {
    fill: var(--success);
}

.hf-tick {
    fill: none;
    stroke: var(--paper-light);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* The tick in a checkbox, dark on the paper */
.hf-tick-dark {
    stroke: var(--success);
}

/* The step it's on, and the hearth's flame: gold, with firelight round it */
.hf-current {
    fill: var(--gold);
    stroke: var(--brass-dark);
}

.hf-glow {
    fill: var(--ember);
    opacity: 0.35;
}

.hf-flag-pole {
    stroke: var(--ink-brown);
    stroke-width: 1.5;
}

.hf-flag {
    fill: var(--oxblood);
}

.hf-roller {
    fill: var(--paper-edge);
    stroke: var(--ink-brown);
    stroke-width: 1.2;
}

.hf-button {
    fill: var(--oxblood);
}

.help-figure .hf-button-text {
    font-size: 11px;
    fill: var(--parchment-light);
}

.hf-feather {
    fill: var(--paper);
    stroke: var(--ink-brown);
    stroke-width: 1;
}

.hf-arrowhead {
    fill: var(--ink-brown);
}

.hf-end text,
.help-figure .hf-end {
    text-anchor: end;
}

/* An arrow drawn in ink, its head from the drawing's own marker */
.hf-arrow {
    fill: none;
    stroke: var(--ink-brown);
    stroke-width: 1.5;
}

/* The Sage's reply: ink on the paper, in its own hand */
.help-figure .hf-ink-text text {
    font-family: 'Almendra', Georgia, serif;
    fill: var(--ink-brown);
}

/* A page's other parts, sketched in faintly behind what the drawing points out */
.hf-faint {
    fill: none;
    stroke: var(--paper-edge);
    stroke-width: 1.2;
}

/* Lines of writing on a page */
.hf-faint-line {
    fill: none;
    stroke: var(--paper-edge);
    stroke-width: 2;
}

/* Allies: a gold bond. Enemies, and a story's failure branch: a broken red line */
.hf-ally {
    fill: none;
    stroke: var(--gold-dark);
    stroke-width: 3;
}

.hf-enemy {
    fill: none;
    stroke: var(--needle);
    stroke-width: 2;
    stroke-dasharray: 5 4;
}

.help-figure .hf-small-gold text {
    font-size: 11px;
}

/* A scale's other marks (an NPC's disposition), empty beside the one it's at */
.hf-meter {
    fill: var(--paper);
    stroke: var(--ink-brown);
    stroke-width: 1;
}

/* A new GM's first campaign: the Sage and its "i" glow gold, like the compass lit, until the GM opens either. The
   Sage keeps its own shadow under the glow */
@keyframes sage-intro-glow {
    0%, 100% {
        filter: drop-shadow(0 0 4px var(--gold));
    }

    50% {
        filter: drop-shadow(0 0 14px var(--glow-light)) drop-shadow(0 0 8px var(--gold));
    }
}

@keyframes sage-intro-glow-fab {
    0%, 100% {
        filter: drop-shadow(0 6px 5px rgba(44, 24, 16, 0.45)) drop-shadow(0 0 4px var(--gold));
    }

    50% {
        filter: drop-shadow(0 6px 5px rgba(44, 24, 16, 0.45)) drop-shadow(0 0 14px var(--glow-light)) drop-shadow(0 0 8px var(--gold));
    }
}

.chat-floating-fab.sage-intro {
    animation: sage-intro-glow-fab 2.2s ease-in-out infinite;
}

/* Lit gold, its "i" stays oxblood, pointed at or not */
.chat-info-button.sage-intro,
.chat-info-button.sage-intro:hover {
    background: var(--gold-light);
    color: var(--oxblood);
    animation: sage-intro-glow 2.2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .chat-floating-fab.sage-intro {
        animation: none;
        filter: drop-shadow(0 6px 5px rgba(44, 24, 16, 0.45)) drop-shadow(0 0 10px var(--glow-light)) drop-shadow(0 0 6px var(--gold));
    }

    .chat-info-button.sage-intro,
    .chat-info-button.sage-intro:hover {
        animation: none;
        filter: drop-shadow(0 0 10px var(--glow-light)) drop-shadow(0 0 6px var(--gold));
    }
}

.chat-title {
    font-size: 1.6rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Toggle wrapper - keeps label and switch inline */

/* Toggle switch - leather track, gold knob */

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 4px;
}

.chat-message {
    margin-bottom: 12px;
    display: flex;
}

.chat-message-user {
    justify-content: flex-end;
}

.chat-message-ai {
    justify-content: flex-start;
}

.chat-bubble {
    padding: 10px 14px;
    max-width: 85%;
    font-family: var(--font-body);
    border-radius: 0;
    color: var(--text-dark);
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Your messages: a parchment slip edged in the gold rule */
.chat-bubble-user {
    background: var(--parchment-light);
    border: 1px solid var(--rule-gold);
    box-shadow: 0 2px 4px rgba(44, 24, 16, 0.2);
}

/* The Sage writes its answers straight onto the scroll: ink in its own hand, no box. chat-panel.js writes them
   at a quill's pace, with .sage-quill at the end of the line. */
.chat-bubble-ai {
    max-width: 100%;
    padding: 2px 4px;
    background: none;
    font-family: 'Almendra', var(--font-body);
    font-size: 1.12rem;
    line-height: 1.5;
    color: var(--leather-darker);
    white-space: normal;
}

.chat-bubble-ai p {
    margin-bottom: 0.5rem;
}

.chat-bubble-ai > :last-child {
    margin-bottom: 0;
}

.chat-bubble-ai ul,
.chat-bubble-ai ol {
    margin-bottom: 0.5rem;
    padding-left: 1.3rem;
}

.chat-bubble-ai li::marker {
    color: var(--oxblood);
}

/* The quill nib at the end of the line while the Sage writes; it scratches back and forth a little */
.sage-quill {
    display: inline-block;
    margin-left: 2px;
    color: var(--oxblood);
    font-family: var(--font-body);
    font-style: normal;
    transform-origin: bottom left;
    animation: quill-scratch 0.35s ease-in-out infinite alternate;
}

@keyframes quill-scratch {
    from { transform: translate(0, 0) rotate(-8deg); }
    to { transform: translate(2px, -1px) rotate(6deg); }
}

/* A reply that failed: crimson-edged, so it reads as an error and not as advice */
.chat-bubble-error {
    font-family: var(--font-body);
    font-size: 1rem;
    background: var(--parchment-light);
    border: 1px solid var(--danger);
    border-left-width: 4px;
    color: var(--danger);
}

/* A one-line notice in the conversation, e.g. that older messages were trimmed */
.chat-notice {
    margin: 0 0 12px;
    text-align: center;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--leather-dark);
}

/* Input area */
.chat-input-area {
    padding: 10px 0 0;
    border-top: 1px solid var(--rule-gold);
    position: relative;
}

.chat-input {
    background: var(--parchment-light);
    border: 1px solid var(--rule-gold);
    border-radius: 0;
    font-family: var(--font-body);
    color: var(--text-dark);
    width: 100%;
    /* Drag the corner to make room for long notes; capped so the Send button stays on the scroll */
    resize: vertical;
    padding: 8px 10px;
    min-height: 60px;
    max-height: 40vh;
    box-sizing: border-box;
}

.chat-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.3);
    background: #fff;
}

.chat-send-btn {
    margin-top: 6px;
    background: var(--oxblood);
    border: 2px solid var(--leather-darker);
    color: var(--parchment-light);
    font-family: var(--font-heading);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    border-radius: 3px;
    padding: 6px 18px;
    cursor: pointer;
}

.chat-send-btn:hover {
    background: #74241a;
    color: #fff;
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading animation */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-loading-d20 {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
}

.chat-loading-d20-icon {
    width: 28px;
    height: 28px;
    animation: d20-roll 1.2s ease-in-out infinite;
}

.chat-loading-d20-icon svg {
    width: 100%;
    height: 100%;
}

.chat-loading-d20 .chat-loading-text {
    font-style: italic;
    color: var(--oxblood);
    font-family: var(--font-body);
    font-size: 0.85rem;
    animation: pulse 1.5s ease-in-out infinite;
}

/* The records @-named in the message being written (chat-panel.js): name chips above the Sage's box. Its own flex,
   not d-flex, so the hidden attribute still hides it when nothing is linked */
.chat-links {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 6px;
}

/* A linked record's × inside its chip: unlinks the record, the message's words stay */
.chat-link-unlink {
    background: none;
    border: 0;
    padding: 0 0 0 0.35em;
    color: inherit;
    font: inherit;
    line-height: 1;
    cursor: pointer;
}

.chat-link-unlink:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 1px;
}

/* @-name suggestions: the campaign's matching records, listed under the Sage's box (autocomplete.js) */
.chat-mention-dropdown {
    position: absolute;
    background: var(--parchment-light);
    border: 1px solid var(--rule-gold);
    border-radius: 0;
    /* Above the floating Sage (1050) and its button (1051), which the list opens over */
    z-index: 1060;
    max-height: 260px;
    overflow-x: hidden;
    overflow-y: auto;
    /* A name chosen by keyboard scrolls clear of its type's heading, which stays at the top */
    scroll-padding-top: 1.75rem;
    min-width: 220px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.chat-mention-item {
    padding: 6px 12px 7px;
    cursor: pointer;
    font-family: var(--font-body);
    color: var(--text-dark);
    line-height: 1.25;
    border-bottom: 1px solid var(--parchment-dark);
    /* A long name wraps inside the list, never past its edge */
    overflow-wrap: anywhere;
}

/* A type's heading over its names (NPC, Location): the theme's small caps on the gold rule, and it stays in view */
.chat-mention-group-header {
    position: sticky;
    top: 0;
    padding: 4px 12px 2px;
    background: var(--parchment-dark);
    border-bottom: 1px solid var(--rule-gold);
    color: var(--oxblood);
    font-family: var(--font-heading);
    font-size: 1.05rem;
    line-height: 1.2;
}

.chat-mention-item:last-child {
    border-bottom: none;
}

.chat-mention-item:hover,
.chat-mention-item.chat-mention-active {
    background: rgba(212, 175, 55, 0.25);
    color: var(--text-dark);
}

.chat-mention-name {
    font-weight: bold;
}

/* What tells two of a name apart (a role, a faction, a place's type): a quieter line under the name */
.chat-mention-sub {
    display: block;
    font-size: 0.85em;
    font-style: italic;
    color: var(--ink-brown);
}


/* Campaign-wide floating chat (fragments/campaign-chat.html) */
.chat-floating {
    position: fixed;
    right: 34px;
    bottom: 100px;
    width: min(420px, calc(100vw - 68px));
    height: min(560px, calc(100vh - 150px));
    z-index: 1050;
    /* It grows out of, and shrinks into, the corner where its button is */
    transform-origin: bottom right;
}

.chat-floating[hidden] {
    display: none;
}

/* On a touch screen the open Sage itself holds the focus (so no keyboard comes up): no ring round the scroll */
.chat-floating:focus {
    outline: none;
}

/* Session Notes (fragments/session-notes.html): the Sage's scroll mirrored, in the bottom-left corner, growing out of
   and shrinking into that corner with the same frames */
.notes-floating {
    right: auto;
    left: 34px;
    transform-origin: bottom left;
}

/* The notepad takes the sheet's room under the title, written in the notes' hand (Kalam), with nothing to format */
.notes-text {
    flex: 1 1 0;
    min-height: 0;
    margin-top: 8px;
    resize: none;
    font-family: 'Kalam', cursive;
}

/* The line under the notepad: the save status on the left, the near-the-limit count on the right */
.notes-status-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin: 4px 0;
}

/* The quiet save status (Saved, Not saved yet …), its height kept when empty so nothing jumps */
.notes-status {
    min-height: 1.5em;
    margin: 0;
    font-size: 0.85rem;
    color: var(--leather-dark);
}

/* How many characters of the 20,000, shown only from 18,000 (session-notes.js) */
.notes-count {
    font-size: 0.85rem;
    color: var(--leather-dark);
    white-space: nowrap;
}

/* The notes scroll's tabs (Session, Table, Mine): the site's nav-tabs, a little smaller to fit the scroll */
.notes-tabs {
    margin-top: 8px;
    font-size: 0.9rem;
}

/* Where the site's tabs become a grid three across, the scroll's share its row evenly: a player's two fill it */
@media (max-width: 1199.98px) {
    .notes-tabs {
        grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    }
}

/* The open tab takes the sheet's room under the tabs, as the notepad alone did */
.notes-panes,
.notes-panes > .tab-pane.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
}

/* The Table tab's sections (table-notes.js) scroll inside the sheet */
.table-notes {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
}

/* A person's own part of the table notes: the notepad's box, a few lines tall, growing as they type */
.notes-text.table-notes-own {
    flex: none;
    min-height: 7rem;
    resize: vertical;
}

/* Everyone's words on the Table tab and in Earlier sessions, in the notes' hand */
.table-notes-text {
    font-family: 'Kalam', cursive;
}

/* Opening the Sage is closing played backwards: the rolled scroll grows out of the corner where its button was, then
   the top roller rolls up from the bottom one and the paper is revealed under it (the clip stays 2px above that
   roller). Same frames and timing as closing, in reverse, so the two mirror each other. They are copies under their
   own names: closing must switch to a different animation, or the browser would not play it again and the Sage
   would vanish at once instead of rolling down. Each opening adds chat-unrolling afresh (campaign-chat.html), so it
   plays every time it opens rather than relying on the browser restarting it when the hidden scroll is shown again
   (Safari doesn't always); open without it, the scroll is simply there (open on the last page as well). */
.chat-floating.chat-unrolling {
    animation: scroll-out-of-button 1.2s ease-in reverse;
}

.chat-floating.chat-unrolling .chat-panel {
    animation: scroll-roll-up 1.2s ease-in reverse;
}

.chat-floating.chat-unrolling .chat-panel::before {
    animation: scroll-top-roller-up 1.2s ease-in reverse;
}

/* Closing rolls it down into its button: the top roller travels down to the bottom one, taking the paper with it
   (the clip stays 2px above that roller), then the rolled scroll shrinks into the corner where the Campaign Sage
   button comes back. */
.chat-floating.chat-rolling-up {
    animation: scroll-into-button 1.2s ease-in forwards;
}

.chat-floating.chat-rolling-up .chat-panel {
    animation: scroll-roll-down 1.2s ease-in forwards;
}

.chat-floating.chat-rolling-up .chat-panel::before {
    animation: scroll-top-roller-down 1.2s ease-in forwards;
}

.chat-floating.chat-rolling-up .chat-panel::after {
    animation: none;
}

/* The top roller travels by transform, not by its top, so a phone moves the one drawn roller (its own layer while it
   moves) instead of laying out and painting it again on every frame: from its place above the sheet (top -42px) down
   to the bottom roller's (top 100% + 6px), the panel's height and 48px further (--sage-roller-travel, measured by
   campaign-chat.html as each roll starts) */
.chat-floating.chat-unrolling .chat-panel::before,
.chat-floating.chat-rolling-up .chat-panel::before {
    will-change: transform;
}

@keyframes scroll-roll-down {
    from { clip-path: inset(-44px -60px -52px -60px) padding-box; }
    60%, to { clip-path: inset(calc(100% + 4px) -60px -52px -60px) padding-box; }
}

@keyframes scroll-top-roller-down {
    from { transform: none; }
    60%, to { transform: translateY(var(--sage-roller-travel)); }
}

@keyframes scroll-into-button {
    from, 60% { transform: none; opacity: 1; }
    to { transform: scale(0.2); opacity: 0; }
}

/* Opening's copies of the three above, played in reverse */
@keyframes scroll-out-of-button {
    from, 60% { transform: none; opacity: 1; }
    to { transform: scale(0.2); opacity: 0; }
}

@keyframes scroll-roll-up {
    from { clip-path: inset(-44px -60px -52px -60px) padding-box; }
    60%, to { clip-path: inset(calc(100% + 4px) -60px -52px -60px) padding-box; }
}

@keyframes scroll-top-roller-up {
    from { transform: none; }
    60%, to { transform: translateY(var(--sage-roller-travel)); }
}

@media (prefers-reduced-motion: reduce) {
    .chat-floating,
    .chat-floating .chat-panel,
    .chat-floating .chat-panel::before,
    .chat-floating .chat-panel::after {
        animation: none !important;
    }

    /* No slide: the wrap shows "Sage" (or "Notes") on hover at once, and opening goes straight to the open scroll */
    .chat-floating-fab,
    .sage-wrap,
    .notes-wrap {
        transition: none !important;
    }
}

.chat-floating .chat-panel {
    height: 100%;
    margin: 0;
}

/* The messages take whatever room is left, so a long reply scrolls instead of squeezing the help or the input */
.chat-floating .chat-messages {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
}

.chat-floating .chat-input {
    /* 30% of the scroll's writing area (its height less the 24px frame), so it fits beside the opened help */
    max-height: calc((min(560px, 100vh - 150px) - 48px) * 0.3);
}

/* The Campaign Sage button, closed: a scroll lying on its side between brass finials, in a tooled leather wrap with
   crossed straps and a brass tree seal (fragments/campaign-chat.html draws it). On a desktop it stands just right of
   the page's sheet (max 1200px, centred) when there is room (from about 1620px wide); narrower, it sits in the corner
   as the old button did, over the sheet's border and the edge of its content. Pointing at
   it or focusing it slides the wrap back to show "Sage"; opening (sage-opening) slides it off first. */
.chat-floating-fab {
    position: fixed;
    right: max(28px, calc(50% - 782px));
    bottom: 24px;
    z-index: 1051;
    width: 170px;
    height: 55px;
    padding: 0;
    background: none;
    border: none;
    filter: drop-shadow(0 6px 5px rgba(44, 24, 16, 0.45));
    transition: transform 0.3s ease;
}

/* Session Notes' button: the same case in the bottom-left corner, just left of the page's sheet when there is room */
.notes-floating-fab {
    right: auto;
    left: max(28px, calc(50% - 782px));
}

.chat-floating-fab:focus:not(:focus-visible) {
    outline: none;
}

.sage-case {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.sage-wrap,
.notes-wrap {
    transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.3, 1);
}

.chat-floating-fab:focus-visible .sage-wrap {
    transform: translateX(-88px);
}

@media (hover: hover) {
    .chat-floating-fab:hover .sage-wrap {
        transform: translateX(-88px);
    }
}

.chat-floating-fab.sage-opening .sage-wrap {
    transform: translateX(-230px);
    transition-duration: 0.35s;
}

/* The notes' wrap is the Sage's mirrored: it slides toward the page's centre, to show "Notes" at the parchment's left
   end, and off that way when the notes open (notes-opening) */
.notes-floating-fab:focus-visible .notes-wrap {
    transform: translateX(88px);
}

@media (hover: hover) {
    .notes-floating-fab:hover .notes-wrap {
        transform: translateX(88px);
    }
}

.notes-floating-fab.notes-opening .notes-wrap {
    transform: translateX(230px);
    transition-duration: 0.35s;
}

/* Its colours: the brass, leather and paper tokens. Shapes reused through <use> (the finials) are styled by their own
   scc- class: a rule written ".sage-case .x" does not reach a <use> copy. The scc- prefix is the scroll case's alone
   (the Sage's, and the notes' drawn again with their own snc ids) */
.sage-case .scc-brass-shine { stop-color: var(--brass-shine); }
.sage-case .scc-brass-light { stop-color: var(--brass-light); }
.sage-case .scc-brass { stop-color: var(--brass); }
.sage-case .scc-brass-dark { stop-color: var(--brass-dark); }
.sage-case .scc-brass-shadow { stop-color: var(--brass-shadow); }
.sage-case .scc-leather-rust { stop-color: var(--leather-rust); }
.sage-case .scc-leather-mid { stop-color: var(--leather-mid); }
.sage-case .scc-leather-deep { stop-color: var(--leather-deep); }
.sage-case .scc-paper-light { stop-color: var(--paper-light); }
.sage-case .scc-paper { stop-color: var(--paper); }
.sage-case .scc-paper-edge { stop-color: var(--paper-edge); }
.scc-flutes { fill: none; stroke: var(--brass-shadow); stroke-width: 1; stroke-opacity: 0.6; }
.scc-tip { fill: var(--brass); }
.sage-case .scc-paper-line { stroke: var(--ink-brown); stroke-width: 0.6; stroke-opacity: 0.5; }
.sage-case .scc-rule { fill: none; stroke: var(--ink-brown); stroke-width: 1; }
.sage-case .scc-name { font-family: 'Almendra', serif; font-weight: bold; font-size: 22px; fill: var(--leather-darker); }
.sage-case .scc-tooling { fill: none; stroke: var(--brass); stroke-width: 1; stroke-opacity: 0.75; }
.sage-case .scc-strap { stroke: var(--leather-darker); stroke-width: 0.8; }
.sage-case .scc-stitch { fill: none; stroke: var(--brass-light); stroke-width: 0.7; stroke-dasharray: 2 2.5; stroke-opacity: 0.7; }
.sage-case .scc-wrap-edge { fill: var(--leather-darker); fill-opacity: 0.35; }
.sage-case .scc-seal { stroke: var(--brass-dark); stroke-width: 1.5; }
.sage-case .scc-seal-ring { fill: none; stroke: var(--brass-dark); stroke-width: 1; }
.sage-case .scc-tree-lines { fill: none; stroke: var(--brass-dark); stroke-width: 1.3; stroke-linecap: round; }
.sage-case .scc-tree-leaves { fill: var(--brass-dark); }

/* On a wide screen the open Sage stands in the room beside the sheet, over at most its decorative border, never the
   page's content: from about 1870px wide, where that room is at least 320px */
@media (min-width: 1870px) {
    .chat-floating {
        right: auto;
        left: calc(50% + 564px);
        width: min(420px, calc(50% - 614px));
    }

    /* The open notes, the same in the room on the sheet's left */
    .notes-floating {
        right: calc(50% + 564px);
        left: auto;
    }
}

.chat-clear-btn {
    margin-left: auto;
    background: none;
    border: none;
    padding: 0 6px;
    color: var(--oxblood);
    font-family: var(--font-body);
    font-size: 0.85rem;
    text-decoration: underline;
}

.chat-clear-btn + .chat-close-btn,
.chat-size-btn + .chat-close-btn {
    margin-left: 0;
}

/* The Sage's size button, just before its ×: arrows pointing out make it bigger, pointing in put it back at the side
   (sage-maximize.js) */
.chat-size-btn {
    display: inline-flex;
    align-items: center;
    padding: 0 6px;
    background: none;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--oxblood);
}

.chat-close-btn {
    margin-left: auto;
    margin-right: 0;
    background: none;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--oxblood);
}

@media (max-width: 768px) {
    .chat-floating {
        right: 30px;
        left: 30px;
        width: auto;
    }

    /* A phone's button is smaller and tucked part way off the right edge: the left finial, the leather and the seal
       show.
       A tap slides it fully in (sage-opening), then the wrap slides off and it unrolls */
    .chat-floating-fab {
        right: -50px;
        bottom: 18px;
        width: 120px;
        height: 39px;
    }

    .chat-floating-fab.sage-opening {
        transform: translateX(-66px);
    }

    /* The notes' button, the same off the left edge, sliding in to the right */
    .notes-floating-fab {
        right: auto;
        left: -50px;
    }

    .notes-floating-fab.notes-opening {
        transform: translateX(66px);
    }

    .chat-title {
        font-size: 1.3rem;
    }
}

/* The Sage made bigger (sage-maximize.js): a large scroll in the middle of the screen, as the edit pop-up stands, room
   left round it for the rollers and their finials; over the open notes, both scroll buttons and the dimmed page.
   Its height is --sage-big-height, one per screen size, which its input's limit follows; the screen's height is
   --sage-screen-height, the visible one (100dvh) where the browser knows it. Without the unroll's motion, it is
   simply there. */
.chat-floating.chat-maximized {
    --sage-screen-height: 100vh;
    --sage-big-height: calc(var(--sage-screen-height) - 96px);
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: min(1000px, calc(100vw - 96px));
    height: var(--sage-big-height);
    margin: auto;
    z-index: 1054;
}

@supports (height: 100dvh) {
    .chat-floating.chat-maximized {
        --sage-screen-height: 100dvh;
    }
}

/* Its input keeps to 30% of the bigger scroll's writing area (its height less the 24px frame), as at the side */
.chat-floating.chat-maximized .chat-input {
    max-height: calc((var(--sage-big-height) - 48px) * 0.3);
}

/* The page dimmed behind the bigger Sage, as behind a pop-up; a click on it puts the Sage back at the side */
.sage-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1053;
    background: rgba(0, 0, 0, 0.5);
}

/* The page while the Sage is big (on its body): held still as Bootstrap's modal-open holds it, the scrollbar's room
   kept by padding (sage-maximize.js); a pop-up the Sage opens (its help) comes over it, its backdrop dimming the Sage
   too, as a pop-up's over a pop-up */
.sage-big-open {
    overflow: hidden;
}

.sage-big-open .modal-backdrop {
    z-index: 1055;
}

.sage-big-open .modal {
    z-index: 1056;
}

/* A phone's bigger Sage fills the screen, less the room its rollers and finials take */
@media (max-width: 768px) {
    .chat-floating.chat-maximized {
        --sage-big-height: calc(var(--sage-screen-height) - 88px);
        width: calc(100vw - 52px);
    }
}

/* Back to top (static/js/back-to-top.js): a brass compass (rims round a leather band, tree medallions at the four
   points, a parchment face, an eight-point rose and a red north arrow), at the very bottom centre of the screen, half below its edge so the north arrow and top medallion show. It comes up whenever the
   page scrolls (past its top) and fades away over 3 seconds once the scrolling stops */
.back-to-top {
    position: fixed;
    left: 50%;
    bottom: -34px;
    transform: translateX(-50%);
    /* Under Bootstrap's pop-up backdrop (1050) and the Sage (1050, its button 1051) */
    z-index: 1045;
    width: 68px;
    height: 68px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    filter: drop-shadow(0 -2px 4px rgba(0, 0, 0, 0.35));
    opacity: 1;
    transition: transform 0.15s ease, opacity 0.2s ease;
}

.back-to-top[hidden] {
    display: none;
}

.back-to-top.back-to-top-fading {
    opacity: 0;
    transition: transform 0.15s ease, opacity 3s linear;
    will-change: opacity;
}

/* Too faint to see: it no longer takes clicks meant for the page under it (the keyboard can still reach it) */
.back-to-top.back-to-top-faint {
    pointer-events: none;
}

/* Only where a pointer really hovers (a tap would leave a phone's compass stuck in its hover look): it rises a
   little further out of the edge */
@media (hover: hover) {
    .back-to-top:hover .compass {
        transform: translateY(-8px);
    }

    .back-to-top:hover {
        filter: drop-shadow(0 0 5px rgba(255, 200, 90, 0.9)) drop-shadow(0 0 12px rgba(240, 160, 50, 0.6));
    }
}

/* No ring after a click; the keyboard's focus ring stays */
.back-to-top:focus:not(:focus-visible) {
    outline: none;
}

/* On hover the drawing rises, not the button, so the pointer never slips off the bottom of a lifted button and
   flickers */
.compass {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    transition: transform 0.15s ease;
}

.compass .cmp-shine { stop-color: var(--brass-shine); }
.compass .cmp-brass-light { stop-color: var(--brass-light); }
.compass .cmp-brass { stop-color: var(--brass); }
.compass .cmp-brass-dark { stop-color: var(--brass-dark); }
.compass .cmp-brass-shadow { stop-color: var(--brass-shadow); }
.compass .cmp-paper-light { stop-color: var(--paper-light); }
.compass .cmp-paper { stop-color: var(--paper); }
.compass .cmp-paper-edge { stop-color: var(--paper-edge); }
.compass .cmp-leather-rust { stop-color: var(--leather-rust); }
.compass .cmp-leather { stop-color: var(--leather-mid); }
.compass .cmp-leather-deep { stop-color: var(--leather-deep); }
.compass .cmp-glow-light { stop-color: var(--glow-light); stop-opacity: 0.95; }
.compass .cmp-glow { stop-color: var(--ember); }
.compass .cmp-half { stop-opacity: 0.4; }
.compass .cmp-none { stop-opacity: 0; }

/* Shapes reused through <use> are styled by their own class: a rule written ".compass .x" does not reach a
   <use> copy. The cmp- prefix is the compass's alone */
.compass .cmp-rim { stroke: var(--brass-shadow); stroke-width: 1.5; }
.compass .cmp-rim-inner { stroke-width: 1; }
.cmp-metal { stroke: var(--brass-shadow); stroke-width: 0.8; }
.cmp-boss { stroke: var(--brass-shadow); stroke-width: 1.2; }
.compass .cmp-pin { stroke-width: 0.8; }
.cmp-line { fill: none; stroke: var(--brass-dark); stroke-width: 0.9; }
.cmp-tree path { fill: none; stroke: var(--brass-shadow); stroke-width: 1.4; stroke-linecap: round; }
.cmp-tree circle { fill: var(--brass-dark); }
.compass .cmp-tooling { fill: none; stroke: var(--brass); stroke-width: 1; opacity: 0.8; }
.compass .cmp-ink { fill: none; stroke: var(--ink-brown); stroke-width: 0.7; }
.compass .cmp-dotted { stroke-width: 0.5; stroke-dasharray: 1.5 2.5; }
.compass .cmp-ink-fill { fill: var(--ink-brown); }
.cmp-rose-light,
.cmp-rose-dark { stroke: var(--brass-shadow); stroke-width: 0.6; }
.cmp-rose-light { fill: var(--brass-light); }
.cmp-rose-dark { fill: var(--brass-dark); }
.compass .cmp-needle { fill: var(--needle); stroke: var(--oxblood); stroke-width: 0.8; }
.compass .cmp-needle-lit { fill: var(--needle-lit); }
.compass .cmp-ray { fill: none; stroke: var(--glow-light); stroke-width: 1.6; stroke-linecap: round; }
.compass .cmp-ray-fine { stroke-width: 1; }

/* The glow: light round the brass and rays behind the north arrow, on hover and while it is pressed */
.compass-glow {
    opacity: 0;
    transition: opacity 0.25s ease;
}

.back-to-top:active .compass-glow,
.back-to-top:focus-visible .compass-glow {
    opacity: 1;
}

@media (hover: hover) {
    .back-to-top:hover .compass-glow {
        opacity: 1;
    }
}

/* Fully above a page's pinned action bar, clear of its count and main button */
body:has(.stat-block-actions) .back-to-top {
    bottom: calc(4.75rem + 8px);
}

/* Without motion it simply goes once its 3 seconds are up */
@media (prefers-reduced-motion: reduce) {
    .back-to-top,
    .back-to-top.back-to-top-fading {
        opacity: 1;
        transition: none;
    }

    .back-to-top.back-to-top-fading.back-to-top-gone {
        opacity: 0;
    }

    /* No fade to watch: it takes clicks as long as it can be seen */
    .back-to-top.back-to-top-faint:not(.back-to-top-gone) {
        pointer-events: auto;
    }

    /* Hover lights it without moving it or fading the glow in */
    .compass,
    .compass-glow {
        transition: none;
    }

    .back-to-top:hover .compass {
        transform: none;
    }
}

@media (max-width: 768px) {
    /* Smaller on a phone, and still half below the edge; it sits over the Sage button's corner while it shows */
    .back-to-top {
        bottom: -28px;
        width: 56px;
        height: 56px;
    }


    /* A phone's open Sage, or the Sage's question banner, spans the screen: the compass waits until it is gone */
    body:has(.chat-floating:not([hidden])) .back-to-top,
    body:has(.sage-ask-banner) .back-to-top {
        display: none;
    }
}

/* "Does this change the world state?" after a plot thread edit (static/js/sage-ask.js); bottom left, clear of the
   Sage's button, and just above the Session Notes button that stands in that corner (over it, should they meet) */
.sage-ask-banner {
    position: fixed;
    left: 20px;
    bottom: 96px;
    z-index: 1052;
    max-width: min(380px, calc(100vw - 40px));
    padding: 12px 14px;
    background: var(--parchment-light);
    border: 2px solid var(--rule-gold);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    font-family: var(--font-body);
    color: var(--text-dark);
}

.sage-ask-banner p {
    margin: 0 0 10px;
}

.sage-ask-banner .btn {
    margin-right: 8px;
}

.sage-ask-yes {
    background: var(--oxblood);
    border: 2px solid var(--leather-darker);
    color: var(--parchment-light);
}

.sage-ask-no {
    background: transparent;
    border: 1px solid var(--rule-gold);
    color: var(--leather-dark);
}

/* Sage status line and proposal card sit under the reply bubble, full width, not beside it */
.chat-message-ai {
    flex-wrap: wrap;
}

.chat-message-ai > .chat-status,
.chat-message-ai > .sage-card {
    flex: 0 0 100%;
    box-sizing: border-box;
}

/* Sage status line while it looks something up */
.chat-status {
    margin: 4px 0 0 2px;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--leather-dark);
    opacity: 0.8;
}

/* Sage proposal checklist, styled like the chat bubbles */
.sage-card {
    margin: 8px 0 0;
    padding: 10px 12px;
    background: var(--parchment-light);
    border: 1px solid var(--rule-gold);
    box-shadow: 0 2px 4px rgba(44, 24, 16, 0.2);
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-dark);
    overflow-wrap: anywhere;
}
.sage-card-title {
    margin: 0 0 6px;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--oxblood);
    border-bottom: 2px solid var(--rule-gold);
    padding-bottom: 2px;
}
.sage-card-summary { margin: 0 0 8px; font-style: italic; }
.sage-card-rows { list-style: none; padding: 0; margin: 0 0 8px; }
.sage-row { padding: 4px 0; border-bottom: 1px dotted var(--parchment-dark); }
.sage-row:last-child { border-bottom: none; }
.sage-row > label {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 8px;
    align-items: start;
    cursor: pointer;
    margin: 0;
}
.sage-row > label > input { margin-top: 3px; }
.sage-row-also { grid-column: 2; opacity: 0.75; }
.sage-row-delete .sage-row-label { color: var(--danger); font-weight: bold; }
.sage-row-result { display: block; margin-left: 22px; font-size: 0.85rem; }
.sage-row-result:empty { display: none; }
.sage-row-result.is-applied { color: var(--success); }
.sage-row-result.is-failed { color: var(--danger); }
.sage-row-result.is-skipped { opacity: 0.6; }
.sage-row-details { margin: 2px 0 0 22px; font-size: 0.8rem; opacity: 0.8; }
.sage-row-details summary { cursor: pointer; }
.sage-row-detail-line { white-space: pre-wrap; margin: 2px 0 0; }
.sage-row-detail-more { margin: 2px 0 0; }
.sage-row-detail-more summary { cursor: pointer; white-space: pre-wrap; }
/* Expand, at the foot of an edit's Details: opens the record's edits side by side (sage-reload's colours, smaller) */
.sage-row-expand {
    display: block;
    margin: 4px 0 0;
    padding: 1px 10px;
    border-radius: 3px;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    cursor: pointer;
}
.session-logging-help { font-size: 0.85rem; margin: 0 0 8px; }
.session-logging-help summary { cursor: pointer; font-weight: 600; }
/* Keeps its size however long the chat or tall the input gets; opened, it scrolls within 40% of the scroll */
.chat-floating .session-logging-help {
    flex: 0 0 auto;
    padding: 4px 12px;
    max-height: 40%;
    overflow-y: auto;
}
.sage-card-note { min-height: 1em; margin: 0 0 8px; font-size: 0.85rem; font-style: italic; }
.sage-card-note:empty { display: none; }
.sage-card-stale:empty { display: none; }
.sage-card-stale { margin: 0 0 8px; font-size: 0.85rem; color: var(--danger); }
.sage-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sage-card-actions button,
.sage-card-stale button {
    font-family: var(--font-heading);
    border-radius: 3px;
    padding: 4px 14px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
/* Apply is the card's main action (oxblood, like btn-primary); Dismiss and Reload are utility */
.sage-apply {
    background: var(--oxblood);
    border: 2px solid var(--leather-darker);
    color: var(--parchment-light);
}
.sage-dismiss,
.sage-reload {
    background: var(--parchment-light);
    border: 1px solid var(--rule-gold);
    color: var(--leather-dark);
}
.sage-card-actions button:disabled { opacity: 0.6; cursor: default; }
.sage-card-locked { opacity: 0.9; }

/* Pictures: an NPC's portrait on its page and its round thumbnail on the list */
.npc-portrait {
    max-width: 220px;
    border: 1px solid var(--rule-gold);
    object-fit: cover;
}

/* A player character's page title (pcs/view): the portrait above the name, as an NPC's, until lg; from lg up a
   120px one to the left of the name, "Played by", and the headline, so the header stays short and the sheet's box
   under it ends on a laptop's screen */
@media (min-width: 992px) {
    .pc-title {
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    .pc-title-portrait {
        flex: none;
        width: 120px;
        height: 120px;
        max-width: 120px;
    }

    .pc-title-text {
        min-width: 0;
    }
}

.npc-thumb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--rule-gold);
}

/* A location's gallery: a grid of tiles that opens in the picture viewer */
.picture-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.picture-tile img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

/* The full-size picture pop-up, and the resized preview shown before saving */
.picture-viewer {
    max-width: 95vw;
    max-height: 95vh;
    padding: 0;
}

.picture-viewer::backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.picture-viewer img {
    max-width: 100%;
    max-height: 90vh;
}

.picture-preview {
    max-height: 200px;
}

/* The table screen's map toolbar: a wrapping row of labeled groups (Mouse, Brush, Zoom), a wide gap between groups
   and a narrow one inside them, and More pushed to the end. No rules between groups: one would dangle at the end of
   a wrapped line. A button's words stay on one line. Layout only; the buttons are the usual roles. */
.screen-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.25rem;
}

.screen-toolbar .btn {
    white-space: nowrap;
}

.screen-toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.screen-toolbar-label {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    color: var(--oxblood);
}

/* The table screen's controls page: the map with its fog of war painted over it (screen-controls.js). The fog
   shows at 60 %, so the map under it stays readable; a finger or a pen paints rather than scrolls the page. */
.screen-paint {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
}

/* The picture with its tokens, fog, and the players' box, moved and scaled as one by "Zoom my map"; the map's area
   then crops what falls outside it */
.screen-zoom {
    position: relative;
    transform-origin: 0 0;
}

.screen-paint.is-zoomed {
    overflow: hidden;
}

.screen-paint img {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
}

.screen-paint canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.6;
    touch-action: none;
    cursor: crosshair;
}

/* A session's tokens over the map (table-tokens.js): a layer the size of the picture, above the fog and the view box
   on the GM's page so a token can always be grabbed (the screen window puts them under its fog). Only the tokens take
   the pointer, so strokes and drags elsewhere reach the fog and the view. */
.screen-tokens {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

/* One token: a round picture (or initials) centred on its place, as wide as its grid squares (table-tokens.js sets
   left, top, and width), its ring colored by kind: players blue, NPCs green, monsters red. */
.screen-token {
    position: absolute;
    aspect-ratio: 1;
    min-width: 28px;
    padding: 0;
    border: 0;
    box-shadow: 0 0 0 3px var(--ring, var(--rule-gold));
    container-type: inline-size;
    border-radius: 50%;
    background: var(--parchment-light);
    transform: translate(-50%, -50%);
    pointer-events: auto;
    touch-action: none;
    cursor: grab;
    line-height: 1;
}

/* Outside the Tokens choice the tokens let strokes and drags through to the fog and the view */
.screen-tokens.is-inert .screen-token {
    pointer-events: none;
}

.screen-token img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    pointer-events: none;
}

.screen-token:focus-visible {
    outline: 3px solid var(--gold-pale);
    outline-offset: 2px;
}

.token-ring-player { --ring: var(--info); }
.token-ring-npc { --ring: var(--success); }
.token-ring-monster { --ring: var(--danger); }

/* Hidden from the players: faded on the GM's page, with a slashed eye */
.screen-token.is-hidden {
    opacity: 0.45;
    box-shadow: 0 0 0 3px var(--ring, var(--rule-gold)), 0 0 0 5px var(--parchment-light);
}

.screen-token.is-hidden::after {
    content: "\2298";
    position: absolute;
    top: -0.4em;
    left: -0.4em;
    font-size: 0.9rem;
    color: var(--text-dark);
}

/* Down or Dead (0 hit points, as the Encounters tile says): greyed, with a cross over it */
.screen-token.is-down {
    filter: grayscale(1);
}

.screen-token.is-down::before {
    content: "\2715";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
    color: var(--danger);
    pointer-events: none;
}

/* Found from the tray: a dark and a bright ring pulse out from it, so it shows on a light map and in the fog alike */
.screen-token.is-found {
    z-index: 1;
    animation: token-found 0.65s ease-out 3;
}

@keyframes token-found {
    0% {
        box-shadow: 0 0 0 3px var(--ring, var(--rule-gold)), 0 0 0 5px var(--oxblood), 0 0 0 8px var(--gold);
    }

    100% {
        box-shadow: 0 0 0 3px var(--ring, var(--rule-gold)), 0 0 0 18px rgba(88, 24, 13, 0), 0 0 0 26px rgba(212, 175, 55, 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .screen-token.is-found {
        animation: none;
        box-shadow: 0 0 0 3px var(--ring, var(--rule-gold)), 0 0 0 6px var(--oxblood), 0 0 0 10px var(--gold);
    }
}

/* The Mouse choice that is on is filled, so it is plain at a glance what a drag will do */
.screen-toolbar .btn-outline-secondary[aria-pressed="true"] {
    background: var(--oxblood) !important;
    border-color: var(--leather-darker) !important;
    color: var(--parchment-light) !important;
}

.screen-token-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-family: var(--font-heading);
    font-size: max(10px, 45cqw);
    color: var(--text-dark);
}

/* The number of one of several alike */
.screen-token-badge {
    position: absolute;
    right: -0.35em;
    bottom: -0.35em;
    min-width: 1.4em;
    padding: 0.1em 0.3em;
    border-radius: 0.7em;
    background: var(--oxblood);
    color: var(--parchment-light);
    font-size: 0.7rem;
}

/* The name, under the token (the GM's page only) */
.screen-token-name {
    position: absolute;
    top: 100%;
    left: 50%;
    margin-top: 0.5em;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.7rem;
    color: var(--text-dark);
    background: rgba(244, 232, 208, 0.85);
    padding: 0 0.25em;
    pointer-events: none;
}

/* Hit points: a thin bar under the token, the tracker's colors */
.screen-token-hp {
    position: absolute;
    top: calc(100% + 1px);
    left: 10%;
    width: 80%;
    height: 4px;
    background: rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.screen-token-hp-fill {
    display: block;
    height: 100%;
    background: var(--success);
}

.screen-token-hp.hp-mid .screen-token-hp-fill { background: var(--warning); }
.screen-token-hp.hp-low .screen-token-hp-fill { background: var(--danger); }

/* Setting the grid: a square box dragged over one of the map's squares */
.screen-paint.is-setting-grid,
.screen-paint.is-setting-grid canvas {
    cursor: crosshair;
}

.screen-grid-box {
    position: absolute;
    aspect-ratio: 1;
    border: 2px solid var(--gold);
    background: rgba(212, 175, 55, 0.2);
    pointer-events: none;
}

/* A row of the Tokens tray: a small round face, the name, and Add (or On the map and Find) */
.token-tray-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.token-tray-face {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: 2px solid var(--rule-gold);
    border-radius: 50%;
    overflow: hidden;
    background: var(--parchment-light);
}

.token-tray-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.token-tray-name {
    flex: 1 1 auto;
    min-width: 0;
}

/* A token's pop-up: parchment with a gold rule, as the app's cards, a little wider for a stat block */
.token-dialog {
    width: min(36rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 1.25rem;
    border: 2px solid var(--rule-gold);
    border-radius: 4px;
    background: var(--parchment-light);
    color: var(--text-dark);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.token-dialog::backdrop {
    background: rgba(44, 24, 16, 0.55);
}

/* What the players see when the screen is zoomed (screen-controls.js places it). It lets strokes through to the fog
   until Move view is on, when the map drags the view instead of painting. */
.screen-view-frame {
    position: absolute;
    padding: 0;
    border: 3px dashed var(--gold);
    background: transparent;
    pointer-events: none;
}

.screen-view-frame:focus-visible {
    outline: 3px solid var(--gold-pale);
    outline-offset: 2px;
}

.screen-paint.is-moving,
.screen-paint.is-moving canvas {
    touch-action: none;
    cursor: grab;
}

.screen-paint.is-moving .screen-view-frame {
    pointer-events: auto;
    cursor: grab;
}

/* A map's small picture in the controls page's Maps list */
.screen-map-thumb {
    width: 64px;
    height: 48px;
    object-fit: cover;
    flex-shrink: 0;
}

/* The portrait focus picker (an NPC's or player character's edit page, the player's sheet pop-up): the whole
   portrait, uncropped, with a ring where it centers (portrait-focus.js places the ring and fills the two numbers from
   a click) */
.portrait-focus-picker {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
}

.portrait-focus-whole {
    display: block;
    max-width: 100%;
    max-height: 420px;
    width: auto;
    height: auto;
    object-fit: contain;
    border: 1px solid var(--rule-gold);
    cursor: crosshair;
}

.portrait-focus-marker {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 28px;
    height: 28px;
    transform: translate(-50%, -50%);
    border: 2px solid var(--gold);
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--leather-darker);
    pointer-events: none;
}

/* A picture the GM's plan doesn't include (Free): kept, greyed out, and opening nothing (fragments/picture-plan) */
.picture-locked {
    filter: grayscale(1);
    opacity: 0.5;
}

/* ===== The hearth: landing and sign-in pages (index.html, login.html) =====
   The picture (images/hearth) is the page: a fire, two chairs and a map table in the lower right, with empty
   parchment upper left where the words are written. The picture is anchored to the bottom right and keeps its
   shape; if the words need more room the scene grows taller and the picture's left edge fades into the paper. */
.hearth-scene {
    /* Its own layer, so the notes on it (a sign-in message) are drawn on its picture, not beneath it */
    isolation: isolate;
    position: relative;
    display: flex;
    align-items: flex-start;
    aspect-ratio: 1672 / 941;
    overflow: hidden;
    background-color: var(--hearth-parchment);
    box-shadow: inset 0 0 18px rgba(80, 40, 10, 0.35);
}

.hearth-picture {
    position: absolute;
    right: 0;
    bottom: 0;
    height: 100%;
    aspect-ratio: 1672 / 941;
    background: url('/images/hearth-9da18e8bc6cb7ab176c127528fcea8a6.png') center / cover no-repeat;
    background-image: image-set(url('/images/hearth-d361c4d9a480ea6554b035dee0011a2d.webp') type('image/webp'),
        url('/images/hearth-9da18e8bc6cb7ab176c127528fcea8a6.png') type('image/png'));
    -webkit-mask-image: linear-gradient(to right, transparent, #000 6%);
    mask-image: linear-gradient(to right, transparent, #000 6%);
}

/* Firelight over the hearth: the one thing on the page that moves. Placed in the picture's own coordinates. */
.hearth-glow {
    position: absolute;
    left: 68%;
    top: 40%;
    width: 26%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle, var(--ember) 0%, transparent 62%);
    mix-blend-mode: soft-light;
    opacity: 0.7;
    animation: hearth-flicker 3.4s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes hearth-flicker {
    0% { opacity: 0.55; transform: scale(0.97); }
    35% { opacity: 0.8; transform: scale(1.02); }
    60% { opacity: 0.62; transform: scale(0.99); }
    100% { opacity: 0.85; transform: scale(1.03); }
}

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

.hearth-scene-text {
    position: relative;
    z-index: 1;
    width: 54%;
    padding: 4.5% 0 2rem 6%;
}

.hearth-title {
    margin: 0 0 1.25rem;
    font-family: 'Almendra', Georgia, serif;
    font-size: clamp(2.2rem, 3.4vw, 3.3rem);
    font-weight: 700;
    line-height: 1.08;
    color: var(--oxblood);
}

.hearth-lead {
    max-width: 30em;
    margin-bottom: 1rem;
    font-size: 1.15rem;
    line-height: 1.6;
    color: var(--text-dark);
}

.hearth-scene a:focus-visible {
    outline: 3px solid var(--ember);
    outline-offset: 3px;
}

/* Campaigns page (home once signed in): a shorter strip of the hearth, so the campaigns follow close behind. The picture shrinks to the strip's
   height at the right; the words sit on its own blank parchment, enlarged, and the picture's left edge fades into it */
.hearth-scene-home {
    aspect-ratio: 1672 / 620;
    background: var(--hearth-parchment) url('/images/hearth-9da18e8bc6cb7ab176c127528fcea8a6.png') 20% 0 / max(250%, 1800px) auto no-repeat;
    background-image: image-set(url('/images/hearth-d361c4d9a480ea6554b035dee0011a2d.webp') type('image/webp'),
        url('/images/hearth-9da18e8bc6cb7ab176c127528fcea8a6.png') type('image/png'));
}

.hearth-scene-home .hearth-picture {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 22%);
    mask-image: linear-gradient(to right, transparent, #000 22%);
}

.hearth-scene-home .hearth-scene-text {
    width: 45%;
}

/* Sign-in: fewer words, so the note is narrower and the fire has more of the sheet */
.hearth-scene-signin .hearth-scene-text {
    width: 40%;
}

.hearth-google {
    max-width: 20rem;
    background-color: var(--parchment-light);
}

.hearth-privacy {
    max-width: 44em;
    margin: 1.25rem auto 0;
    text-align: center;
}

/* What the app keeps track of, under the picture: a written list in two columns, not a row of cards */
.hearth-keeps {
    padding: 2.5rem 6% 1rem;
}

.hearth-keeps-title {
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--rule-gold);
    color: var(--oxblood);
}

.hearth-keeps-intro {
    margin-bottom: 1.5rem;
}

.hearth-keeps-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.4rem 3rem;
    margin: 0;
}

.hearth-keeps-list dt {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: var(--oxblood);
}

.hearth-keeps-list dd {
    margin: 0.15rem 0 0;
    max-width: 38em;
    line-height: 1.55;
}

/* Below a wide desk the words would run into the chairs: they go first, on plain parchment, then the whole
   picture beneath them, its top edge fading into the paper */
@media (max-width: 1199.98px) {
    /* The words sit on the picture's own empty parchment, enlarged so only its blank upper middle shows behind
       them (no chair, and the vine on its left edge cropped off), so the paper runs on unbroken */
    .hearth-scene {
        flex-direction: column;
        aspect-ratio: auto;
        background: var(--hearth-parchment) url('/images/hearth-9da18e8bc6cb7ab176c127528fcea8a6.png') 20% 0 / max(250%, 1800px) auto no-repeat;
        background-image: image-set(url('/images/hearth-d361c4d9a480ea6554b035dee0011a2d.webp') type('image/webp'),
            url('/images/hearth-9da18e8bc6cb7ab176c127528fcea8a6.png') type('image/png'));
    }

    .hearth-scene-text,
    .hearth-scene-signin .hearth-scene-text {
        width: 100%;
        padding: 2rem 1.5rem 0;
    }

    .hearth-scene-home .hearth-scene-text {
        width: 100%;
    }

    /* On the campaigns page the picture stays a picture, not a second screenful above the campaigns */
    .hearth-scene-home .hearth-picture {
        width: min(100%, 34rem);
        margin-left: auto;
    }

    .hearth-picture {
        position: relative;
        width: 100%;
        height: auto;
        -webkit-mask-image: linear-gradient(to bottom, transparent, #000 22%);
        mask-image: linear-gradient(to bottom, transparent, #000 22%);
    }

}

/* The campaigns page's strip is short enough to stay side by side down to a tablet; only a phone stacks it */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .hearth-scene-home {
        flex-direction: row;
        aspect-ratio: 1672 / 620;
    }

    .hearth-scene-home .hearth-scene-text {
        width: 50%;
        padding: 4.5% 0 2rem 5%;
    }

    .hearth-scene-home .hearth-picture {
        position: absolute;
        width: auto;
        height: 100%;
        margin-left: 0;
        -webkit-mask-image: linear-gradient(to right, transparent, #000 22%);
        mask-image: linear-gradient(to right, transparent, #000 22%);
    }
}

@media (max-width: 767.98px) {
    .hearth-keeps {
        padding: 2rem 0.5rem 0.5rem;
    }

    .hearth-keeps-list {
        grid-template-columns: 1fr;
    }
}

/* ===== Session Planner (templates/session-planner, static/js/session-planner.js) ===== */

/* A plan's conversation: the Sage's own scroll given the page's main column, as tall as the screen allows. Padded
   so its rollers' finials, which reach past the sheet, stay inside the column */
.planner-chat {
    padding: 0 36px;
}

.planner-chat .chat-panel {
    height: max(520px, calc(100vh - 220px));
    margin: 44px 0;
}

/* The messages take whatever room is left, so a long reply scrolls inside the scroll, not the page */
.planner-chat .chat-messages {
    flex: 1 1 0;
    min-height: 0;
    padding: 16px 12px;
}

/* Thorough replies run long: kept to a comfortable line length, with more air between lines and paragraphs */
.planner-chat .chat-bubble-ai {
    max-width: 72ch;
    line-height: 1.6;
}

.planner-chat .chat-bubble-ai p,
.planner-chat .chat-bubble-ai ul,
.planner-chat .chat-bubble-ai ol {
    margin-bottom: 0.85rem;
}

.planner-chat .chat-bubble-ai h2,
.planner-chat .chat-bubble-ai h3,
.planner-chat .chat-bubble-ai h4 {
    margin: 1rem 0 0.4rem;
    color: var(--oxblood);
    font-family: var(--font-heading);
}

.planner-chat .chat-bubble-user {
    max-width: 75%;
}

.planner-chat .chat-input {
    max-height: 30vh;
}

/* A planned session's side column (Actions, Jump to, Encounters, and what the session involves) stays in view as a
   long prep or fight scrolls, on screens wide enough for the columns to sit side by side; taller than the window, it
   scrolls on its own. On a phone the columns stack and it stays in the flow */
@media (min-width: 768px) {
    .side-column-follows {
        position: sticky;
        top: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
}

/* Beside a long plan (wide screens, where the columns sit side by side), the Sage stays in view as the page scrolls:
   its column sticks at the top, sized to the screen with room for its finials, so the left side is never blank. On a
   phone the columns stack and it stays in the flow */
@media (min-width: 992px) {
    .planner-chat {
        position: sticky;
        top: 0;
    }

    .planner-chat .chat-panel {
        height: calc(100vh - 88px);
        min-height: 420px;
    }
}

@media (max-width: 575.98px) {
    .planner-chat {
        padding: 0 30px;
    }
}

/* What the conversation has settled: numbered as the server numbers them, each with its timing under it */
.planner-decisions {
    padding-left: 1.6rem;
    margin-bottom: 1rem;
}

.planner-decision {
    margin-bottom: 0.75rem;
}

.planner-decision::marker {
    color: var(--oxblood);
    font-weight: bold;
}

.planner-decision-text {
    display: block;
}

/* Struck, but kept: its words crossed out and faded */
.planner-decision.is-struck .planner-decision-text {
    color: var(--leather-dark);
    opacity: 0.75;
}

.planner-decision-timing {
    display: block;
    font-size: 0.8rem;
    font-style: italic;
    color: var(--leather-dark);
}

.planner-decision-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

/* Change on the fly: the decision's timing and Add decision on one line under the box, wrapping on a narrow tile */
.planner-add-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.planner-timing .form-check-inline:last-child {
    margin-right: 0;
}

.planner-finished {
    margin-bottom: 1rem;
}

.planner-finish-proposal .sage-card {
    margin-bottom: 0.75rem;
}

.planner-title-form {
    display: flex;
    gap: 0.5rem;
    max-width: 40rem;
}

.planner-title-form[hidden] {
    display: none;
}

/* A plan in the list: its name and where it stands, Delete at the right */
.planner-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.planner-row-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
}

/* ===== Editing a planned session (templates/sessions/planned/edit.html, static/js/planned-edit.js) ===== */

/* A section's words as written, line breaks and all: the text the GM edits, not its formatted look */
.planned-section-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* A section's words on the edit page, formatted as on the session's page */
.planned-section-formatted {
    overflow-wrap: anywhere;
}

/* One suggested change: what the Sage suggests beside the words as they are now, stacked on a narrow tile */
.planned-change {
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px dotted var(--parchment-dark);
}

.planned-change-compare {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

/* In the review pop-up the suggestion and the session as it is now always sit side by side, stacked on a phone */
.planned-review .planned-change-compare {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 767.98px) {
    .planned-review .planned-change-compare {
        grid-template-columns: 1fr;
    }
}

/* What a suggested change does to a section's words: those it puts in tinted green in the suggestion, those it takes
   out tinted red and struck through in the old words */
.planned-diff-added {
    background: color-mix(in srgb, var(--success) 25%, transparent);
    text-decoration: none;
    border-radius: 2px;
}

.planned-diff-removed {
    background: color-mix(in srgb, var(--danger) 18%, transparent);
    text-decoration: line-through;
    text-decoration-color: var(--danger);
    border-radius: 2px;
}

.planned-change-side {
    padding: 0.5rem 0.6rem;
    background: var(--parchment-light);
    border: 1px solid var(--rule-gold);
    font-size: 0.9rem;
}

.planned-change-caption {
    margin: 0 0 0.25rem;
    font-size: 0.8rem;
    font-style: italic;
    color: var(--leather-dark);
}

.planned-change-heading {
    margin: 0 0 0.25rem;
    font-family: var(--font-heading);
    color: var(--oxblood);
}

/* Under a Sage edit's side-by-side pop-up: the record's other suggestions it can't set side by side, by their lines */
.sage-compare-others {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--leather-dark);
}

/* ===== Character sheet (fragments/sheet.html): the player's link and the GM's character page =====
   Phone first. The sheet lays itself out by its own width (a container), so it reads the same in the GM page's
   column as on a phone, and goes to one row of tiles and one row of tabs only when it has the room. */
.sheet {
    container-type: inline-size;
}

/* The strip of vitals and tabs under the name: stays at the top of the screen while the sheet scrolls under it */
.sheet-strip {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--parchment-light);
    border-bottom: 1px solid var(--rule-gold);
    padding: 0.4rem 0.25rem 0.3rem;
    margin: 0 -0.25rem 0.75rem;
}

/* The GM's character page (pcs/view): from lg up the sheet is a box about the height of the screen under the navbar
   and the page's header (--sheet-frame-offset, larger with a portrait), never under 26.5rem. Its strip of tiles and
   tabs stays put and only the open tab scrolls inside it (each pane is already a keyboard stop, named by its tab),
   so the GM's cards start right under it. Below lg it flows with the page, the strip sticky as on the player's link */
.sheet-frame {
    /* What sits above the sheet: the navbar, breadcrumb, name, and headline */
    --sheet-frame-offset: 24rem;
}

/* With the character's portrait beside the name (pc-title), a little taller than the name's lines alone */
.sheet-frame-portrait {
    --sheet-frame-offset: 24.5rem;
}

/* What the box grows by so the open tab keeps its room: the Level up banner over the strip, and the XP line on it */
.sheet-owes-level {
    --sheet-banner: 5.75rem;
}

.sheet-shows-xp {
    --sheet-xp: 1.6rem;
}

@media screen and (min-width: 992px) {
    .sheet-frame > .sheet {
        display: flex;
        flex-direction: column;
        height: max(calc(26.5rem + var(--sheet-banner, 0rem) + var(--sheet-xp, 0rem)),
                    calc(100vh - var(--sheet-frame-offset) + var(--sheet-banner, 0rem) + var(--sheet-xp, 0rem)));
    }

    .sheet-frame > .sheet > .sheet-strip {
        position: static;
        flex: none;
    }

    .sheet-frame > .sheet > .tab-content {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }

    .sheet-frame > .sheet > .tab-content > .tab-pane.active {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        /* room for the focus ring and the last card's shadow */
        padding: 0 0.25rem 0.5rem;
    }

    .sheet-frame > .sheet > .tab-content > .tab-pane:focus-visible {
        outline: 3px solid var(--gold);
        outline-offset: -3px;
    }
}

/* The tiles: hit points across the whole width on a phone, then AC, Initiative, Speed (and Spell DC) sharing a row */
.sheet-vitals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.sheet-vitals > * {
    flex: 1 1 0;
    min-width: 0;
}

/* One tile: its number over its label, centred */
.sheet-vital {
    margin: 0;
    padding: 0.35rem 0.2rem 0.3rem;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.sheet-vital-value {
    font-size: 1.35rem;
    font-weight: bold;
    line-height: 1.1;
    white-space: nowrap;
}

/* A tile's label: the heading face in oxblood */
.sheet-vital-label {
    margin: 0;
    font-family: var(--font-heading);
    color: var(--oxblood);
    font-size: 0.85rem;
    line-height: 1;
    letter-spacing: 0.02em;
}


/* The hit points tile: across the whole width on a phone, a wider tile beside the others in one row */
.sheet-vitals > .sheet-vital-hp {
    flex: 1 1 100%;
}

.sheet-vital-hp .sheet-vital-value {
    font-size: 1.6rem;
}

/* At the table the hit points tile is one row: the numbers, then Damage, the amount, and Heal, then temp */
.sheet-vital-hp:has(.sheet-hp-adjust) {
    flex-direction: row;
    justify-content: space-between;
    gap: 0.25rem;
    padding: 0.3rem 0.35rem;
}

/* The numbers never give up room to the buttons: "103 / 112" fits a 390px phone beside them, a little smaller */
.sheet-hp-now {
    flex: none;
    text-align: center;
}

.sheet-vital-hp:has(.sheet-hp-adjust) .sheet-vital-value {
    font-size: 1.35rem;
}

/* Damage, the amount, and Heal: as tall as a thumb */
.sheet-hp-adjust {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.sheet-hp-adjust .btn {
    min-height: 2.75rem;
    padding: 0 0.35rem;
    font-size: 0.9rem;
    line-height: 1;
}

.sheet-hp-adjust .form-control {
    width: 2.6rem;
    height: 2.75rem;
    padding: 0.2rem;
    text-align: center;
}

/* Temporary hit points: a small box over its label */
.sheet-hp-temp {
    text-align: center;
}

.sheet-hp-temp .form-control {
    width: 2.4rem;
    height: 2.1rem;
    margin: 0 auto 0.15rem;
    padding: 0.1rem;
    text-align: center;
}

/* The line under the tile saying what the last change did, with Undo; nothing while there is nothing to say */
.sheet-hp-log {
    margin-top: 0.3rem;
}

.sheet-hp-log:empty {
    display: none;
}

/* Undo: a button that reads as a link */
.sheet-undo {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: bold;
    color: var(--leather-brown);
    text-decoration: underline;
}

.sheet-undo:hover {
    color: var(--gold);
}

/* Death saves at 0 hit points: three successes and three failures, boxes big enough for a finger */
.sheet-death-saves {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.3rem 1rem;
    margin-top: 0.4rem;
    padding: 0.4rem;
}

.sheet-death-saves .form-check-input {
    width: 1.6em;
    height: 1.6em;
    margin: 0 0.15rem;
    vertical-align: middle;
}

/* The tabs: an even grid four across (two rows on a phone), each a closed tile */
.sheet-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.25rem;
    margin-top: 0.4rem;
    border-bottom: none;
}

.sheet-tabs .nav-link,
.sheet-tabs .nav-link.active {
    margin: 0;
    padding: 0.3rem 0.1rem;
    border-bottom: 1px solid var(--rule-gold);
    font-size: 0.95rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* On the narrowest phones the labels shrink a little, so Backstory and Homebrew fit */
@media (max-width: 420px) {
    .sheet-tabs .nav-link,
    .sheet-tabs .nav-link.active {
        font-size: 0.85rem;
        letter-spacing: -0.01em;
    }
}

/* Skills as a paper sheet lists them: a dot, the bonus, the name, and the ability, two columns on a phone */
.sheet-skills {
    columns: 2;
    column-gap: 1.5rem;
    font-size: 0.9rem;
}

.sheet-skill {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.12rem 0;
    border-bottom: 1px dotted var(--rule-gold);
    break-inside: avoid;
}

/* Proficiency: an empty ring, filled when proficient, ringed again for expertise */
.sheet-dot {
    flex: none;
    width: 0.7em;
    height: 0.7em;
    border: 1.5px solid var(--oxblood);
    border-radius: 50%;
}

.sheet-dot.is-proficient,
.sheet-dot.is-expert {
    background: var(--oxblood);
}

.sheet-dot.is-expert {
    box-shadow: 0 0 0 2px var(--parchment-light), 0 0 0 3.5px var(--oxblood);
}

.sheet-skill-name {
    min-width: 0;
}

.sheet-skill-bonus {
    flex: none;
    width: 2.2em;
    text-align: right;
    font-weight: bold;
}

.sheet-skill-ability {
    margin-left: auto;
    color: var(--leather-brown);
    font-size: 0.8em;
}

/* A line on Actions or Gear: its name and a muted line on the left, what to roll (or how many) on the right */
.sheet-action {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--rule-gold);
}

.sheet-action:last-child {
    border-bottom: 0;
}

/* Both sides of a line wrap rather than run past the card's edge on a phone: the name (and its badge) on the left,
   and on the right the roll ("+12 to hit", "8d6 radiant") with its damage under it, in at most 60% of the line */
.sheet-action > :first-child {
    min-width: 0;
}

.sheet-action-roll {
    text-align: right;
    font-weight: bold;
    max-width: 60%;
    overflow-wrap: break-word;
}

/* An action's name, a button that opens what it does: bold as the name was, with the dashed rule of a number on the
   strip that opens its form (sheet-edit-value) */
.sheet-action-name {
    padding: 0;
    border: 0;
    border-bottom: 1px dashed var(--leather-brown);
    background: none;
    font: inherit;
    font-weight: bold;
    color: inherit;
    text-align: left;
}

.sheet-action-name:hover,
.sheet-action-name:focus-visible,
.sheet-action-tappable:hover .sheet-action-name,
.sheet-action-tappable:active .sheet-action-name {
    color: var(--oxblood);
    border-bottom-style: solid;
}

/* A working sheet's action opens from a tap anywhere on its line (sheet-actions.js): the line shows it can be tapped,
   and its name takes the look it has under the pointer; the name stays the one control for a keyboard */
.sheet-action-tappable {
    cursor: pointer;
}

/* Spell slots: two columns, the labels as wide as the widest ("Pact (3rd)"), so every row's boxes start at the same
   edge and keep the same spacing; tick boxes big enough for a finger, far enough apart to hit one at a time */
.sheet-slots {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: 0.75rem;
    row-gap: 0.5rem;
    align-items: center;
}

.sheet-slot-row {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    align-items: center;
}

.sheet-slot-boxes {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.sheet-slot-boxes .form-check-input {
    width: 1.6em;
    height: 1.6em;
    margin: 0;
}

/* A number on the strip that opens its own form (the maximum hit points), or a box in place (AC, initiative, speed,
   a button): underlined with a dashed rule */
.sheet-edit-value {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed var(--leather-brown);
}

.sheet-edit-value:hover,
.sheet-edit-value:focus-visible {
    color: var(--oxblood);
    border-bottom-style: solid;
}

/* A hit points tile across a wide sheet keeps its numbers and controls together in the middle, not at its edges */
@container (min-width: 440px) {
    .sheet-vital-hp:has(.sheet-hp-adjust) {
        justify-content: center;
        gap: 1.25rem;
    }
}

/* A narrow sheet (a phone): skills go one to a line, so a long name and its ability stay inside the card */
@container (max-width: 439.98px) {
    .sheet-skills {
        columns: 1;
    }
}

/* On a phone the tab grid folds to one line, the open tab's name and the caret (sheet-tabs.js): a fold-toggle drawn as
   the open tab is. Wider than one row of tabs it is hidden and the grid always shows. Only a fold the script has wired
   folds: without it, the grid simply shows */
.fold-toggle.sheet-tabs-toggle {
    display: none;
    margin-top: 0.4rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--rule-gold);
    background: var(--parchment-light);
    color: var(--oxblood);
    font-family: var(--font-heading);
    font-size: 0.95rem;
}

@container (max-width: 619.98px) {
    [data-sheet-tabs-wired] > .fold-toggle.sheet-tabs-toggle {
        display: flex;
    }

    [data-sheet-tabs-wired] > .sheet-tabs {
        overflow: hidden;
        transition: max-height 0.6s ease;
    }

    [data-sheet-tabs-wired]:not([data-sheet-tabs-shown]) > .sheet-tabs {
        max-height: 0;
        margin-top: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    [data-sheet-tabs-wired] > .sheet-tabs {
        transition: none;
    }
}

/* Eight or nine tabs (Campaign, or Start here, with them): five across once there is room, so they take two rows */
@container (min-width: 480px) {
    .sheet-tabs {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

/* Room for every tab in one row (the GM's column on a laptop, the player's link on a tablet), so the GM's box keeps
   its height for the pane: the labels smaller and closer to their edges until there is room for the longest
   (Start here, Backstory, Homebrew, Campaign) at full size */
@container (min-width: 620px) {
    .sheet-tabs {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
    }
}

@container (min-width: 620px) and (max-width: 859.98px) {
    .sheet-tabs .nav-link,
    .sheet-tabs .nav-link.active {
        padding-left: 0;
        padding-right: 0;
        font-size: 0.8rem;
        letter-spacing: -0.01em;
    }
}

/* Room for the hit points tile beside the other four (the player's link on a tablet or laptop, the GM's column on
   a laptop): every tile in one row, hit points the widest */
@container (min-width: 640px) {
    .sheet-vitals {
        flex-wrap: nowrap;
    }

    .sheet-vitals > .sheet-vital-hp {
        flex: 1.6 1 0;
    }

    /* With its controls, the hit points tile takes the room they need and the other tiles share the rest */
    .sheet-vitals > .sheet-vital-hp:has(.sheet-hp-adjust) {
        flex: 0 0 auto;
    }
}

/* A laptop's full width: skills three across */
@container (min-width: 680px) {
    .sheet-skills {
        columns: 3;
        font-size: 1rem;
    }
}

/* A page printed (a share page's Print, or the browser's own): its sheet on plain paper, without the desk, the
   navbar, the footer, the Sage, banners, or buttons, and no card split across two pages */
@media print {
    html {
        background: none;
    }

    nav[data-layout],
    body > footer,
    .import-banner,
    .read-only-banner,
    .back-to-top,
    .chat-floating-fab,
    .sage-ask-banner,
    .btn {
        display: none !important;
    }

    .page-frame {
        border: 0;
        padding: 0;
        margin: 0;
        max-width: none;
    }

    .page-frame::before {
        display: none;
    }

    /* A card's (and an alert's, a story step's) parchment and shadow are its ::before and ::after: on paper, a plain
       ruled box */
    .card {
        break-inside: avoid;
        border: 1px solid var(--rule-gold);
    }

    .card::before, .dnd-card::before, .story-step::before, .import-format-callout::before, .alert::before,
    .card::after, .dnd-card::after, .story-step::after, .import-format-callout::after, .alert::after {
        display: none;
    }

    /* A character sheet prints every tab's pane, one after another, under its vitals */
    .sheet-strip {
        position: static;
    }

    .sheet-tabs,
    .sheet .nav-tabs {
        display: none;
    }

    .sheet .tab-content > .tab-pane {
        display: block;
        opacity: 1;
    }
}

/* The table screen (screen/screen.html): a black window for a projector. The map fills it and turns in quarter
   turns; the portrait sits in a corner over it. Nothing on it is a caption or a name. */
.table-screen-body {
    margin: 0;
    background: var(--leather-darker);
}

.table-screen {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: #000;
    color: var(--text-light);
    outline: none;
    cursor: pointer;
}

.table-screen.pointer-hidden {
    cursor: none;
}

.table-screen-layer,
.table-screen-portrait {
    transition: opacity 200ms ease;
}

.table-screen.no-fade .table-screen-layer,
.table-screen.no-fade .table-screen-portrait {
    transition: none;
}

/* Hiding is instant and only showing fades, so a picture still fading out can never be seen without its fog */
.table-screen .is-hidden {
    opacity: 0;
    transition: none;
}

.table-screen-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: 100vh;
    transform: translate(-50%, -50%);
}

.table-screen-layer.turns-1 {
    width: 100vh;
    height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg);
}

.table-screen-layer.turns-2 {
    transform: translate(-50%, -50%) rotate(180deg);
}

.table-screen-layer.turns-3 {
    width: 100vh;
    height: 100vw;
    transform: translate(-50%, -50%) rotate(270deg);
}

/* The map's zoom and place (table-screen-view.js): the picture and its fog move as one, gliding to each new view */
.table-screen-view {
    position: absolute;
    inset: 0;
    transform-origin: 0 0;
    transition: transform 330ms ease;
}

.table-screen.no-fade .table-screen-view,
.table-screen-view.no-glide {
    transition: none;
}

/* The picture and its fog are the same size, so the mask lies exactly over the map */
.table-screen-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* A session's shown tokens on the screen (table-screen-window.js places them in px on the fitted picture): under the
   fog canvas, which comes after them, so the fog hides a token as it hides the map. Ringed by kind as on the controls
   page; a name only under a player character. */
.table-screen-tokens {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.table-screen-token {
    position: absolute;
    border-radius: 50%;
    background: var(--parchment-light);
    transform: translate(-50%, -50%);
    container-type: inline-size;
    box-shadow: 0 0 0 3px var(--ring, var(--rule-gold)), 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* The rings by kind, as on the controls page (this rule comes after .table-screen-token's own border) */
.table-screen-token.token-ring-player { --ring: var(--info); }
.table-screen-token.token-ring-npc { --ring: var(--success); }
.table-screen-token.token-ring-monster { --ring: var(--danger); }

.table-screen-token-face {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.table-screen-token-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-family: var(--font-heading);
    font-size: max(10px, 45cqw);
    color: var(--text-dark);
}

.table-screen-token-badge {
    position: absolute;
    right: -0.3em;
    bottom: -0.3em;
    padding: 0.05em 0.35em;
    border-radius: 0.7em;
    background: var(--oxblood);
    color: var(--parchment-light);
    font-size: 0.8rem;
}

.table-screen-token-name {
    position: absolute;
    top: 100%;
    left: 50%;
    margin-top: 0.3em;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.9rem;
    color: var(--parchment-light);
    text-shadow: 0 1px 3px #000;
}

.table-screen-portrait {
    position: absolute;
    right: 2vmin;
    bottom: 2vmin;
    width: 40vmin;
    height: 55vmin;
}

.table-screen-portrait.turns-1 {
    transform: rotate(90deg);
}

.table-screen-portrait.turns-2 {
    transform: rotate(180deg);
}

.table-screen-portrait.turns-3 {
    transform: rotate(270deg);
}

.table-screen-portrait img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.table-screen-note {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 2vmin;
    margin: 0;
    text-align: center;
    color: var(--gold-pale);
}
