/* ==========================================================================
   deyderae.dev — Catppuccin theme system
   Palettes: Latte, Frappé, Macchiato, Mocha
   Source: https://github.com/catppuccin/catppuccin (official hex values)
   ========================================================================== */

:root {
  --radius: 14px;
  --maxw: 880px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ---- Latte (light) ---- */
[data-theme="latte"] {
  --rosewater: #dc8a78; --flamingo: #dd7878; --pink: #ea76cb; --mauve: #8839ef;
  --red: #d20f39; --maroon: #e64553; --peach: #fe640b; --yellow: #df8e1d;
  --green: #40a02b; --teal: #179299; --sky: #04a5e5; --sapphire: #209fb5;
  --blue: #1e66f5; --lavender: #7287fd;
  --text: #4c4f69; --subtext1: #5c5f77; --subtext0: #6c6f85;
  --overlay2: #7c7f93; --overlay1: #8c8fa1; --overlay0: #9ca0b0;
  --surface2: #acb0be; --surface1: #bcc0cc; --surface0: #ccd0da;
  --base: #eff1f5; --mantle: #e6e9ef; --crust: #dce0e8;
}
/* ---- Frappé ---- */
[data-theme="frappe"] {
  --rosewater: #f2d5cf; --flamingo: #eebebe; --pink: #f4b8e4; --mauve: #ca9ee6;
  --red: #e78284; --maroon: #ea999c; --peach: #ef9f76; --yellow: #e5c890;
  --green: #a6d189; --teal: #81c8be; --sky: #99d1db; --sapphire: #85c1dc;
  --blue: #8caaee; --lavender: #babbf1;
  --text: #c6d0f5; --subtext1: #b5bfe2; --subtext0: #a5adce;
  --overlay2: #949cbb; --overlay1: #838ba7; --overlay0: #737994;
  --surface2: #626880; --surface1: #51576d; --surface0: #414559;
  --base: #303446; --mantle: #292c3c; --crust: #232634;
}
/* ---- Macchiato ---- */
[data-theme="macchiato"] {
  --rosewater: #f4dbd6; --flamingo: #f0c6c6; --pink: #f5bde6; --mauve: #c6a0f6;
  --red: #ed8796; --maroon: #ee99a0; --peach: #f5a97f; --yellow: #eed49f;
  --green: #a6da95; --teal: #8bd5ca; --sky: #91d7e3; --sapphire: #7dc4e4;
  --blue: #8aadf4; --lavender: #b7bdf8;
  --text: #cad3f5; --subtext1: #b8c0e0; --subtext0: #a5adcb;
  --overlay2: #939ab7; --overlay1: #8087a2; --overlay0: #6e738d;
  --surface2: #5b6078; --surface1: #494d64; --surface0: #363a4f;
  --base: #24273a; --mantle: #1e2030; --crust: #181926;
}
/* ---- Mocha (default) ---- */
[data-theme="mocha"] {
  --rosewater: #f5e0dc; --flamingo: #f2cdcd; --pink: #f5c2e7; --mauve: #cba6f7;
  --red: #f38ba8; --maroon: #eba0ac; --peach: #fab387; --yellow: #f9e2af;
  --green: #a6e3a1; --teal: #94e2d5; --sky: #89dceb; --sapphire: #74c7ec;
  --blue: #89b4fa; --lavender: #b4befe;
  --text: #cdd6f4; --subtext1: #bac2de; --subtext0: #a6adc8;
  --overlay2: #9399b2; --overlay1: #7f849c; --overlay0: #6c7086;
  --surface2: #585b70; --surface1: #45475a; --surface0: #313244;
  --base: #1e1e2e; --mantle: #181825; --crust: #11111b;
}

* { box-sizing: border-box; }

html { color-scheme: dark; scroll-behavior: smooth; }
[data-theme="latte"] { color-scheme: light; }

/* ==========================================================================
   Site layout (sr3.deyderae.dev only, not part of the shared theme system above)
   Small text uses --subtext1 rather than the overlay or --subtext0 tokens so
   it stays >= 4.5:1 in Latte, the lowest-contrast palette.
   ========================================================================== */
:root {
  --gutter: clamp(1rem, 4vw, 2rem);
  --page-w: 72rem;
  --content-w: 50rem;
  --link: color-mix(in srgb, var(--blue) 75%, var(--text));
  --hover-title: color-mix(in srgb, var(--green) 55%, var(--text));
  --field-border: color-mix(in srgb, var(--text) 70%, var(--base));
  --danger: color-mix(in srgb, var(--red) 70%, var(--text));
  --success: color-mix(in srgb, var(--green) 70%, var(--text));
  --icon: var(--green);
}
/* Raw Latte green is under 3:1 on the footer band. */
[data-theme="latte"] { --icon: color-mix(in srgb, var(--green) 70%, var(--text)); }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  line-height: 1.55;
  background: var(--base);
  color: var(--text);
  transition: background-color 0.25s ease, color 0.25s ease;
}

