/* Fanflare base sheet: tokens, document, type, forms and shared components.
   Every page loads base.css and shell.css. Feature sheets live beside them.
   Breakpoints (CSS cannot read custom properties in media queries):
     mobile  < 768px   @media (max-width: 767.98px)
     tablet  768–1023  @media (min-width: 768px) and (max-width: 1023.98px)
     desktop ≥ 1024px  @media (min-width: 1024px) */

@font-face {
  font-family: "DM Sans";
  src: url("/dm.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/instrument.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/instrument-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  /* Colour. One token set for both themes: light-dark() picks the value for the
     element's color-scheme. <html data-theme="light|dark"> forces a theme; without it
     the page follows prefers-color-scheme. Tokens without light-dark() are fixed. */
  --ink: light-dark(#0a2540, #e6edf6);
  --ink-hover: light-dark(#254768, #c3d1e2);
  --muted: light-dark(#53667a, #9aabbf);
  --paper: light-dark(#fff, #0b1424);
  --surface: light-dark(#fff, #111c2f);
  --surface-sunken: light-dark(#f7f9fc, #0e1829);
  --surface-tint: light-dark(#f0f4fa, #1a263b);
  --surface-hover: light-dark(#f8faff, #18243a);
  --surface-raised: light-dark(#fff, #26354f);
  --surface-well: light-dark(#eef2f8, #17233a);
  --surface-well-hover: light-dark(#e9eef6, #1c2a44);
  --surface-glass: light-dark(#ffffffdb, #0b1424db);
  --surface-glass-strong: light-dark(#fffffff5, #0b1424f5);
  --ink-wash: light-dark(#0a25400f, #ffffff14);
  --line: light-dark(#e2e9f0, #1f2c42);
  --line-strong: light-dark(#c8d3df, #34455f);
  --field-line: light-dark(#bccad9, #42536e);
  --accent: light-dark(#5840db, #a597ff);
  --accent-hover: light-dark(#4733c2, #bcb2ff);
  --accent-ink: light-dark(#4f3bd6, #b2a6ff);
  --accent-soft: light-dark(#eef1fb, #231f4d);
  --accent-wash: light-dark(#f3f4ff, #1a1a3d);
  --accent-line: light-dark(#dedcff, #3a3478);
  --focus: light-dark(#7665de, #b2a6ff);
  --danger: light-dark(#a33448, #ff8fa3);
  --danger-soft: light-dark(#fceef1, #3a1520);
  --danger-line: light-dark(#e9c3cb, #6a2a3a);
  --success: light-dark(#1d7350, #6fd8a8);
  --success-soft: light-dark(#e9f6ef, #0f2c21);
  --spark: light-dark(#a44a00, #ffb36b);
  --spark-soft: light-dark(#fff1e2, #36230f);
  --spark-soft-hover: light-dark(#ffe6cc, #452d13);
  --spark-icon: light-dark(#f08a1c, #ff9a3c);
  --spark-glow: #ffbc78;
  --favorite: light-dark(#d23c74, #ff7aa8);
  --rarity-epic: light-dark(#764394, #d6a2f2);
  --rarity-legendary: light-dark(#936018, #e8b45a);
  --toast-success: light-dark(#7be0b0, #1d7350);
  --scrim: light-dark(#0a254066, #00000099);
  --scrim-strong: light-dark(#06172ae6, #000000e6);
  --backdrop: light-dark(#0a254052, #0000008c);
  /* Over artwork and on the always-dark viewer stage */
  --on-image: #fff;
  --on-image-accent: #c9bfff;
  --on-image-favorite: #ff8fb8;
  --image-scrim: #0a2540b8;
  --image-control: #ffffff2b;
  --stage: #06172a;
  --stage-media: #0d1d30;
  --stage-control: #ffffff1f;
  --stage-control-hover: #ffffff38;
  --stage-muted: #ffffffb3;
  --stage-track: #ffffff33;
  /* Brand surfaces keep white text in both themes */
  --on-brand: #fff;
  --brand-amount: #ffe2bf;
  --brand-glow: #5840db88;
  --gradient-brand: linear-gradient(120deg, #2a1d6b, #5840db 60%, #8b5cf6);
  --gradient-medal: radial-gradient(circle at 30% 22%, #ffffff59, transparent 42%),
    linear-gradient(140deg, #ac79fa, #5840db 55%, #2a1d6b);
  --gradient-hero: linear-gradient(
    125deg,
    light-dark(#84edee, #2b8792) 0%,
    light-dark(#81a1fa, #3d5fc0) 25%,
    light-dark(#ac79fa, #7146c0) 43%,
    light-dark(#ff9bd1, #ad4a8a) 63%,
    light-dark(#ffbc78, #b5703c) 80%,
    light-dark(#fff1b4, #9a8645)
  );
  --gradient-wash: linear-gradient(
    110deg,
    light-dark(#f6faff, #0f1a2e),
    light-dark(#faf7ff, #16163a) 70%,
    light-dark(#fff3eb, #271a22)
  );
  --gradient-soft: linear-gradient(
    110deg,
    light-dark(#f2f3fb70, #1a1a3d70),
    light-dark(#fff5f650, #2a1a2250)
  );
  --gradient-glow: radial-gradient(
    ellipse at 100% 0%,
    light-dark(#c7c2ff40, #6a5cff2e),
    transparent 50%
  );
  --gradient-avatar: linear-gradient(
    135deg,
    light-dark(#e4e2ff, #2c2860),
    light-dark(#e4f5fc, #173445)
  );
  --gradient-image-fade: linear-gradient(#0a254000, #0a2540d9);
  /* Covers: the frame before an image loads, its spine light and its shadows */
  --cover-blank: linear-gradient(
    140deg,
    light-dark(#dfe6f5, #1d2a42),
    light-dark(#c9d3ea, #27354f)
  );
  --cover-spine: linear-gradient(90deg, #ffffff30 0, #ffffff00 6%, #0000000d 7%, #00000000 10%);
  --cover-edge: light-dark(#0a25401a, #ffffff1a);
  --cover-glow: light-dark(#c7ccf1aa, #4a45a066);

  /* Type */
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-serif: "Instrument Serif", Georgia, serif;
  --weight-regular: 400;
  --weight-strong: 600;
  --text-2xs: 10px;
  --text-xs: 11px;
  --text-sm: 13px;
  --text-ui: 14px;
  --text-base: 16px;
  --text-md: 18px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: clamp(30px, 3.1vw, 42px);
  --text-3xl: clamp(39px, 5.2vw, 65px);
  --text-hero: clamp(46px, 5.1vw, 69px);
  --leading-tight: 1.12;
  --leading-snug: 1.4;
  --leading: 1.6;
  --tracking-display: -0.065em;
  --tracking-heading: -0.045em;
  --tracking-title: -0.025em;
  --tracking-label: 0.06em;

  /* Space (4px steps) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;
  --space-11: 80px;
  --space-12: 96px;
  --gutter: clamp(22px, 5vw, 64px);
  --page-max: 1240px;
  --prose-max: 720px;
  --tap: 44px;

  /* Radius */
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  /* Shadow */
  --shadow-xs: 0 2px 4px light-dark(#0a254005, #00000033);
  --shadow-sm: 0 3px 10px light-dark(#0a254008, #0000004d), 0 1px 2px light-dark(#0a254008, #00000033);
  --shadow-md: 0 12px 28px -12px light-dark(#183e6e38, #00000099), 0 2px 6px light-dark(#183e6e0d, #00000040);
  --shadow-lg: 0 25px 70px -25px light-dark(#183e6e50, #000000b3), 0 5px 12px light-dark(#183e6e09, #00000040);
  --shadow-focus: 0 0 0 3px light-dark(#7665de55, #b2a6ff55);
  --shadow-edge: light-dark(#0a254026, #00000080);
  --shadow-pill: 0 1px 4px light-dark(#0a254018, #00000066), 0 0 0 1px light-dark(#0a254008, #ffffff0f);
  --shadow-cover: 3px 4px 10px light-dark(#0a25401f, #00000066), 0 1px 2px light-dark(#0a254014, #00000040);
  --shadow-cover-lift: 6px 10px 22px light-dark(#0a254026, #00000080), 0 1px 2px light-dark(#0a254014, #00000040);
  --shadow-book: 8px 18px 30px -8px light-dark(#1d264742, #00000099);
  --shadow-figure: drop-shadow(0 14px 14px light-dark(#63518c16, #00000066));

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-in-out: cubic-bezier(0.6, 0, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.5, 1);
  --duration-fast: 120ms;
  --duration: 200ms;
  --duration-slow: 360ms;
  --duration-celebrate: 1600ms;

  /* Layers (dialogs, popovers and the toast region use the browser's top layer) */
  --z-raised: 1;
  --z-tile-meta: 2;
  --z-sticky: 20;
  --z-tabbar: 30;
  --z-menu: 40;
  --z-search-panel: 45;
  --z-tooltip: 50;

  /* Shell geometry */
  --header-height: 72px;
  --tabbar-height: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  color: var(--ink);
  background: var(--paper);
  font: var(--weight-regular) var(--text-base) / var(--leading) var(--font-sans);
  color-scheme: light dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
:root[data-theme="light"] {
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
}
@media (max-width: 767.98px) {
  :root {
    --header-height: 60px;
  }
}
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration: 0ms;
    --duration-slow: 0ms;
    --duration-celebrate: 0ms;
  }
}

/* Document */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + var(--space-6));
}
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}
body::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 720px;
  z-index: -1;
  pointer-events: none;
  background: var(--gradient-glow);
}
img,
svg {
  max-width: 100%;
}
img {
  height: auto;
}
svg {
  flex-shrink: 0;
}
[hidden] {
  display: none !important;
}
html:has(dialog:modal) {
  overflow: hidden;
}

/* Type */
h1,
h2,
h3,
h4 {
  font-weight: var(--weight-strong);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-heading);
  margin: 0;
  text-wrap: balance;
}
h1 {
  font-size: var(--text-3xl);
}
h2 {
  font-size: var(--text-2xl);
}
h3 {
  font-size: var(--text-xl);
}
h4 {
  font-size: var(--text-md);
  letter-spacing: var(--tracking-title);
}
p {
  margin-block: var(--space-4);
}
a {
  color: inherit;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  transition: color var(--duration-fast);
}
a:hover {
  color: var(--accent);
}
strong,
b {
  font-weight: var(--weight-strong);
}
.eyebrow {
  display: block;
  color: var(--accent);
  font-weight: var(--weight-strong);
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-label);
  margin-bottom: var(--space-4);
}
.muted,
small,
.back {
  color: var(--muted);
}
small {
  font-size: var(--text-sm);
}
.serif {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: 0;
}
code {
  overflow-wrap: anywhere;
  font-size: 0.9em;
  background: var(--surface-tint);
  padding: 2px 5px;
  border-radius: var(--radius-xs);
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: var(--text-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
}
blockquote {
  margin: var(--space-7) 0;
  padding-left: var(--space-6);
  border-left: 2px solid var(--accent);
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
}
blockquote cite {
  display: block;
  font: var(--text-sm) var(--font-sans);
  color: var(--muted);
  font-style: normal;
}
figure {
  margin: 0;
}
.preview {
  display: block;
  max-width: 100%;
  max-height: 66vh;
  margin-inline: auto;
  object-fit: contain;
  border-radius: var(--radius);
}
figcaption {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--space-2);
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--space-6) 0;
}
dl {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: var(--space-2) var(--space-6);
  font-size: var(--text-ui);
}
dt {
  color: var(--muted);
}
dd {
  margin: 0;
  overflow-wrap: anywhere;
}
ul,
ol {
  padding-left: 1.3em;
}
li {
  margin-block: var(--space-2);
}

/* Layout */
.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
  border-inline: 1px solid var(--line);
  min-height: 65vh;
}
.narrow {
  max-width: var(--prose-max);
  margin-inline: auto;
  padding-bottom: var(--space-9);
}
.narrow.tight {
  max-width: 480px;
}
.stack {
  display: grid;
  gap: var(--space-5);
}
.stack > button,
.stack > .btn {
  justify-self: start;
}
.cluster,
.actions {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
  align-items: center;
}
.grow {
  flex: 1;
  min-width: 0;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}
.section {
  padding-block: var(--space-9) var(--space-7);
}
.section + .section {
  border-top: 1px solid var(--line);
}
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-7);
  margin-bottom: var(--space-7);
}
.section-head .eyebrow {
  margin-bottom: var(--space-3);
}
.section-head p {
  font-size: var(--text-ui);
  margin: var(--space-3) 0 0;
  max-width: 52ch;
  color: var(--muted);
}
.heading {
  padding: var(--space-10) 0 var(--space-7);
}
.heading p {
  max-width: 52ch;
  color: var(--muted);
  font-size: 17px;
  margin-bottom: 0;
}
.heading .back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  margin: calc(-1 * var(--space-3)) 0 var(--space-3);
  font-size: var(--text-sm);
  text-decoration: none;
}
.heading .actions {
  margin-top: var(--space-6);
  font-size: var(--text-sm);
}
.prose {
  max-width: 65ch;
}
.prose h2 {
  margin-top: var(--space-8);
  font-size: 29px;
}
.prose li {
  margin: var(--space-3) 0;
}

/* Forms */
label {
  display: grid;
  gap: 6px;
  font-size: var(--text-ui);
}
label.check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap);
}
input,
textarea,
select {
  background: var(--surface);
  border: 1px solid var(--field-line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: max(16px, 1em);
  color: inherit;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
  min-height: var(--tap);
  transition:
    border-color var(--duration-fast),
    box-shadow var(--duration-fast);
}
input:hover,
textarea:hover,
select:hover {
  border-color: var(--muted);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}
textarea {
  min-height: 110px;
  resize: vertical;
}
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  accent-color: var(--accent);
  margin: 0;
}
input[type="file"] {
  padding: 8px;
  background: var(--surface-sunken);
  border-style: dashed;
}
input[type="file"]::file-selector-button {
  font: var(--weight-strong) var(--text-sm) var(--font-sans);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  margin-right: var(--space-3);
  cursor: pointer;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
  margin: 0;
  padding: var(--space-4);
}
legend {
  font-size: var(--text-ui);
  font-weight: var(--weight-strong);
  padding-inline: var(--space-1);
}
.field-hint {
  font-size: var(--text-sm);
  color: var(--muted);
}
.notice {
  color: var(--danger);
}

/* Buttons: <button> and .btn share one look. Variants: .secondary .accent .quiet; size: .small */
.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: 10px 18px;
  min-height: var(--tap);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font: var(--weight-strong) var(--text-ui) / 1.5 var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background var(--duration) var(--ease-out),
    border-color var(--duration) var(--ease-out),
    color var(--duration) var(--ease-out),
    transform var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out);
}
.btn:hover,
button:hover {
  background: var(--ink-hover);
  border-color: var(--ink-hover);
  color: var(--paper);
  transform: translateY(-1px);
}
.btn:active,
button:active {
  transform: translateY(0) scale(0.98);
}
.btn.secondary,
button.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn.secondary:hover,
button.secondary:hover {
  background: var(--surface-hover);
  border-color: var(--muted);
  color: var(--ink);
}
.btn.accent,
button.accent {
  background: var(--accent);
  border-color: var(--accent);
}
.btn.accent:hover,
button.accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn.quiet,
button.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink);
}
.btn.quiet:hover,
button.quiet:hover {
  background: var(--accent-soft);
  color: var(--ink);
}
.btn.small,
button.small {
  min-height: 36px;
  padding: 6px 13px;
  font-size: var(--text-sm);
  gap: var(--space-2);
}
.btn:disabled,
button:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  position: relative;
  width: var(--tap);
  height: var(--tap);
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--duration-fast),
    color var(--duration-fast),
    transform var(--duration) var(--ease-out);
}
.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  transform: none;
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn svg {
  width: 22px;
  height: 22px;
}
/* Instant tooltip: <Tooltip text> wraps a control; shown below it on hover and keyboard
   focus with no delay. /js/tooltip.js dismisses it with Escape. */
.has-tooltip {
  position: relative;
  display: inline-flex;
}
.tooltip {
  position: absolute;
  z-index: var(--z-tooltip);
  top: calc(100% + var(--space-2));
  left: 50%;
  width: max-content;
  max-width: 260px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font: var(--weight-strong) var(--text-sm) / var(--leading-snug) var(--font-sans);
  letter-spacing: normal;
  text-align: left;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  translate: -50% 0;
  visibility: hidden;
  opacity: 0;
}
/* Arrow, and a bridge over the gap so the pointer can move onto the tooltip */
.tooltip::before {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--space-2)) 0 100%;
}
.tooltip::after {
  content: "";
  position: absolute;
  top: -4px;
  left: calc(50% - 4px);
  width: 8px;
  height: 8px;
  background: inherit;
  rotate: 45deg;
}
.tooltip.end {
  left: auto;
  right: 0;
  translate: none;
}
.tooltip.end::after {
  left: auto;
  right: calc(var(--tap) / 2 - 4px);
}
@media (hover: hover) and (pointer: fine) {
  .has-tooltip:hover > .tooltip {
    visibility: visible;
    opacity: 1;
  }
}
.has-tooltip:has(:focus-visible) > .tooltip {
  visibility: visible;
  opacity: 1;
}
.has-tooltip.tooltip-dismissed > .tooltip {
  visibility: hidden;
  opacity: 0;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  font-size: var(--text-ui);
  font-weight: var(--weight-strong);
  text-decoration: none;
}
.text-link.accent {
  color: var(--accent);
}

/* Chips (interactive, pill) and tags (static metadata) */
.chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
  list-style: none;
}
.chips > li {
  margin: 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  font: var(--weight-regular) var(--text-sm) / 1.4 var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background var(--duration-fast),
    border-color var(--duration-fast),
    color var(--duration-fast);
}
/* A secondary part of a chip label, such as the book after a character. */
.chip-book {
  color: var(--muted);
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface);
  transform: none;
}
.chip[aria-pressed="true"],
.chip[aria-current] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: var(--weight-strong);
}
.chip svg {
  width: 15px;
  height: 15px;
}
.chip .count {
  color: var(--muted);
  font-size: var(--text-xs);
}
@media (pointer: coarse) {
  .chip {
    min-height: var(--tap);
  }
}
.tag {
  display: inline-block;
  background: var(--surface-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.5;
}
.tag.accent {
  background: var(--accent-wash);
  border-color: var(--accent-line);
  color: var(--accent);
}
.chiplist {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Segmented control: links or radios. The sliding pill is enabled by /js/segmented.js. */
.segmented {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 4px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-well);
  isolation: isolate;
}
.segmented > legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.segmented a,
.segmented label {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 6px 16px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--duration) var(--ease-out);
}
.segmented label input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented a:hover,
.segmented label:hover {
  color: var(--ink);
}
.segmented a[aria-current],
.segmented label:has(:checked) {
  color: var(--ink);
  background: var(--surface-raised);
  box-shadow: var(--shadow-pill);
}
.segmented label:has(:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.segmented svg {
  width: 16px;
  height: 16px;
}
.segmented.is-sliding::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: var(--seg-w, 0);
  transform: translateX(var(--seg-x, 0));
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-pill);
  transition:
    transform var(--duration-slow) var(--ease-spring),
    width var(--duration-slow) var(--ease-spring);
}
.segmented.is-sliding a[aria-current],
.segmented.is-sliding label:has(:checked) {
  background: transparent;
  box-shadow: none;
}
@media (any-pointer: coarse) {
  .btn.small,
  button.small,
  a.chip,
  button.chip,
  .segmented a,
  .segmented label {
    min-height: var(--tap);
    min-width: var(--tap);
  }
}

/* Cards and panels */
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
  color: inherit;
  text-decoration: none;
}
a.card {
  transition:
    border-color var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out),
    transform var(--duration) var(--ease-out);
}
a.card:hover {
  color: inherit;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card > :first-child {
  margin-top: 0;
}
.card > :last-child {
  margin-bottom: 0;
}
.card.flush {
  padding: 0;
  overflow: hidden;
}
.panel {
  border: 1px solid var(--line);
  background: var(--surface-sunken);
  padding: var(--space-6);
  border-radius: var(--radius);
  margin: var(--space-5) 0;
}
.panel > :first-child {
  margin-top: 0;
}
.panel > :last-child {
  margin-bottom: 0;
}

/* Cover: always 2:3, lazy, sized by width */
.cover {
  --cover-width: 120px;
  position: relative;
  display: block;
  flex-shrink: 0;
  width: var(--cover-width);
  aspect-ratio: 2 / 3;
  border-radius: 2px 5px 5px 2px;
  overflow: hidden;
  background: var(--cover-blank);
  box-shadow: var(--shadow-cover);
}
.cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: var(--cover-spine);
  box-shadow: inset 0 0 0 1px var(--cover-edge);
}
.cover.xs {
  --cover-width: 40px;
}
.cover.sm {
  --cover-width: 64px;
}
.cover.lg {
  --cover-width: 200px;
}
.cover.xl {
  --cover-width: 260px;
}
a.cover {
  transition:
    transform var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out);
}
a.cover:hover {
  transform: translateY(-3px) rotate(-0.6deg);
  box-shadow: var(--shadow-cover-lift);
}

/* Avatar: image from /avatars/:handle.svg or a neutral glyph */
.avatar {
  --avatar-size: 36px;
  display: inline-grid;
  place-items: center;
  width: var(--avatar-size);
  height: var(--avatar-size);
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--gradient-avatar);
  color: var(--accent);
  font-size: calc(var(--avatar-size) * 0.4);
  font-weight: var(--weight-strong);
  line-height: 1;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar svg {
  width: 62%;
  height: 62%;
}
.avatar.xs {
  --avatar-size: 22px;
}
.avatar.sm {
  --avatar-size: 28px;
}
.avatar.lg {
  --avatar-size: 64px;
}
.avatar.xl {
  --avatar-size: 128px;
}

/* Empty and error states */
.empty {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  border: 1px dashed var(--line-strong);
  background: var(--surface-sunken);
  padding: var(--space-10) var(--space-7);
  border-radius: var(--radius-md);
  margin: var(--space-5) 0;
  text-align: center;
}
.empty-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: var(--space-2);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.empty-mark svg {
  width: 26px;
  height: 26px;
}
.empty h2,
.empty h3 {
  font-size: var(--text-xl);
}
.empty p {
  max-width: 46ch;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-ui);
}
.empty .actions {
  justify-content: center;
  margin-top: var(--space-3);
}
.empty.error {
  border-color: var(--danger-line);
  background: var(--danger-soft);
}
.empty.error .empty-mark {
  color: var(--danger);
}

/* Focus, skip link, utilities */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.skip {
  position: absolute;
  left: -9999px;
  top: var(--space-2);
  z-index: var(--z-menu);
}
.skip:focus {
  left: var(--space-2);
  background: var(--surface);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.mobile-only {
  display: none;
}
@media (max-width: 767.98px) {
  .desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: revert;
  }
  .heading {
    padding-top: var(--space-7);
  }
  .heading h1 {
    font-size: 40px;
    overflow-wrap: anywhere;
  }
  .heading p {
    font-size: 15px;
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
  .section-head {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-5);
  }
  .empty {
    padding: var(--space-8) var(--space-5);
  }
  dl {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  dd + dt {
    margin-top: var(--space-3);
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