a { color: var(--link); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--mauve);
  outline-offset: 3px;
  border-radius: 0.25rem;
}
/* Headings are focused by script after a view change; they are not controls. */
[tabindex="-1"]:focus { outline: none; }

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  background: var(--mauve);
  color: var(--base);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

h1 { margin: 0; font-size: 1.75rem; line-height: 1.2; }
h2 { margin: 0; font-size: 1.25rem; line-height: 1.3; }
p { margin: 0; }

/* ---- Header (full-width bar: brand at the left edge, controls at the right edge) ---- */
.site-header {
  background: var(--mantle);
  border-bottom: 1px solid var(--surface0);
  transition: background-color 0.25s ease;
}
/* Sticky only where there is room: on a phone the header is two rows tall. */
@media (min-width: 40rem) {
  .site-header { position: sticky; top: 0; z-index: 50; }
}
.bar {
  padding: 0.75rem var(--gutter);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-right: auto;
  text-decoration: none;
}
.logo { display: block; width: 2rem; height: 2rem; }
.wordmark {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--mauve);
}
.wordmark span { color: var(--text); font-weight: 400; }
@media (max-width: 40rem) {
  .wordmark span { display: none; }
  .theme-switcher { order: 2; }
  .account { order: 3; flex-basis: 100%; }
  .account .btn-small { padding-inline: 0.5rem; }
}
/* A button that does not fit goes to the next row; its words stay on one line. */
.account { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.account .btn { white-space: nowrap; }
.places { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
/* The place a page belongs to. */
.account [aria-current="page"] { background: var(--surface0); border-color: var(--text); }
.account-name {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Theme switcher ---- */
.theme-switcher {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  background: var(--base);
  border: 1px solid var(--surface0);
  border-radius: 999px;
  padding: 4px;
}
.theme-btn {
  border: none;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  padding: 0;
  position: relative;
}
.theme-btn[data-swatch="latte"]      { background: #eff1f5; box-shadow: inset 0 0 0 1px #acb0be; }
.theme-btn[data-swatch="frappe"]     { background: #303446; box-shadow: inset 0 0 0 1px #626880; }
.theme-btn[data-swatch="macchiato"]  { background: #24273a; box-shadow: inset 0 0 0 1px #5b6078; }
.theme-btn[data-swatch="mocha"]      { background: #1e1e2e; box-shadow: inset 0 0 0 1px #585b70; }
.theme-btn.active { box-shadow: 0 0 0 2px var(--base), 0 0 0 4px var(--mauve); }
.theme-label {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  z-index: 1;
  padding: .3rem .5rem;
  border: 1px solid var(--surface2);
  border-radius: .35rem;
  background: var(--mantle);
  color: var(--text);
  font: .8rem var(--font-sans);
  white-space: nowrap;
  visibility: hidden;
  pointer-events: none;
}
.theme-btn:is(:hover, :focus-visible) .theme-label { visibility: visible; }

/* ---- Page and content ---- */
.site-header .bar { padding-block: .55rem; gap: .5rem 1rem; }
.site-header .places { gap: .3rem; }
.site-header .places .btn { border-radius: 0; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--subtext1); padding: .5rem .65rem; }
.site-header .places .btn:hover { color: var(--text); border-bottom-color: var(--surface2); }
.site-header .places .btn[aria-current="page"] { color: var(--text); border-bottom-color: var(--mauve); background: transparent; }
.header-popover { position: fixed; inset: var(--popover-top, 4rem) var(--popover-right, 1rem) auto auto; margin: 0; max-width: calc(100vw - 1rem); max-height: calc(100dvh - var(--popover-top, 4rem) - 1rem); overflow: auto; padding: .55rem; background: var(--mantle); color: var(--text); border: 1px solid var(--surface1); border-radius: .65rem; box-shadow: 0 .75rem 2rem #0004; }
.header-popover:popover-open { display: flex; flex-direction: column; gap: .35rem; }
.header-popover:not(:popover-open) { display: none; }
.header-popover .btn { text-align: left; }
@media (min-width: 40rem) and (max-width: 75rem) { .wordmark span { display: none; } }
.characters-heading { padding: clamp(1.25rem, 3vw, 2rem); background: linear-gradient(120deg, color-mix(in srgb, var(--mauve) 9%, var(--mantle)), var(--mantle)); border: 1px solid var(--surface0); border-left: 3px solid var(--mauve); border-radius: 1rem; }
.characters-heading p { margin-block: .65rem 1.25rem; }
.characters-page > .characters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 23rem), 1fr)); align-items: stretch; gap: 1rem; }
.characters-page > .characters > .character-card { display: flex; flex-direction: column; border-top: 3px solid var(--blue); }
.characters-page > .characters > .character-card:is(:hover, :focus-within) { border-top-color: var(--mauve); }
.characters-page > .characters .card-head { align-items: start; }
.characters-page > .characters .actions { margin-top: auto; padding-top: 1rem; align-items: center; }
.characters-page > #characters-full { max-width: 95ch; font-size: .9rem; }
.page:has(.characters-page) { max-width: 88rem; }
.page > .characters-page { max-width: none; }
/* The page is as wide as the footer. Its content is a narrow column by default. A page that
   holds a grid of cards is "roomy", and the sheet is "wide" (sheet.css). */
.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--page-w);
  margin: 0 auto;
  padding: clamp(1.5rem, 6vw, 3rem) var(--gutter) 4rem;
}
.page > * { max-width: var(--content-w); margin-inline: auto; }
.page-roomy > *, .page-wide > *, .page-full > * { max-width: none; }
.page-roomy p { max-width: 60ch; }
/* The rulebook: the window's width, so tables and the chapter list have room; its
   paragraphs keep a line short enough to read. */
.page-full { max-width: 120rem; }
.page-full p { max-width: 80ch; }
/* The lists reset their own margins, so give them the stack's gap. */
.stack > :is(.characters, .history, .roster) { margin-top: 1rem; }
/* Cards side by side, as wide as the panel above them. */
.two-up { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 1rem; align-items: start; }
.stack > * + * { margin-top: 1rem; }
.muted { color: var(--subtext1); }
.hint { font-size: 0.9rem; color: var(--subtext1); }

.card {
  min-width: 0;
  overflow-wrap: anywhere;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 1rem;
  padding: 1.5rem;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-head > :is(h1, h2, h3) { min-width: 0; overflow-wrap: anywhere; }
.card-head > .badge { flex: 0 1 auto; max-width: 100%; }
.badge {
  display: inline-block;
  width: fit-content;
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface0);
  color: var(--text);
}
.code {
  display: inline-block;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--field-border);
  border-radius: 0.4rem;
  background: var(--base);
  font-family: var(--font-mono);
  font-size: 1.15rem;
  letter-spacing: 0.12em;
}

/* ---- Forms ---- */
.field + .field { margin-top: 1rem; }
.field label { display: block; margin-bottom: 0.35rem; font-weight: 600; }
.field .hint { margin-bottom: 0.35rem; }
.field .notice { margin-top: 0.35rem; }
input,
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 2px solid var(--field-border);
  border-radius: 0.5rem;
  background: var(--base);
  color: var(--text);
  font: inherit;
}
input::placeholder, textarea::placeholder { color: var(--subtext1); opacity: 1; }
select { cursor: pointer; }
.toggle-row { margin-top: 0.5rem; }
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}
.status { margin-top: 0.75rem; }
.actions .status { margin-top: 0; }
.actions > .action-status { flex-basis: 100%; order: 1; }
.status:empty { display: none; }

.btn {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border: 2px solid transparent;
  border-radius: 0.5rem;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn-primary { background: var(--mauve); color: var(--base); }
.btn-primary:hover { background: color-mix(in srgb, var(--mauve) 85%, var(--text)); }
.btn-quiet { background: transparent; border-color: var(--field-border); color: var(--text); }
.btn-quiet:hover { background: var(--surface0); }
.btn-small { padding: 0.3rem 0.7rem; font-size: 0.9rem; }
/* Disabled is a dashed border, not dimming: opacity would drop the text below
   the contrast minimum. Keep this after the hover rules so it wins. */
.btn:disabled {
  border: 2px dashed var(--field-border);
  background: transparent;
  color: var(--subtext1);
  cursor: not-allowed;
}

.notice {
  overflow-wrap: anywhere;
  padding: 0.75rem 1rem;
  border: 2px solid var(--field-border);
  border-radius: 0.5rem;
  background: var(--base);
}
.notice-error { border-color: var(--danger); }
.notice-success { border-color: var(--success); }

/* ---- Invites (DM page) ---- */
.invites { margin: 0; padding: 0; list-style: none; }
.invite {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--surface0);
}
.invite:first-child { padding-top: 0; border-top: none; }
.invite-main { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; }
.linkbox { display: block; word-break: break-all; font-size: 0.95rem; letter-spacing: 0; }

/* Text for screen readers only. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---- Home ---- */
article.card h3 { margin: 0; font-size: 1.25rem; line-height: 1.3; }
.stack > h2.section-title { margin-top: 2rem; }

/* ---- Path line: where a page is, from Home down. Its last part is the page. ---- */
.path { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; width: 100%; min-width: 0; color: var(--subtext1); font-size: 0.9rem; }
.path-back { flex: none; padding: 0.25rem 0.6rem 0.25rem 0; border-right: 1px solid var(--surface2); white-space: nowrap; }
.path-trail { display: flex; flex: 1; align-items: center; gap: 0.4rem; min-width: 0; margin: 0; padding: 0; list-style: none; }
.path-trail > li { display: flex; align-items: center; min-width: 0; }
.path-trail > li + li::before { content: "\203A"; flex: none; margin-right: 0.4rem; color: var(--subtext1); }
.path-trail > li > a, .path-trail > li > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.path [aria-current="page"] { font-weight: 700; }
.path-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.path-overflow { display: none; position: relative; flex: none; }
.path-overflow summary { display: grid; place-items: center; width: 2.75rem; min-height: 2.75rem; cursor: pointer; list-style: none; border: 1px solid var(--field-border); border-radius: 0.4rem; color: var(--text); background: var(--mantle); }
.path-overflow summary::-webkit-details-marker { display: none; }
.path-overflow ul { position: absolute; z-index: 10; top: 100%; left: 0; width: max-content; max-width: min(20rem, 75vw); margin: 0.25rem 0 0; padding: 0.4rem; list-style: none; border: 1px solid var(--surface2); border-radius: 0.4rem; background: var(--mantle); box-shadow: 0 0.5rem 1rem #0003; }
.path-overflow a { display: block; padding: 0.65rem; overflow-wrap: anywhere; }
@media (max-width: 40rem) {
  .path { gap: 0.25rem 0.4rem; }
  .path-back, .path-trail a { display: flex; align-items: center; min-height: 2.75rem; }
  .path-trail > li.path-ancestor { display: none; }
  .path-overflow { display: block; }
  .path-actions { flex-basis: 100%; }
}

/* ---- Home: every campaign beside the person's characters ---- */
.page:has(> .home-page) { max-width: 80rem; padding-block: 2rem 3rem; }
.home-page { display: grid; gap: 1.75rem; }
.home-welcome { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 1.5rem; padding: 1.5rem 2rem; border: 1px solid var(--surface1); border-left: 3px solid var(--mauve); border-radius: 1rem; background: linear-gradient(110deg, var(--mantle), color-mix(in srgb, var(--mauve) 6%, var(--base))); }
.home-eyebrow { margin-bottom: .5rem; color: var(--subtext1); font: .75rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; }
.home-welcome h1 { margin-bottom: .5rem; font-size: clamp(1.75rem, 3vw, 2.5rem); font-weight: 400; line-height: 1.2; letter-spacing: -.025em; overflow-wrap: anywhere; }
.home-welcome h1 strong { color: color-mix(in srgb, var(--mauve) 25%, var(--text)); }
.home-emblem { width: 64px; height: 64px; margin-inline: .5rem; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.home-grid > * { min-width: 0; }
.home-campaigns, .home-characters, .home-campaign-list { display: grid; gap: .9rem; min-width: 0; }
.home-section-heading { display: grid; gap: .25rem; }
.home-section-heading h2, .home-books h2 { font: 600 1.3rem "Chakra Petch", var(--font-sans); }
.home-section-heading p { font-size: .9rem; }
.home-campaign-list:empty { display: none; }
.home-campaign { --home-accent: var(--blue); border-top: 3px solid var(--home-accent); }
.home-campaign-keeper { --home-accent: var(--mauve); }
.home-campaign-none { --home-accent: var(--surface2); }
.home-campaign h3 { color: color-mix(in srgb, var(--home-accent) 25%, var(--text)); overflow-wrap: anywhere; }
.home-campaign .card-head { align-items: flex-start; }
.home-campaign .badge { border: 1px solid var(--surface2); }
.home-campaign .actions { gap: .6rem; }
.home-active-character { display: grid; gap: .35rem; padding: .75rem 1rem; border-left: 3px solid var(--blue); border-radius: .4rem; background: color-mix(in srgb, var(--blue) 5%, var(--base)); }
.home-label { color: var(--subtext1); font-size: .8rem; }
.home-available { display: grid; gap: .9rem; margin-top: .75rem; }
.home-available h2 { font-size: 1.15rem; }
.home-sidebar { display: grid; gap: 1.5rem; min-width: 0; }
.home-character-card { padding: .5rem 1.25rem 1.25rem; border-top: 3px solid var(--blue); }
.home-character-list { list-style: none; margin: 0; padding: 0; }
.home-character-list li { border-bottom: 1px solid var(--surface0); }
.home-character-link { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .85rem .5rem; color: var(--text); text-decoration: none; border-radius: .35rem; }
.home-character-link > span:first-child { display: grid; gap: .2rem; min-width: 0; }
.home-character-link .muted { font-size: .85rem; }
.home-character-link:hover { background: color-mix(in srgb, var(--blue) 5%, var(--mantle)); }
.home-character-link:hover strong { text-decoration: underline; text-underline-offset: .2em; }
.home-character-link:focus-visible { outline-offset: -3px; }
.home-link-arrow { flex: none; color: var(--text); }
.home-character-footer { padding-top: 1rem; }
.home-character-footer .btn { width: 100%; }
.home-books { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 1rem; border-top: 3px solid var(--teal); padding: 1.25rem; }
.home-books h2 { color: color-mix(in srgb, var(--teal) 25%, var(--text)); margin-bottom: .35rem; }
.home-books p { font-size: .9rem; }
.home-books .btn { white-space: nowrap; }
.home-empty { display: grid; gap: .5rem; }
.home-empty h3 { font-size: 1rem; margin: 0; }
.home-character-card > .home-empty { padding: 1rem .25rem .25rem; }
.plain-list { margin: 0; padding: 0; list-style: none; }
.plain-list li + li { margin-top: 0.5rem; }
.plain-list .muted { display: block; font-size: 0.9rem; }
@media (max-width: 55rem) {
  .home-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 40rem) {
  .home-welcome { padding: 1.25rem; }
  .home-emblem { display: none; }
  .home-books { grid-template-columns: minmax(0,1fr); }
  .home-books .btn { justify-self: start; }
}
/* On a phone the brand is the way Home, so the header stays two rows. */
@media (max-width: 40rem) {
  .places [data-place="home"] { display: none; }
}
h2.section-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--subtext1);
}

/* ---- Version history ---- */
.history { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.75rem; }
.history-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; padding: 1rem; background: var(--base); }
.history-item p { margin: 0.15rem 0 0; }

/* ---- Characters ---- */
.characters { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.character-card { background: var(--base); padding: 1rem; }
.character-card h2 { margin: 0; font-size: 1.15rem; line-height: 1.3; overflow-wrap: anywhere; }
details.card summary { cursor: pointer; font-weight: 600; }

/* Cards that hold actions, not links: a stronger border and a shadow on hover and focus,
   with no lift, so they do not look like one big link (deyderae.dev lifts link cards). */
article.card, .character-card, .player-card, .history-item {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
article.card:hover, article.card:focus-within,
.character-card:hover, .character-card:focus-within,
.player-card:hover, .player-card:focus-within,
.history-item:hover, .history-item:focus-within {
  border-color: color-mix(in srgb, var(--text) 50%, transparent);
  box-shadow: 0 0.5rem 1.5rem color-mix(in srgb, var(--text) 15%, transparent);
}
.character-card h2, .player-card h3, article.card h3 { transition: color 0.2s ease; }
.character-card:hover h2, .character-card:focus-within h2,
.player-card:hover h3, .player-card:focus-within h3,
article.card:hover h3, article.card:focus-within h3 { color: var(--hover-title); }

/* ---- Confirm dialogs (an "are you sure?" question, and delete a character forever) ---- */
dialog.confirm-dialog {
  width: min(30rem, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  margin: auto;
  padding: 1.25rem;
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
  background: var(--base);
  color: var(--text);
  overflow: auto;
}
dialog.confirm-dialog::backdrop { background: color-mix(in srgb, var(--crust) 75%, transparent); }
dialog.campaign-dialog { width: min(42rem, calc(100vw - 2rem)); }
dialog.confirm-dialog h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }
dialog.confirm-dialog > * + * { margin-top: 0.75rem; }

/* ---- Roster (DM page) ---- */
.roster { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.player-card { background: var(--base); padding: 1rem; }
.player-card h3 { margin: 0; font-size: 1.15rem; line-height: 1.3; overflow-wrap: anywhere; }
.player-card .penalty strong { font-size: 1.6rem; font-family: var(--font-mono); }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.75rem; margin: 0; font-size: 0.9rem; }
.stats dt { color: var(--subtext1); }
.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.small { font-size: 0.85rem; }
.badge-alert { border: 2px solid var(--danger); background: transparent; }

/* Shared Markdown book and reference content. */
.chapter { overflow-wrap: break-word; }
.chapter * { margin: 0; }
.chapter > * + *, .chapter blockquote > * + *, .chapter li > * + * { margin-top: 1rem; }
.chapter li + li { margin-top: 0.25rem; }
.chapter > :is(h2, h3, h4, h5, h6):not(:first-child) { margin-top: 2rem; }
.chapter :is(h1, h2, h3, h4, h5, h6) { line-height: 1.25; scroll-margin-top: calc(var(--header-h, 0px) + 1rem); }
.chapter h3 { font-size: 1.1rem; }
.chapter :is(h4, h5, h6) { font-size: 1rem; }
.chapter :is(ul, ol) { padding-left: 1.5rem; }
.chapter blockquote { padding: 0.75rem 1rem; border-left: 4px solid var(--field-border); background: var(--mantle); }
.chapter hr { border: 0; border-top: 1px solid var(--surface0); }
.chapter code { padding: 0.1em 0.3em; border-radius: 0.25rem; background: var(--mantle); font-family: var(--font-mono); font-size: 0.9em; }
/* Code wraps, so only a table can be wider than the page. */
.chapter pre { padding: 0.75rem 1rem; border: 1px solid var(--surface0); border-radius: 0.5rem; background: var(--mantle); white-space: pre-wrap; }
.chapter pre code { padding: 0; background: none; }
.table-scroll { overflow-x: auto; }
.chapter table { min-width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.chapter :is(th, td) { padding: 0.4rem 0.75rem; border: 1px solid var(--surface0); text-align: left; vertical-align: top; }
.chapter th { background: var(--mantle); }
.chapter .align-center { text-align: center; }
.chapter .align-right { text-align: right; }

/* ---- Footer (full-width band, like deyderae.dev) ---- */
.site-footer {
  background: var(--crust);
  border-top: 1px solid var(--surface0);
  color: var(--subtext1);
  font-size: 0.9rem;
  transition: background-color 0.25s ease;
}
.footer-inner {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 2rem var(--gutter);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}
.footer-inner p { margin: 0; }
.site-footer a { color: var(--text); }
.socials {
  display: flex;
  gap: 0.75rem;
  margin: 0 0 0.25rem;
  padding: 0;
  list-style: none;
}
.socials a {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  color: var(--icon);
  text-decoration: none;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.socials a:hover { color: var(--mauve); background: var(--mantle); }
.socials svg { width: 1.4rem; height: 1.4rem; fill: currentColor; }
.socials svg.stroke { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* Site administration */
.admin-dashboard { gap: 2rem; }
.admin-hero { padding: 2rem; border: 1px solid var(--surface1); border-left: 4px solid var(--mauve); border-radius: 1rem; background: linear-gradient(120deg, var(--mantle), color-mix(in srgb, var(--mauve) 8%, var(--base))); }
.admin-hero h1 { font-size: clamp(2rem, 4vw, 3rem); }
.admin-eyebrow { color: var(--subtext1); font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.12em; }
.admin-overview { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 1rem; }
.admin-metric { display: flex; flex-direction: column; gap: 0.25rem; padding: 1.25rem 1.5rem; border: 1px solid var(--surface1); border-radius: 0.75rem; background: var(--mantle); }
.admin-metric strong { font-size: 2rem; line-height: 1.25; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--surface1); }
.admin-nav a { display: block; padding: 0.5rem 1rem; border-radius: 0.5rem; color: var(--text); text-decoration: none; background: var(--mantle); }
.admin-nav a:hover { background: var(--surface0); }
.admin-section { scroll-margin-top: 7rem; }
.admin-section > .card-head { align-items: center; flex-wrap: wrap; gap: 1rem; }
.admin-section > .card-head p { margin-top: 0.5rem; max-width: 42rem; }
.admin-toolbar { display: grid; grid-template-columns: minmax(0,1fr) minmax(10rem,15rem); gap: 1rem; align-items: end; }
.admin-toolbar input, .admin-toolbar select { width: 100%; min-width: 0; box-sizing: border-box; }
.admin-campaign-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.admin-campaign { border-top: 3px solid var(--mauve); }
.admin-campaign h3 { margin: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
.admin-campaign-stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); margin: 0; padding: 1rem 0; border-top: 1px solid var(--surface1); border-bottom: 1px solid var(--surface1); gap: 0.5rem; }
.admin-campaign-stats dt { font-size: 0.8rem; color: var(--subtext1); }
.admin-campaign-stats dd { margin: 0; font-size: 1.5rem; font-weight: 700; }
.admin-empty { grid-column: 1 / -1; padding: 2rem; border: 1px dashed var(--field-border); border-radius: 0.75rem; color: var(--subtext1); text-align: center; }
.admin-danger { color: var(--danger); }
.admin-activity { list-style: none; margin: 0; padding: 0; }
.admin-activity li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1rem; padding: 1rem 0; border-bottom: 1px solid var(--surface1); overflow-wrap: anywhere; }
.admin-activity li:last-child { border-bottom: 0; }
.admin-dashboard .invite-main { min-width: 0; overflow-wrap: anywhere; }
.admin-dialog { width: min(36rem,calc(100vw - 2rem)); }
.admin-dialog > * + * { margin-top: 1rem; }
.admin-dialog input, .admin-dialog select { box-sizing: border-box; min-width: 0; width: 100%; }
@media(max-width: 48rem) { .admin-overview { grid-template-columns: repeat(2,minmax(0,1fr)); } .admin-campaign-grid { grid-template-columns: minmax(0,1fr); } }
@media(max-width: 30rem) { .admin-toolbar { grid-template-columns: minmax(0,1fr); } .admin-hero { padding: 1.25rem; } .admin-metric { padding: 1rem; } }
.admin-dashboard .btn { transition: border-color 0.2s ease; }
.admin-approval-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); align-items: start; gap: 1.5rem; }
@media(max-width:48rem) { .admin-approval-grid { grid-template-columns: minmax(0,1fr); } }
.confirm-details:empty { display: none; }
.confirm-details:not(:empty) { max-height: 35dvh; overflow-y: auto; overscroll-behavior: contain; padding: .5rem 1rem; border: 1px solid var(--surface1); border-radius: .5rem; font-size: .9rem; line-height: 1.5; }
