/* ===== Tokens ===== */
/* data-theme controls light/dark; data-ui-theme controls classic/warm.
   Shared layout rules stay unscoped. :where() keeps theme variants at the
   original specificity, including component styles injected by Quick Build. */
:root:where(:not([data-ui-theme="warm"])),
html:where(:not([data-ui-theme="warm"]))[data-theme="light"] {
  color-scheme: light;
  --app-max-width: 720px;
  --app-gutter: 0.875rem;
  --app-header-offset: 5.1rem;

  --bg: #eef3ff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(243, 247, 255, 0.9);
  --surface-muted: #eef2f7;

  --text: #16213d;
  --text-body: #33415d;
  --text-muted: #62728e;
  --detail-text: #33415d;
  --class-tagline: #6f3f1e;
  --accent: #2852d6;
  --accent-strong: #2147b2;
  --accent-soft: rgba(40, 82, 214, 0.12);

  --page-background:
    radial-gradient(circle at top left, rgba(83, 106, 176, 0.18), transparent 31%),
    radial-gradient(circle at top right, rgba(55, 145, 179, 0.1), transparent 24%),
    linear-gradient(180deg, #eef3ff 0%, #e8eef8 44%, #eef2f8 100%);
  --nav-surface: rgba(241, 246, 255, 0.86);
  --nav-hover: rgba(255, 255, 255, 0.74);
  --input-bg: #fff;
  --control-bg: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
  --control-hover-bg: linear-gradient(180deg, #ffffff 0%, #e9f0ff 100%);
  --accent-gradient: linear-gradient(180deg, var(--accent-strong) 0%, #2962e8 100%);
  --on-accent: #fff;
  --focus-ring: rgba(36, 93, 255, 0.24);
  --overlay: rgba(13, 25, 52, 0.52);
  --overlay-strong: rgba(8, 18, 40, 0.72);
  --z-backdrop: 12500;
  --z-dialog: 12600;
  --z-toast: 12900;
  --scrollbar-track: rgba(114, 133, 176, 0.1);
  --scrollbar-thumb: rgba(76, 104, 168, 0.5);
  --scrollbar-thumb-hover: rgba(40, 82, 214, 0.68);
  --disabled-bg: #eef3fb;
  --disabled-text: #667085;
  --danger: #9b2929;
  --danger-border: #e7aaaa;
  --danger-soft: #fff2f2;
  --warning: #7a4b00;
  --warning-border: #f3c76e;
  --warning-soft: #fff6d9;
  --success: #17643a;
  --success-soft: #e9f8ef;

  --border: rgba(114, 133, 176, 0.24);
  --border-strong: rgba(76, 104, 168, 0.32);
  --shadow-soft: 0 14px 30px rgba(18, 33, 68, 0.09);
  --shadow-strong: 0 18px 44px rgba(17, 31, 63, 0.12);
  --context-popup-bg: #111827;
  --context-popup-text: #f8fafc;
  --context-popup-muted: #cbd5e1;
  --context-popup-border: rgba(255, 255, 255, 0.2);
  --context-popup-shadow: 0 18px 44px rgba(17, 31, 63, 0.3);

  --radius-lg: 1.35rem;
  --radius-md: 1rem;
  --radius-sm: 0.8rem;
  --glass: blur(16px) saturate(145%);

  --fs-xs: 0.78rem;
  --fs-sm: 0.86rem;
  --fs-md: 0.93rem;
  --fs-base: 1rem;
  --fs-lg: 1.06rem;
  --fs-xl: 1.14rem;
  --fs-2xl: 1.42rem;
  --fs-3xl: 1.95rem;

  /* Backward-compatible aliases for existing component rules */
  --panel: var(--surface);
  --panel-soft: var(--surface-soft);
  --panel-muted: var(--surface-muted);
  --muted: var(--text-muted);
  --app-body: var(--text-body);
  --app-title: var(--text);
  --app-muted: var(--text-muted);
  --app-accent: var(--accent);

  --qb-overlay: rgba(13, 25, 52, 0.64);
  --qb-overlay-nested: rgba(8, 18, 40, 0.78);
  --qb-surface: var(--surface-strong);
  --qb-surface-elevated: #fff;
  --qb-surface-soft: #f4f7fd;
  --qb-surface-muted: #eaf0fa;
  --qb-text: var(--text);
  --qb-text-body: var(--detail-text);
  --qb-text-muted: var(--text-muted);
  --qb-border: var(--border-strong);
  --qb-border-strong: #8fa3ca;
  --qb-accent: #1677a6;
  --qb-accent-hover: #0f628d;
  --qb-accent-soft: #e4f6fd;
  --qb-accent-text: #075b84;
  --qb-input: #fff;
  --qb-disabled: #e7edf6;
  --qb-disabled-text: #7a879d;
  --qb-warning-bg: #fff6d9;
  --qb-warning-text: #704600;
  --qb-warning-border: #d99300;
  --qb-pending-bg: #eef0ff;
  --qb-pending-text: #373a82;
  --qb-success-bg: #e7f7ee;
  --qb-success-text: #17643a;
  --qb-success-border: #22a45a;
  --qb-danger: #b4232c;
  --qb-danger-text: #9f2430;
  --qb-shadow: 0 24px 70px rgba(17, 31, 63, 0.24);
}/* ===== Tokens ===== */
:root:where([data-ui-theme="warm"]),
html:where([data-ui-theme="warm"])[data-theme="light"] {
  color-scheme: light;
  --app-max-width: 720px;
  --app-gutter: 0.875rem;
  --app-header-offset: 5.1rem;

  --bg: #FAF5E9;
  --surface: #F3E7CF;
  --surface-strong: #FFF9EF;
  --surface-soft: #F5ECDC;
  --surface-muted: #EDE2D0;

  --text: #191919;
  --text-body: #3D3027;
  --text-muted: #71604F;
  --detail-text: var(--text-body);
  --class-tagline: #6E4932;
  --accent: #A82F28;
  --accent-strong: #8E2923;
  --accent-soft: #EFD2BF;

  /* Only the page canvas receives texture; all component surfaces stay solid. */
  --page-background:
    linear-gradient(rgba(254, 249, 237, 0.94), rgba(254, 249, 237, 0.94)),
    url("paper002-color-512.webp") 0 0 / 512px 512px repeat var(--bg);
  --nav-surface: var(--surface);
  --nav-border: var(--ink);
  --nav-bottom-border: #80644D;
  --nav-hover: var(--surface-soft);
  --input-bg: #FFF9EF;
  --control-bg: var(--surface-strong);
  --control-hover-bg: var(--surface-soft);
  /* Legacy paint alias: intentionally a solid fill. */
  --accent-gradient: var(--action-fill);
  --on-accent: #FFF3DE;
  --focus-ring: #8E2923;
  --overlay: rgba(30,23,17,.58);
  --overlay-strong: rgba(30,23,17,.78);
  --z-backdrop: 12500;
  --z-dialog: 12600;
  --z-toast: 12900;
  --scrollbar-track: var(--surface-soft);
  --scrollbar-thumb: #9B8268;
  --scrollbar-thumb-hover: #6E4932;
  --disabled-bg: #E6DCC9;
  --disabled-text: #786C5D;
  --danger: #9F2924;
  --danger-border: #B56552;
  --danger-soft: #F2DCD0;
  --warning: #76500E;
  --warning-border: #AF8842;
  --warning-soft: #F1E2BA;
  --success: #3E6242;
  --success-soft: #E1E6CC;

  --border: #CBB38F;
  --border-strong: #80644D;
  --shadow-soft: 2px 2px 0 var(--shadow-ink);
  --shadow-strong: 4px 4px 0 var(--shadow-ink);
  --context-popup-bg: var(--surface-strong);
  --context-popup-text: var(--text);
  --context-popup-muted: var(--text-muted);
  --context-popup-border: var(--border-strong);
  --context-popup-shadow: var(--shadow-strong);

  --radius-lg: 6px;
  --radius-md: 4px;
  --radius-sm: 3px;
  --glass: none;

  --font-body: "IBM Plex Sans", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-heading: "Arial Black", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;

  --fs-xs: 0.78rem;
  --fs-sm: 0.86rem;
  --fs-md: 0.93rem;
  --fs-base: 1rem;
  --fs-lg: 1.06rem;
  --fs-xl: 1.14rem;
  --fs-2xl: 1.42rem;
  --fs-3xl: 1.95rem;

  /* Backward-compatible aliases for existing component rules */
  --panel: var(--surface);
  --panel-soft: var(--surface-soft);
  --panel-muted: var(--surface-muted);
  --muted: var(--text-muted);
  --app-body: var(--text-body);
  --app-title: var(--text);
  --app-muted: var(--text-muted);
  --app-accent: var(--accent);

  --qb-overlay: var(--overlay);
  --qb-overlay-nested: var(--overlay-strong);
  --qb-surface: var(--surface-strong);
  --qb-surface-elevated: var(--surface-strong);
  --qb-surface-soft: var(--surface-soft);
  --qb-surface-muted: var(--surface-muted);
  --qb-text: var(--text);
  --qb-text-body: var(--detail-text);
  --qb-text-muted: var(--text-muted);
  --qb-border: var(--border);
  --qb-border-strong: var(--border-strong);
  --qb-accent: var(--accent);
  --qb-accent-hover: var(--action-fill);
  --qb-accent-soft: var(--accent-soft);
  --qb-accent-text: var(--accent-strong);
  --qb-input: var(--input-bg);
  --qb-disabled: var(--disabled-bg);
  --qb-disabled-text: var(--disabled-text);
  --qb-warning-bg: var(--warning-soft);
  --qb-warning-text: var(--warning);
  --qb-warning-border: var(--warning-border);
  --qb-pending-bg: var(--surface-soft);
  --qb-pending-text: var(--text-muted);
  /* Completed character reviews use a quiet paper tone, not a green surface. */
  --qb-success-bg: #E8DDC8;
  --qb-success-text: #594331;
  --qb-success-border: #9A8060;
  --qb-danger: var(--danger);
  --qb-danger-text: var(--danger);
  --qb-shadow: var(--shadow-strong);
  --action-fill: #B9362E;
  --action-hover: #A22D26;
  --ink: #38281D;
  --shadow-ink: #6E4932;
  --shadow-control: 2px 2px 0 var(--shadow-ink);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09111f;
  --surface: rgba(17, 28, 47, 0.94);
  --surface-strong: #17243a;
  --surface-soft: #1b2b43;
  --surface-muted: #22334c;
  --text: #f1f7fd;
  --text-body: #d5e2ef;
  --text-muted: #97aac0;
  --detail-text: #edf4fa;
  --class-tagline: #f0c98f;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --page-background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.1), transparent 30%),
    radial-gradient(circle at top right, rgba(45, 212, 191, 0.06), transparent 24%),
    linear-gradient(180deg, #09111f 0%, #0c1627 46%, #0a1321 100%);
  --nav-surface: rgba(15, 27, 45, 0.92);
  --nav-hover: rgba(68, 89, 116, 0.38);
  --input-bg: #0f1b2d;
  --control-bg: linear-gradient(180deg, #1b2b43 0%, #15243a 100%);
  --control-hover-bg: linear-gradient(180deg, #243953 0%, #1a2d46 100%);
  --accent-gradient: linear-gradient(180deg, #0ea5e9 0%, #087eae 100%);
  --on-accent: #f8fcff;
  --border: rgba(148, 174, 205, 0.23);
  --border-strong: rgba(148, 190, 222, 0.38);
  --shadow-soft: 0 14px 30px rgba(0, 0, 0, 0.28);
  --shadow-strong: 0 20px 48px rgba(0, 0, 0, 0.42);
  --context-popup-bg: #f8fafc;
  --context-popup-text: #1e293b;
  --context-popup-muted: #52627a;
  --context-popup-border: rgba(148, 163, 184, 0.55);
  --context-popup-shadow: 0 20px 48px rgba(0, 0, 0, 0.46);
  --focus-ring: rgba(56, 189, 248, 0.4);
  --overlay: rgba(2, 7, 16, 0.7);
  --overlay-strong: rgba(2, 6, 15, 0.84);
  --disabled-bg: #172338;
  --disabled-text: #6f8298;
  --danger: #ff9ba5;
  --danger-border: #8e3d49;
  --danger-soft: #3a1d28;
  --warning: #ffd486;
  --warning-border: #9c6d18;
  --warning-soft: #382b15;
  --success: #86efac;
  --success-soft: #143425;
  --scrollbar-track: rgba(148, 174, 205, 0.08);
  --scrollbar-thumb: rgba(148, 190, 222, 0.46);
  --scrollbar-thumb-hover: rgba(56, 189, 248, 0.68);

  --qb-overlay: rgba(8, 12, 20, 0.76);
  --qb-overlay-nested: rgba(2, 6, 23, 0.82);
  --qb-surface: #111827;
  --qb-surface-elevated: #1e293b;
  --qb-surface-soft: #172033;
  --qb-surface-muted: #0f172a;
  --qb-text: #f8fafc;
  --qb-text-body: var(--detail-text);
  --qb-text-muted: #94a3b8;
  --qb-border: #475569;
  --qb-border-strong: #64748b;
  --qb-accent: #38bdf8;
  --qb-accent-hover: #075985;
  --qb-accent-soft: #243449;
  --qb-accent-text: #7dd3fc;
  --qb-input: #0f172a;
  --qb-disabled: #334155;
  --qb-disabled-text: #94a3b8;
  --qb-warning-bg: #422006;
  --qb-warning-text: #fef3c7;
  --qb-warning-border: #f59e0b;
  --qb-pending-bg: #312e81;
  --qb-pending-text: #e0e7ff;
  --qb-success-bg: #052e24;
  --qb-success-text: #d1fae5;
  --qb-success-border: #22c55e;
  --qb-danger: #b91c1c;
  --qb-danger-text: #fca5a5;
  --qb-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

html:where([data-ui-theme="warm"])[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141312;
  --surface: #211C18;
  --surface-strong: #211C18;
  --surface-soft: #181513;
  --surface-muted: #2C241E;
  --text: #E2D3BA;
  --text-body: #CCBDA5;
  --text-muted: #A99A86;
  --detail-text: var(--text-body);
  --class-tagline: #C3A17F;
  --accent: #D08F79;
  --accent-strong: #D9A08A;
  --accent-soft: #3D2721;
  --page-background: var(--bg);
  --nav-surface: var(--surface-strong);
  --nav-border: #8D7962;
  --nav-bottom-border: var(--nav-border);
  --nav-hover: var(--surface-soft);
  --input-bg: #181513;
  --control-bg: var(--surface-strong);
  --control-hover-bg: var(--surface-soft);
  /* Legacy paint alias: intentionally a solid fill. */
  --accent-gradient: var(--action-fill);
  --on-accent: #EBDCC4;
  --border: #584737;
  --border-strong: #79634F;
  --shadow-soft: 1px 1px 0 var(--shadow-ink);
  --shadow-strong: 3px 3px 0 var(--shadow-ink);
  --context-popup-bg: var(--surface-strong);
  --context-popup-text: var(--text);
  --context-popup-muted: var(--text-muted);
  --context-popup-border: var(--border-strong);
  --context-popup-shadow: var(--shadow-strong);
  --focus-ring: #C6A584;
  --overlay: rgba(20,17,14,.72);
  --overlay-strong: rgba(20,17,14,.86);
  --disabled-bg: #29241E;
  --disabled-text: #958673;
  --danger: #D39987;
  --danger-border: #8F5345;
  --danger-soft: #39231E;
  --warning: #CEB47C;
  --warning-border: #887142;
  --warning-soft: #332B1D;
  --success: #A9BB8E;
  --success-soft: #283024;
  --scrollbar-track: var(--surface-soft);
  --scrollbar-thumb: #766450;
  --scrollbar-thumb-hover: #A18A70;

  --qb-overlay: var(--overlay);
  --qb-overlay-nested: var(--overlay-strong);
  --qb-surface: var(--surface-strong);
  --qb-surface-elevated: var(--surface-strong);
  --qb-surface-soft: var(--surface-soft);
  --qb-surface-muted: var(--surface-muted);
  --qb-text: var(--text);
  --qb-text-body: var(--detail-text);
  --qb-text-muted: var(--text-muted);
  --qb-border: var(--border);
  --qb-border-strong: var(--border-strong);
  --qb-accent: var(--accent);
  --qb-accent-hover: var(--action-fill);
  --qb-accent-soft: var(--accent-soft);
  --qb-accent-text: var(--accent-strong);
  --qb-input: var(--input-bg);
  --qb-disabled: var(--disabled-bg);
  --qb-disabled-text: var(--disabled-text);
  --qb-warning-bg: var(--warning-soft);
  --qb-warning-text: var(--warning);
  --qb-warning-border: var(--warning-border);
  --qb-pending-bg: var(--surface-soft);
  --qb-pending-text: var(--text-muted);
  --qb-success-bg: #302820;
  --qb-success-text: #D3BE9E;
  --qb-success-border: #79634D;
  --qb-danger: var(--danger);
  --qb-danger-text: var(--danger);
  --qb-shadow: var(--shadow-strong);
  --action-fill: #8F302B;
  --action-hover: #9B3930;
  --ink: #A18A70;
  --shadow-ink: #100E0C;
  --shadow-control: 1px 1px 0 var(--shadow-ink);
}

/* ===== Base ===== */
* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background: var(--page-background);
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

* {
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: var(--scrollbar-thumb);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

@media (forced-colors: active) {
  html,
  * {
    scrollbar-color: auto;
  }
}

:where(html:not([data-ui-theme="warm"])) body {
  width: 100%;
  max-width: var(--app-max-width);
  margin: 0 auto;
  overflow-x: hidden;
  padding: calc(var(--app-header-offset) + env(safe-area-inset-top, 0px)) var(--app-gutter) calc(2rem + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-body);
}

:where(html[data-ui-theme="warm"]) body {
  width: 100%;
  max-width: var(--app-max-width);
  margin: 0 auto;
  overflow-x: hidden;
  padding: calc(var(--app-header-offset) + env(safe-area-inset-top, 0px)) var(--app-gutter) calc(2rem + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-body);
}

#main-content {
  display: grid;
  gap: 0.9rem;
}

/* Grid items default to an intrinsic minimum width, which can push a mobile
   layout wider than its viewport when they contain long labels or controls. */
#main-content > *,
.selection-summary-list > *,
.form-grid-2col > *,
.form-grid-3col > *,
.form-grid-6col > *,
.language-section > *,
.language-base-grid > *,
.language-field > *,
.language-extra-container > *,
.language-extra-container > div > *,
.language-extra-row > *,
.tool-section > *,
.tool-proficiency-list > *,
.tool-proficiency-row > *,
.tool-proficiency-control > *,
.hp-title > *,
.basic-overview > *,
.basic-row > *,
.basic-pair-card > *,
.basic-metric-values > *,
.ability-grid > *,
.save-grid > *,
.skill-grid > *,
.save-pair > *,
.skill-control-row > *,
.condition-display-grid > *,
.action-grid-pretty > *,
#tab-equipment .form-row.small-text > *,
.money-grid > *,
.money-cell > *,
.money-action-stack > *,
#tab-actions .form-row.small-text > *,
.spell-picked-grid > *,
.magic-initiate-controls > *,
.spell-row-top > *,
.spell-slot-grid > *,
.spell-casting-stats > *,
.spell-casting-field > *,
.utility-menu__grid > *,
.ability-choice-actions > *,
.point-buy-table-head > *,
.point-buy-row > *,
.point-buy-rows > *,
.pdf-export-flow-modal__card > * {
  min-width: 0;
}

button,
[role="button"] {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button,
a,
input,
select,
summary,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

.site-header {
  position: relative;
  z-index: 20;
}

:where(html[data-ui-theme="warm"]) a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

label {
  width: 100%;
  margin-bottom: 0.45rem;
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--text);
}

.small-text,
.skill-action-hint,
.site-footer,
.site-hero p,
.quo-text {
  color: var(--text-muted);
}

.small-text {
  font-size: var(--fs-sm);
  line-height: 1.55;
}

.is-hidden {
  display: none;
}

.summary-title-inline {
  display: inline;
  margin: 0;
}

:where(html[data-ui-theme="warm"]) h1,
:where(html[data-ui-theme="warm"]) h2,
:where(html[data-ui-theme="warm"]) h3,
:where(html[data-ui-theme="warm"]) .section-heading {
  font-family: var(--font-heading);
  font-weight: 900;
  line-height: 1.35;
}

:where(html[data-ui-theme="warm"]) input,
:where(html[data-ui-theme="warm"]) select,
:where(html[data-ui-theme="warm"]) textarea,
:where(html[data-ui-theme="warm"]) button {
  font-family: var(--font-body);
}

:where(html[data-ui-theme="warm"]) input[type="number"],
:where(html[data-ui-theme="warm"]) .ability-score,
:where(html[data-ui-theme="warm"]) .tabletop-key-stat dd {
  font-variant-numeric: tabular-nums;
}

:where(html[data-ui-theme="warm"]) select:disabled,
:where(html[data-ui-theme="warm"]) input:disabled,
:where(html[data-ui-theme="warm"]) textarea:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  opacity: 1;
}

/* ===== Navigation ===== */
:where(html:not([data-ui-theme="warm"])) .tabs-shell {
  position: fixed;
  top: max(0.55rem, env(safe-area-inset-top, 0px));
  right: 0;
  left: 0;
  z-index: 1000;
  width: min(var(--app-max-width), calc(100vw - 1rem));
  max-width: calc(100% - 1rem);
  margin-right: auto;
  margin-left: auto;
  padding: 0.32rem;
  border: 1px solid var(--border);
  border-radius: 1.35rem;
  background: var(--nav-surface);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow: 0 14px 34px rgba(17, 31, 63, 0.11), inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

/* ===== Navigation ===== */
:where(html[data-ui-theme="warm"]) .tabs-shell {
  position: fixed;
  top: max(0.55rem, env(safe-area-inset-top, 0px));
  right: 0;
  left: 0;
  z-index: 1000;
  width: min(var(--app-max-width), calc(100vw - 1rem));
  max-width: calc(100% - 1rem);
  margin-right: auto;
  margin-left: auto;
  padding: 0.32rem;
  border: 2px solid var(--nav-border);
  border-bottom-color: var(--nav-bottom-border);
  border-radius: var(--radius-lg);
  background: var(--nav-surface);
  box-shadow: 2px 2px 0 color-mix(in srgb, var(--shadow-ink) 65%, var(--nav-surface));
}

.tabs-row {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
}

html[data-view-mode="tabletop"] .tabs-shell {
  right: max(0.5rem, env(safe-area-inset-right, 0px), calc((100vw - var(--app-max-width)) / 2 + 0.5rem));
  left: auto;
  width: max-content;
}

html[data-view-mode="tabletop"] {
  --app-header-offset: 0.75rem;
}

html[data-view-mode="tabletop"] #sheet-tabs-row {
  justify-content: flex-end;
}

html[data-view-mode="tabletop"] #sheet-tabs-row .tabs {
  display: none;
}

html[data-view-mode="tabletop"] .utility-menu {
  width: min(22rem, calc(100vw - 1rem));
}

.tabs {
  display: flex;
  flex: 1 1 auto;
  align-items: stretch;
  gap: 0.35rem;
  width: auto;
  min-width: 0;
  margin: 0;
}

:where(html:not([data-ui-theme="warm"])) .tab-button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 2.7rem;
  padding: 0.7rem 0.3rem;
  border: 0;
  border-radius: 1.1rem;
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 800;
  letter-spacing: 0.01em;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.18s ease, box-shadow 0.2s ease;
}

:where(html[data-ui-theme="warm"]) .tab-button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 2.7rem;
  padding: 0.7rem 0.3rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 800;
  letter-spacing: 0.01em;
  text-align: center;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

:where(html:not([data-ui-theme="warm"])) .tab-button:hover:not(.active) {
  background: var(--nav-hover);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(145, 165, 205, 0.18);
}

:where(html[data-ui-theme="warm"]) .tab-button:hover:not(.active) {
  background: var(--nav-hover);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: none;
}

:where(html:not([data-ui-theme="warm"])) .tab-button.active {
  background: var(--accent-gradient);
  color: var(--on-accent);
  box-shadow: 0 7px 16px rgba(31, 100, 255, 0.3);
}

:where(html[data-ui-theme="warm"]) .tab-button.active {
  background: var(--action-fill);
  color: var(--on-accent);
  box-shadow: inset 0 0 0 1px var(--ink), var(--shadow-control);
}

:where(html:not([data-ui-theme="warm"])) .utility-menu-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 1.1rem;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 800;
  white-space: nowrap;
  box-shadow: none;
}

:where(html[data-ui-theme="warm"]) .utility-menu-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 800;
  white-space: nowrap;
  box-shadow: none;
}

.utility-menu-toggle__icon {
  display: grid;
  gap: 4px;
  width: 20px;
}

:where(html:not([data-ui-theme="warm"])) .utility-menu-toggle__icon span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

:where(html[data-ui-theme="warm"]) .utility-menu-toggle__icon span {
  display: block;
  height: 2px;
  border-radius: var(--radius-sm);
  background: currentColor;
}

:where(html:not([data-ui-theme="warm"])) .utility-menu-toggle:hover {
  background: var(--nav-hover);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(145, 165, 205, 0.18);
}

:where(html[data-ui-theme="warm"]) .utility-menu-toggle:hover {
  background: var(--nav-hover);
  color: var(--text);
  box-shadow: none;
}

:where(html:not([data-ui-theme="warm"])) .tabs-shell.utility-menu-open .utility-menu-toggle {
  border-color: rgba(40, 82, 214, 0.2);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(40, 82, 214, 0.08);
}

:where(html[data-ui-theme="warm"]) .tabs-shell.utility-menu-open .utility-menu-toggle {
  border-color: var(--border);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: none;
}

.utility-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: -1px;
  z-index: 4;
  width: min(22rem, calc(100% + 2px));
  max-height: max(0px, calc(100vh - var(--utility-menu-top, 5.1rem) - max(0.75rem, env(safe-area-inset-bottom, 0px))));
  max-height: max(0px, calc(100dvh - var(--utility-menu-top, 5.1rem) - max(0.75rem, env(safe-area-inset-bottom, 0px))));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.55rem) scaleY(0.96);
  transform-origin: top;
  pointer-events: none;
  transition: opacity 160ms ease, transform 190ms cubic-bezier(0.22, 1, 0.36, 1), visibility 190ms;
}

.utility-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scaleY(1);
  pointer-events: auto;
}

.utility-menu__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.55rem;
}

.utility-menu__row {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
}

.utility-menu__row--split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.utility-menu__row--footer {
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
}

.utility-menu__settings {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.utility-menu__settings-row {
  display: grid;
  gap: 0.12rem;
}

.utility-menu__settings-divider {
  display: none;
}

.utility-menu__settings-row .utility-menu__setting {
  width: 100%;
  margin: 0;
  gap: 0.75rem;
  font-size: var(--fs-base);
  white-space: nowrap;
}

.utility-menu__settings-row .utility-menu__switch {
  flex-basis: 2.5rem;
  width: 2.5rem;
}

.utility-menu__settings legend,
.utility-menu__section-title {
  margin-bottom: 0.4rem;
  padding: 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.utility-menu__section-title {
  margin-top: 0;
}

.utility-menu__divider {
  height: 1px;
  margin: 0.65rem 0;
  background: var(--border);
}

.utility-menu__setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.5rem;
  color: var(--text-body);
  font-size: var(--fs-base);
  font-weight: 700;
  cursor: pointer;
}

.utility-menu__setting input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.utility-menu__settings-row .utility-menu__theme-setting {
  gap: 0.5rem;
  cursor: default;
}

#theme-toggle-label {
  flex: 1 1 auto;
  margin: 0;
  cursor: pointer;
}

#theme-current-label {
  display: block;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 400;
}

.utility-menu__theme-setting #color-mode-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--control-bg);
  box-shadow: none;
  font-size: 1.35rem;
  cursor: pointer;
}

.utility-menu__theme-setting #color-mode-toggle:hover {
  background: var(--control-hover-bg);
}

.utility-menu__theme-setting #color-mode-toggle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.utility-menu__theme-switch {
  display: flex;
  align-items: center;
  flex: 0 0 2.5rem;
  width: 2.5rem;
  min-height: 44px;
  margin: 0;
  cursor: pointer;
}

html[data-ui-theme="warm"] .legal-modal-logo-classic,
html:not([data-ui-theme="warm"]) .legal-modal-logo-warm {
  display: none;
}

.utility-menu__switch {
  position: relative;
  flex: 0 0 2.5rem;
  width: 2.5rem;
  height: 1.4rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-muted);
  transition: border-color 160ms ease, background 160ms ease;
}

:where(html:not([data-ui-theme="warm"])) .utility-menu__switch::after {
  content: "";
  position: absolute;
  top: 0.16rem;
  left: 0.16rem;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--surface-strong);
  box-shadow: 0 1px 4px rgba(17, 31, 63, 0.25);
  transition: transform 160ms ease;
}

:where(html[data-ui-theme="warm"]) .utility-menu__switch::after {
  content: "";
  position: absolute;
  top: 0.16rem;
  left: 0.16rem;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease;
}

:where(html:not([data-ui-theme="warm"])) .utility-menu__setting input:checked + .utility-menu__switch {
  border-color: var(--accent);
  background: var(--accent);
}

:where(html[data-ui-theme="warm"]) .utility-menu__setting input:checked + .utility-menu__switch {
  border-color: var(--accent);
  background: var(--action-fill);
}

.utility-menu__setting input:checked + .utility-menu__switch::after {
  transform: translateX(1.08rem);
}

.utility-menu__setting input:focus-visible + .utility-menu__switch {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.utility-menu__mode-row {
  align-items: stretch;
}

.utility-menu__mode-button {
  display: flex;
  align-items: center;
  gap: 0;
  justify-content: center;
  text-align: center;
}

.utility-menu__mode-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

:where(html:not([data-ui-theme="warm"])) .utility-menu__button {
  width: 100%;
  min-height: 3rem;
  border-color: var(--border);
  background: linear-gradient(180deg, var(--surface-strong) 0%, var(--surface-soft) 100%);
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 800;
  box-shadow: none;
  white-space: nowrap;
}

:where(html[data-ui-theme="warm"]) .utility-menu__button {
  width: 100%;
  min-height: 3rem;
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 800;
  box-shadow: none;
  white-space: nowrap;
}

.utility-menu__qr-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  align-self: center;
  justify-self: end;
}

.utility-menu__qr-icon {
  display: block;
  width: 24px;
  height: 24px;
  fill: currentColor;
}

:where(html:not([data-ui-theme="warm"])) .utility-menu__button--primary,
:where(html:not([data-ui-theme="warm"])) .utility-menu__button--primary:hover {
  border-color: var(--accent-strong);
  background: linear-gradient(180deg, #5f7cff 0%, #4765ea 100%);
  color: #fff;
  box-shadow: 0 8px 16px rgba(71, 101, 234, 0.2);
}

:where(html[data-ui-theme="warm"]) .utility-menu__button--primary,
:where(html[data-ui-theme="warm"]) .utility-menu__button--primary:hover {
  border-color: var(--accent-strong);
  background: var(--action-fill);
  color: var(--on-accent);
  box-shadow: var(--shadow-control);
  border: 2px solid var(--ink);
}

:where(html:not([data-ui-theme="warm"])) .utility-menu__button--danger,
:where(html:not([data-ui-theme="warm"])) .utility-menu__button--danger:hover {
  border-color: #e7aaaa;
  background: linear-gradient(180deg, var(--surface-strong) 0%, #fff2f2 100%);
  color: #9b2929;
}

:where(html[data-ui-theme="warm"]) .utility-menu__button--danger,
:where(html[data-ui-theme="warm"]) .utility-menu__button--danger:hover {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.tabs-shell.utility-menu-open .spell-toolbar,
.tabs-shell.utility-menu-open .equipment-toolbar {
  display: none;
}

body.utility-menu-open #spell-search-fab,
body.utility-menu-open #equipment-search-fab {
  visibility: hidden;
  pointer-events: none;
}

.tab-content {
  display: none;
  width: 100%;
  padding-bottom: 0;
}

.tab-content.active {
  display: block;
  animation: tab-content-enter 180ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes tab-content-enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tab-content > .section + .section,
.tab-content > .section + details.section,
.tab-content > details.section + .section,
.tab-content > details.section + details.section {
  margin-top: 0.95rem;
}

#tab-skills > * + *,
#tab-equipment > * + *,
#tab-spells > * + * {
  margin-top: 0.95rem;
}

/* ===== Surfaces ===== */
:where(html:not([data-ui-theme="warm"])) .section {
  margin-bottom: 0;
  padding: 1rem 1rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

/* ===== Surfaces ===== */
:where(html[data-ui-theme="warm"]) .section {
  margin-bottom: 0;
  padding: 1rem 1rem 1.05rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: border-color 120ms ease, box-shadow 120ms ease;
  border-top: 3px solid var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .section:hover,
  details.section:hover {
    border-color: var(--border-strong);
  }
}

.section > h3,
.section summary h3,
h3 {
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.section > h3,
#tab-actions > h3,
#tab-equipment .section > h3,
#tab-spells .section > h3 {
  margin-bottom: 0.75rem;
  font-size: var(--fs-lg);
  font-weight: 850;
}

details > summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2rem;
  padding-bottom: 0.1rem;
  list-style: none;
  cursor: pointer;
}

:where(html:not([data-ui-theme="warm"])) details > summary:not(.equipment-note-summary)::before {
  content: "▸";
  color: var(--accent);
  font-size: 0.9rem;
  line-height: 1;
  transform-origin: center;
  transition: transform 0.18s ease, color 0.18s ease;
}

:where(html[data-ui-theme="warm"]) details > summary:not(.equipment-note-summary)::before {
  content: "▸";
  color: var(--accent);
  font-size: 0.9rem;
  line-height: 1;
  transform-origin: center;
  transition: transform 120ms ease, color 120ms ease;
}

details[open] > summary:not(.equipment-note-summary)::before {
  transform: rotate(90deg);
}

details > summary::-webkit-details-marker,
.spell-level-section > summary::-webkit-details-marker {
  display: none;
}

:where(html:not([data-ui-theme="warm"])) #equipment-notes-section details {
  margin-top: 0.65rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1rem;
  background: rgba(246, 249, 255, 0.72);
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

:where(html[data-ui-theme="warm"]) #equipment-notes-section details {
  margin-top: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  overflow: hidden;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

:where(html:not([data-ui-theme="warm"])) #equipment-notes-section details:hover {
  border-color: rgba(76, 104, 168, 0.32);
  background: rgba(248, 251, 255, 0.9);
}

:where(html[data-ui-theme="warm"]) #equipment-notes-section details:hover {
  border-color: var(--border);
  background: var(--surface-strong);
}

:where(html:not([data-ui-theme="warm"])) #equipment-notes-section .equipment-note-summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.8rem 0.95rem;
  font-weight: 800;
  color: var(--text);
}

:where(html[data-ui-theme="warm"]) #equipment-notes-section .equipment-note-summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.8rem 0.95rem;
  font-size: var(--fs-xl);
  line-height: 1.5;
  font-weight: 800;
  color: var(--text);
}

:where(html:not([data-ui-theme="warm"])) #equipment-notes-section .equipment-note-summary::before {
  content: "▸";
  color: var(--accent);
  font-size: 0.9rem;
  line-height: 1;
  transform-origin: center;
  transition: transform 0.18s ease, color 0.18s ease;
}

:where(html[data-ui-theme="warm"]) #equipment-notes-section .equipment-note-summary::before {
  content: "▸";
  color: var(--accent);
  font-size: 0.9rem;
  line-height: 1;
  transform-origin: center;
  transition: transform 120ms ease, color 120ms ease;
}

#equipment-notes-section details[open] > .equipment-note-summary::before {
  transform: rotate(90deg);
}

#equipment-notes-section .equipment-note-summary:hover {
  color: var(--accent-strong);
}

#equipment-notes-section .equipment-note-body {
  margin: 0;
  padding: 0 0.95rem 0.95rem;
}

:where(html:not([data-ui-theme="warm"])) .equipment-catalog-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-strong);
  -webkit-overflow-scrolling: touch;
}

:where(html[data-ui-theme="warm"]) .equipment-catalog-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  -webkit-overflow-scrolling: touch;
}

.equipment-catalog-table {
  width: 100%;
  min-width: 39rem;
  border-collapse: collapse;
  white-space: normal;
}

.equipment-catalog-table th,
.equipment-catalog-table td {
  padding: 0.5rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.equipment-catalog-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.equipment-catalog-table tbody tr:nth-child(even) {
  background: var(--accent-soft);
}

.equipment-catalog-table tbody tr:last-child td {
  border-bottom: 0;
}

/* 名稱,類型,傷害,精通,重量,價格欄不換行 */
.equipment-catalog-table th:nth-child(1),
.equipment-catalog-table td:nth-child(1),
.equipment-catalog-table th:nth-child(2),
.equipment-catalog-table td:nth-child(2),
.equipment-catalog-table th:nth-child(3),
.equipment-catalog-table td:nth-child(3),
.equipment-catalog-table th:nth-child(5),
.equipment-catalog-table td:nth-child(5),
.equipment-catalog-table th:nth-child(6),
.equipment-catalog-table td:nth-child(6),
.equipment-catalog-table th:nth-child(7),
.equipment-catalog-table td:nth-child(7) {
  white-space: nowrap;
}

/* 職業特性表：沿用裝備清單的獨立橫向捲動容器，避免擠壓下方內容。 */
:where(html:not([data-ui-theme="warm"])) .class-feature-table-wrap {
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  margin: 0.45rem 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-strong);
  -webkit-overflow-scrolling: touch;
}

/* 職業特性表：沿用裝備清單的獨立橫向捲動容器，避免擠壓下方內容。 */
:where(html[data-ui-theme="warm"]) .class-feature-table-wrap {
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  margin: 0.45rem 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  -webkit-overflow-scrolling: touch;
}

.class-feature-table {
  width: max-content;
  max-width: none;
  border-collapse: collapse;
  table-layout: auto;
  white-space: nowrap;
  font-size: clamp(0.76rem, 1.7vw, 0.9rem) !important;
  line-height: 1.42;
}

.class-feature-table th,
.class-feature-table td {
  padding: 0.46rem 0.42rem !important;
  border-color: var(--border) !important;
  text-align: center;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.class-feature-table th {
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 800;
  line-height: 1.25;
}

/* 第三欄為特性說明；維持靠左與較寬行距，讓文字表格仍易於掃讀。 */
.class-feature-table th:nth-child(3),
.class-feature-table td:nth-child(3) {
  text-align: left;
  line-height: 1.5;
}

/* 野蠻人的三個數值欄標題維持單行，搭配專屬欄寬避免表頭拉高。 */
[data-class-feature-table="barbarian"] .class-feature-table th:nth-child(4),
[data-class-feature-table="barbarian"] .class-feature-table th:nth-child(5),
[data-class-feature-table="barbarian"] .class-feature-table th:nth-child(6) {
  white-space: nowrap;
}

/* 基本頁的通用表格規則會強制允許換行；盜賊的熟練加值欄需覆寫它。 */
[data-class-feature-table="rogue"] .class-feature-table th:nth-child(2) {
  white-space: nowrap !important;
  word-break: normal !important;
}

[data-class-feature-table="warlock"] .class-feature-table th:nth-child(8) {
  white-space: nowrap !important;
  word-break: normal !important;
}

[data-class-feature-table="bard"] .class-feature-table,
[data-class-feature-table="cleric"] .class-feature-table,
[data-class-feature-table="druid"] .class-feature-table,
[data-class-feature-table="sorcerer"] .class-feature-table {
  font-size: clamp(0.72rem, 1.55vw, 0.84rem) !important;
}

/* 吟遊詩人表新增四環法術位後，讓四個法術位欄維持一致寬度。 */
[data-class-feature-table="bard"] .class-feature-table th:nth-child(n + 7),
[data-class-feature-table="bard"] .class-feature-table td:nth-child(n + 7) {
  min-width: 2.65em;
}

.class-feature-table tbody tr:nth-child(even) {
  background: var(--accent-soft);
}

.class-feature-table tbody tr:last-child td {
  border-bottom: 0;
}

.class-feature-tagline {
  margin: 8px 0;
  color: var(--class-tagline);
  font-size: 1.08em;
  font-style: italic;
  font-weight: 600;
}

.output,
#warlock-invocation-summary,
.condition-display-card,
.save-pair,
.skill-cell,
.spell-slot-column,
.hp-card,
.mini-stat-card,
.site-footer {
  background: var(--surface-soft);
  border-color: var(--border);
}

:where(html:not([data-ui-theme="warm"])) .output {
  padding: 0.95rem 1rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.05rem;
  white-space: pre-wrap;
  line-height: 1.5;
}

:where(html[data-ui-theme="warm"]) .output {
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  line-height: 1.5;
}

#raceFeatures {
  white-space: normal;
  max-width: 100%;
}

#raceFeatures .race-feature-line {
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.race-option-row {
  display: grid;
  gap: 8px;
}

.race-options {
  max-width: 100%;
}

.race-option-row.is-hidden {
  display: none;
}

.race-option-row select {
  width: 100%;
  margin: 0;
  font-weight: 800;
  text-align: left;
}

#dragonborn-ancestry-row,
#gnome-lineage-row,
#goliath-ancestry-row {
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
}

.dragonborn-breath-uses,
.proficiency-use-checks {
  display: inline-flex;
  align-items: center;
  gap: clamp(0.2rem, 0.8vw, 0.45rem);
  width: max-content;
  white-space: nowrap;
}

.dragonborn-breath-uses.is-hidden,
.proficiency-use-checks.is-hidden {
  display: none;
}

.dragonborn-breath-uses__label,
.proficiency-use-checks__label {
  font-size: var(--fs-xs);
  font-weight: 800;
}

.dragonborn-breath-uses input[type="checkbox"],
.proficiency-use-checks input[type="checkbox"] {
  flex: 0 0 auto;
  margin: 0;
}

.dragonborn-breath-uses input[type="checkbox"][hidden],
.proficiency-use-checks input[type="checkbox"][hidden] {
  display: none;
}

#elf-lineage-row.has-cantrip {
  grid-template-columns: 1fr;
}

.class-feature-option {
  margin: 8px 0 12px;
}

.class-feature-option select {
  width: min(100%, 280px);
  margin: 0;
}

:where(html:not([data-ui-theme="warm"])) .derived-stat-note {
  margin-top: 4px;
  color: #526078;
  font-size: 0.78rem;
  line-height: 1.2;
}

:where(html[data-ui-theme="warm"]) .derived-stat-note {
  margin-top: 4px;
  color: var(--text-body);
  font-size: 0.78rem;
  line-height: 1.2;
}

#raceFeatures .race-feature-line + .race-feature-line {
  margin-top: 0.2rem;
}

#raceFeatures .race-feature-spacer {
  height: 0.8rem;
}

:where(html:not([data-ui-theme="warm"])) #raceFeatures .race-feature-table-wrap {
  position: relative;
  width: 100%;
  margin: 0.8rem 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--surface-strong);
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

:where(html[data-ui-theme="warm"]) #raceFeatures .race-feature-table-wrap {
  position: relative;
  width: 100%;
  margin: 0.8rem 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

#raceFeatures .race-feature-table-wrap table {
  width: 100%;
  min-width: 0;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text-body);
  font-size: clamp(0.82rem, 1.7vw, 0.92rem);
  line-height: 1.45;
}

#raceFeatures .race-feature-table-wrap td,
#raceFeatures .race-feature-table-wrap th {
  padding: 0.62rem 0.7rem;
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#raceFeatures .race-feature-table-wrap tr > :last-child {
  border-right: 0;
}

#raceFeatures .race-feature-table-wrap tbody tr:last-child > * {
  border-bottom: 0;
}

#raceFeatures .race-feature-table-wrap thead th {
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 800;
  text-align: center;
  vertical-align: middle;
}

#raceFeatures .race-feature-table-wrap tbody tr:hover > * {
  background: var(--accent-soft);
}

#raceFeatures .dragon-ancestry-table,
#raceFeatures .dragon-ancestry-table tbody {
  display: block;
}

#raceFeatures .dragon-ancestry-table tbody {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
}

#raceFeatures .dragon-ancestry-table tr {
  display: contents;
}

#raceFeatures .dragon-ancestry-table td {
  display: flex;
  min-width: 0;
  min-height: 4rem;
  flex-direction: column;
  gap: 0.15rem;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.35rem;
  border: 0;
  background: var(--surface-strong);
  text-align: center;
  overflow-wrap: normal;
  word-break: keep-all;
}

#raceFeatures .dragon-ancestry-table td:hover {
  background: var(--accent-soft);
}

.dragon-ancestry-name {
  color: var(--text);
  font-weight: 800;
}

.dragon-ancestry-damage {
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 750;
}

#raceFeatures .race-lineage-table {
  min-width: 42rem;
  table-layout: fixed;
}

#raceFeatures .race-lineage-table th:first-child {
  width: 4.25rem;
}

#raceFeatures .race-lineage-table tbody th {
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  text-align: center;
  vertical-align: middle;
}

#raceFeatures .race-lineage-table tbody td {
  text-align: center;
  vertical-align: middle;
}

#raceFeatures .race-lineage-table tbody td strong:not(.spell-highlight) {
  display: inline-block;
  margin-top: 0.12rem;
  color: var(--text);
}

#raceFeatures .lineage-detail {
  display: inline-block;
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.4;
}

.race-lineage-mobile {
  display: none;
}

#tab-basic .output {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
}

#tab-basic .output table:not(.class-feature-table) {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
}

#tab-basic .output table:not(.class-feature-table) th,
#tab-basic .output table:not(.class-feature-table) td {
  white-space: normal !important;
  word-break: break-word;
}

:where(html:not([data-ui-theme="warm"])) #tab-basic .output .rule-table-shell {
  width: fit-content;
  max-width: 100%;
  margin: 0.45rem 0 0.9rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--surface-strong);
  white-space: normal;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

:where(html[data-ui-theme="warm"]) #tab-basic .output .rule-table-shell {
  width: fit-content;
  max-width: 100%;
  margin: 0.45rem 0 0.9rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  white-space: normal;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

#tab-basic .output .rule-table-shell--wild-shape {
  width: min(100%, 34rem);
}

#tab-basic .output .rule-table-shell--spell-slot {
  width: min(100%, 28rem);
}

#tab-basic .output table.rule-reference-table {
  width: 100%;
  max-width: none;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
  color: var(--text-body);
  font-size: clamp(0.82rem, 1.7vw, 0.92rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

#tab-basic .output .rule-progress-table--wild-shape {
  min-width: 32rem;
}

#tab-basic .output .rule-reference-table th,
#tab-basic .output .rule-reference-table td {
  padding: 0.62rem 0.68rem;
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}

#tab-basic .output .rule-reference-table tr > :last-child {
  border-right: 0;
}

#tab-basic .output .rule-reference-table tbody tr:last-child > * {
  border-bottom: 0;
}

#tab-basic .output .rule-reference-table thead th {
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 800;
  line-height: 1.3;
}

#tab-basic .output .rule-reference-table tbody th {
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 1rem;
  font-weight: 850;
}

#tab-basic .output .rule-reference-table tbody tr:hover > * {
  background: var(--accent-soft);
}

#tab-basic .output .rule-progress-table--spell-slot tbody td:nth-child(2) {
  color: var(--accent-strong);
  font-size: 1rem;
  font-weight: 850;
}

.rule-level-suffix {
  display: none;
}

#tab-basic .output .class-core-profile-table {
  margin: 0 0 0.75rem;
  border-collapse: separate !important;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text-body);
  white-space: normal;
  overflow: hidden;
}

#tab-basic .output .class-core-profile-table td {
  padding: 0.52rem 0.65rem !important;
  border: 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

#tab-basic .output .class-core-profile-table tr:last-child td {
  border-bottom: 0;
}

#tab-basic .output .class-core-profile-table td:first-child {
  width: 7.2rem !important;
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 800 !important;
}

#tab-basic .output .class-core-equipment-note {
  margin: 0.5rem 0 0.35rem;
  color: var(--text-body);
  line-height: 1.55;
  white-space: normal;
}

#tab-basic .output .class-flavor-quote {
  margin: 0.35rem 0;
  padding: 0.1rem 0 0.1rem 0.9rem;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-style: italic;
  line-height: 1.65;
  white-space: normal;
}

#tab-basic .output .class-feature-content {
  width: min(100%, 38rem);
  margin-top: 0.85rem;
  color: var(--text-body);
  white-space: normal;
}

#tab-basic .output .class-feature-section {
  padding: 1rem 0 1.05rem;
  border-top: 1px solid var(--border);
}

#tab-basic .output .class-feature-section:first-child {
  border-top-color: var(--border-strong);
}

#tab-basic .output .class-feature-section:last-child {
  padding-bottom: 0;
}

#tab-basic .output .class-feature-section:last-child > :last-child {
  margin-bottom: 0;
}

#tab-basic .output .class-feature-section > h3 {
  margin: 0 0 0.62rem;
  padding-left: 0.7rem;
  border-left: 3px solid var(--accent);
  color: var(--text);
  font-size: var(--fs-lg);
  font-weight: 850;
  line-height: 1.35;
}

#tab-basic .output .class-feature-section p {
  margin: 0.48rem 0;
  line-height: 1.62;
}

#tab-basic .output .class-rule-list {
  margin: 0.5rem 0 0;
  padding-left: 1.35rem;
}

#tab-basic .output .class-rule-list li {
  padding-left: 0.08rem;
  line-height: 1.58;
}

#tab-basic .output .class-rule-list li::marker {
  color: var(--accent);
}

#tab-basic .output .class-rule-list li + li {
  margin-top: 0.34rem;
}

#tab-basic .output .class-rule-list ul {
  margin: 0.32rem 0 0.18rem;
  padding-left: 1.25rem;
  color: var(--text-body);
  list-style-type: circle;
}

#tab-basic .output .class-rule-list ul li + li {
  margin-top: 0.22rem;
}

#tab-basic .output .class-rule-list ul ul {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  list-style-type: square;
}

#tab-basic .output .class-rule-subsection {
  margin-top: 0.85rem;
}

#tab-basic .output .barbarian-rule-subsection + .barbarian-rule-subsection {
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-strong);
}

#tab-basic .output .class-rule-subsection > h4,
#tab-basic .output .wild-shape-known-forms > h4 {
  margin: 0 0 0.42rem;
  color: var(--accent-strong);
  font-size: var(--fs-sm);
  font-weight: 850;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

#tab-basic .output .druid-mission-options {
  margin: 0.65rem 0 0.2rem 0.15rem;
  border-left: 2px solid var(--border-strong);
}

#tab-basic .output .druid-mission-option {
  padding: 0.2rem 0 0.45rem 0.85rem;
}

#tab-basic .output .druid-mission-option + .druid-mission-option {
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

#tab-basic .output .druid-mission-option__heading {
  color: var(--text-body);
  line-height: 1.58;
}

#tab-basic .output .druid-mission-option__heading label {
  color: var(--text);
  font-weight: 800;
}

#tab-basic .output .druid-mission-option .class-rule-list {
  margin-top: 0.35rem;
}

#tab-basic .output .druid-rule-subsection--transformation {
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border-strong);
}

#tab-basic .output .rule-table-shell--druid-terrain-spells {
  margin-top: 0.72rem;
}

#tab-basic .output .druid-terrain-spells {
  width: max-content;
  max-width: none;
  table-layout: auto;
}

/* 覆寫基本頁通用表格的強制換行，讓欄寬與德魯伊特性表一樣依文字內容計算。 */
#tab-basic .output .druid-terrain-spells th,
#tab-basic .output .druid-terrain-spells td {
  white-space: nowrap !important;
  word-break: normal !important;
}

#tab-basic .output .druid-terrain-spells td {
  text-align: left;
}

#tab-basic .output .wild-shape-known-forms {
  width: min(100%, 34rem);
  margin: 0.95rem 0 1.1rem;
  color: var(--text-body);
  white-space: normal;
}

#tab-basic .output .wild-shape-known-forms > h4 {
  margin: 0 0 0.45rem;
}

#tab-basic .output .wild-shape-known-forms__intro {
  margin: 0;
  line-height: 1.6;
}

#tab-basic .output .wild-shape-known-forms__recommendation {
  margin: 0.7rem 0;
  padding: 0.62rem 0.75rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft);
  line-height: 1.55;
}

#tab-basic .output .wild-shape-known-forms__recommendation strong {
  color: var(--accent-strong);
}

#tab-basic .output .wild-shape-known-forms__rules {
  margin: 0.65rem 0 0;
  padding-left: 1.35rem;
}

#tab-basic .output .wild-shape-known-forms__rules li + li {
  margin-top: 0.28rem;
}

#tab-basic .output .wild-shape-beast-disclosure {
  margin-top: 0.85rem;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

:where(html:not([data-ui-theme="warm"])) #tab-basic .output .wild-shape-beast-disclosure > summary {
  min-height: 0;
  padding: 0.68rem 0.78rem;
  color: var(--text);
  font-weight: 800;
  transition: background 0.18s ease, color 0.18s ease;
}

:where(html[data-ui-theme="warm"]) #tab-basic .output .wild-shape-beast-disclosure > summary {
  min-height: 0;
  padding: 0.68rem 0.78rem;
  color: var(--text);
  font-weight: 800;
  transition: background 120ms ease, color 120ms ease;
}

#tab-basic .output .wild-shape-beast-disclosure > summary:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

#tab-basic .output .wild-shape-beast-disclosure > summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}

#tab-basic .output .wild-shape-beast-disclosure__hide,
#tab-basic .output .wild-shape-beast-disclosure[open] .wild-shape-beast-disclosure__show {
  display: none;
}

#tab-basic .output .wild-shape-beast-disclosure[open] .wild-shape-beast-disclosure__hide {
  display: inline;
}

#tab-basic .output .wild-shape-beast-groups {
  border-top: 1px solid var(--border-strong);
}

#tab-basic .output .wild-shape-beast-group {
  display: grid;
  grid-template-columns: 4.25rem minmax(0, 1fr);
}

#tab-basic .output .wild-shape-beast-group + .wild-shape-beast-group {
  border-top: 1px solid var(--border);
}

#tab-basic .output .wild-shape-beast-group h4 {
  display: flex;
  align-items: flex-start;
  margin: 0;
  padding: 0.72rem 0.65rem;
  background: var(--surface-muted);
  color: var(--accent-strong);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  line-height: 1.4;
  white-space: nowrap;
}

#tab-basic .output .wild-shape-beast-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem 1rem;
  align-content: flex-start;
  padding: 0.68rem 0.8rem;
  border-left: 1px solid var(--border);
  line-height: 1.45;
}

#tab-basic .output .wild-shape-beast-grid .beast-tip {
  display: inline-block;
  color: var(--text-body);
  font-weight: 650;
  white-space: nowrap;
}

@media (max-width: 520px) {
  #raceFeatures .dragon-ancestry-table tbody {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #raceFeatures .dragon-ancestry-table td {
    min-height: 3.6rem;
    padding: 0.58rem 0.4rem;
  }

  #raceFeatures .race-feature-table-wrap--lineage {
    overflow-x: hidden;
  }

  #raceFeatures .race-feature-table-wrap--lineage .race-lineage-table {
    display: none;
  }

  #raceFeatures .race-lineage-mobile {
    display: block;
  }

  #raceFeatures .race-lineage-mobile__group + .race-lineage-mobile__group {
    border-top: 1px solid var(--border-strong);
  }

  #raceFeatures .race-lineage-mobile__heading {
    margin: 0;
    padding: 0.62rem 0.75rem;
    background: var(--surface-muted);
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 850;
    line-height: 1.35;
  }

  #raceFeatures .race-lineage-mobile__list {
    display: grid;
    grid-template-columns: 3.5rem minmax(0, 1fr);
    margin: 0;
  }

  #raceFeatures .race-lineage-mobile__list dt,
  #raceFeatures .race-lineage-mobile__list dd {
    margin: 0;
    padding: 0.58rem 0.68rem;
    border-bottom: 1px solid var(--border);
  }

  #raceFeatures .race-lineage-mobile__list dt {
    background: var(--surface-soft);
    color: var(--accent-strong);
    font-variant-numeric: tabular-nums;
    font-weight: 850;
    text-align: center;
  }

  #raceFeatures .race-lineage-mobile__list dd {
    min-width: 0;
    border-left: 1px solid var(--border);
    color: var(--text-body);
    overflow-wrap: anywhere;
  }

  #raceFeatures .race-lineage-mobile__list dt:last-of-type,
  #raceFeatures .race-lineage-mobile__list dd:last-of-type {
    border-bottom: 0;
  }

  #raceFeatures .race-lineage-mobile__group:not(:last-child) .race-lineage-mobile__list dt:last-of-type,
  #raceFeatures .race-lineage-mobile__group:not(:last-child) .race-lineage-mobile__list dd:last-of-type {
    border-bottom: 0;
  }

  #tab-basic .output .rule-table-shell--wild-shape {
    width: 100%;
    margin-block: 0.22rem 0.58rem;
    overflow-x: hidden;
  }

  #tab-basic .output table.rule-progress-table--wild-shape {
    display: block;
    min-width: 0;
  }

  #tab-basic .output .rule-progress-table--wild-shape thead {
    display: none;
  }

  #tab-basic .output .rule-progress-table--wild-shape tbody {
    display: block;
  }

  #tab-basic .output .rule-progress-table--wild-shape tbody tr {
    display: grid;
    grid-template-columns: 3.2rem repeat(3, minmax(0, 1fr));
    background: var(--surface-strong);
  }

  #tab-basic .output .rule-progress-table--wild-shape tbody tr + tr {
    border-top: 1px solid var(--border-strong);
  }

  #tab-basic .output .rule-progress-table--wild-shape tbody th,
  #tab-basic .output .rule-progress-table--wild-shape tbody td {
    display: flex;
    min-width: 0;
    min-height: 3.15rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.22rem;
    border-bottom: 0;
  }

  #tab-basic .output .rule-progress-table--wild-shape tbody td::before {
    content: attr(data-label);
    margin-bottom: 0.16rem;
    color: var(--text-muted);
    font-size: clamp(0.62rem, 2.8vw, 0.72rem);
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
  }

  #tab-basic .output .rule-progress-table--wild-shape tbody th {
    flex-direction: row;
    background: var(--accent-soft);
  }

  .rule-level-suffix {
    display: inline;
    margin-left: 0.08rem;
    font-size: 0.72rem;
  }

  #tab-basic .output .wild-shape-beast-group {
    grid-template-columns: 3.75rem minmax(0, 1fr);
  }

  #tab-basic .output .wild-shape-beast-group h4,
  #tab-basic .output .wild-shape-beast-grid {
    padding-inline: 0.58rem;
  }

  #tab-basic .output .wild-shape-beast-grid {
    gap: 0.42rem 0.8rem;
  }

  #tab-basic .output .rule-progress-table--spell-slot th,
  #tab-basic .output .rule-progress-table--spell-slot td {
    padding-inline: 0.4rem;
  }
}

:where(html:not([data-ui-theme="warm"])) .selection-summary {
  margin-top: 6px;
  padding: 12px;
  border: 1px solid rgba(128, 148, 184, 0.28);
  border-radius: 14px;
  background: var(--surface-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

:where(html[data-ui-theme="warm"]) .selection-summary {
  margin-top: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  box-shadow: none;
}

.selection-summary-empty {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.selection-summary-list {
  display: grid;
  gap: 10px;
}

:where(html:not([data-ui-theme="warm"])) .selection-summary-card {
  padding: 10px 12px;
  border: 1px solid rgba(151, 168, 201, 0.3);
  border-radius: 12px;
  background: var(--control-bg);
}

:where(html[data-ui-theme="warm"]) .selection-summary-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--control-bg);
}

.selection-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.selection-summary-title {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 900;
}

:where(html:not([data-ui-theme="warm"])) .selection-summary-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(40, 82, 214, 0.12);
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 900;
}

:where(html[data-ui-theme="warm"]) .selection-summary-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 900;
}

.selection-summary-body {
  white-space: pre-wrap;
  line-height: 1.55;
  color: var(--text-body);
}

     #metamagic-summary .selection-summary-body {
     white-space: normal;
      }

#metamagic-summary {
  margin-bottom: 12px;
}

#backgroundFeatures {
  white-space: normal;
}

/* ===== Forms ===== */
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

:where(html:not([data-ui-theme="warm"])) select,
:where(html:not([data-ui-theme="warm"])) input[type="number"],
:where(html:not([data-ui-theme="warm"])) input[type="text"],
:where(html:not([data-ui-theme="warm"])) textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 2px rgba(8, 18, 40, 0.08);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

:where(html[data-ui-theme="warm"]) select,
:where(html[data-ui-theme="warm"]) input[type="number"],
:where(html[data-ui-theme="warm"]) input[type="text"],
:where(html[data-ui-theme="warm"]) textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  box-shadow: none;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

/* 基本資料四個下拉改為一般方角樣式 */
select,
input[type="text"],
textarea {
  min-height: 2.9rem;
  padding: 0.8rem 0.95rem;
  font-size: var(--fs-base);
}

input[type="number"] {
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  font-size: var(--fs-lg);
  font-weight: 800;
  text-align: center;
}

:where(html:not([data-ui-theme="warm"])) select:focus,
:where(html:not([data-ui-theme="warm"])) input[type="number"]:focus,
:where(html:not([data-ui-theme="warm"])) input[type="text"]:focus,
:where(html:not([data-ui-theme="warm"])) textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

:where(html[data-ui-theme="warm"]) select:focus,
:where(html[data-ui-theme="warm"]) input[type="number"]:focus,
:where(html[data-ui-theme="warm"]) input[type="text"]:focus,
:where(html[data-ui-theme="warm"]) textarea:focus {
  border-color: var(--accent);
  box-shadow: none; outline: 2px solid var(--focus-ring); outline-offset: 2px;
}

textarea {
  min-height: 6.5rem;
  resize: vertical;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  vertical-align: middle;
}

:where(html:not([data-ui-theme="warm"])) button {
  width: 100%;
  min-height: 2.9rem;
  margin-bottom: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--control-bg);
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(31, 55, 112, 0.07);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

:where(html[data-ui-theme="warm"]) button {
  width: 100%;
  min-height: 2.9rem;
  margin-bottom: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--control-bg);
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 700;
  box-shadow: none;
  cursor: pointer;
  transition: translate 100ms ease, background-color 120ms ease, border-color 120ms ease;
  font-family: var(--font-body);
}

@media (hover: hover) and (pointer: fine) {
  :where(html:not([data-ui-theme="warm"])) button:hover {
    transform: translateY(-1px);
    background: var(--control-hover-bg);
    border-color: var(--border-strong);
    box-shadow: 0 7px 16px rgba(31, 55, 112, 0.1);
  }
  :where(html[data-ui-theme="warm"]) button:not(:disabled):hover {
    background: var(--control-hover-bg);
    border-color: var(--border-strong);
    box-shadow: none;
  }
}

:where(html:not([data-ui-theme="warm"])) button:active {
  transform: translateY(0) scale(0.98);
}

:where(html[data-ui-theme="warm"]) button:not(:disabled):active {
  translate: 1px 1px;
  box-shadow: none;
}

:where(html:not([data-ui-theme="warm"])) .tabs-shell .tab-button.active:hover {
  transform: none;
  border-color: transparent;
  background: var(--accent-gradient);
  color: var(--on-accent);
  box-shadow: 0 7px 16px rgba(31, 100, 255, 0.3);
}

:where(html[data-ui-theme="warm"]) .tabs-shell .tab-button.active:hover {
  transform: none;
  border-color: transparent;
  background: var(--action-fill);
  color: var(--on-accent);
  box-shadow: inset 0 0 0 1px var(--ink), var(--shadow-control);
}

:where(html:not([data-ui-theme="warm"])) button:focus-visible,
:where(html:not([data-ui-theme="warm"])) summary:focus-visible,
:where(html:not([data-ui-theme="warm"])) a:focus-visible,
:where(html:not([data-ui-theme="warm"])) .mini-stat-label--jump:focus-visible,
:where(html:not([data-ui-theme="warm"])) .spell-slot-label--jump:focus-visible,
:where(html:not([data-ui-theme="warm"])) .spell-picked-jump:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Primary actions share the same press depth; dense/secondary controls stay flat. */
:where(html[data-ui-theme="warm"]) #set-default-abilities {
  border: 2px solid var(--ink);
  background: var(--action-fill);
  color: var(--on-accent);
  box-shadow: var(--shadow-control);
  font-weight: 900;
}

@media (hover: hover) and (pointer: fine) {
  :where(html[data-ui-theme="warm"]) :is(#set-default-abilities, #legal-ack-btn, .utility-menu__button--primary,
      .app-dialog__button--primary, .pdf-export-flow-modal__button--primary):not(:disabled):hover {
    background: var(--action-hover);
  }
}

:where(html[data-ui-theme="warm"]) :is(#set-default-abilities, #legal-ack-btn, .utility-menu__button--primary,
    .app-dialog__button--primary, .pdf-export-flow-modal__button--primary,
    .tabs-shell .tab-button):not(:disabled):active {
  box-shadow: none;
  translate: 1px 1px;
}

:where(html[data-ui-theme="warm"]) button:focus-visible,
:where(html[data-ui-theme="warm"]) [role="button"]:focus-visible,
:where(html[data-ui-theme="warm"]) summary:focus-visible,
:where(html[data-ui-theme="warm"]) a:focus-visible,
:where(html[data-ui-theme="warm"]) .mini-stat-label--jump:focus-visible,
:where(html[data-ui-theme="warm"]) .spell-slot-label--jump:focus-visible,
:where(html[data-ui-theme="warm"]) .spell-picked-jump:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

:where(html:not([data-ui-theme="warm"])) button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

:where(html[data-ui-theme="warm"]) button:disabled {
  opacity: 1;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: var(--disabled-bg);
  color: var(--disabled-text);
  border-color: var(--border);
  translate: none;
}

:where(html:not([data-ui-theme="warm"])) input[type="checkbox"]:focus-visible {
  outline: 3px solid rgba(36, 93, 255, 0.2);
  outline-offset: 3px;
}

:where(html[data-ui-theme="warm"]) input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.button-compact {
  margin-bottom: 0;
  font-size: var(--fs-sm);
  font-weight: 800;
}

.form-grid-2col,
.form-grid-3col,
.form-grid-6col,
.save-grid,
.skill-grid,
.ability-grid,
.spell-picked-grid,
.spell-slot-grid,
.spell-casting-stats,
.bottom-buttons {
  gap: 0.75rem;
}

.form-grid-2col,
.form-grid-3col {
  display: grid;
  margin-bottom: 0.75rem;
}

.form-grid-2col {
  grid-template-columns: 1fr;
}

.form-grid-3col {
  grid-template-columns: 1fr;
  align-items: end;
}

:where(html:not([data-ui-theme="warm"])) .form-grid-6col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0.85rem;
  font-size: var(--fs-md);
  background: var(--surface-soft);
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 0.95rem;
}

:where(html[data-ui-theme="warm"]) .form-grid-6col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0.85rem;
  font-size: var(--fs-md);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.form-grid-6col label {
  margin-bottom: 0;
  color: var(--text-muted);
}

.form-grid-6col > span:empty {
  display: none;
}

.language-card > h3,
.tool-card > h3 {
  margin-bottom: 0.8rem;
}

.language-section,
.language-base-grid,
.language-field,
.language-extra-container,
.language-extra-container > div {
  display: grid;
  gap: 0.75rem;
}

.language-section {
  margin-top: 0;
}

.language-section > label,
.language-field > label,
.language-extra-container > div > label,
.language-extra-label {
  margin-bottom: 0;
}

.language-select {
  width: 100%;
  margin-left: 0;
}

.language-extra-container {
  margin-top: 0;
}

.language-extra-container:empty {
  display: none;
}

.language-extra-row {
  display: grid;
  gap: 0.45rem;
  margin-top: 0;
}

.language-extra-label {
  margin-right: 0;
}

.tool-section,
.tool-proficiency-list {
  display: grid;
  gap: 0.75rem;
}

.tool-proficiency-row {
  display: grid;
  gap: 0.45rem;
}

.tool-proficiency-row > label {
  margin-bottom: 0;
}

:where(html:not([data-ui-theme="warm"])) .tool-proficiency-row--background {
  padding: 0.75rem;
  border: 1px solid rgba(151, 168, 201, 0.28);
  border-radius: 0.85rem;
  background: rgba(151, 168, 201, 0.12);
}

:where(html[data-ui-theme="warm"]) .tool-proficiency-row--background {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

:where(html:not([data-ui-theme="warm"])) .tool-proficiency-row--derived,
:where(html:not([data-ui-theme="warm"])) .feat-entry--derived {
  padding: 0.75rem;
  border: 1px solid rgba(151, 168, 201, 0.28);
  border-radius: 0.85rem;
  background: rgba(151, 168, 201, 0.12);
}

:where(html[data-ui-theme="warm"]) .tool-proficiency-row--derived,
:where(html[data-ui-theme="warm"]) .feat-entry--derived {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.tool-proficiency-row--derived .tool-proficiency-control {
  grid-template-columns: minmax(0, 1fr);
}

:where(html:not([data-ui-theme="warm"])) .feat-entry--derived > select:disabled {
  opacity: 0.78;
  color: #667085;
  cursor: not-allowed;
}

:where(html[data-ui-theme="warm"]) .feat-entry--derived > select:disabled {
  opacity: 0.78;
  color: var(--text-muted);
  cursor: not-allowed;
}

.tool-proficiency-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
}

.tool-proficiency-row--background .tool-proficiency-control {
  grid-template-columns: minmax(0, 1fr);
}

.tool-proficiency-select {
  width: 100%;
  margin-left: 0;
}

.tool-proficiency-add,
.tool-proficiency-remove {
  width: auto;
}

.tool-proficiency-hint {
  margin: -0.2rem 0 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.inline-check-label {
  width: auto;
  margin: 0 6px 0 0;
}

/* ===== Basic Tab ===== */
:where(html:not([data-ui-theme="warm"])) .hp-card,
:where(html:not([data-ui-theme="warm"])) .mini-stat-card {
  padding: 0.95rem 1rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.25rem;
  box-shadow: 0 4px 14px rgba(18, 33, 68, 0.055);
}

/* ===== Basic Tab ===== */
:where(html[data-ui-theme="warm"]) .hp-card,
:where(html[data-ui-theme="warm"]) .mini-stat-card {
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: none;
}

:where(html:not([data-ui-theme="warm"])) #tab-basic .mini-stat-card {
  padding: 0.85rem;
  border-radius: 1.1rem;
}

:where(html[data-ui-theme="warm"]) #tab-basic .mini-stat-card {
  padding: 0.85rem;
  border-radius: var(--radius-lg);
}

.hp-title,
.mini-stat-label {
  margin-bottom: 0.35rem;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hp-title {
  display: grid;
  gap: 0.55rem;
}

.basic-overview {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.basic-row {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.basic-row--class-level {
  grid-template-columns: 1fr;
}

.basic-row--origin {
  grid-template-columns: 1fr;
}

.basic-row--vitals,
.basic-row--misc {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.basic-row--combat {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.basic-row--combat .mini-stat-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.basic-row--combat .speed-current-display {
  width: 100%;
  height: 3rem;
  min-height: 3rem;
}

.basic-pair-card {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.basic-pair-card--class-level {
  grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, 1fr));
}

.basic-pair-field--level,
.basic-pair-field--hit-dice {
  width: 100%;
}

.basic-pair-field--hit-dice {
  container-type: inline-size;
}

.hit-die-size {
  white-space: nowrap;
}

@container (max-width: 6.5rem) {
  .hit-die-size {
    display: none;
  }
}

.basic-pair-field--level select,
.basic-pair-field--hit-dice select {
  width: 100%;
  min-height: 2.9rem;
}

:where(html:not([data-ui-theme="warm"])) .basic-pair-card--class-level .class-feature-option {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(151, 168, 201, 0.2);
}

:where(html[data-ui-theme="warm"]) .basic-pair-card--class-level .class-feature-option {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.basic-pair-card--class-level .class-feature-option select {
  width: 100%;
  margin: 0;
  font-weight: 800;
  text-align: left;
}

.basic-pair-card--equal {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-content: start;
}

:where(html:not([data-ui-theme="warm"])) .basic-pair-card--equal .race-options {
  grid-column: 1 / -1;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(151, 168, 201, 0.2);
}

:where(html[data-ui-theme="warm"]) .basic-pair-card--equal .race-options {
  grid-column: 1 / -1;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.basic-pair-field,
.basic-single-card {
  min-width: 0;
}

.basic-metric-card {
  min-width: 0;
}

.basic-metric-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.basic-metric-values > * {
  min-width: 0;
}

.hp-value,
#ac-display,
#hp-display {
  color: var(--accent);
  font-size: var(--fs-2xl);
  font-weight: 900;
}

:where(html:not([data-ui-theme="warm"])) #tab-basic #hp-display,
:where(html:not([data-ui-theme="warm"])) #tab-basic #ac-display,
:where(html:not([data-ui-theme="warm"])) #tab-basic .speed-current-display,
:where(html:not([data-ui-theme="warm"])) #tab-basic .basic-display-checkbox,
:where(html:not([data-ui-theme="warm"])) #tab-basic .tight-input,
:where(html:not([data-ui-theme="warm"])) #tab-basic .hp-card input[type="number"] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border-radius: 1rem;
  border: 1px solid rgba(151, 168, 201, 0.34);
  background: #fff;
  color: var(--text);
  text-align: center;
  font-size: var(--fs-xl);
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 1px 2px rgba(22, 38, 80, 0.04);
}

:where(html[data-ui-theme="warm"]) #tab-basic #hp-display,
:where(html[data-ui-theme="warm"]) #tab-basic #ac-display,
:where(html[data-ui-theme="warm"]) #tab-basic .speed-current-display,
:where(html[data-ui-theme="warm"]) #tab-basic .basic-display-checkbox,
:where(html[data-ui-theme="warm"]) #tab-basic .tight-input,
:where(html[data-ui-theme="warm"]) #tab-basic .hp-card input[type="number"] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  text-align: center;
  font-size: var(--fs-xl);
  font-weight: 800;
  box-shadow: none;
}

#tab-basic #hp-display,
#tab-basic #ac-display,
#tab-basic .speed-current-display {
  margin-left: 0;
  color: var(--accent);
}

#tab-basic .derived-stat-input {
  margin: 0;
  caret-color: transparent;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

#tab-basic .derived-stat-input[readonly] {
  cursor: default;
}

#tab-basic.manual-key-stats .derived-stat-input {
  caret-color: auto;
  cursor: text;
}

#tab-basic.manual-key-stats .derived-stat-input:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

#tab-basic .basic-display-checkbox {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  width: 100%;
  min-width: 0;
  height: auto;
  cursor: pointer;
  position: relative;
}

:where(html:not([data-ui-theme="warm"])) #tab-basic .basic-display-checkbox::after {
  content: "";
  width: 1.35rem;
  height: 1.35rem;
  border: 1.5px solid rgba(110, 110, 110, 0.72);
  border-radius: 0.16rem;
  background:
    linear-gradient(135deg, transparent 36%, rgba(110, 110, 110, 0.86) 37%, rgba(110, 110, 110, 0.86) 43%, transparent 44%) center/100% 100%,
    linear-gradient(225deg, transparent 36%, rgba(110, 110, 110, 0.86) 37%, rgba(110, 110, 110, 0.86) 43%, transparent 44%) center/100% 100%,
    linear-gradient(315deg, transparent 36%, rgba(110, 110, 110, 0.86) 37%, rgba(110, 110, 110, 0.86) 43%, transparent 44%) center/100% 100%,
    linear-gradient(45deg, transparent 36%, rgba(110, 110, 110, 0.86) 37%, rgba(110, 110, 110, 0.86) 43%, transparent 44%) center/100% 100%,
    linear-gradient(180deg, #ffffff 0%, #f4f4f4 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.92), 0 1px 2px rgba(22, 38, 80, 0.08);
}

:where(html[data-ui-theme="warm"]) #tab-basic .basic-display-checkbox::after {
  content: "";
  width: 1.35rem;
  height: 1.35rem;
  border: 1.5px solid var(--border);
  border-radius: 0.16rem;
  background:
    linear-gradient(135deg, transparent 36%, var(--surface-muted) 37%, var(--surface-muted) 43%, transparent 44%) center/100% 100%,
    linear-gradient(225deg, transparent 36%, var(--surface-muted) 37%, var(--surface-muted) 43%, transparent 44%) center/100% 100%,
    linear-gradient(315deg, transparent 36%, var(--surface-muted) 37%, var(--surface-muted) 43%, transparent 44%) center/100% 100%,
    linear-gradient(45deg, transparent 36%, var(--surface-muted) 37%, var(--surface-muted) 43%, transparent 44%) center/100% 100%,
    var(--surface-strong);
  box-shadow: none;
}

:where(html:not([data-ui-theme="warm"])) #tab-basic .basic-display-checkbox:checked::after {
  border-color: rgba(40, 82, 214, 0.78);
  background:
    linear-gradient(135deg, transparent 34%, rgba(40, 82, 214, 0.96) 35%, rgba(40, 82, 214, 0.96) 44%, transparent 45%) center/100% 100%,
    linear-gradient(225deg, transparent 34%, rgba(40, 82, 214, 0.96) 35%, rgba(40, 82, 214, 0.96) 44%, transparent 45%) center/100% 100%,
    linear-gradient(315deg, transparent 34%, rgba(40, 82, 214, 0.96) 35%, rgba(40, 82, 214, 0.96) 44%, transparent 45%) center/100% 100%,
    linear-gradient(45deg, transparent 34%, rgba(40, 82, 214, 0.96) 35%, rgba(40, 82, 214, 0.96) 44%, transparent 45%) center/100% 100%,
    linear-gradient(180deg, #ffffff 0%, #eaf0ff 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.96), 0 2px 6px rgba(40, 82, 214, 0.18);
}

:where(html[data-ui-theme="warm"]) #tab-basic .basic-display-checkbox:checked::after {
  border-color: var(--accent);
  background:
    linear-gradient(135deg, transparent 34%, var(--action-fill) 35%, var(--action-fill) 44%, transparent 45%) center/100% 100%,
    linear-gradient(225deg, transparent 34%, var(--action-fill) 35%, var(--action-fill) 44%, transparent 45%) center/100% 100%,
    linear-gradient(315deg, transparent 34%, var(--action-fill) 35%, var(--action-fill) 44%, transparent 45%) center/100% 100%,
    linear-gradient(45deg, transparent 34%, var(--action-fill) 35%, var(--action-fill) 44%, transparent 45%) center/100% 100%,
    var(--surface-strong);
  box-shadow: none;
}

:where(html:not([data-ui-theme="warm"])) #tab-basic .basic-display-checkbox:focus-visible {
  border-color: rgba(36, 93, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(36, 93, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

:where(html[data-ui-theme="warm"]) #tab-basic .basic-display-checkbox:focus-visible {
  border-color: var(--accent);
  box-shadow: none; outline: 2px solid var(--focus-ring); outline-offset: 2px;
}

#tab-basic .mini-stat-card input[type="number"],
#tab-basic .mini-stat-card button,
.tight-input {
  min-height: 2.7rem;
  font-size: var(--fs-base);
}

#class,
#class option,
#level,
#level option,
#lifedicen,
#lifedicen option,
#background,
#background option,
#race,
#race option,
#alignment,
#alignment option {
  font-weight: 800;
}

.ability-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem;
}

:where(html:not([data-ui-theme="warm"])) .ability {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
  min-height: 0;
  padding: 0.95rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.25rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(241, 246, 255, 0.88) 100%);
  box-shadow: 0 4px 14px rgba(18, 33, 68, 0.05);
}

:where(html[data-ui-theme="warm"]) .ability {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
  min-height: 0;
  padding: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  box-shadow: none;
}

.ability-title {
  font-size: var(--fs-sm);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  color: var(--text-muted);
}

:where(html:not([data-ui-theme="warm"])) .modifier {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 4.65rem;
  margin: 0;
  border: 1px solid rgba(129, 153, 194, 0.28);
  border-radius: 0.95rem;
  background: linear-gradient(180deg, #f7faff 0%, #eef4ff 100%);
  color: var(--text);
  font-size: var(--fs-3xl);
  font-weight: 900;
}

:where(html[data-ui-theme="warm"]) .modifier {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 4.65rem;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  font-size: var(--fs-3xl);
  font-weight: 900;
}

.modifier-main {
  white-space: nowrap;
}

:where(html:not([data-ui-theme="warm"])) .ability-score {
  appearance: textfield;
  -moz-appearance: textfield;
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(151, 168, 201, 0.34);
  border-radius: 0.95rem;
  background: #fff;
  color: var(--text);
  font-size: var(--fs-xl);
  font-weight: 900;
  text-align: center;
}

:where(html[data-ui-theme="warm"]) .ability-score {
  appearance: textfield;
  -moz-appearance: textfield;
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text);
  font-size: var(--fs-xl);
  font-weight: 900;
  text-align: center;
}

.ability-score::-webkit-inner-spin-button,
.ability-score::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

/* ===== Skills ===== */
.save-grid,
.skill-grid {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.save-grid {
  grid-template-columns: 1fr;
}

.skill-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

#tab-skills > .section {
  container: skill-section / inline-size;
}

@container skill-section (min-width: 18.75rem) {
  .skill-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container skill-section (min-width: 28.5rem) {
  .skill-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .language-base-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container skill-section (min-width: 38.25rem) {
  .skill-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.save-pair,
.skill-cell {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.save-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4rem;
  align-items: stretch;
  padding: 0.8rem 0.9rem;
}

.save-pair label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.save-name {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  font-weight: 800;
  color: var(--text);
}

.save-name .save-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.08;
}

.save-name .save-abbr {
  font-weight: 900;
}

.save-name .save-full,
.skill-name {
  color: var(--text-body);
}

.save-pair input[type="text"],
.save-pair input[type="number"] {
  width: 100%;
  min-width: 0;
  margin: 0;
  text-align: center;
  font-size: var(--fs-xl);
  font-weight: 800;
}

.save-pair input[type="number"] {
  min-height: 3rem;
}

.skill-cell {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.5rem;
  box-shadow: none;
}

.skill-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.5rem;
  align-items: center;
  gap: 0.5rem;
}

.skill-control-row input[type="text"] {
  height: 2.75rem;
  min-height: 2.75rem;
  padding: 0.25rem;
  min-width: 0;
  margin: 0;
  text-align: center;
  font-size: var(--fs-xl);
  font-weight: 800;
  background: var(--surface-strong);
}

.skill-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.25rem;
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 800;
  line-height: 1.4;
}

.skill-ability {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 400;
}

.skill-rank-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.skill-rank-target {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 1.75rem;
  min-height: 2.75rem;
  margin: 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.skill-rank-target[hidden] {
  display: none;
}

.skill-rank-target:hover {
  background: var(--accent-soft);
}

.skill-rank-controls input[type="checkbox"] {
  flex: 0 0 20px;
  width: 20px;
  min-width: 20px;
  height: 20px;
  cursor: pointer;
}

.skill-legend {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 0.6rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-size: var(--fs-md);
  font-weight: 800;
}

.skill-action-hint {
  margin: 0.6rem 0 0;
  font-size: var(--fs-sm);
  line-height: 1.45;
  text-align: left;
}

.legend-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

:where(html:not([data-ui-theme="warm"])) .legend-box,
:where(html:not([data-ui-theme="warm"])) .legend-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 2px solid #667085;
  background: #fff;
}

:where(html[data-ui-theme="warm"]) .legend-box,
:where(html[data-ui-theme="warm"]) .legend-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  background: var(--surface-strong);
}

.legend-circle {
  border-radius: 999px;
}

#tab-skills > .section:nth-of-type(2) > div[style*="font-size: 0.92em"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: var(--fs-base);
  font-weight: 700;
  line-height: 1.45;
}

:where(html:not([data-ui-theme="warm"])) .circle-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-left: 0;
  border: 2px solid #7a8697;
  border-radius: 50%;
  background: #fff;
  vertical-align: middle;
  cursor: pointer;
  position: relative;
  flex: 0 0 auto;
}

:where(html[data-ui-theme="warm"]) .circle-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-left: 0;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--surface-strong);
  vertical-align: middle;
  cursor: pointer;
  position: relative;
  flex: 0 0 auto;
}

:where(html:not([data-ui-theme="warm"])) .circle-checkbox:checked {
  border-color: #4a6cf7;
  background: #4a6cf7;
  box-shadow: inset 0 0 0 4px #fff;
}

:where(html[data-ui-theme="warm"]) .circle-checkbox:checked {
  border-color: var(--accent);
  background: var(--action-fill);
  box-shadow: none;
}

html[data-ui-theme="warm"][data-theme="dark"] .circle-checkbox {
  border-color: var(--border-strong);
}

html[data-ui-theme="warm"][data-theme="dark"] .circle-checkbox:checked {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 4px var(--surface-strong);
}

/* ===== Actions / Conditions / Equipment ===== */
.condition-display-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

:where(html:not([data-ui-theme="warm"])) .condition-display-card {
  padding: 12px;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 12px;
}

:where(html[data-ui-theme="warm"]) .condition-display-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.condition-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: var(--fs-md);
  font-weight: 700;
}

.condition-title-row span {
  color: var(--text-muted);
  font-weight: 600;
}

.condition-display-card ul {
  margin: 0;
  padding-left: 18px;
}

:where(html:not([data-ui-theme="warm"])) #condition-button-grid .active-condition {
  background: var(--accent-soft);
  border-color: #b8c8ff;
  color: #2447c7;
}

:where(html[data-ui-theme="warm"]) #condition-button-grid .active-condition {
  background: var(--accent-soft);
  border-color: var(--border);
  color: var(--accent);
}

:where(html:not([data-ui-theme="warm"])) .action-help {
  margin-bottom: 14px;
  padding: 0.9rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: none;
}

:where(html[data-ui-theme="warm"]) .action-help {
  margin-bottom: 14px;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: none;
}

:where(html:not([data-ui-theme="warm"])) .action-help table {
  width: 100%;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
}

:where(html[data-ui-theme="warm"]) .action-help table {
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

.action-help th,
.action-help td {
  padding: 9px 8px;
}

:where(html:not([data-ui-theme="warm"])) .action-help th {
  background: #eef3ff;
}

:where(html[data-ui-theme="warm"]) .action-help th {
  background: var(--surface-soft);
}

.action-grid-pretty {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action-grid-pretty button {
  min-height: 2.75rem;
  padding: 0.5rem 0.4rem;
  font-size: var(--fs-sm);
}

.action-description,
.action-grid-panel {
  margin-top: 10px;
}

.action-attack-block {
  margin-bottom: 0.95rem;
}

.action-attack-block > h3 {
  margin-bottom: 0.8rem;
}

.action-command-card {
  position: relative;
  overflow: hidden;
  padding: 0;
  background: var(--surface-strong);
}

.action-command-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--accent-gradient);
}

.action-command-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.05rem 0.9rem;
}

.action-command-heading h3 {
  margin-top: 0.18rem;
  font-size: var(--fs-xl);
}

.action-command-eyebrow {
  display: block;
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 900;
  letter-spacing: 0.12em;
}

.action-mode-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  margin-inline: 1.05rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  overflow: hidden;
}

.action-mode-tab {
  position: relative;
  min-height: 3rem;
  padding: 0.65rem 0.35rem;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 850;
}

.action-mode-tab:last-child {
  border-right: 0;
}

:where(html:not([data-ui-theme="warm"])) .action-mode-tab::after {
  content: "";
  position: absolute;
  right: 22%;
  bottom: 0;
  left: 22%;
  height: 3px;
  border-radius: 999px 999px 0 0;
  background: var(--accent);
  opacity: 0;
  transform: scaleX(0.45);
  transition: opacity 0.18s ease, transform 0.2s ease;
}

:where(html[data-ui-theme="warm"]) .action-mode-tab::after {
  content: "";
  position: absolute;
  right: 22%;
  bottom: 0;
  left: 22%;
  height: 3px;
  border-radius: var(--radius-sm);
  background: var(--action-fill);
  opacity: 0;
  transform: scaleX(0.45);
  transition: opacity 120ms ease, transform 120ms ease;
}

.action-mode-tab.is-active {
  background: var(--surface-strong);
  color: var(--text);
}

.action-mode-tab.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

@media (hover: hover) and (pointer: fine) {
  .action-mode-tab:hover,
  .action-mode-tab.is-active:hover {
    transform: none;
    border-color: transparent;
    background: var(--surface-strong);
    color: var(--text);
    box-shadow: none;
  }
}

.action-mode-panel {
  padding: 1rem 1.05rem 1.1rem;
}

.action-mode-context {
  display: flex;
  align-items: baseline;
  gap: 0.55rem 0.8rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.action-mode-context strong {
  flex: 0 0 auto;
  color: var(--text);
  font-size: var(--fs-sm);
}

:where(html:not([data-ui-theme="warm"])) .action-description {
  min-height: 6.25rem;
  margin: 0;
  padding: 0.9rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--text-body);
  font-size: var(--fs-md);
  line-height: 1.7;
  transition: border-color 0.2s ease, background 0.2s ease;
}

:where(html[data-ui-theme="warm"]) .action-description {
  min-height: 6.25rem;
  margin: 0;
  padding: 0.9rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--text-body);
  font-size: var(--fs-md);
  line-height: 1.7;
  transition: border-color 120ms ease, background 120ms ease;
}

.action-description-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.action-description-heading strong {
  color: var(--text);
  font-size: var(--fs-base);
}

.action-description-heading span {
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 800;
}

.action-description-copy {
  white-space: pre-line;
}

.action-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.8rem;
}

.action-option-grid[data-action-mode="basic"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.action-option-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 3rem;
  padding: 0.55rem 0.65rem;
  box-shadow: none;
  font-size: var(--fs-sm);
  animation: action-option-enter 0.2s ease backwards;
}

.action-option-button:nth-child(n + 5) {
  animation-delay: 0.025s;
}

.action-option-button:nth-child(n + 9) {
  animation-delay: 0.05s;
}

.action-option-button.is-character-option {
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
  text-align: center;
}

.action-option-button.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.action-option-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.action-option-source {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 800;
}

@keyframes action-option-enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .action-mode-tab::after,
  .action-option-button {
    animation: none;
    transition: none;
  }
}

#tab-skills > .section > button,
#tab-actions > .section > button {
  margin-bottom: 0.75rem;
}

:where(html:not([data-ui-theme="warm"])) .weapon-automation-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0 0 0.9rem;
  padding: 0.9rem 0.95rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.25rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(241, 246, 255, 0.88) 100%);
  box-shadow: 0 4px 14px rgba(18, 33, 68, 0.05);
  cursor: pointer;
}

:where(html[data-ui-theme="warm"]) .weapon-automation-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0 0 0.9rem;
  padding: 0.9rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  box-shadow: none;
  cursor: pointer;
}

.weapon-automation-toggle > span {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.weapon-automation-toggle strong {
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 900;
}

.weapon-automation-toggle small {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
}

:where(html:not([data-ui-theme="warm"])) .weapon-automation-toggle input {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 2.8rem;
  height: 1.55rem;
  margin: 0;
  border: 1px solid rgba(126, 148, 198, 0.4);
  border-radius: 999px;
  background: rgba(151, 168, 201, 0.35);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

:where(html[data-ui-theme="warm"]) .weapon-automation-toggle input {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 2.8rem;
  height: 1.55rem;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--accent-soft);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

:where(html:not([data-ui-theme="warm"])) .weapon-automation-toggle input::after {
  content: "";
  position: absolute;
  top: 0.17rem;
  left: 0.18rem;
  width: 1.08rem;
  height: 1.08rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(18, 33, 68, 0.2);
  transition: transform 160ms ease;
}

:where(html[data-ui-theme="warm"]) .weapon-automation-toggle input::after {
  content: "";
  position: absolute;
  top: 0.17rem;
  left: 0.18rem;
  width: 1.08rem;
  height: 1.08rem;
  border-radius: 50%;
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease;
}

:where(html:not([data-ui-theme="warm"])) .weapon-automation-toggle input:checked { border-color: var(--accent); background: var(--accent); }

:where(html[data-ui-theme="warm"]) .weapon-automation-toggle input:checked { border-color: var(--accent); background: var(--action-fill); }
.weapon-automation-toggle input:checked::after { transform: translateX(1.22rem); }
:where(html:not([data-ui-theme="warm"])) .weapon-automation-toggle input:focus-visible { outline: 3px solid rgba(36, 93, 255, 0.3); outline-offset: 2px; }
:where(html[data-ui-theme="warm"]) .weapon-automation-toggle input:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

.weapon-attack-grid {
  display: grid;
  gap: 0.9rem;
}

:where(html:not([data-ui-theme="warm"])) .weapon-attack-card,
:where(html:not([data-ui-theme="warm"])) .equipment-loadout-summary {
  min-width: 0;
  padding: 0.95rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.25rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(241, 246, 255, 0.88) 100%);
  box-shadow: 0 4px 14px rgba(18, 33, 68, 0.05);
}

:where(html[data-ui-theme="warm"]) .weapon-attack-card,
:where(html[data-ui-theme="warm"]) .equipment-loadout-summary {
  min-width: 0;
  padding: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  box-shadow: none;
}

.weapon-attack-card h4,
.equipment-loadout-summary h4 {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.weapon-attack-card h4 {
  position: relative;
  min-height: 1.35rem;
}

:where(html:not([data-ui-theme="warm"])) .weapon-mastery-badge {
  position: absolute;
  top: 50%;
  left: 5.3rem;
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0.18rem 0.55rem;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 128, 42, 0.58);
  border-radius: 999px;
  background: rgba(255, 128, 42, 0.12);
  color: #b84f08;
  box-shadow: none;
  font-size: var(--fs-xs);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0;
  cursor: pointer;
}

:where(html[data-ui-theme="warm"]) .weapon-mastery-badge {
  position: absolute;
  top: 50%;
  left: 5.3rem;
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0.18rem 0.55rem;
  transform: translateY(-50%);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  color: var(--warning);
  box-shadow: none;
  font-size: var(--fs-xs);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0;
  cursor: pointer;
}

.weapon-mastery-badge[hidden] {
  display: none;
}

.weapon-mastery-badge:hover,
.weapon-mastery-badge:focus-visible,
.weapon-mastery-badge:active {
  transform: translateY(-50%);
}

.weapon-attack-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(4.25rem, 0.72fr) minmax(5.25rem, 0.9fr);
  gap: 0.55rem;
}

.weapon-attack-fields label {
  display: grid;
  gap: 0.28rem;
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 900;
  white-space: nowrap;
}

.weapon-attack-free-note {
  grid-column: 1 / -1;
}

:where(html:not([data-ui-theme="warm"])) .weapon-attack-fields input {
  min-height: 3rem;
  margin: 0;
  padding: 0.7rem 0.55rem;
  border: 1px solid rgba(151, 168, 201, 0.34);
  border-radius: 0.95rem;
  background: #fff;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 800;
  text-align: center;
}

:where(html[data-ui-theme="warm"]) .weapon-attack-fields input {
  min-height: 3rem;
  margin: 0;
  padding: 0.7rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 800;
  text-align: center;
}

:where(html:not([data-ui-theme="warm"])) .weapon-attack-fields input.is-automated {
  background: linear-gradient(180deg, #f7faff 0%, #eef4ff 100%);
  color: var(--accent);
}

:where(html[data-ui-theme="warm"]) .weapon-attack-fields input.is-automated {
  background: var(--surface-soft);
  color: var(--accent);
}

:where(html:not([data-ui-theme="warm"])) .weapon-attack-fields input.is-calculation-enabled {
  cursor: pointer;
  text-decoration: underline dotted rgba(40, 82, 214, 0.55);
  text-underline-offset: 0.18em;
}

:where(html[data-ui-theme="warm"]) .weapon-attack-fields input.is-calculation-enabled {
  cursor: pointer;
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 0.18em;
}

:where(html:not([data-ui-theme="warm"])) .weapon-attack-fields .weapon-attack-free-note {
  background: #fff;
  color: var(--text);
  text-align: left;
}

:where(html[data-ui-theme="warm"]) .weapon-attack-fields .weapon-attack-free-note {
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
}

.equipment-loadout-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

#tab-equipment .equipment-loadout-field--armor {
  grid-column: 1 / -1;
}

.equipment-loadout-intro {
  max-width: 34rem;
  margin: -0.15rem 0 0.9rem;
  color: var(--text-body);
  font-size: var(--fs-sm);
  line-height: 1.55;
}

.armor-proficiency-note {
  margin: -0.4rem 0 0.75rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.55;
}

#tab-equipment .equipment-loadout-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 0.35rem;
  min-width: 0;
  margin: 0;
}

#tab-equipment .equipment-loadout-field label {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 900;
  white-space: nowrap;
}

#tab-equipment .equipment-loadout-field select {
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  padding: 0.65rem 0.75rem;
  font-size: var(--fs-sm);
}

.equipment-alternate-main-option {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 0.55rem;
  min-height: 2rem;
  margin-top: 0.05rem;
  color: var(--text-body);
  font-size: var(--fs-sm);
  font-weight: 750;
  line-height: 1.45;
  cursor: pointer;
}

.equipment-mode-options {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.25rem;
}

.equipment-alternate-main-option input {
  flex: 0 0 auto;
}

.equipment-loadout-summary {
  margin-top: 0.9rem;
}

.equipment-loadout-summary-content {
  display: grid;
  gap: 0.65rem;
}

:where(html:not([data-ui-theme="warm"])) .equipment-summary-row {
  display: grid;
  grid-template-columns: minmax(4.25rem, auto) minmax(0, 1fr);
  gap: 0.2rem 0.55rem;
  align-items: baseline;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(129, 153, 194, 0.22);
  border-radius: 0.95rem;
  background: linear-gradient(180deg, #f7faff 0%, #eef4ff 100%);
}

:where(html[data-ui-theme="warm"]) .equipment-summary-row {
  display: grid;
  grid-template-columns: minmax(4.25rem, auto) minmax(0, 1fr);
  gap: 0.2rem 0.55rem;
  align-items: baseline;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.equipment-summary-row strong {
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 900;
}

.equipment-summary-row small {
  color: var(--text-body);
  font-size: var(--fs-sm);
  font-weight: 700;
}

:where(html:not([data-ui-theme="warm"])) .equipment-summary-row .equipment-proficiency-warning {
  color: #c62828;
}

:where(html[data-ui-theme="warm"]) .equipment-summary-row .equipment-proficiency-warning {
  color: var(--warning);
}

.weapon-rule-link {
  display: inline;
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  font: inherit;
  line-height: inherit;
  text-align: inherit;
  text-decoration: underline dotted currentColor;
  text-underline-offset: 0.16em;
  cursor: pointer;
}

.weapon-rule-link:hover,
.weapon-rule-link:focus-visible {
  background: transparent;
  color: var(--accent-strong);
  outline-offset: 2px;
}

.equipment-summary-row small:empty {
  display: none;
}

:where(html:not([data-ui-theme="warm"])) .equipment-current-ac {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(151, 168, 201, 0.26);
  position: relative;
}

:where(html[data-ui-theme="warm"]) .equipment-current-ac {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  position: relative;
}

.equipment-current-ac span {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 900;
}

.equipment-current-ac strong {
  min-width: 3.5rem;
  color: var(--accent);
  font-size: var(--fs-2xl);
  font-weight: 900;
  text-align: center;
}

.equipment-untrained-consequence {
  position: absolute;
  top: 50%;
  left: 0;
  max-width: calc(100% - 8.5rem);
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
}

:where(html:not([data-ui-theme="warm"])) #attack-calculation-popup {
  position: fixed;
  z-index: 10020;
  display: none;
  width: min(18rem, calc(100vw - 20px));
  padding: 0.9rem;
  border: 1px solid rgba(114, 133, 176, 0.28);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.98);
  color: var(--text-body);
  box-shadow: 0 18px 38px rgba(17, 31, 63, 0.18);
}

:where(html[data-ui-theme="warm"]) #attack-calculation-popup {
  position: fixed;
  z-index: 10020;
  display: none;
  width: min(18rem, calc(100vw - 20px));
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text-body);
  box-shadow: var(--shadow-strong);
}

.attack-calculation-title {
  margin-bottom: 0.6rem;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 900;
}

.attack-calculation-rows {
  display: grid;
  gap: 0.4rem;
}

.attack-calculation-rows div,
.attack-calculation-total {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.attack-calculation-rows span,
.attack-calculation-total span {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.attack-calculation-rows strong {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 900;
  text-align: right;
}

:where(html:not([data-ui-theme="warm"])) .attack-calculation-total {
  align-items: baseline;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(151, 168, 201, 0.3);
}

:where(html[data-ui-theme="warm"]) .attack-calculation-total {
  align-items: baseline;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.attack-calculation-total strong {
  color: var(--accent);
  font-size: var(--fs-xl);
  font-weight: 900;
}

:where(html:not([data-ui-theme="warm"])) .money-section {
  margin-top: 0.95rem;
  padding: 0.9rem;
  border: 1px solid rgba(128, 151, 199, 0.26);
  border-radius: 1rem;
  background: rgba(244, 248, 255, 0.78);
}

:where(html[data-ui-theme="warm"]) .money-section {
  margin-top: 0.95rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

.money-title {
  margin: 0;
  white-space: nowrap;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 850;
}

.money-balance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.money-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  min-width: 0;
}

.money-detail-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 750;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

:where(html:not([data-ui-theme="warm"])) .money-detail-toggle input {
  appearance: none;
  position: relative;
  width: 2.8rem;
  height: 1.55rem;
  margin: 0;
  border: 1px solid rgba(126, 148, 198, 0.4);
  border-radius: 999px;
  background: rgba(151, 168, 201, 0.35);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

:where(html[data-ui-theme="warm"]) .money-detail-toggle input {
  appearance: none;
  position: relative;
  width: 2.8rem;
  height: 1.55rem;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--accent-soft);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

:where(html:not([data-ui-theme="warm"])) .money-detail-toggle input::after {
  content: "";
  position: absolute;
  top: 0.17rem;
  left: 0.18rem;
  width: 1.08rem;
  height: 1.08rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(18, 33, 68, 0.2);
  transition: transform 160ms ease;
}

:where(html[data-ui-theme="warm"]) .money-detail-toggle input::after {
  content: "";
  position: absolute;
  top: 0.17rem;
  left: 0.18rem;
  width: 1.08rem;
  height: 1.08rem;
  border-radius: 50%;
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease;
}

:where(html:not([data-ui-theme="warm"])) .money-detail-toggle input:checked { border-color: var(--accent); background: var(--accent); }

:where(html[data-ui-theme="warm"]) .money-detail-toggle input:checked { border-color: var(--accent); background: var(--action-fill); }
.money-detail-toggle input:checked::after { transform: translateX(1.22rem); }
.money-detail-toggle input:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

.money-secondary-btn {
  width: auto;
  min-height: 2.2rem;
  margin: 0;
  padding: 0.42rem 0.72rem;
  font-size: var(--fs-sm);
  font-weight: 800;
  white-space: nowrap;
}

#money-adjust-toggle,
#money-log-toggle { flex: 0 0 auto; }

.money-quick-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-top: 0.65rem;
}

.money-balance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.money-balance-details.is-hidden,
.money-modal.is-hidden { display: none; }

.money-balance-details { margin-top: 0.75rem; }

:where(html:not([data-ui-theme="warm"])) .money-balance-grid > div {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.8rem 0.55rem;
  border: 1px solid rgba(126, 148, 198, 0.25);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.88);
}

:where(html[data-ui-theme="warm"]) .money-balance-grid > div {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.8rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

.money-balance-grid span {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.money-balance-grid strong { color: var(--text); font-size: var(--fs-xl); font-variant-numeric: tabular-nums; }

.money-weight-summary {
  margin: 0.55rem 0 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-align: right;
}

.money-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 0.65rem;
  align-items: start;
}

.money-grid label,
.money-transaction > label {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--text);
}

.money-modal-card h4 { margin: 0 3rem 0.75rem 0; color: var(--text); }
.money-adjust-grid { margin-bottom: 0.65rem; }
.money-panel-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.65rem; }

.money-type-toggle {
  display: flex;
  gap: 0.4rem;
  margin: 0;
}

.money-type-toggle button {
  width: auto;
  min-height: 2.2rem;
  margin: 0;
  padding: 0.42rem 0.72rem;
  font-size: var(--fs-sm);
  font-weight: 800;
  white-space: nowrap;
}
:where(html:not([data-ui-theme="warm"])) .money-type-toggle button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
:where(html[data-ui-theme="warm"]) .money-type-toggle button.is-active {
  border-color: var(--accent);
  background: var(--action-fill);
  color: var(--on-accent);
}

.money-amount-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(6.5rem, 0.4fr);
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.money-amount-row input,
.money-amount-row select { margin: 0; }
.money-mixed-details { margin: 0.4rem 0 0.7rem; }
.money-mixed-details summary { cursor: pointer; color: var(--accent); font-weight: 750; }
.money-mixed-details .money-grid { margin-top: 0.6rem; }
.money-mixed-details p { margin: 0.45rem 0 0; color: var(--text-muted); font-size: var(--fs-xs); }
.money-submit-btn { width: 100%; margin: 0; }
:where(html:not([data-ui-theme="warm"])) .money-submit-btn,
:where(html:not([data-ui-theme="warm"])) #money-adjust-save { background: var(--accent); color: #fff; }
:where(html[data-ui-theme="warm"]) .money-submit-btn,
:where(html[data-ui-theme="warm"]) #money-adjust-save { background: var(--action-fill); color: var(--on-accent); }
:where(html:not([data-ui-theme="warm"])) .money-submit-btn:hover,
:where(html:not([data-ui-theme="warm"])) #money-adjust-save:hover { background: var(--accent-strong); }
:where(html[data-ui-theme="warm"]) .money-submit-btn:hover,
:where(html[data-ui-theme="warm"]) #money-adjust-save:hover { background: var(--action-hover); }

.money-log-list {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-body);
  font-size: var(--fs-sm);
}

:where(html:not([data-ui-theme="warm"])) .money-log-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.75);
}

:where(html[data-ui-theme="warm"]) .money-log-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

.money-log-list li > span:last-child { flex: 0 0 auto; font-weight: 800; }

.money-modal-card input,
.money-grid input {
  min-height: 2.7rem;
  margin: 0;
  padding: 0.6rem 0.72rem;
  font-weight: 700;
}

:where(html:not([data-ui-theme="warm"])) .money-modal {
  position: fixed;
  z-index: 1200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(13, 25, 52, 0.52);
}

:where(html[data-ui-theme="warm"]) .money-modal {
  position: fixed;
  z-index: 1200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: var(--overlay);
}

:where(html:not([data-ui-theme="warm"])) .money-modal-card {
  position: relative;
  width: min(100%, 34rem);
  max-height: min(88vh, 46rem);
  overflow-y: auto;
  padding: 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
}

:where(html[data-ui-theme="warm"]) .money-modal-card {
  position: relative;
  width: min(100%, 34rem);
  max-height: min(88vh, 46rem);
  overflow-y: auto;
  padding: 1.1rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
}

.money-modal-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  font-size: 1.65rem;
  line-height: 1;
}

.money-modal-card > label {
  display: grid;
  gap: 0.35rem;
  margin: 0 0 0.4rem;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 800;
}

.money-modal-card > input + label { margin-top: 0.75rem; }

#money-log-modal .money-log-list { max-height: 60vh; overflow-y: auto; }
#money-log-modal .money-balance-header { padding-right: 3.25rem; }

.money-log-limit-note {
  margin: -0.2rem 0 0.75rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
}

:where(html:not([data-ui-theme="warm"])) .money-summary {
  margin: 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(129, 153, 194, 0.28);
  border-radius: 0.95rem;
  background: linear-gradient(180deg, #f7faff 0%, #eef4ff 100%);
  color: var(--text);
  font-size: var(--fs-xl);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

:where(html[data-ui-theme="warm"]) .money-summary {
  margin: 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  font-size: var(--fs-xl);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

:where(html:not([data-ui-theme="warm"])) .equipment-purchase-link {
  display: inline;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #315fc4;
  font: inherit;
  font-weight: 800;
  line-height: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  vertical-align: baseline;
}

:where(html[data-ui-theme="warm"]) .equipment-purchase-link {
  display: inline;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--accent);
  font: inherit;
  font-weight: 800;
  line-height: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  vertical-align: baseline;
}

:where(html:not([data-ui-theme="warm"])) .equipment-purchase-link:hover,
:where(html:not([data-ui-theme="warm"])) .equipment-purchase-link:focus-visible {
  background: transparent;
  box-shadow: none;
  color: #173c94;
}

:where(html[data-ui-theme="warm"]) .equipment-purchase-link:hover,
:where(html[data-ui-theme="warm"]) .equipment-purchase-link:focus-visible {
  background: transparent;
  box-shadow: none;
  color: var(--accent);
}

:where(html:not([data-ui-theme="warm"])) .equipment-purchase-modal {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 24, 48, 0.55);
}

:where(html[data-ui-theme="warm"]) .equipment-purchase-modal {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: none;
  place-items: center;
  padding: 1rem;
  background: var(--overlay);
}

.equipment-purchase-modal.open {
  display: grid;
}

:where(html:not([data-ui-theme="warm"])) .equipment-purchase-card {
  width: min(22rem, 100%);
  padding: 1.25rem;
  border: 1px solid rgba(126, 148, 198, 0.45);
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 18px 45px rgba(18, 32, 70, 0.24);
  text-align: center;
}

:where(html[data-ui-theme="warm"]) .equipment-purchase-card {
  width: min(22rem, 100%);
  padding: 1.25rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
  text-align: center;
}

.equipment-purchase-card h3 {
  margin: 0 0 0.55rem;
}

.equipment-purchase-description {
  margin: 0 0 1rem;
  color: var(--text-body);
  font-weight: 700;
}

:where(html:not([data-ui-theme="warm"])) .equipment-purchase-balance {
  margin: -0.35rem 0 1rem;
  padding: 0.55rem 0.7rem;
  border-radius: 0.7rem;
  background: rgba(232, 240, 255, 0.9);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 800;
}

:where(html[data-ui-theme="warm"]) .equipment-purchase-balance {
  margin: -0.35rem 0 1rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 800;
}

.equipment-purchase-quantity-label {
  display: grid;
  grid-template-columns: 1fr minmax(5rem, 7rem);
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
  color: var(--text);
  font-weight: 800;
  text-align: left;
}

.equipment-purchase-quantity {
  min-height: 2.5rem;
  margin: 0;
  text-align: center;
}

.equipment-purchase-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.equipment-purchase-actions button {
  margin: 0;
}

.equipment-purchase-free {
  grid-column: 1 / -1;
}

#tab-actions .form-row.small-text {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

:where(html:not([data-ui-theme="warm"])) #tab-actions .form-row.small-text input {
  min-height: 2.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: #fff;
  font-size: var(--fs-md);
  font-weight: 750;
  text-align: left;
  box-shadow: none;
}

:where(html[data-ui-theme="warm"]) #tab-actions .form-row.small-text input {
  min-height: 2.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  font-size: var(--fs-md);
  font-weight: 750;
  text-align: left;
  box-shadow: none;
}

/* ===== Spells / Feats ===== */
:where(html:not([data-ui-theme="warm"])) .spell-toolbar,
:where(html:not([data-ui-theme="warm"])) .equipment-toolbar {
  width: 100%;
  margin-top: 0.32rem;
  padding: 0.45rem 0 0;
  border-top: 1px solid rgba(112, 134, 184, 0.16);
  background: transparent;
  box-shadow: none;
}

/* ===== Spells / Feats ===== */
:where(html[data-ui-theme="warm"]) .spell-toolbar,
:where(html[data-ui-theme="warm"]) .equipment-toolbar {
  width: 100%;
  margin-top: 0.32rem;
  padding: 0.45rem 0 0;
  border-top: 1px solid var(--border);
  background: transparent;
  box-shadow: none;
}

.spell-toolbar-row,
.equipment-toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: nowrap;
  width: 100%;
  min-width: 0;
}

.spell-search-controls {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 0.35rem;
  margin: 0;
  min-width: 0;
}

.spell-toolbar #spell-search,
.equipment-toolbar #equipment-search {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 8px 48px 8px 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spell-toolbar #spell-search {
  padding-right: 12px;
}

:where(html:not([data-ui-theme="warm"])) .spell-search-results {
  width: 100%;
  max-width: 100%;
  max-height: min(42vh, 19rem);
  margin-top: 0.55rem;
  padding: 0.65rem 0.75rem;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(112, 134, 184, 0.2);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.96);
  overscroll-behavior: contain;
}

:where(html[data-ui-theme="warm"]) .spell-search-results {
  width: 100%;
  max-width: 100%;
  max-height: min(42vh, 19rem);
  margin-top: 0.55rem;
  padding: 0.65rem 0.75rem;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  overscroll-behavior: contain;
}

.spell-search-summary {
  margin: 0 0 0.45rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.spell-search-result-list {
  display: grid;
  gap: 0;
  min-width: 0;
}

:where(html:not([data-ui-theme="warm"])) .spell-search-result-item {
  min-width: 0;
  padding: 0.45rem 0;
  overflow-wrap: anywhere;
  border-top: 1px solid rgba(112, 134, 184, 0.14);
  line-height: 1.45;
  white-space: normal;
}

:where(html[data-ui-theme="warm"]) .spell-search-result-item {
  min-width: 0;
  padding: 0.45rem 0;
  overflow-wrap: anywhere;
  border-top: 1px solid var(--border);
  line-height: 1.45;
  white-space: normal;
}

.spell-search-result-item:first-child {
  border-top: 0;
}

.spell-search-result-name {
  display: inline;
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  line-height: inherit;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.spell-search-result-name:hover,
.spell-search-result-name:focus-visible {
  background: transparent;
  color: var(--accent-strong);
  box-shadow: none;
}

.equipment-search-count {
  flex: 0 0 auto;
  min-width: 3.8rem;
  color: var(--text-muted);
  font-size: var(--fs-md);
  text-align: center;
  white-space: nowrap;
}

.equipment-search-count:empty {
  display: none;
}

.equipment-search-input-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

:where(html:not([data-ui-theme="warm"])) .equipment-search-clear {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #d7deea;
  background: #fff;
  color: #667085;
  box-shadow: none;
  line-height: 1;
  margin-bottom: 0;
}

:where(html[data-ui-theme="warm"]) .equipment-search-clear {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-muted);
  box-shadow: none;
  line-height: 1;
  margin-bottom: 0;
}

.equipment-search-clear.is-hidden {
  display: none;
}

:where(html:not([data-ui-theme="warm"])) .equipment-search-results {
  width: 100%;
  max-height: min(42vh, 19rem);
  margin-top: 0.55rem;
  padding: 0.65rem 0.75rem;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(112, 134, 184, 0.2);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.96);
  overscroll-behavior: contain;
}

:where(html[data-ui-theme="warm"]) .equipment-search-results {
  width: 100%;
  max-height: min(42vh, 19rem);
  margin-top: 0.55rem;
  padding: 0.65rem 0.75rem;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  overscroll-behavior: contain;
}

.equipment-search-summary {
  margin: 0 0 0.45rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.equipment-search-result-list {
  display: grid;
}

:where(html:not([data-ui-theme="warm"])) .equipment-search-result-item {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.5rem 0;
  border-top: 1px solid rgba(112, 134, 184, 0.14);
}

:where(html[data-ui-theme="warm"]) .equipment-search-result-item {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
}

.equipment-search-result-item:first-child {
  border-top: 0;
}

:where(html:not([data-ui-theme="warm"])) .equipment-search-result-category {
  flex: 0 0 auto;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 750;
}

:where(html[data-ui-theme="warm"]) .equipment-search-result-category {
  flex: 0 0 auto;
  padding: 0.12rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 750;
}

.equipment-search-result-name {
  display: inline;
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-wrap: anywhere;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  line-height: 1.45;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.equipment-search-result-name:hover,
.equipment-search-result-name:focus-visible {
  background: transparent;
  box-shadow: none;
  color: var(--accent-strong);
}

html.equipment-detail-open,
html.equipment-detail-open body {
  overflow: hidden;
}

:where(html:not([data-ui-theme="warm"])) #equipment-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 18, 40, 0.72);
  backdrop-filter: blur(4px);
}

:where(html[data-ui-theme="warm"]) #equipment-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: var(--overlay-strong);

}

#equipment-detail-modal.open {
  display: flex;
}

:where(html:not([data-ui-theme="warm"])) .equipment-detail-modal__card {
  display: flex;
  flex-direction: column;
  width: min(100%, 36rem);
  max-height: calc(100dvh - 2.5rem);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 1.15rem;
  background: var(--surface-strong);
  color: var(--text-body);
  box-shadow: 0 28px 80px rgba(17, 31, 63, 0.32);
}

:where(html[data-ui-theme="warm"]) .equipment-detail-modal__card {
  display: flex;
  flex-direction: column;
  width: min(100%, 36rem);
  max-height: calc(100dvh - 2.5rem);
  overflow: hidden;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  color: var(--text-body);
  box-shadow: var(--shadow-strong);
}

.equipment-detail-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.9rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.equipment-detail-modal__header h2 {
  margin: 0.2rem 0 0;
  color: var(--text);
  font-size: var(--fs-xl);
}

.equipment-detail-modal__category {
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.06em;
}

:where(html:not([data-ui-theme="warm"])) .equipment-detail-modal__close {
  flex: 0 0 2.5rem;
  width: 2.5rem;
  min-width: 2.5rem;
  height: 2.5rem;
  min-height: 2.5rem;
  margin: 0;
  padding: 0;
  border-radius: 0.7rem;
  box-shadow: none;
  font-size: 1.35rem;
  line-height: 1;
}

:where(html[data-ui-theme="warm"]) .equipment-detail-modal__close {
  flex: 0 0 2.5rem;
  width: 2.5rem;
  min-width: 2.5rem;
  height: 2.5rem;
  min-height: 2.5rem;
  margin: 0;
  padding: 0;
  border-radius: var(--radius-lg);
  box-shadow: none;
  font-size: 1.35rem;
  line-height: 1;
}

.equipment-detail-modal__content {
  padding: 1.15rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.equipment-detail-modal__actions {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  justify-content: flex-end;
  gap: 0.65rem;
  padding: 0.9rem 1.15rem;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
}

.equipment-detail-modal__actions[hidden] {
  display: none;
}

.equipment-detail-modal__actions select {
  flex: 1 1 12rem;
  min-width: 0;
}

.equipment-detail-modal__actions button {
  width: auto;
  min-width: 6rem;
  margin: 0;
}

.equipment-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

:where(html:not([data-ui-theme="warm"])) .equipment-detail-tags span {
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(40, 82, 214, 0.18);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--fs-sm);
  font-weight: 700;
}

:where(html[data-ui-theme="warm"]) .equipment-detail-tags span {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.equipment-detail-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0;
}

:where(html:not([data-ui-theme="warm"])) .equipment-detail-stats > div {
  min-width: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-soft);
}

:where(html[data-ui-theme="warm"]) .equipment-detail-stats > div {
  min-width: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.equipment-detail-stats dt {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.equipment-detail-stats dd {
  margin: 0.18rem 0 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-weight: 750;
}

.equipment-detail-description {
  white-space: pre-wrap;
  line-height: 1.7;
}

.equipment-detail-table {
  margin-top: 1rem;
  overflow-x: auto;
}

.equipment-detail-table table {
  width: 100%;
}

@media (max-width: 480px) {
  #equipment-detail-modal { padding: 0.75rem; }
  .equipment-detail-modal__card { max-height: calc(100dvh - 1.5rem); }
  .equipment-detail-stats { grid-template-columns: 1fr; }
}

.spell-toolbar-actions {
  display: flex;
  gap: 0.6rem;
  flex: 0 0 auto;
  width: auto;
  margin-left: auto;
}

:where(html:not([data-ui-theme="warm"])) .spell-search-button,
:where(html:not([data-ui-theme="warm"])) .spell-toolbar-actions button {
  width: auto;
  box-sizing: border-box;
  height: 50px;
  min-height: 50px;
  max-height: 50px;
  padding: 0 12px;
  margin-bottom: 0;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: none;
}

:where(html[data-ui-theme="warm"]) .spell-search-button,
:where(html[data-ui-theme="warm"]) .spell-toolbar-actions button {
  width: auto;
  box-sizing: border-box;
  height: 50px;
  min-height: 50px;
  max-height: 50px;
  padding: 0 12px;
  margin-bottom: 0;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  box-shadow: none;
}

#tab-spells > .spell-overview-section {
  position: relative;
  z-index: 20;
  overflow: visible;
}

#tab-spells.spell-toolbar-visible {
  padding-top: 3.85rem;
}

#tab-equipment.equipment-toolbar-visible {
  padding-top: 3.85rem;
}

:where(html:not([data-ui-theme="warm"])) #spell-overview-management-wrap {
  margin: 1rem 0 1.15rem;
  padding: 0.95rem 1rem 1rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.05rem;
  background: var(--surface-soft);
}

:where(html[data-ui-theme="warm"]) #spell-overview-management-wrap {
  margin: 1rem 0 1.15rem;
  padding: 0.95rem 1rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

#spell-overview-management-wrap > h3 {
  margin-bottom: 0.8rem;
}

#spell-overview-management-wrap .form-row {
  margin-top: 0.9rem;
  margin-bottom: 0;
}

.spell-capability-warning {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: var(--fs-sm);
  font-weight: 750;
  line-height: 1.55;
}

.spell-capability-warning:not([hidden]) + #spell-slot-management-wrap:not(.is-hidden) {
  margin-top: 0.9rem;
}

.spell-slot-heading {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.spell-slot-heading h3,
.spell-slot-heading .spell-note-muted {
  margin: 0;
}

.equipment-search-block + .equipment-search-block {
  margin-top: 0.7rem;
}

.equipment-search-block table {
  margin-top: 0.35rem;
  width: 100%;
}

.equipment-search-table-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

:where(html:not([data-ui-theme="warm"])) .equipment-search-highlight {
  background: #fff1a8;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

:where(html[data-ui-theme="warm"]) .equipment-search-highlight {
  background: var(--warning-soft);
  color: inherit;
  padding: 0 1px;
  border-radius: var(--radius-sm);
}

.equipment-search-results.is-hidden {
  display: none;
}

#spellbook-card[hidden] { display: none; }
#spellbook-card > summary { display: flex; align-items: center; gap: 10px; }
#spellbook-card > summary::before { flex-shrink: 0; }
#spellbook-manage { margin: 0 0 0 auto; padding: 5px 10px; width: auto; font-size: .85rem; }
.spellbook-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding-top: 10px; }
:where(html:not([data-ui-theme="warm"])) .spellbook-ring { min-width: 0; padding: 8px 10px; border-radius: 12px; }
:where(html[data-ui-theme="warm"]) .spellbook-ring { min-width: 0; padding: 8px 10px; border-radius: var(--radius-sm); }
.spellbook-ring h4 { margin: 0 0 4px; font-size: .9rem; }
.spellbook-names { display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: baseline; }
.spellbook-spell { display: inline; width: auto; min-height: 28px; margin: 0; padding: 1px 0; border: 0; background: transparent; box-shadow: none; transform: none; color: var(--text-body); font: inherit; text-align: left; cursor: pointer; }
:where(html:not([data-ui-theme="warm"])) .spellbook-spell.is-prepared { color: #b3262e; }
:where(html[data-ui-theme="warm"]) .spellbook-spell.is-prepared { color: var(--danger); }
:where(html:not([data-ui-theme="warm"])) [data-theme="dark"] .spellbook-spell.is-prepared { color: #ff9399; }
:where(html[data-ui-theme="warm"]) [data-theme="dark"] .spellbook-spell.is-prepared { color: var(--danger); }
.spellbook-spell:hover { text-decoration: underline; background: transparent; }
.spellbook-spell:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.spellbook-legend { margin: 8px 0 0; font-size: .78rem; }
.app-dialog[data-variant="spellbook"] .app-dialog__surface { width: min(740px, 100%); }
.app-dialog[data-variant="spellbook"] .app-dialog__body { padding: 10px 14px; }
:where(html:not([data-ui-theme="warm"])) .app-dialog[data-variant="spellbook"] .app-dialog__button--primary:hover,
:where(html:not([data-ui-theme="warm"])) .app-dialog[data-variant="spellbook"] .app-dialog__button--primary:focus-visible { background: var(--accent-strong); color: var(--on-accent); }
:where(html[data-ui-theme="warm"]) .app-dialog[data-variant="spellbook"] .app-dialog__button--primary:hover,
:where(html[data-ui-theme="warm"]) .app-dialog[data-variant="spellbook"] .app-dialog__button--primary:focus-visible { background: var(--action-fill); color: var(--on-accent); }
.spellbook-toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
:where(html:not([data-ui-theme="warm"])) .spellbook-toolbar input { flex: 1 1 140px; min-width: 0; min-height: 34px; padding: 5px 8px; border: 1px solid var(--border-color, #8886); border-radius: 8px; background: transparent; color: var(--text-body); font: inherit; font-size: .85rem; }
:where(html[data-ui-theme="warm"]) .spellbook-toolbar input { flex: 1 1 140px; min-width: 0; min-height: 34px; padding: 5px 8px; border: 1px solid var(--border-color, var(--border)); border-radius: var(--radius-sm); background: transparent; color: var(--text-body); font: inherit; font-size: .85rem; }
.spellbook-toolbar select { width: auto; }
.spellbook-toolbar button { width: auto; margin: 0; padding: 5px 8px; }
.spellbook-manager .spell-note-muted { font-size: .78rem; margin: 6px 0; }
.spellbook-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; max-height: 52dvh; overflow: auto; }
:where(html:not([data-ui-theme="warm"])) .spellbook-option { display: grid; grid-template-columns: 18px 28px minmax(0, 1fr) auto; align-items: center; gap: 5px; min-height: 32px; padding: 3px 0; border-bottom: 1px solid var(--border-color, #8884); cursor: pointer; font-size: .88rem; }
:where(html[data-ui-theme="warm"]) .spellbook-option { display: grid; grid-template-columns: 18px 28px minmax(0, 1fr) auto; align-items: center; gap: 5px; min-height: 32px; padding: 3px 0; border-bottom: 1px solid var(--border-color, var(--border)); cursor: pointer; font-size: .88rem; }
.spellbook-option input { width: 16px; height: 16px; margin: 0; }
.spellbook-option small { font-size: .72rem; color: var(--text-muted); }
.spellbook-tome-manager { display: grid; gap: 8px; }
.spellbook-tome-field { display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 8px; }
.spellbook-tome-field select { min-width: 0; width: 100%; }
@media (max-width: 520px) {
  .spellbook-grid, .spellbook-options { grid-template-columns: 1fr; }
  #spellbook-card > summary { gap: 6px; }
  #spellbook-card .summary-title-inline { font-size: 1rem; }
  #spellbook-manage { padding: 5px 7px; font-size: .78rem; flex-shrink: 0; }
}

.utility-menu__help {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.utility-menu__help .utility-menu__button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding-inline: 0.4rem;
}

.spell-picked-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  margin-top: 1.1rem;
}

#feats-area .form-row,
#cantrips-area .form-row,
div[id$="spells-area"] .form-row {
  margin-bottom: 1rem;
}

#feats-area .form-row > .output,
#cantrips-area .form-row > .output,
div[id$="spells-area"] .form-row > .output {
  flex: 1 0 100%;
  width: 100%;
  min-width: 0;
}

.spell-picked-box {
  grid-column: 1 / -1;
  min-width: 0;
}

.spell-picked-heading {
  margin: 0 0 0.3rem;
  color: var(--text);
  font-size: var(--fs-base);
}

.spell-picked-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 1rem;
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--text-body);
}

.spell-picked-item {
  min-width: 0;
}

.free-spell-use-checks {
  display: inline-flex;
  gap: 0.22em;
  margin-left: 0.35em;
  vertical-align: middle;
}

.free-spell-use-check {
  margin: 0;
}

/* 一般角色卡只顯示法術摘要；免費施放的消耗追蹤集中於桌邊模式。 */
html:not([data-view-mode="tabletop"]) .free-spell-use-checks {
  display: none;
}

:where(html:not([data-ui-theme="warm"])) .magic-initiate-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(151, 168, 201, 0.34);
  align-items: start;
  flex: 1 0 100%;
  width: 100%;
}

:where(html[data-ui-theme="warm"]) .magic-initiate-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  align-items: start;
  flex: 1 0 100%;
  width: 100%;
}

.magic-initiate-controls.is-hidden {
  display: none;
}

.magic-initiate-field {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.magic-initiate-field select {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.magic-initiate-spell-detail {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 1.1rem;
  line-height: 1;
}

.magic-initiate-spell-detail:hover:not(:disabled),
.magic-initiate-spell-detail:focus-visible {
  background: transparent;
  color: var(--accent);
  box-shadow: none;
}

.bard-magical-discoveries {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.bard-magical-discovery-row {
  display: grid;
  grid-template-columns: minmax(6.75rem, 0.72fr) minmax(6.75rem, 0.68fr) minmax(12rem, 1.6fr);
  gap: 0.5rem 0.65rem;
  min-width: 0;
}

.bard-magical-discovery-row__marker {
  grid-column: 1 / -1;
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 850;
  letter-spacing: 0.06em;
}

.bard-magical-discovery-field {
  display: grid;
  gap: 0.28rem;
  min-width: 0;
}

.bard-magical-discovery-field__label {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 750;
  line-height: 1.2;
}

.bard-magical-discovery-field select {
  width: 100%;
  min-width: 0;
}

.bard-magical-discovery-spell-control {
  display: flex;
  gap: 0.35rem;
  min-width: 0;
}

.bard-magical-discovery-spell-control select {
  flex: 1 1 auto;
}

.bard-magical-discovery-detail {
  flex: 0 0 auto;
  width: auto;
  min-width: 3.2rem;
  padding-inline: 0.65rem;
  border-color: var(--border-strong);
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 800;
}

.bard-magical-discovery-detail:hover:not(:disabled),
.bard-magical-discovery-detail:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

:where(html:not([data-ui-theme="warm"])) .magic-initiate-source-badge {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: start;
  align-self: center;
  color: #667085;
  font-size: var(--fs-xs);
  font-weight: 800;
  white-space: nowrap;
}

:where(html[data-ui-theme="warm"]) .magic-initiate-source-badge {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: start;
  align-self: center;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 800;
  white-space: nowrap;
}

:where(html:not([data-ui-theme="warm"])) .spell-entry--derived {
  border-color: rgba(70, 112, 214, 0.28);
  background: linear-gradient(180deg, #f8fbff 0%, #f1f6ff 100%);
}

:where(html[data-ui-theme="warm"]) .spell-entry--derived {
  border-color: var(--border);
  background: var(--surface-soft);
}

:where(html:not([data-ui-theme="warm"])) .spell-entry--derived select:disabled,
:where(html:not([data-ui-theme="warm"])) .spell-entry--placeholder select:disabled {
  opacity: 0.78;
  color: #667085;
  cursor: not-allowed;
}

:where(html[data-ui-theme="warm"]) .spell-entry--derived select:disabled,
:where(html[data-ui-theme="warm"]) .spell-entry--placeholder select:disabled {
  opacity: 0.78;
  color: var(--text-muted);
  cursor: not-allowed;
}

@media (max-width: 520px) {
  .magic-initiate-controls {
    grid-template-columns: 1fr;
  }

  .bard-magical-discovery-row {
    grid-template-columns: 1fr;
  }

  .bard-magical-discovery-row__marker {
    grid-column: 1;
  }
}

:where(html:not([data-ui-theme="warm"])) .spell-highlight {
  color: #c40000;
}

:where(html[data-ui-theme="warm"]) .spell-highlight {
  color: var(--danger);
}

.spell-level-section > summary {
  cursor: pointer;
  list-style: none;
}

.feat-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-bottom: 6px;
}

.feat-row-head label {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 850;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.feat-row-controls {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  justify-content: flex-end;
  margin-left: auto;
}

.spell-row-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content max-content;
  grid-template-rows: auto auto;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.spell-row-top select:first-child,
.spell-row-index,
.spell-row-top select:last-of-type,
.spell-row-top .feat-row-controls,
.feat-row-controls {
  width: 100%;
}

.spell-row-top select:first-child {
  grid-column: 1;
  grid-row: 1;
}

:where(html:not([data-ui-theme="warm"])) .spell-row-index {
  grid-column: 2;
  grid-row: 1;
  width: auto;
  min-width: 2.5rem;
  color: #98a2b3;
  font-size: var(--fs-sm);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

:where(html[data-ui-theme="warm"]) .spell-row-index {
  grid-column: 2;
  grid-row: 1;
  width: auto;
  min-width: 2.5rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.spell-row-top .feat-row-controls {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  width: auto;
  justify-self: start;
  margin-left: 0;
}

.spell-row-top select:last-of-type {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
}

.spell-entry--derived .spell-row-top select:last-of-type {
  grid-row: 3;
}

:where(html:not([data-ui-theme="warm"])) .feat-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  min-height: 44px;
  max-height: 44px;
  padding: 0;
  border-radius: 999px;
  box-shadow: none;
  line-height: 1;
}

:where(html[data-ui-theme="warm"]) .feat-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  min-height: 44px;
  max-height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
  box-shadow: none;
  line-height: 1;
}

:where(html:not([data-ui-theme="warm"])) .feat-icon-btn {
  border: 1px solid #d7deea;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5fc 100%);
  font-size: var(--fs-base);
  font-weight: 900;
}

:where(html[data-ui-theme="warm"]) .feat-icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: var(--fs-base);
  font-weight: 900;
}

:where(html:not([data-ui-theme="warm"])) .feat-icon-btn--add {
  color: #2a55d4;
}

:where(html[data-ui-theme="warm"]) .feat-icon-btn--add {
  color: var(--accent);
}

:where(html:not([data-ui-theme="warm"])) .feat-icon-btn--delete {
  color: #c53a4a;
}

:where(html[data-ui-theme="warm"]) .feat-icon-btn--delete {
  color: var(--danger);
}

.feat-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.spell-slot-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
  align-items: start;
}

:where(html:not([data-ui-theme="warm"])) .spell-slot-column {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: nowrap;
  padding: 8px 7px;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 14px;
  text-align: left;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9fd 100%);
}

:where(html[data-ui-theme="warm"]) .spell-slot-column {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: nowrap;
  padding: 8px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  background: var(--surface-soft);
}

.spell-slot-column h4 {
  margin: 0 0 6px;
  font-size: var(--fs-base);
}

.spell-slot-label {
  display: inline-block;
  width: auto;
  margin: 0;
  white-space: nowrap;
  flex: 0 0 auto;
  font-size: 1rem;
}

.spell-slot-label--jump {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.14em;
}

.spell-slot-label--jump:hover,
.spell-slot-label--jump:focus-visible {
  color: var(--accent-strong);
}

.mini-stat-label--jump {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.14em;
}

.mini-stat-label--jump:hover,
.mini-stat-label--jump:focus-visible {
  color: var(--accent-strong);
}

.spell-picked-jump {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 0.14em;
}

.spell-picked-jump:hover,
.spell-picked-jump:focus-visible {
  color: var(--accent-strong);
}

:where(html:not([data-ui-theme="warm"])) .spell-select-jump-highlight {
  outline: 2px solid rgba(78, 122, 255, 0.42);
  outline-offset: 2px;
  transition: outline-color 0.28s ease;
}

:where(html[data-ui-theme="warm"]) .spell-select-jump-highlight {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  transition: outline-color 0.28s ease;
}

.spell-slot-placeholder {
  visibility: hidden;
  pointer-events: none;
}

.spell-note-muted {
  margin-top: 0.85rem;
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: var(--text-muted);
}

.spell-note-muted--warning {
  color: var(--warning);
  font-weight: 750;
}

.spell-meta-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.spell-meta-row > .spell-note-muted {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 0;
}

.spell-primer {
  position: relative;
  z-index: 12;
  flex: 0 0 auto;
}

:where(html:not([data-ui-theme="warm"])) .spell-primer > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 2.15rem;
  padding: 0.38rem 0.58rem 0.38rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--control-bg);
  color: var(--accent-strong);
  box-shadow: 0 5px 14px rgba(17, 31, 63, 0.08);
  font-size: var(--fs-xs);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

:where(html[data-ui-theme="warm"]) .spell-primer > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 2.15rem;
  padding: 0.38rem 0.58rem 0.38rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--control-bg);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
  font-size: var(--fs-xs);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.spell-primer > summary::before {
  display: none;
}

.spell-primer > summary:hover {
  border-color: var(--accent);
  background: var(--control-hover-bg);
  color: var(--accent);
  transform: translateY(-1px);
}

.spell-primer > summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.spell-primer__info {
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--accent-soft);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 900;
}

.spell-primer__chevron {
  color: var(--text-muted);
  font-size: 0.9rem;
  transform: translateY(-0.08rem) rotate(0deg);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.spell-primer[open] > summary {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.spell-primer[open] .spell-primer__chevron {
  transform: translateY(0.08rem) rotate(180deg);
}

.spell-primer__popover {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 2;
  width: min(25rem, calc(100vw - 2.75rem));
  max-height: min(22rem, calc(100dvh - 8rem));
  padding: 1rem 1.05rem 1.05rem;
  overflow-y: auto;
  /* Let wheel and touch gestures continue scrolling the page at either edge. */
  overscroll-behavior-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--text-body);
  box-shadow: var(--shadow-strong);
  animation: spell-primer-reveal 190ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.spell-primer__heading {
  margin-bottom: 0.65rem;
}

.spell-primer__eyebrow {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.spell-primer__heading h3 {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-lg);
}

.spell-primer__popover p {
  margin: 0;
  font-size: var(--fs-sm);
  line-height: 1.75;
}

.spell-primer__popover strong {
  color: var(--text);
  font-weight: 850;
}

@keyframes spell-primer-reveal {
  from {
    opacity: 0;
    transform: translateY(-0.4rem) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 420px) {
  .spell-meta-row {
    align-items: flex-start;
    gap: 0.5rem;
  }

  .spell-primer > summary {
    min-height: 2rem;
    padding-inline: 0.42rem 0.5rem;
  }
}

.spell-casting-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
  align-items: start;
}

.spell-casting-field {
  display: grid;
  gap: 0.45rem;
}

:where(html:not([data-ui-theme="warm"])) .spell-casting-stats .stat-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #475467;
  text-align: left;
}

:where(html[data-ui-theme="warm"]) .spell-casting-stats .stat-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-body);
  text-align: left;
}

.spell-casting-stats select,
.spell-casting-stats input {
  min-height: 40px;
  padding: 6px 4px;
  font-size: var(--fs-xl);
  font-weight: 800;
  text-align: center;
}

/* ===== Share / Utility ===== */
:where(html:not([data-ui-theme="warm"])) .share-mode-tip {
  padding: 10px 12px;
  border: 1px solid #f3c76e;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff9e8 0%, #fff2c8 100%);
  color: #7a4b00;
  font-weight: 700;
}

/* ===== Share / Utility ===== */
:where(html[data-ui-theme="warm"]) .share-mode-tip {
  padding: 10px 12px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--warning);
  font-weight: 700;
}

.feature-choice-card {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0.78rem 0.86rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--text-body);
  line-height: 1.58;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.feature-choice-card + .feature-choice-card {
  margin-top: 0.62rem;
}

.feature-choice-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.feature-choice-card.is-unavailable {
  opacity: 0.62;
}

.feature-choice-card.is-unavailable .inline-check-label {
  cursor: not-allowed;
}

.feature-choice-card__heading {
  display: flex;
  align-items: center;
  gap: 0.58rem;
  min-height: 1.5rem;
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 800;
}

label.feature-choice-card__heading {
  cursor: pointer;
}

.feature-choice-card__checks {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.26rem;
}

.feature-choice-card--invocation .feature-choice-card__heading {
  align-items: flex-start;
}

.feature-choice-card--invocation .feature-choice-card__checks,
.feature-choice-card__invocation-pick {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.feature-choice-card__invocation-pick {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.feature-choice-card__repeatable-checks {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  margin-right: 0.5rem;
  vertical-align: middle;
  white-space: nowrap;
}

.feature-choice-card__repeatable-checks .inline-check-label {
  margin: 0;
}

.feature-choice-card__settings-button {
  width: auto;
  min-height: 2rem;
  margin: -0.2rem 0 -0.2rem auto;
  padding: 0.28rem 0.55rem;
  font-size: var(--fs-xs);
  font-weight: 750;
  white-space: nowrap;
}

.agonizing-blast-setting {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.agonizing-blast-setting > label {
  display: grid;
  gap: 0.34rem;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 800;
}

.agonizing-blast-setting__select {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.agonizing-blast-setting__description {
  color: var(--text-body);
  font-size: var(--fs-sm);
  line-height: 1.58;
}

.agonizing-blast-setting__description > :first-child {
  margin-top: 0;
}

.agonizing-blast-setting__description > :last-child {
  margin-bottom: 0;
}

.invocation-target-select {
  display: grid;
  gap: 0.2rem;
  min-width: 11rem;
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 750;
}

.invocation-target-select select {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.feature-choice-card__body {
  padding-left: 1.65rem;
  color: var(--text-body);
  font-size: var(--fs-sm);
  line-height: 1.62;
  white-space: normal;
}

.feature-choice-card__meta {
  margin-bottom: 0.38rem;
  color: var(--accent-strong);
  font-weight: 750;
}

.feature-choice-card__body > :first-child {
  margin-top: 0;
}

.feature-choice-card__body > :last-child {
  margin-bottom: 0;
}

.feature-choice-card__body p {
  margin: 0.42rem 0;
  line-height: 1.62;
}

.feature-choice-card__body ul {
  margin: 0.44rem 0;
  padding-left: 1.3rem;
}

.feature-choice-card__body li {
  padding-left: 0.08rem;
  line-height: 1.58;
}

.feature-choice-card__body li + li {
  margin-top: 0.28rem;
}

.feature-choice-card__body .invocation-prereq {
  margin: 0;
}

@media (hover: hover) {
  .feature-choice-card:not(.is-unavailable):hover {
    border-color: var(--border-strong);
    background: var(--surface-strong);
  }
}

@media (max-width: 420px) {
  .feature-choice-card {
    padding: 0.72rem 0.76rem;
  }

  .feature-choice-card__body {
    padding-left: 0;
  }
}

:where(html:not([data-ui-theme="warm"])) .invocation-prereq {
  display: inline-block;
  margin: 2px 0 6px;
  padding: 2px 8px;
  border: 1px solid #d7deea;
  border-radius: 999px;
  background: #eef3fb;
  color: #51627c;
  font-size: 0.9em;
  line-height: 1.35;
  font-weight: 800;
}

:where(html[data-ui-theme="warm"]) .invocation-prereq {
  display: inline-block;
  margin: 2px 0 6px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text-body);
  font-size: 0.9em;
  line-height: 1.35;
  font-weight: 800;
}

/* ===== Hero / Footer ===== */
:where(html:not([data-ui-theme="warm"])) .site-hero {
  padding: 8px 14px 2px;
}

/* ===== Hero / Footer ===== */
:where(html[data-ui-theme="warm"]) .site-hero {
  padding: 6px 10px 4px;
  border-left: 4px solid var(--action-fill);
}

.site-hero h1 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 900;
}

.site-hero p {
  margin: 2px 0 0;
  font-size: var(--fs-sm);
}

:where(html:not([data-ui-theme="warm"])) .site-footer {
  width: 100%;
  margin-top: 0.75rem;
  padding: 1rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.25rem;
  box-shadow: none;
  font-size: var(--fs-xs);
  text-align: center;
}

:where(html[data-ui-theme="warm"]) .site-footer {
  width: 100%;
  margin-top: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: none;
  font-size: var(--fs-xs);
  text-align: center;
}

.site-footer-links {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

:where(html:not([data-ui-theme="warm"])) .site-footer a {
  color: #2d58dd;
  font-weight: 700;
  text-decoration: none;
}

:where(html[data-ui-theme="warm"]) .site-footer a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  text-decoration: underline;
}

/* ===== Floating UI ===== */
#scrollToTopBtn {
  position: fixed;
  right: max(0.95rem, calc((100vw - var(--app-max-width)) / 2 + 0.95rem));
  bottom: 0.85rem;
  z-index: 999;
  width: auto;
  height: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  box-shadow: none;
  opacity: 1;
}

:where(html:not([data-ui-theme="warm"])) #scrollToBottomBtn {
  position: fixed;
  top: var(--floating-top-offset, 4.2rem);
  left: max(0.95rem, calc((100vw - var(--app-max-width)) / 2 + 0.95rem));
  z-index: 1100;
  width: auto;
  height: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  box-shadow: none;
  opacity: 1;
  transition: top 0.2s ease;
}

:where(html[data-ui-theme="warm"]) #scrollToBottomBtn {
  position: fixed;
  top: var(--floating-top-offset, 4.2rem);
  left: max(0.95rem, calc((100vw - var(--app-max-width)) / 2 + 0.95rem));
  z-index: 1100;
  width: auto;
  height: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  box-shadow: none;
  opacity: 1;
  transition: top 120ms ease;
}

html:where([data-ui-theme="warm"])[data-theme="dark"] :is(#scrollToTopBtn, #scrollToBottomBtn) {
  color: var(--text-muted);
}

html[data-view-mode="tabletop"] #scrollToBottomBtn {
  top: max(0.75rem, env(safe-area-inset-top, 0px));
}

:where(html:not([data-ui-theme="warm"])) #spell-search-fab,
:where(html:not([data-ui-theme="warm"])) #equipment-search-fab {
  position: fixed;
  top: 4.2rem;
  right: max(0.95rem, calc((100vw - var(--app-max-width)) / 2 + 0.95rem));
  z-index: 1200;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: inherit;
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: none;
  opacity: 1;
  transition: transform 0.2s ease;
}

:where(html[data-ui-theme="warm"]) #spell-search-fab,
:where(html[data-ui-theme="warm"]) #equipment-search-fab {
  position: fixed;
  top: 4.2rem;
  right: max(0.95rem, calc((100vw - var(--app-max-width)) / 2 + 0.95rem));
  z-index: 1200;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: inherit;
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: none;
  opacity: 1;
  transition: transform 120ms ease;
}

#spell-search-fab.is-hidden,
#equipment-search-fab.is-hidden {
  display: none;
}

#spell-search-fab.toolbar-open,
#equipment-search-fab.toolbar-open {
  transform: translateY(3.15rem);
}

#spell-search-fab:hover,
#equipment-search-fab:hover {
  opacity: 1;
}

#scrollToTopBtn:hover {
  opacity: 1;
}

#scrollToBottomBtn:hover {
  opacity: 1;
}

/* ===== Dice roller ===== */
#dice-roller-fab {
  position: fixed;
  left: max(0.95rem, calc((100vw - var(--app-max-width)) / 2 + 0.95rem));
  bottom: 0.85rem;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: none;
}

#dice-roller-fab.is-hidden {
  display: none;
}

#dice-roller-fab:hover,
#dice-roller-fab:focus-visible,
#dice-roller-fab:active {
  transform: none;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.dice-roller-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-backdrop);
  display: grid;
  place-items: center;
  padding:
    max(0.75rem, env(safe-area-inset-top, 0px))
    max(0.75rem, env(safe-area-inset-right, 0px))
    max(0.75rem, env(safe-area-inset-bottom, 0px))
    max(0.75rem, env(safe-area-inset-left, 0px));
  background: var(--overlay-strong);
  opacity: 0;
  transition: opacity 180ms ease-out;
}

.dice-roller-modal[hidden] {
  display: none;
}

.dice-roller-modal.is-open {
  opacity: 1;
}

:where(html:not([data-ui-theme="warm"])) .dice-roller-card {
  position: relative;
  z-index: var(--z-dialog);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  width: min(51rem, 100%);
  height: min(33rem, calc(100svh - 1.5rem));
  max-height: 100%;
  padding: clamp(0.75rem, 2vw, 1.15rem);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: 0 28px 90px rgba(3, 10, 24, 0.42);
  opacity: 0;
  transform: scale(1.025);
  transition: opacity 220ms ease-out, transform 240ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

:where(html[data-ui-theme="warm"]) .dice-roller-card {
  position: relative;
  z-index: var(--z-dialog);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  width: min(51rem, 100%);
  height: min(33rem, calc(100svh - 1.5rem));
  max-height: 100%;
  padding: clamp(0.75rem, 2vw, 1.15rem);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
  opacity: 0;
  transform: scale(1.025);
  transition: opacity 220ms ease-out, transform 240ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.dice-roller-modal.is-open .dice-roller-card {
  opacity: 1;
  transform: scale(1);
}

.dice-roller-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.dice-roller-header h2 {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-xl);
  letter-spacing: 0.02em;
}

.dice-roller-close {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-color: transparent;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
}

.dice-roller-display {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
}

.dice-roller-stage {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: clamp(0.65rem, 2vw, 1.2rem);
  overflow: hidden;
  contain: layout paint;
}

.dice-roller-stage.is-history {
  place-items: stretch;
  overflow-y: auto;
  scrollbar-gutter: stable;
  contain: layout paint style;
}

.dice-roller-stage.is-history .dice-roller-empty {
  align-self: center;
  justify-self: center;
}

.dice-roller-stage.is-history:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}

.dice-roller-card.is-ability-roll {
  width: min(38rem, 100%);
  height: min(44rem, calc(100svh - 1.5rem));
  grid-template-rows: auto minmax(0, 1fr);
}

.dice-roller-controls[hidden] { display: none; }

.is-ability-roll .dice-roller-stage { padding: 0.7rem; }

.dice-ability-form {
  display: grid;
  align-content: start;
  gap: 0.6rem;
  min-width: 0;
}

.dice-ability-form label { margin: 0; }

.dice-ability-hint,
.dice-ability-status {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.dice-ability-results,
.dice-ability-assignments {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 1rem;
}

.dice-ability-results {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 7rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.dice-ability-start {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--accent);
  font-size: 0.85rem;
}

.dice-ability-art {
  display: grid;
  place-content: center;
  width: 5rem;
  height: 5rem;
  overflow: hidden;
}

.dice-ability-art canvas,
.dice-ability-art img {
  display: block;
  width: 10rem;
  height: 10rem;
  max-width: none;
}

.dice-ability-art span { font-size: 3rem; }

.dice-ability-results strong { align-self: center; }

.dice-ability-results strong {
  color: var(--accent);
  font-size: clamp(1.6rem, 4vw, 2rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  text-align: center;
}

.dice-ability-assignments label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.dice-ability-form select {
  width: 100%;
  min-width: 0;
  min-height: 2.4rem;
  margin: 0;
  padding: 0.3rem 1.5rem 0.3rem 0.5rem;
  font-size: 0.85rem;
}

.dice-ability-background {
  min-width: 0;
  margin: 0;
  padding: 0.4rem 0 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.dice-ability-background legend {
  padding: 0 0.5rem 0 0;
  font-size: 0.85rem;
  font-weight: 800;
}

.dice-ability-pattern {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
}

.dice-ability-pattern label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 2rem;
  width: auto;
  cursor: pointer;
}

.dice-ability-pattern input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.dice-ability-bonuses {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.dice-ability-bonuses label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dice-ability-apply { width: 100%; }

.dice-ability-history-dice {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

:where(html:not([data-ui-theme="warm"])) .dice-ability-history-dice > span {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.3rem;
  background: var(--surface-soft);
  font-variant-numeric: tabular-nums;
}

:where(html[data-ui-theme="warm"]) .dice-ability-history-dice > span {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-variant-numeric: tabular-nums;
}

.dice-ability-history-dice .is-dropped,
.dice-roller-detail-result.is-dropped {
  text-decoration: line-through;
  opacity: 0.45;
  color: var(--text-muted);
}

.dice-roller-history {
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dice-roller-history-entry {
  border-bottom: 1px solid var(--border);
  color: var(--text-body);
  font-size: clamp(0.86rem, 2.8vw, 1.08rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.dice-roller-history-entry.is-legacy {
  padding: clamp(0.65rem, 1.8vw, 0.9rem) clamp(0.65rem, 2vw, 1rem);
}

.dice-roller-history-entry:first-child {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.dice-roller-history-open {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: clamp(0.65rem, 1.8vw, 0.9rem) clamp(0.65rem, 2vw, 1rem);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  box-shadow: none;
}

.dice-roller-history-open:hover,
.dice-roller-history-open:active {
  transform: none;
  border: 0;
  background: color-mix(in srgb, var(--accent-soft) 62%, transparent);
  color: inherit;
  box-shadow: none;
}

.dice-roller-history-open:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}

.dice-roller-history-chevron {
  color: var(--text-muted);
  font-size: 1.45em;
  font-weight: 400;
  line-height: 0.75;
}

.dice-roller-detail-back {
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: none;
}

.dice-roller-detail-back:hover,
.dice-roller-detail-back:active {
  transform: none;
  border: 0;
  background: transparent;
  color: var(--primary);
  box-shadow: none;
}

.dice-roller-history-detail {
  display: grid;
  align-content: start;
  gap: clamp(0.7rem, 2vw, 1rem);
  width: 100%;
}

.dice-roller-automated-results {
  display: grid;
  align-content: start;
  gap: 0.55rem;
  width: 100%;
}

.dice-roller-automated-result {
  display: grid;
  gap: 0.28rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  overflow-wrap: anywhere;
}

.dice-roller-automated-result__equation {
  color: var(--text);
  font-size: var(--fs-lg);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.dice-roller-automated-result__detail {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.45;
}

.dice-roller-detail-expression {
  margin: 0;
  color: var(--text-muted);
  font-size: clamp(0.78rem, 2.2vw, 0.94rem);
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.dice-roller-detail-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.05rem, 1fr));
  gap: 0.42rem;
}

.dice-roller-detail-result {
  display: grid;
  place-items: center;
  min-height: 2.55rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text);
  font-size: clamp(0.88rem, 2.5vw, 1.05rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.dice-roller-detail-result.is-low {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  color: var(--danger);
}

.dice-roller-detail-result.is-high {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
  color: var(--primary);
}

.dice-roller-empty {
  color: var(--text-muted);
  font-size: clamp(0.82rem, 2.2vw, 1rem);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.dice-roller-animation {
  display: block;
  width: min(48%, 14rem);
  max-height: 72%;
  object-fit: contain;
}

.dice-roller-results {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: clamp(0.25rem, 1.2vw, 0.8rem);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.dice-roller-result {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  color: var(--text);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 0.9;
  letter-spacing: -0.055em;
  opacity: 0;
  transform: scale(0.86);
  animation: dice-result-reveal 220ms ease-out forwards;
}

.dice-roller-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  min-height: 3.45rem;
  padding: 0.65rem clamp(0.85rem, 2.5vw, 1.35rem);
  border-top: 1px solid var(--border-strong);
  color: var(--text);
}

.dice-roller-view-tabs {
  display: flex;
  align-items: center;
  gap: 0.38em;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.dice-roller-view-tab {
  width: auto;
  min-width: 0;
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: inherit;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.08em;
  box-shadow: none;
  text-align: left;
}

.dice-roller-view-tab:hover,
.dice-roller-view-tab:active,
.dice-roller-view-tab.is-active {
  transform: none;
  border: 0;
  background: transparent;
  color: var(--primary);
  box-shadow: none;
}

.dice-roller-view-tab:disabled:not(.is-active) {
  opacity: 1;
  color: var(--text-muted);
  cursor: default;
}

.dice-roller-total output {
  font-size: clamp(1.4rem, 4vw, 2.25rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.dice-roller-controls {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: clamp(0.35rem, 1vw, 0.65rem);
  min-width: 0;
}

.dice-roller-controls button {
  position: relative;
  min-width: 0;
  min-height: 3.15rem;
  padding: 0.52rem 0.4rem;
  overflow: hidden;
  border-radius: var(--radius-sm);
  font-size: clamp(0.78rem, 2.3vw, 1rem);
  font-weight: 900;
  letter-spacing: 0.015em;
}

.dice-roller-die {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  transition: filter 180ms ease, color 180ms ease, background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.dice-roller-die.has-count {
  border-color: var(--border-strong);
  background: var(--surface-muted);
  color: var(--text-body);
  filter: grayscale(1);
  box-shadow: inset 0 0 0 1px var(--border);
}

.dice-roller-count {
  position: absolute;
  right: 0.28rem;
  bottom: 0.22rem;
  min-width: 1.15rem;
  color: currentColor;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: right;
}

:where(html:not([data-ui-theme="warm"])) .dice-roller-die::after,
:where(html:not([data-ui-theme="warm"])) .dice-roller-roll::after,
:where(html:not([data-ui-theme="warm"])) .dice-roller-clear::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

:where(html[data-ui-theme="warm"]) .dice-roller-die::after,
:where(html[data-ui-theme="warm"]) .dice-roller-roll::after,
:where(html[data-ui-theme="warm"]) .dice-roller-clear::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--action-fill);
  transform: scaleX(0);
  transform-origin: left;
}

.dice-roller-die.is-holding::after {
  animation: dice-long-press 1.2s linear forwards;
}

.dice-roller-roll.is-holding::after {
  animation: dice-long-press 2.5s linear forwards;
}

.dice-roller-clear.is-holding::after {
  animation: dice-long-press 3s linear forwards;
}

.dice-roller-roll {
  border-color: transparent;
  background: var(--accent-gradient);
  color: var(--on-accent);
}

.dice-roller-clear {
  color: var(--text-muted);
}

@keyframes dice-result-reveal {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes dice-long-press {
  to { transform: scaleX(1); }
}

@media (max-width: 620px) {
  .dice-roller-card {
    gap: 0.55rem;
    padding: 0.65rem;
    border-radius: var(--radius-md);
  }

  .dice-roller-controls {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .dice-roller-controls button {
    min-height: 3rem;
  }

  .dice-roller-roll {
    grid-column: span 2;
  }
}

@media (max-height: 560px) {
  .dice-roller-card:not(.is-ability-roll) {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .dice-roller-card:not(.is-ability-roll) .dice-roller-header {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    z-index: 1;
  }

  .dice-roller-card:not(.is-ability-roll) .dice-roller-header h2 {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .dice-roller-close {
    background: var(--surface-strong);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dice-roller-modal,
  .dice-roller-card,
  .dice-roller-die,
  .dice-roller-result {
    transition-duration: 100ms;
    animation-duration: 100ms;
    animation-delay: 0ms;
    transform: none;
  }

  .dice-roller-die.is-holding::after {
    animation-duration: 1.2s;
  }

  .dice-roller-clear.is-holding::after {
    animation-duration: 3s;
  }
}

#tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: none;
  pointer-events: none;
}

#point-buy-modal.onboarding-tour-preview .point-buy-modal-card {
  pointer-events: none;
  user-select: none;
}

:where(html:not([data-ui-theme="warm"])) .tour-branch-tooltip {
  position: fixed;
  z-index: 12020;
  width: min(290px, calc(100vw - 20px));
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid rgba(126, 157, 218, 0.72);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text-body);
  box-shadow: 0 10px 28px rgba(10, 20, 46, 0.3);
  font-size: var(--fs-sm);
  font-weight: 650;
  line-height: 1.55;
  pointer-events: none;
}

:where(html[data-ui-theme="warm"]) .tour-branch-tooltip {
  position: fixed;
  z-index: 12020;
  width: min(290px, calc(100vw - 20px));
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text-body);
  box-shadow: var(--shadow-strong);
  font-size: var(--fs-sm);
  font-weight: 650;
  line-height: 1.55;
  pointer-events: none;
}

:where(html:not([data-ui-theme="warm"])) .tour-mask {
  position: fixed;
  background: rgba(10, 16, 30, 0.72);
  pointer-events: auto;
}

:where(html[data-ui-theme="warm"]) .tour-mask {
  position: fixed;
  background: var(--overlay-strong);
  pointer-events: auto;
}

:where(html:not([data-ui-theme="warm"])) #tour-focus-ring,
:where(html:not([data-ui-theme="warm"])) #tour-focus-ring-secondary {
  position: fixed;
  border: 3px solid #7aa2ff;
  border-radius: 12px;
  box-shadow: 0 0 0 2px rgba(122, 162, 255, 0.38), 0 0 26px rgba(122, 162, 255, 0.7);
  pointer-events: auto;
  touch-action: none;
  cursor: default;
}

:where(html[data-ui-theme="warm"]) #tour-focus-ring,
:where(html[data-ui-theme="warm"]) #tour-focus-ring-secondary {
  position: fixed;
  border: 3px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  pointer-events: auto;
  touch-action: none;
  cursor: default;
}

:where(html:not([data-ui-theme="warm"])) #tour-tooltip {
  position: fixed;
  width: min(252px, calc(100vw - 20px));
  padding: 10px;
  border: 1px solid #c7d2e9;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(10, 16, 30, 0.24);
  pointer-events: auto;
}

:where(html[data-ui-theme="warm"]) #tour-tooltip {
  position: fixed;
  width: min(252px, calc(100vw - 20px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
  pointer-events: auto;
}

#tour-overlay[data-tour-kind="tabletop"] #tour-tooltip {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  max-height: min(55dvh, calc(100dvh - 32px));
  top: auto !important;
  bottom: 10px;
  touch-action: pan-y !important;
  cursor: default !important;
}

#tour-overlay[data-tour-kind="tabletop"] #tour-step-text {
  overflow-y: auto;
  overscroll-behavior: contain;
  white-space: pre-line;
  min-height: 0;
  line-height: 1.6;
}

#tour-overlay[data-tour-kind="tabletop"] .tour-heading-row,
#tour-overlay[data-tour-kind="tabletop"] .tour-btn-row {
  flex-shrink: 0;
}

#tour-overlay[data-tour-kind="tabletop"] .tour-btn-row {
  flex-wrap: wrap;
}

#tour-overlay[data-tour-kind="tabletop"] .tour-btn-row button {
  width: auto;
  min-width: 0;
  flex: 1 1 auto;
}

#tour-step-text details {
  margin-top: 12px;
  white-space: normal;
}

#tour-step-text summary {
  cursor: pointer;
  min-height: 44px;
  display: list-item;
  align-content: center;
  font-weight: 700;
}

#tour-step-text details p { margin: 8px 0; }

.tour-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

#tour-step-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 900;
}

:where(html:not([data-ui-theme="warm"])) #tour-step-progress {
  flex: 0 0 auto;
  padding: 0.18rem 0.48rem;
  border: 1px solid rgba(86, 117, 242, 0.28);
  border-radius: 999px;
  background: rgba(86, 117, 242, 0.1);
  color: #4562ca;
  font-size: var(--fs-xs);
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
}

:where(html[data-ui-theme="warm"]) #tour-step-progress {
  flex: 0 0 auto;
  padding: 0.18rem 0.48rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
}

:where(html:not([data-ui-theme="warm"])) #tour-step-text {
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: #34425b;
}

:where(html[data-ui-theme="warm"]) #tour-step-text {
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--text);
}

.tour-btn-row {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

#tour-next-btn,
#tour-skip-btn,
#tour-prev-btn {
  min-height: 44px;
  padding: 0 10px;
  font-size: var(--fs-xs);
}

:where(html:not([data-ui-theme="warm"])) #tour-prev-btn {
  background: linear-gradient(180deg, #f7f9ff 0%, #edf2ff 100%);
  color: #32415f;
}

:where(html[data-ui-theme="warm"]) #tour-prev-btn {
  background: var(--surface-soft);
  color: var(--text);
}

#tour-prev-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

:where(html:not([data-ui-theme="warm"])) #tour-next-btn {
  background: linear-gradient(180deg, #6d89ff 0%, #5675f2 100%);
  color: #fff;
}

:where(html[data-ui-theme="warm"]) #tour-next-btn {
  background: var(--action-fill);
  color: var(--on-accent);
}

/* ===== Modals / Popups ===== */
:where(html:not([data-ui-theme="warm"])) #beastPopup,
:where(html:not([data-ui-theme="warm"])) #skillPopup,
:where(html:not([data-ui-theme="warm"])) #weaponRulePopup,
:where(html:not([data-ui-theme="warm"])) .druid-beast-tooltip {
  position: fixed;
  z-index: 9999;
  box-sizing: border-box;
  width: max-content;
  max-width: min(320px, calc(100vw - 20px));
  display: none;
  padding: 10px 12px;
  border: 1px solid var(--context-popup-border);
  border-radius: 12px;
  background: var(--context-popup-bg);
  color: var(--context-popup-text);
  box-shadow: var(--context-popup-shadow);
  font-size: var(--fs-sm);
  line-height: 1.45;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

/* ===== Modals / Popups ===== */
:where(html[data-ui-theme="warm"]) #beastPopup,
:where(html[data-ui-theme="warm"]) #skillPopup,
:where(html[data-ui-theme="warm"]) #weaponRulePopup,
:where(html[data-ui-theme="warm"]) .druid-beast-tooltip {
  position: fixed;
  z-index: 9999;
  box-sizing: border-box;
  width: max-content;
  max-width: min(320px, calc(100vw - 20px));
  display: none;
  padding: 10px 12px;
  border: 1px solid var(--context-popup-border);
  border-radius: var(--radius-sm);
  background: var(--context-popup-bg);
  color: var(--context-popup-text);
  box-shadow: var(--shadow-strong);
  font-size: var(--fs-sm);
  line-height: 1.45;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#beastPopup.is-dragging,
#skillPopup.is-dragging,
#weaponRulePopup.is-dragging {
  cursor: grabbing;
}

#beastPopup .title,
#skillPopup .title,
#weaponRulePopup .title {
  margin-bottom: 6px;
  color: var(--context-popup-text);
  font-size: var(--fs-md);
  font-weight: 700;
}

#beastPopup .row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

#beastPopup .muted,
#beastPopup .close,
#skillPopup .close,
#weaponRulePopup .close {
  color: var(--context-popup-muted);
  opacity: 0.85;
}

#beastPopup .close,
#skillPopup .close,
#weaponRulePopup .close {
  float: right;
  margin-left: 10px;
  cursor: pointer;
}

#weaponRulePopup .close {
  width: auto;
  min-width: 0;
  min-height: 0;
  margin-top: -2px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: var(--fs-sm);
}

.weapon-rule-popup-category {
  margin: -2px 0 6px;
  color: var(--context-popup-muted);
  font-size: var(--fs-xs);
  font-weight: 800;
}

.beast-tip,
.skill-tip {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#spell-qr-modal,
#deity-info-modal,
#ability-choice-modal,
#point-buy-modal,
#default-ability-class-modal,
#point-buy-exit-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

#spell-qr-modal {
  z-index: 10001;
  padding: 16px;
  background: var(--overlay-strong);
}

#deity-info-modal {
  z-index: 10002;
  padding: 12px;
  background: var(--overlay-strong);
}

:where(html:not([data-ui-theme="warm"])) #point-buy-modal {
  z-index: 10003;
  padding: 14px;
  background: rgba(10, 14, 28, 0.66);
}

:where(html[data-ui-theme="warm"]) #point-buy-modal {
  z-index: 10003;
  padding: 14px;
  background: var(--overlay);
}

:where(html:not([data-ui-theme="warm"])) #ability-choice-modal {
  z-index: 10003;
  padding: 14px;
  background: rgba(10, 14, 28, 0.58);
}

:where(html[data-ui-theme="warm"]) #ability-choice-modal {
  z-index: 10003;
  padding: 14px;
  background: var(--overlay);
}

:where(html:not([data-ui-theme="warm"])) #default-ability-class-modal {
  z-index: 10004;
  padding: 14px;
  background: rgba(10, 14, 28, 0.68);
}

:where(html[data-ui-theme="warm"]) #default-ability-class-modal {
  z-index: 10004;
  padding: 14px;
  background: var(--overlay);
}

:where(html:not([data-ui-theme="warm"])) #point-buy-exit-modal {
  z-index: 10005;
  padding: 14px;
  background: rgba(10, 14, 28, 0.74);
}

:where(html[data-ui-theme="warm"]) #point-buy-exit-modal {
  z-index: 10005;
  padding: 14px;
  background: var(--overlay-strong);
}

#spell-qr-modal.open,
#deity-info-modal.open,
#ability-choice-modal.open,
#point-buy-modal.open,
#default-ability-class-modal.open,
#point-buy-exit-modal.open {
  display: flex;
}

:where(html:not([data-ui-theme="warm"])) .spell-qr-modal-card {
  position: relative;
  width: min(92vw, 320px);
  padding: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface-strong);
  color: var(--text-body);
  box-shadow: var(--shadow-strong);
}

:where(html[data-ui-theme="warm"]) .spell-qr-modal-card {
  position: relative;
  width: min(92vw, 320px);
  padding: 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  color: var(--text-body);
  box-shadow: var(--shadow-strong);
}

:where(html:not([data-ui-theme="warm"])) .spell-qr-modal-image {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

:where(html[data-ui-theme="warm"]) .spell-qr-modal-image {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
}

.spell-qr-modal-note {
  margin: 0.75rem 0 0;
  color: var(--text-muted);
  text-align: center;
}

:where(html:not([data-ui-theme="warm"])) .deity-info-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(94vw, 860px);
  max-height: min(88vh, 920px);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--surface-strong) 0%, var(--surface-soft) 100%);
  color: var(--text-body);
  box-shadow: var(--shadow-strong);
}

:where(html[data-ui-theme="warm"]) .deity-info-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(94vw, 860px);
  max-height: min(88vh, 920px);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  color: var(--text-body);
  box-shadow: var(--shadow-strong);
}

:where(html:not([data-ui-theme="warm"])) .deity-info-header {
  padding: 16px 54px 12px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-soft) 0%, var(--surface-muted) 100%);
}

:where(html[data-ui-theme="warm"]) .deity-info-header {
  padding: 16px 54px 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.deity-info-header h3 {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-lg);
}

.deity-info-disclaimer {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.55;
}

:where(html:not([data-ui-theme="warm"])) .deity-info-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  min-height: 44px;
  max-height: 44px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--control-bg);
  color: var(--text);
  box-shadow: none;
  font-weight: 900;
  line-height: 1;
}

:where(html[data-ui-theme="warm"]) .deity-info-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  min-height: 44px;
  max-height: 44px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--control-bg);
  color: var(--text);
  box-shadow: none;
  font-weight: 900;
  line-height: 1;
}

.deity-info-content {
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

:where(html:not([data-ui-theme="warm"])) .deity-group {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

:where(html[data-ui-theme="warm"]) .deity-group {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.deity-group:last-child {
  margin-bottom: 0;
}

.deity-group h4 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: var(--fs-base);
}

.deity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0 12px;
}

.deity-item {
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
}

.deity-item-main {
  margin-bottom: 4px;
  color: var(--text);
  font-weight: 900;
}

.deity-item-sub {
  color: var(--text-muted);
}

.deity-impression {
  color: var(--text-body);
}


:where(html:not([data-ui-theme="warm"])) .point-buy-modal-card {
  position: relative;
  width: min(96vw, 680px);
  max-height: min(88vh, 920px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #d3deef;
  border-radius: 18px;
  padding: 14px 14px 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f8ff 100%);
  box-shadow: 0 20px 56px rgba(14, 24, 52, 0.36);
}


:where(html[data-ui-theme="warm"]) .point-buy-modal-card {
  position: relative;
  width: min(96vw, 680px);
  max-height: min(88vh, 920px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 14px 14px 16px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
}

:where(html:not([data-ui-theme="warm"])) .ability-choice-card {
  position: relative;
  width: min(92vw, 360px);
  border: 1px solid #d3deef;
  border-radius: 16px;
  padding: 16px 14px 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f8ff 100%);
  box-shadow: 0 18px 44px rgba(15, 26, 58, 0.3);
}

:where(html[data-ui-theme="warm"]) .ability-choice-card {
  position: relative;
  width: min(92vw, 360px);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 16px 14px 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
}

:where(html:not([data-ui-theme="warm"])) .default-ability-class-card {
  position: relative;
  width: min(94vw, 460px);
  max-height: min(88vh, 760px);
  overflow-y: auto;
  border: 1px solid #d3deef;
  border-radius: 16px;
  padding: 16px 14px 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f8ff 100%);
  box-shadow: 0 18px 44px rgba(15, 26, 58, 0.34);
  animation: default-ability-class-enter 160ms ease-out;
}

:where(html[data-ui-theme="warm"]) .default-ability-class-card {
  position: relative;
  width: min(94vw, 460px);
  max-height: min(88vh, 760px);
  overflow-y: auto;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 16px 14px 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
  animation: default-ability-class-enter 160ms ease-out;
}

@keyframes default-ability-class-enter {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

:where(html:not([data-ui-theme="warm"])) .default-ability-class-card h3 {
  margin: 0 52px 6px 0;
  color: #223664;
}

:where(html[data-ui-theme="warm"]) .default-ability-class-card h3 {
  margin: 0 52px 6px 0;
  color: var(--text);
}

:where(html:not([data-ui-theme="warm"])) .default-ability-class-note {
  margin: 0 52px 14px 0;
  color: #526587;
  font-size: var(--fs-sm);
  line-height: 1.55;
}

:where(html[data-ui-theme="warm"]) .default-ability-class-note {
  margin: 0 52px 14px 0;
  color: var(--text-body);
  font-size: var(--fs-sm);
  line-height: 1.55;
}

.default-ability-class-grid {
  display: grid;
  gap: 12px;
}

:where(html:not([data-ui-theme="warm"])) .default-ability-class-group h4 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 6px;
  color: #526587;
  font-size: var(--fs-xs);
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

:where(html[data-ui-theme="warm"]) .default-ability-class-group h4 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 6px;
  color: var(--text-body);
  font-size: var(--fs-xs);
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

:where(html:not([data-ui-theme="warm"])) .default-ability-class-group h4::before,
:where(html:not([data-ui-theme="warm"])) .default-ability-class-group h4::after {
  content: "";
  height: 1px;
  flex: 1;
  background: #cfd9ee;
}

:where(html[data-ui-theme="warm"]) .default-ability-class-group h4::before,
:where(html[data-ui-theme="warm"]) .default-ability-class-group h4::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--surface-soft);
}

.default-ability-class-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

:where(html:not([data-ui-theme="warm"])) .default-ability-class-grid button {
  min-width: 0;
  min-height: 42px;
  margin: 0;
  padding: 8px 5px;
  border: 1px solid #c9d5ea;
  border-radius: 10px;
  background: #fff;
  color: #223664;
  box-shadow: none;
  font-weight: 800;
  white-space: nowrap;
}

:where(html[data-ui-theme="warm"]) .default-ability-class-grid button {
  min-width: 0;
  min-height: 42px;
  margin: 0;
  padding: 8px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: none;
  font-weight: 800;
  white-space: nowrap;
}

:where(html:not([data-ui-theme="warm"])) .default-ability-class-grid button:hover,
:where(html:not([data-ui-theme="warm"])) .default-ability-class-grid button:focus-visible {
  border-color: #7892c4;
  background: #edf3ff;
  transform: translateY(-1px);
}

:where(html[data-ui-theme="warm"]) .default-ability-class-grid button:hover,
:where(html[data-ui-theme="warm"]) .default-ability-class-grid button:focus-visible {
  border-color: var(--accent);
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.default-ability-class-grid button:active {
  transform: translateY(0) scale(0.98);
}

:where(html:not([data-ui-theme="warm"])) .default-ability-class-grid button.is-current-class {
  border-color: #718dc4;
  box-shadow: inset 0 0 0 1px #718dc4;
}

:where(html[data-ui-theme="warm"]) .default-ability-class-grid button.is-current-class {
  border-color: var(--border);
  box-shadow: none;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-exit-card {
  width: min(92vw, 390px);
  border: 1px solid #d3deef;
  border-radius: 16px;
  padding: 18px 16px 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f8ff 100%);
  color: #34496f;
  box-shadow: 0 18px 44px rgba(15, 26, 58, 0.36);
  animation: default-ability-class-enter 160ms ease-out;
}

:where(html[data-ui-theme="warm"]) .point-buy-exit-card {
  width: min(92vw, 390px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px 16px;
  background: var(--surface-soft);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  animation: default-ability-class-enter 160ms ease-out;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-exit-card h3 {
  margin: 0;
  color: #8b3b32;
  font-size: var(--fs-lg);
}

:where(html[data-ui-theme="warm"]) .point-buy-exit-card h3 {
  margin: 0;
  color: var(--danger);
  font-size: var(--fs-lg);
}

.point-buy-exit-card p {
  margin: 8px 0 16px;
  line-height: 1.6;
}

.point-buy-exit-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.point-buy-exit-actions button {
  margin: 0;
}

:where(html:not([data-ui-theme="warm"])) #point-buy-exit-confirm {
  border-color: #c88a82;
  background: #fff5f3;
  color: #8b3b32;
}

:where(html[data-ui-theme="warm"]) #point-buy-exit-confirm {
  border-color: var(--danger-border);
  background: var(--surface-strong);
  color: var(--danger);
}

:where(html:not([data-ui-theme="warm"])) .ability-choice-card h3 {
  margin: 0 52px 0 0;
  color: #223664;
}

:where(html[data-ui-theme="warm"]) .ability-choice-card h3 {
  margin: 0 52px 0 0;
  color: var(--text);
}

:where(html:not([data-ui-theme="warm"])) .ability-choice-card p {
  margin: 8px 0 0;
  color: #4d5f84;
}

:where(html[data-ui-theme="warm"]) .ability-choice-card p {
  margin: 8px 0 0;
  color: var(--text-body);
}

:where(html:not([data-ui-theme="warm"])) .ability-choice-tip {
  font-weight: 700;
  color: #2e4b85;
}

:where(html[data-ui-theme="warm"]) .ability-choice-tip {
  font-weight: 700;
  color: var(--accent);
}

.ability-choice-actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

:where(html:not([data-ui-theme="warm"])) .ability-choice-close,
:where(html:not([data-ui-theme="warm"])) .default-ability-class-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid #cfd9ee;
  background: #fff;
  border-radius: 9px;
  box-shadow: none;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

:where(html[data-ui-theme="warm"]) .ability-choice-close,
:where(html[data-ui-theme="warm"]) .default-ability-class-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: var(--radius-sm);
  box-shadow: none;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid #cfd9ee;
  background: #fff;
  border-radius: 10px;
  box-shadow: none;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

:where(html[data-ui-theme="warm"]) .point-buy-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: var(--radius-sm);
  box-shadow: none;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.point-buy-header {
  margin-bottom: 10px;
  padding-right: 52px;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-header h3 {
  margin: 0;
  color: #223664;
}

:where(html[data-ui-theme="warm"]) .point-buy-header h3 {
  margin: 0;
  color: var(--text);
}

:where(html:not([data-ui-theme="warm"])) .point-buy-header p {
  margin: 6px 0 0;
  color: #4b5c7f;
  font-size: var(--fs-sm);
}

:where(html[data-ui-theme="warm"]) .point-buy-header p {
  margin: 6px 0 0;
  color: var(--text-body);
  font-size: var(--fs-sm);
}

:where(html:not([data-ui-theme="warm"])) .point-buy-background {
  display: grid;
  grid-template-columns: auto minmax(130px, 220px);
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-top: 8px;
  color: #2e4678;
  font-size: var(--fs-sm);
  font-weight: 800;
}

:where(html[data-ui-theme="warm"]) .point-buy-background {
  display: grid;
  grid-template-columns: auto minmax(130px, 220px);
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-top: 8px;
  color: var(--accent);
  font-size: var(--fs-sm);
  font-weight: 800;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-background select {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 5px 30px 5px 10px;
  border-color: #c9d5ea;
  border-radius: 9px;
  background-color: #fff;
  color: #223664;
  font-weight: 700;
}

:where(html[data-ui-theme="warm"]) .point-buy-background select {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 5px 30px 5px 10px;
  border-color: var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface-strong);
  color: var(--text);
  font-weight: 700;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-preset {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 8px 12px;
  margin: 10px 0;
  padding: 10px 0;
  border-top: 1px solid #d8e2f2;
  border-bottom: 1px solid #d8e2f2;
}

:where(html[data-ui-theme="warm"]) .point-buy-preset {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 8px 12px;
  margin: 10px 0;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.point-buy-preset-copy {
  display: grid;
  gap: 2px;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-preset-copy strong {
  color: #223664;
}

:where(html[data-ui-theme="warm"]) .point-buy-preset-copy strong {
  color: var(--text);
}

:where(html:not([data-ui-theme="warm"])) .point-buy-preset-copy span,
:where(html:not([data-ui-theme="warm"])) .point-buy-preset-status {
  color: #607090;
  font-size: var(--fs-xs);
}

:where(html[data-ui-theme="warm"]) .point-buy-preset-copy span,
:where(html[data-ui-theme="warm"]) .point-buy-preset-status {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

#ability-choice-default {
  margin: 0;
  white-space: nowrap;
}

.point-buy-preset-status {
  grid-column: 1;
  min-height: 1.4em;
  font-weight: 700;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-preset-status.is-applied {
  color: #2c6a4c;
}

:where(html[data-ui-theme="warm"]) .point-buy-preset-status.is-applied {
  color: var(--success);
}

:where(html:not([data-ui-theme="warm"])) .point-buy-hint {
  font-weight: 700;
  color: #395489;
}

:where(html[data-ui-theme="warm"]) .point-buy-hint {
  font-weight: 700;
  color: var(--accent);
}

.point-buy-table-head,
.point-buy-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) minmax(0, 1fr) 40px;
  align-items: center;
  gap: 4px;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-table-head {
  padding: 6px 10px;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: #1f315f;
}

:where(html[data-ui-theme="warm"]) .point-buy-table-head {
  padding: 6px 10px;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
}

.point-buy-rows {
  display: grid;
  gap: 6px;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-row {
  padding: 8px 10px;
  border: 1px solid #d8e2f2;
  border-radius: 12px;
  background: #fff;
}

:where(html[data-ui-theme="warm"]) .point-buy-row {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

:where(html:not([data-ui-theme="warm"])) .point-buy-row--bonus-locked {
  background: #f3f5f9;
}

:where(html[data-ui-theme="warm"]) .point-buy-row--bonus-locked {
  background: var(--surface-soft);
}

:where(html:not([data-ui-theme="warm"])) .point-buy-ability {
  font-weight: 700;
  color: #223664;
}

:where(html[data-ui-theme="warm"]) .point-buy-ability {
  font-weight: 700;
  color: var(--text);
}

.point-buy-control-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-step {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid #c9d5ea;
  background: #fff;
  border-radius: 999px;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1;
}

:where(html[data-ui-theme="warm"]) .point-buy-step {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: var(--radius-sm);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1;
}

.point-buy-step:hover,
.point-buy-step:active,
.ability-choice-close:hover,
.ability-choice-close:active,
.default-ability-class-close:hover,
.default-ability-class-close:active,
.point-buy-close:hover,
.point-buy-close:active {
  transform: none;
  box-shadow: none;
}

.point-buy-step:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-value {
  min-width: 26px;
  text-align: center;
  font-weight: 700;
  color: #1d315f;
}

:where(html[data-ui-theme="warm"]) .point-buy-value {
  min-width: 26px;
  text-align: center;
  font-weight: 700;
  color: var(--text);
}

:where(html:not([data-ui-theme="warm"])) .point-buy-value--bonus {
  color: #2d4f8f;
}

:where(html[data-ui-theme="warm"]) .point-buy-value--bonus {
  color: var(--accent);
}

:where(html:not([data-ui-theme="warm"])) .point-buy-total {
  text-align: center;
  font-weight: 800;
  color: #132a56;
}

:where(html[data-ui-theme="warm"]) .point-buy-total {
  text-align: center;
  font-weight: 800;
  color: var(--text);
}

:where(html:not([data-ui-theme="warm"])) .point-buy-summary {
  margin-top: 10px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: #2a3f6f;
}

:where(html[data-ui-theme="warm"]) .point-buy-summary {
  margin-top: 10px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text);
}

.point-buy-actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.point-buy-table-head {
  display: none;
}

.point-buy-row {
  grid-template-columns: 52px minmax(0, 1fr) 40px;
  grid-template-rows: repeat(2, minmax(44px, auto));
  gap: 4px;
}

.point-buy-ability {
  grid-column: 1;
  grid-row: 1 / -1;
  align-self: center;
}

.point-buy-total {
  grid-column: 3;
  grid-row: 1 / -1;
  align-self: center;
}

.point-buy-control-group {
  grid-column: 2;
  min-width: 0;
  justify-content: flex-start;
  gap: 4px;
}

.point-buy-row > .point-buy-control-group:not(.point-buy-control-group--bonus) {
  grid-row: 1;
}

.point-buy-control-group--bonus {
  grid-row: 2;
}

:where(html:not([data-ui-theme="warm"])) .point-buy-control-group::before {
  flex: 0 0 4.5rem;
  color: #607090;
  font-size: var(--fs-xs);
  font-weight: 700;
}

:where(html[data-ui-theme="warm"]) .point-buy-control-group::before {
  flex: 0 0 4.5rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.point-buy-row > .point-buy-control-group:not(.point-buy-control-group--bonus)::before {
  content: "基礎值";
}

.point-buy-control-group--bonus::before {
  content: "背景加值";
}

@media (max-width: 420px) {
  #point-buy-modal {
    padding: 8px;
  }

  .point-buy-modal-card {
    width: 100%;
    padding-inline: 8px;
  }

  .point-buy-row {
    grid-template-columns: 48px minmax(0, 1fr) 30px;
    padding: 7px 5px;
  }

  .point-buy-ability,
  .point-buy-total {
    font-size: var(--fs-sm);
  }

  .point-buy-value {
    flex: 0 0 26px;
    font-size: var(--fs-sm);
  }
}

@media (max-width: 340px) {
  .point-buy-row {
    grid-template-columns: 44px minmax(0, 1fr) 28px;
  }

  .point-buy-row {
    padding-inline: 3px;
  }

  .point-buy-control-group::before {
    flex-basis: 4rem;
  }
}

:where(html:not([data-ui-theme="warm"])) #legal-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  background: rgba(0, 0, 0, 0.45);
}

:where(html[data-ui-theme="warm"]) #legal-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  background: var(--overlay);
}

:where(html:not([data-ui-theme="warm"])) #legal-about-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top, 0px)) 1rem max(1rem, env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, 0.58);
}

:where(html[data-ui-theme="warm"]) #legal-about-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top, 0px)) 1rem max(1rem, env(safe-area-inset-bottom, 0px));
  background: var(--overlay);
}

#legal-about-modal[aria-hidden="true"] {
  display: none;
}

:where(html:not([data-ui-theme="warm"])) .legal-about-card {
  position: relative;
  width: min(680px, 100%);
  height: min(82dvh, 760px);
  overflow: hidden;
  padding: 0;
  border: 1px solid #d3deef;
  border-radius: 1.25rem;
  background: linear-gradient(180deg, #ffffff 0%, #f5f8ff 100%);
  box-shadow: 0 18px 44px rgba(15, 26, 58, 0.34);
  overscroll-behavior: contain;
}

:where(html[data-ui-theme="warm"]) .legal-about-card {
  position: relative;
  width: min(680px, 100%);
  height: min(82dvh, 760px);
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  box-shadow: var(--shadow-soft);
  overscroll-behavior: contain;
}

:where(html:not([data-ui-theme="warm"])) .legal-about-close {
  position: absolute;
  z-index: 2;
  top: 0.65rem;
  right: 0.8rem;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid #cfd9ee;
  border-radius: 0.6rem;
  background: var(--surface-strong, #fff);
  color: var(--text);
  box-shadow: none;
  line-height: 1;
}

:where(html[data-ui-theme="warm"]) .legal-about-close {
  position: absolute;
  z-index: 2;
  top: 0.65rem;
  right: 0.8rem;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong, var(--surface-strong));
  color: var(--text);
  box-shadow: none;
  line-height: 1;
}

.legal-about-header h2 {
  margin: 0;
  font-size: var(--fs-xl);
}

:where(html:not([data-ui-theme="warm"])) .legal-about-header {
  position: relative;
  z-index: 1;
  padding: 1rem 4rem 0.9rem 1.2rem;
  border-bottom: 1px solid #d3deef;
  background: var(--surface-strong, #fff);
}

:where(html[data-ui-theme="warm"]) .legal-about-header {
  position: relative;
  z-index: 1;
  padding: 1rem 4rem 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-strong, var(--surface-strong));
}

:where(html:not([data-ui-theme="warm"])) .legal-about-frame {
  display: block;
  width: 100%;
  height: calc(100% - 4.25rem);
  border: 0;
  background: #eef3ff;
}

:where(html[data-ui-theme="warm"]) .legal-about-frame {
  display: block;
  width: 100%;
  height: calc(100% - 4.25rem);
  border: 0;
  background: var(--surface-soft);
}

:where(html:not([data-ui-theme="warm"])) .legal-modal-card {
  position: relative;
  max-width: 310px;
  margin: 56px auto 0;
  padding: 16px 12px;
  border: 1px solid #d3deef;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f8ff 100%);
  box-shadow: 0 18px 44px rgba(15, 26, 58, 0.3);
}

:where(html[data-ui-theme="warm"]) .legal-modal-card {
  position: relative;
  max-width: 310px;
  margin: 56px auto 0;
  padding: 16px 12px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
}

:where(html:not([data-ui-theme="warm"])) #legal-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid #cfd9ee;
  border-radius: 9px;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5fc 100%);
  color: var(--text);
  box-shadow: none;
  font-size: var(--fs-md);
  line-height: 1;
}

:where(html[data-ui-theme="warm"]) #legal-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  box-shadow: none;
  font-size: var(--fs-md);
  line-height: 1;
}

.legal-modal-title {
  margin: 0 0 6px;
  font-size: var(--fs-lg);
  line-height: 1.15;
  text-align: center;
}

:where(html:not([data-ui-theme="warm"])) .legal-modal-logo {
  display: block;
  width: 7rem;
  max-width: 42%;
  height: auto;
  margin: 0 auto 0.85rem;
  border-radius: 1rem;
  box-shadow: 0 10px 24px rgba(10, 16, 48, 0.22);
}

:where(html[data-ui-theme="warm"]) .legal-modal-logo {
  position: relative;
  width: 100%;
  max-width: 18rem;
  aspect-ratio: 1080 / 350;
  overflow: hidden;
  margin: 2.25rem auto 0.85rem;
  border-radius: var(--radius-sm);
}

/* Original artwork crop: x=350, y=45, width=1080, height=350.
   Keep the wordmark and underline; hide palette notes and slogans. */
:where(html[data-ui-theme="warm"]) .legal-modal-logo img {
  position: absolute;
  width: 164.259259%;
  max-width: none;
  height: auto;
  left: -32.407407%;
  top: -12.857143%;
  display: block;
}

:where(html[data-ui-theme="warm"]) .legal-modal-logo .legal-modal-logo-dark,
html:where([data-ui-theme="warm"])[data-theme="dark"] .legal-modal-logo-light {
  display: none;
}

html:where([data-ui-theme="warm"])[data-theme="dark"] .legal-modal-logo-dark {
  display: block;
}

.legal-modal-section-title {
  margin-top: 16px;
}

.legal-modal-copy {
  font-size: var(--fs-xs);
  line-height: 1.55;
  color: var(--text-body);
}

:where(html:not([data-ui-theme="warm"])) .legal-modal-meta {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e4e8f2;
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: #49566d;
  text-align: center;
}

:where(html[data-ui-theme="warm"]) .legal-modal-meta {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: var(--text-body);
  text-align: center;
}

:where(html:not([data-ui-theme="warm"])) .legal-modal-meta-title {
  font-weight: 700;
  color: #2a3b56;
}

:where(html[data-ui-theme="warm"]) .legal-modal-meta-title {
  font-weight: 700;
  color: var(--text);
}

.legal-modal-dismiss {
  margin-top: 10px;
  font-size: var(--fs-sm);
  line-height: 1.2;
  text-align: center;
}

.legal-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

:where(html:not([data-ui-theme="warm"])) #legal-onboarding-btn,
:where(html:not([data-ui-theme="warm"])) #legal-ack-btn {
  flex: 1 1 0;
  width: auto;
  margin-top: 0;
  padding: 6px 0;
  border-radius: 0.8rem;
  font-size: var(--fs-base);
}

:where(html[data-ui-theme="warm"]) #legal-onboarding-btn,
:where(html[data-ui-theme="warm"]) #legal-ack-btn {
  flex: 1 1 0;
  width: auto;
  margin-top: 0;
  padding: 6px 0;
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  border: 2px solid var(--ink);
  background: var(--action-fill);
  color: var(--on-accent);
  box-shadow: var(--shadow-control);
}

#legal-onboarding-btn {
  border: 1px solid var(--accent-strong);
  background: var(--control-bg);
  color: var(--accent-strong);
  box-shadow: none;
}

:where(html:not([data-ui-theme="warm"])) #legal-ack-btn {
  border: 1px solid transparent;
  background: linear-gradient(180deg, var(--accent-strong) 0%, #2962e8 100%);
  color: #fff;
  box-shadow: 0 8px 18px rgba(31, 100, 255, 0.24);
}

:where(html[data-ui-theme="warm"]) #legal-ack-btn {
  border: 2px solid var(--ink);
  background: var(--action-fill);
  color: var(--on-accent);
  box-shadow: var(--shadow-control);
}

:where(html:not([data-ui-theme="warm"])) .selection-pill {
  display: inline-block;
  margin: 2px 6px 2px 0;
  padding: 2px 6px;
  border: 1px solid #ccc;
  border-radius: 999px;
}

:where(html[data-ui-theme="warm"]) .selection-pill {
  display: inline-block;
  margin: 2px 6px 2px 0;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.feat-desc-spacer {
  height: 10px;
}

.feat-desc-title {
  margin-bottom: 2px;
  font-size: var(--fs-base);
  font-weight: 800;
}

:where(html:not([data-ui-theme="warm"])) .feat-desc-subtitle {
  margin-bottom: 10px;
  font-size: var(--fs-sm);
  color: #555;
}

:where(html[data-ui-theme="warm"]) .feat-desc-subtitle {
  margin-bottom: 10px;
  font-size: var(--fs-sm);
  color: var(--text-body);
}

.feat-desc-body {
  line-height: 1.35;
}

:where(html:not([data-ui-theme="warm"])) .feat-expansion-notice {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(128, 148, 184, 0.22);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.45;
}

:where(html[data-ui-theme="warm"]) .feat-expansion-notice {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.45;
}

.feat-combat-note .selection-summary-body {
  font-size: var(--fs-sm);
}

.monster-detail-line + .monster-detail-line {
  margin-top: 6px;
}

.monster-detail-line--first {
  margin-top: 8px;
}

.background-guide-block {
  line-height: 1.25;
}

.background-guide-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft);
  color: var(--text-body);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

:where(html:not([data-ui-theme="warm"])) .background-guide-note__icon {
  display: inline-grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.68rem;
  line-height: 1;
}

:where(html[data-ui-theme="warm"]) .background-guide-note__icon {
  display: inline-grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--action-fill);
  color: var(--on-accent);
  font-size: 0.68rem;
  line-height: 1;
}

.background-guide-note__content {
  min-width: 0;
}

.background-guide-note__label {
  display: block;
  margin-bottom: 1px;
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.background-guide-note__content strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.background-guide-section {
  margin-top: 12px;
}

.background-guide-description {
  margin-top: 16px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Responsive ===== */

@media (max-width: 319px) {
  body {
    padding-inline: 0.7rem;
  }

  .tabs-shell {
    width: calc(100vw - 0.7rem);
  }

.tab-button {
    min-height: 2.65rem;
    font-size: var(--fs-sm);
  }

  #tab-actions .form-row.small-text {
    grid-template-columns: 1fr;
  }

  .action-command-heading,
  .action-mode-panel {
    padding-inline: 0.8rem;
  }

  .action-mode-tabs {
    margin-inline: 0.8rem;
  }

  .point-buy-control-group::before {
    display: none;
  }

}

@media (min-width: 360px) {
  .action-option-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .action-option-grid[data-action-mode="basic"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .spell-slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1rem;
  }

  .spell-slot-column {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    justify-content: center;
    justify-items: center;
    align-content: start;
    gap: 0.45rem 0.55rem;
    text-align: center;
  }

  .spell-slot-label {
    display: block;
    grid-column: 1 / -1;
  }

  #elf-lineage-row.has-cantrip {
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 3.3fr);
  }

  .spell-picked-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #tab-skills .save-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-grid-pretty {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #tab-basic .ability-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* 360–399px：豁免卡維持雙欄，但為名稱保留足夠空間，避免 input 蓋住文字。 */
@media (min-width: 360px) and (max-width: 399px) {
  #tab-skills .save-pair {
    grid-template-columns: minmax(0, 1fr) 3.5rem;
    padding-inline: 0.75rem;
  }

  #tab-skills .save-name {
    gap: 4px;
  }

  #tab-skills .save-pair input[type="text"] {
    padding-inline: 0.4rem;
  }
}

@media (min-width: 500px) {
  .weapon-attack-fields {
    grid-template-columns: minmax(7rem, 1.4fr) minmax(4.75rem, 0.7fr) minmax(6.5rem, 1fr);
    gap: 0.7rem;
  }

  .weapon-attack-fields input {
    padding-inline: 0.85rem;
    font-size: var(--fs-base);
  }

  .equipment-loadout-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #tab-equipment .equipment-loadout-field--armor {
    grid-column: auto;
  }

  .spell-row-top {
    grid-template-columns: 118px max-content max-content 1fr;
  }

  .spell-entry--derived .magic-initiate-source-badge {
    grid-column: 4;
    grid-row: 1;
    justify-self: end;
  }

  .spell-entry--derived .spell-row-top select:last-of-type {
    grid-row: 2;
  }

  .point-buy-preset {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .point-buy-preset-status {
    grid-column: 1 / -1;
  }

  .point-buy-actions {
    display: flex;
    justify-content: flex-end;
  }

  .point-buy-table-head {
    display: grid;
  }

  .point-buy-table-head,
  .point-buy-row {
    grid-template-columns: 72px minmax(0, 1fr) minmax(0, 1fr) 40px;
    grid-template-rows: none;
    gap: 4px;
  }

  .point-buy-row {
    padding: 8px 10px;
  }

  .point-buy-ability {
    grid-column: 1;
    grid-row: 1;
  }

  .point-buy-row > .point-buy-control-group:not(.point-buy-control-group--bonus) {
    grid-column: 2;
    grid-row: 1;
  }

  .point-buy-control-group--bonus {
    grid-column: 3;
    grid-row: 1;
  }

  .point-buy-total {
    grid-column: 4;
    grid-row: 1;
  }

  .point-buy-control-group {
    justify-content: center;
    gap: 6px;
  }

  .point-buy-control-group::before {
    content: none;
    display: none;
  }

  .money-balance-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .spell-slot-column {
    display: flex;
    justify-content: center;
    text-align: left;
  }

  .spell-slot-label {
    display: inline-block;
  }
}

@media (min-width: 620px) {
  html[data-view-mode="sheet"] {
    --app-header-offset: 5.35rem;
  }

  .tabs {
    width: 100%;
  }

  .tabs-shell {
    width: min(var(--app-max-width), calc(100vw - 1.5rem));
  }

  .tab-button {
    font-size: var(--fs-base);
  }

  .form-grid-2col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid-3col {
    grid-template-columns: 1fr auto 1fr;
  }

  .spell-casting-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 720px) {
  #tab-basic .ability-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.5rem;
  }

  #tab-basic .ability {
    padding-inline: 0.5rem;
  }

  #tab-basic .ability-title {
    font-size: 0.8rem;
  }

  #tab-basic .modifier {
    font-size: 1.65rem;
  }

  #tab-basic .ability-score {
    padding-inline: 0.25rem;
    font-size: 1rem;
  }

  #tab-skills .save-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .spell-picked-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .spell-slot-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #spell-slot-management-wrap .spell-slot-grid,
  .tabletop-spell-slot-grid {
    gap: 0.5rem;
  }

  #spell-slot-management-wrap .spell-slot-column,
  .tabletop-spell-slot-grid .spell-slot-column {
    gap: 0.25rem;
    padding: 0.5rem 0.375rem;
    min-height: 44px;
  }

  #spell-slot-management-wrap .spell-slot-label,
  .tabletop-spell-slot-grid .spell-slot-label {
    font-size: 0.875rem;
  }

  #spell-slot-management-wrap input[type="checkbox"],
  .tabletop-spell-slot-grid input[type="checkbox"] {
    flex: 0 0 20px;
    width: 20px;
    min-width: 20px;
    height: 20px;
  }
}

@media (min-width: 720px) {
  .action-grid-pretty,
  .action-option-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .action-option-grid[data-action-mode="basic"] {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.spell-highlight-action {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 0.14em;
}

@media (prefers-reduced-motion: reduce) {
  :where(html:not([data-ui-theme="warm"])) *,
:where(html:not([data-ui-theme="warm"])) *::before,
:where(html:not([data-ui-theme="warm"])) *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  :where(html[data-ui-theme="warm"]) *,
:where(html[data-ui-theme="warm"]) *::before,
:where(html[data-ui-theme="warm"]) *::after {
    translate: none !important;
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal {
  position: fixed;
  inset: 0;
  z-index: 10010;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(12, 20, 38, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: pdf-export-overlay-in 160ms ease-out both;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal {
  position: fixed;
  inset: 0;
  z-index: 10010;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: var(--overlay);
  animation: pdf-export-overlay-in 160ms ease-out both;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card {
  display: grid;
  gap: 0;
  width: min(560px, 100%);
  max-height: min(90vh, 760px);
  max-height: min(90dvh, 760px);
  padding: clamp(1.1rem, 3vw, 1.45rem);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 1px solid rgba(151, 168, 201, 0.38);
  border-radius: 1.35rem;
  background: #f8faff;
  box-shadow: 0 28px 80px rgba(9, 18, 39, 0.36);
  animation: pdf-export-card-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card {
  display: grid;
  gap: 0;
  width: min(560px, 100%);
  max-height: min(90vh, 760px);
  max-height: min(90dvh, 760px);
  padding: clamp(1.1rem, 3vw, 1.45rem);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
  animation: pdf-export-card-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(114, 133, 176, 0.2);
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.pdf-export-flow-modal__heading {
  display: grid;
  gap: 4px;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__eyebrow {
  color: #5870a3;
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.06em;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__eyebrow {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.06em;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card h3 {
  margin: 0;
  color: #172541;
  font-size: clamp(1.2rem, 4vw, 1.4rem);
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card h3 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.2rem, 4vw, 1.4rem);
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.pdf-export-flow-modal__card p {
  margin: 0;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__subtitle {
  max-width: 42rem;
  color: #64708a;
  font-size: 0.88rem;
  line-height: 1.55;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__subtitle {
  max-width: 42rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-flow-modal__close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin: -0.2rem -0.2rem 0 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #66718a;
  font-size: 1.55rem;
  font-weight: 500;
  line-height: 1;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-flow-modal__close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin: -0.2rem -0.2rem 0 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.55rem;
  font-weight: 500;
  line-height: 1;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-flow-modal__close:hover,
:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-flow-modal__close:focus-visible {
  border-color: rgba(82, 111, 174, 0.24);
  background: #eef3fc;
  color: #243b69;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-flow-modal__close:hover,
:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-flow-modal__close:focus-visible {
  border-color: var(--accent);
  background: var(--surface-soft);
  color: var(--text);
}

#pdf-export-desc {
  padding-top: 18px;
  animation: pdf-export-step-in 180ms ease-out both;
}

.pdf-export-flow-modal__card ol {
  margin: 0;
  padding: 0;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-step-copy {
  color: #56627b;
  font-size: 0.9rem;
  line-height: 1.55;
}

:where(html[data-ui-theme="warm"]) .pdf-export-step-copy {
  color: var(--text-body);
  font-size: 0.9rem;
  line-height: 1.55;
}

.pdf-export-precheck-list {
  display: grid;
  gap: 8px;
  margin-top: 12px !important;
  list-style: none;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-precheck-list__jump {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(76, 100, 154, 0.22);
  border-radius: 0.75rem;
  background: #fff;
  color: #24324f;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: left;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-precheck-list__jump {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: left;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-precheck-list__jump:hover,
:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-precheck-list__jump:focus-visible {
  border-color: #526fae;
  background: #fdfefe;
  transform: translateY(-1px);
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-precheck-list__jump:hover,
:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-precheck-list__jump:focus-visible {
  border-color: var(--accent);
  background: var(--surface-strong);
  transform: translateY(-1px);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-precheck-list__action {
  flex: 0 0 auto;
  color: #46639f;
  font-size: 0.86rem;
  font-weight: 700;
}

:where(html[data-ui-theme="warm"]) .pdf-export-precheck-list__action {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 700;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-check-success,
:where(html:not([data-ui-theme="warm"])) .pdf-export-status,
:where(html:not([data-ui-theme="warm"])) .pdf-export-wait-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 0.9rem;
}

:where(html[data-ui-theme="warm"]) .pdf-export-check-success,
:where(html[data-ui-theme="warm"]) .pdf-export-status,
:where(html[data-ui-theme="warm"]) .pdf-export-wait-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-check-success {
  border: 1px solid rgba(49, 126, 88, 0.2);
  background: #f0f8f4;
  color: #235e43;
}

:where(html[data-ui-theme="warm"]) .pdf-export-check-success {
  border: 1px solid var(--success);
  background: var(--success-soft);
  color: var(--success);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-check-success > span,
:where(html:not([data-ui-theme="warm"])) .pdf-export-status__icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  background: #dcefe5;
  font-weight: 900;
}

:where(html[data-ui-theme="warm"]) .pdf-export-check-success > span,
:where(html[data-ui-theme="warm"]) .pdf-export-status__icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  font-weight: 900;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-check-success strong,
:where(html:not([data-ui-theme="warm"])) .pdf-export-status strong,
:where(html:not([data-ui-theme="warm"])) .pdf-export-wait-note strong {
  display: block;
  color: #24324f;
  font-size: 0.92rem;
  line-height: 1.4;
}

:where(html[data-ui-theme="warm"]) .pdf-export-check-success strong,
:where(html[data-ui-theme="warm"]) .pdf-export-status strong,
:where(html[data-ui-theme="warm"]) .pdf-export-wait-note strong {
  display: block;
  color: var(--success);
  font-size: 0.92rem;
  line-height: 1.4;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-check-success p,
:where(html:not([data-ui-theme="warm"])) .pdf-export-status p,
:where(html:not([data-ui-theme="warm"])) .pdf-export-wait-note span {
  display: block;
  margin-top: 2px;
  color: #64708a;
  font-size: 0.84rem;
  line-height: 1.5;
}

:where(html[data-ui-theme="warm"]) .pdf-export-check-success p,
:where(html[data-ui-theme="warm"]) .pdf-export-status p,
:where(html[data-ui-theme="warm"]) .pdf-export-wait-note span {
  display: block;
  margin-top: 2px;
  color: var(--success);
  font-size: 0.84rem;
  line-height: 1.5;
}

.pdf-export-name-field {
  display: grid;
  gap: 8px;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-name-field label {
  color: #263754;
  font-size: 0.88rem;
  font-weight: 850;
}

:where(html[data-ui-theme="warm"]) .pdf-export-name-field label {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 850;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-name-field__input {
  width: 100%;
  min-height: 50px;
  margin: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(76, 100, 154, 0.32);
  border-radius: 0.85rem;
  background: #fff;
  box-shadow: 0 1px 0 rgba(15, 26, 58, 0.03);
  color: #172541;
  font-size: 1rem;
  font-weight: 700;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

:where(html[data-ui-theme="warm"]) .pdf-export-name-field__input {
  width: 100%;
  min-height: 50px;
  margin: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  box-shadow: none;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-name-field__input::placeholder {
  color: #9aa5b9;
  font-weight: 500;
}

:where(html[data-ui-theme="warm"]) .pdf-export-name-field__input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-name-field__input:hover {
  border-color: rgba(62, 88, 148, 0.52);
}

:where(html[data-ui-theme="warm"]) .pdf-export-name-field__input:hover {
  border-color: var(--border);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-name-field__input:focus {
  border-color: #4569bb;
  outline: 0;
  box-shadow: 0 0 0 4px rgba(69, 105, 187, 0.14);
}

:where(html[data-ui-theme="warm"]) .pdf-export-name-field__input:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: none; outline: 2px solid var(--focus-ring); outline-offset: 2px;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-name-field__input[aria-invalid="true"] {
  border-color: #c94a42;
  box-shadow: 0 0 0 4px rgba(201, 74, 66, 0.1);
}

:where(html[data-ui-theme="warm"]) .pdf-export-name-field__input[aria-invalid="true"] {
  border-color: var(--danger-border);
  box-shadow: none;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-name-field__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #77839a;
  font-size: 0.78rem;
  line-height: 1.4;
}

:where(html[data-ui-theme="warm"]) .pdf-export-name-field__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.pdf-export-name-field__counter {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-name-field__counter.is-over {
  color: #b42318;
}

:where(html[data-ui-theme="warm"]) .pdf-export-name-field__counter.is-over {
  color: var(--warning);
}

.pdf-export-choice-options,
.pdf-export-race-options {
  display: grid;
  gap: 9px;
}

.pdf-export-choice-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pdf-export-race-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-choice-option,
:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-race-option {
  width: 100%;
  min-height: 48px;
  margin: 0;
  border: 1px solid rgba(76, 100, 154, 0.24);
  border-radius: 0.8rem;
  background: #fff;
  color: #24324f;
  text-align: left;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-choice-option,
:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-race-option {
  width: 100%;
  min-height: 48px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.pdf-export-flow-modal__card .pdf-export-choice-option {
  display: grid;
  gap: 4px;
  padding: 13px 14px;
}

.pdf-export-choice-option strong {
  font-size: 0.92rem;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-choice-option span {
  color: #68758e;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.45;
}

:where(html[data-ui-theme="warm"]) .pdf-export-choice-option span {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.45;
}

.pdf-export-flow-modal__card .pdf-export-race-option {
  padding: 11px 12px;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-choice-option:hover,
:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-choice-option:focus-visible,
:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-race-option:hover,
:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-race-option:focus-visible {
  border-color: #526fae;
  background: #fdfefe;
  transform: translateY(-1px);
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-choice-option:hover,
:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-choice-option:focus-visible,
:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-race-option:hover,
:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-race-option:focus-visible {
  border-color: var(--accent);
  background: var(--surface-strong);
  transform: translateY(-1px);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-wait-note {
  border: 1px solid rgba(69, 105, 187, 0.18);
  background: #edf3ff;
}

:where(html[data-ui-theme="warm"]) .pdf-export-wait-note {
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.pdf-export-wait-note > span {
  flex: 0 0 auto;
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.5;
}

.pdf-export-format-options {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-format-option {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 14px 15px;
  border: 1px solid rgba(76, 100, 154, 0.24);
  border-radius: 0.9rem;
  background: #fff;
  color: #24324f;
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-format-option {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-format-option:hover,
:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-format-option:focus-visible {
  border-color: #526fae;
  background: #fdfefe;
  transform: translateY(-1px);
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-format-option:hover,
:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-format-option:focus-visible {
  border-color: var(--accent);
  background: var(--surface-strong);
  transform: translateY(-1px);
}

.pdf-export-format-option__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 1rem;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-format-option__badge {
  flex: 0 0 auto;
  color: #46639f;
  font-size: 0.82rem;
  font-weight: 800;
}

:where(html[data-ui-theme="warm"]) .pdf-export-format-option__badge {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-format-option__detail {
  color: #56627b;
  font-size: 0.9rem;
  line-height: 1.55;
}

:where(html[data-ui-theme="warm"]) .pdf-export-format-option__detail {
  color: var(--text-body);
  font-size: 0.9rem;
  line-height: 1.55;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-format-note {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid rgba(114, 133, 176, 0.2);
  color: #5b6680;
  font-size: 0.85rem;
  line-height: 1.55;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-format-note {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-body);
  font-size: 0.85rem;
  line-height: 1.55;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-format-note a {
  color: #3f5f9f;
  font-weight: 750;
}

:where(html[data-ui-theme="warm"]) .pdf-export-format-note a {
  color: var(--accent);
  font-weight: 750;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-status--progress {
  border: 1px solid rgba(69, 105, 187, 0.18);
  background: #edf3ff;
}

:where(html[data-ui-theme="warm"]) .pdf-export-status--progress {
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-status--error {
  border: 1px solid rgba(180, 35, 24, 0.18);
  background: #fff3f1;
}

:where(html[data-ui-theme="warm"]) .pdf-export-status--error {
  border: 1px solid var(--danger-border);
  background: var(--danger-soft);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-status--error .pdf-export-status__icon {
  background: #fbded9;
  color: #a82a21;
}

:where(html[data-ui-theme="warm"]) .pdf-export-status--error .pdf-export-status__icon {
  background: var(--danger-soft);
  color: var(--danger);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-status--error .pdf-export-flow-modal__error {
  color: #a82a21;
}

:where(html[data-ui-theme="warm"]) .pdf-export-status--error .pdf-export-flow-modal__error {
  color: var(--danger);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-status__spinner {
  flex: 0 0 auto;
  width: 1.65rem;
  height: 1.65rem;
  border: 3px solid rgba(69, 105, 187, 0.2);
  border-top-color: #4569bb;
  border-radius: 999px;
  animation: pdf-export-spin 800ms linear infinite;
}

:where(html[data-ui-theme="warm"]) .pdf-export-status__spinner {
  flex: 0 0 auto;
  width: 1.65rem;
  height: 1.65rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: pdf-export-spin 800ms linear infinite;
}

@keyframes pdf-export-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pdf-export-card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pdf-export-step-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pdf-export-spin {
  to { transform: rotate(360deg); }
}

.onboarding-jump-target {
  animation: onboarding-jump-highlight 1.8s ease-out;
}

@keyframes onboarding-jump-highlight {
  0%, 35% {
    outline: 3px solid rgba(82, 111, 174, 0.88);
    outline-offset: 5px;
    box-shadow: 0 0 0 8px rgba(82, 111, 174, 0.16);
  }
  100% {
    outline-color: transparent;
    outline-offset: 9px;
    box-shadow: 0 0 0 14px transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  :where(html:not([data-ui-theme="warm"])) .onboarding-jump-target {
    animation-duration: 0.01ms;
    outline: 3px solid #526fae;
    outline-offset: 5px;
  }
  :where(html[data-ui-theme="warm"]) .onboarding-jump-target {
    animation-duration: 0.01ms;
    outline: 3px solid var(--focus-ring);
    outline-offset: 5px;
  }
}

.pdf-export-flow-modal__card button {
  width: auto;
  margin: 0;
  font: inherit;
  cursor: pointer;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(114, 133, 176, 0.18);
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.pdf-export-flow-modal__actions[hidden] {
  display: none;
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card .pdf-export-flow-modal__button {
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  font-weight: 850;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card .pdf-export-flow-modal__button {
  min-height: 42px;
  padding: 9px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  font-weight: 850;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.pdf-export-flow-modal__card .pdf-export-flow-modal__button:hover,
.pdf-export-flow-modal__card .pdf-export-flow-modal__button:focus-visible {
  transform: translateY(-1px);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__button--primary {
  border: 1px solid #365dac;
  background: #3e67bc;
  box-shadow: 0 7px 16px rgba(42, 78, 157, 0.2);
  color: #fff;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__button--primary {
  border: 2px solid var(--ink);
  background: var(--action-fill);
  box-shadow: var(--shadow-control);
  color: var(--on-accent);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__button--primary:hover,
:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__button--primary:focus-visible {
  background: #3459a7;
  box-shadow: 0 9px 20px rgba(42, 78, 157, 0.25);
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__button--primary:hover,
:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__button--primary:focus-visible {
  background: var(--action-fill);
  box-shadow: var(--shadow-control);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__button--secondary {
  border: 1px solid rgba(76, 100, 154, 0.28);
  background: #fff;
  color: #405170;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__button--secondary {
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-body);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__button--secondary:hover,
:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__button--secondary:focus-visible {
  border-color: #6c83b5;
  background: #f5f7fc;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__button--secondary:hover,
:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__button--secondary:focus-visible {
  border-color: var(--accent);
  background: var(--surface-strong);
}

:where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__error {
  margin: 0;
  color: #b42318;
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.45;
}

:where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__error {
  margin: 0;
  color: var(--warning);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.45;
}

.pdf-export-flow-modal__error:empty {
  display: none;
}

@media (max-width: 520px) {
  .pdf-export-flow-modal {
    align-items: flex-end;
    padding: 8px;
  }

  :where(html:not([data-ui-theme="warm"])) .pdf-export-flow-modal__card {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 1.25rem;
  }

  :where(html[data-ui-theme="warm"]) .pdf-export-flow-modal__card {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--radius-lg);
  }

  .pdf-export-choice-options {
    grid-template-columns: 1fr;
  }

  .pdf-export-format-option__heading {
    align-items: flex-start;
  }

  .pdf-export-flow-modal__actions .pdf-export-flow-modal__button {
    flex: 1 1 0;
  }
}

/* ===== Tabletop mode ===== */
.condition-reference-section {
  margin-top: 2.25rem;
}

.condition-reference-intro {
  margin: 0.5rem 0 0;
}

.condition-button-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.625rem;
  margin-top: 0.625rem;
}

.condition-display-grid {
  margin-top: 0.625rem;
}

.tabletop-mode,
.tabletop-mode * {
  min-width: 0;
}

.tabletop-mode {
  width: 100%;
}

:where(html[data-ui-theme="warm"]) .tabletop-spell-slot-grid input[type="checkbox"] {
  flex: 0 0 20px;
  width: 20px;
  min-width: 20px;
  height: 20px;
}

:where(html:not([data-ui-theme="warm"])) .tabletop-sheet {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
}

:where(html[data-ui-theme="warm"]) .tabletop-sheet {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.tabletop-summary {
  padding: 1.05rem 1rem 0.95rem;
  border-left: 4px solid var(--accent);
}

.tabletop-eyebrow,
.tabletop-danger-eyebrow {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 850;
  letter-spacing: 0.06em;
}

.tabletop-danger-eyebrow {
  color: var(--danger);
}

.tabletop-summary h1,
.tabletop-section h2,
.tabletop-condition-modal__header h2,
.app-dialog__header h2 {
  margin: 0;
  color: var(--text);
}

.tabletop-summary h1 {
  font-size: var(--fs-2xl);
  line-height: 1.25;
}

.tabletop-summary p {
  margin: 0.35rem 0 0;
  color: var(--text-body);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.tabletop-key-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.32rem;
  margin: 0;
  padding: 0 0.75rem 0.85rem;
}

.tabletop-key-stat {
  position: relative;
  padding: 0.6rem 0.25rem 0.55rem;
  border-top: 3px solid var(--accent);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--accent-soft);
  text-align: center;
}

.tabletop-key-stat dt {
  color: var(--text-muted);
  font-size: clamp(0.68rem, 3.25vw, var(--fs-xs));
  font-weight: 800;
  line-height: 1.25;
}

.tabletop-key-stat dd {
  margin: 0.18rem 0 0;
  color: var(--accent-strong);
  font-size: var(--fs-lg);
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.tabletop-section {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.tabletop-section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.tabletop-section-heading__actions {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}

.tabletop-section-heading h2 {
  font-size: var(--fs-xl);
}

.tabletop-gear-notes > p {
  margin: 0 0 0.65rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.tabletop-gear-notes textarea,
.tabletop-shared-notes textarea {
  margin: 0;
}

.tabletop-condition-manage,
.tabletop-death-reset {
  flex: 0 0 auto;
  width: auto;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  font-size: var(--fs-sm);
}

.tabletop-hp-readout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(6.2rem, 0.52fr);
  align-items: stretch;
  gap: 0.6rem;
  padding-bottom: 0.9rem;
}

/* 總覽生命值：頭像與操作保持成一個緊湊、有限寬度的工作區。 */
.tabletop-health-layout {
  display: grid;
  grid-template-columns: clamp(6.5rem, 28%, 12rem) 1.5rem minmax(0, 1fr);
  align-items: start;
  gap: 0.45rem;
  max-width: 60rem;
  margin-inline: auto;
}

.tabletop-health-layout--avatar-collapsed {
  grid-template-columns: 1.5rem minmax(0, 1fr);
}

.tabletop-health-layout--avatar-collapsed .tabletop-avatar-visibility-toggle {
  grid-column: 1;
}

.tabletop-health-layout--avatar-collapsed .tabletop-health-controls {
  grid-column: 2;
}

.tabletop-health-controls {
  min-width: 0;
}

.tabletop-avatar {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--text-muted);
  box-shadow: none;
  align-self: start;
}

.tabletop-avatar[hidden] {
  display: none;
}

.tabletop-avatar-visibility-toggle {
  align-self: stretch;
  width: 1.5rem;
  min-width: 0;
  min-height: 5.5rem;
  padding: 0;
  border-color: var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text-muted);
  box-shadow: none;
  font-size: 1.1rem;
}

.tabletop-avatar-visibility-toggle:hover,
.tabletop-avatar-visibility-toggle:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tabletop-avatar:hover,
.tabletop-avatar:focus-visible {
  border-color: var(--accent);
}

.tabletop-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tabletop-avatar__placeholder {
  display: grid;
  gap: 0.3rem;
  place-items: center;
  font-size: var(--fs-sm);
  font-weight: 800;
}

.tabletop-avatar__placeholder span {
  font-size: 2rem;
  font-weight: 400;
  line-height: 1;
}

.tabletop-avatar-modal {
  position: fixed;
  z-index: 10020;
  inset: 0;
  display: grid;
  padding: 1rem;
  place-items: center;
  background: rgb(0 0 0 / 72%);
}

.tabletop-avatar-modal[hidden] { display: none; }

.tabletop-avatar-modal__surface {
  width: min(92vw, 34rem);
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.tabletop-avatar-modal__surface h2 {
  margin: 0 0 0.8rem;
  text-align: center;
  font-size: var(--fs-lg);
}

.tabletop-avatar-crop {
  position: relative;
  width: min(76vw, 28rem);
  aspect-ratio: 1;
  margin-inline: auto;
  overflow: hidden;
  background: #111;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.tabletop-avatar-crop:active { cursor: grabbing; }

.tabletop-avatar-crop img {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: none;
  pointer-events: none;
  transform-origin: center;
  will-change: transform;
}

.tabletop-avatar-crop__frame {
  position: absolute;
  z-index: 1;
  inset: 0;
  border: 2px solid rgb(255 255 255 / 85%);
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 38%);
  pointer-events: none;
}

.tabletop-avatar-modal__hint {
  margin: 0.55rem 0;
  color: var(--text-muted);
  text-align: center;
  font-size: var(--fs-xs);
}

.tabletop-avatar-modal__actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
}

html.tabletop-avatar-modal-open { overflow: hidden; }

@media (max-width: 520px) {
  .tabletop-health-layout {
    grid-template-columns: minmax(5.75rem, 29%) 1.35rem minmax(0, 1fr);
    gap: 0.3rem;
  }

  .tabletop-health-layout--avatar-collapsed {
    grid-template-columns: 1.35rem minmax(0, 1fr);
  }

  .tabletop-avatar-visibility-toggle { width: 1.35rem; }

  .tabletop-health-controls .tabletop-hp-primary strong {
    font-size: clamp(1.35rem, 6.5vw, 1.8rem);
    white-space: nowrap;
  }
}

.tabletop-hp-primary,
.tabletop-hp-temporary {
  display: grid;
  align-content: center;
  gap: 0.15rem;
  min-height: 5.4rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.tabletop-hp-label,
.tabletop-hp-temporary span {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 800;
}

.tabletop-hp-primary strong {
  color: var(--text);
  font-size: clamp(1.8rem, 9vw, 2.6rem);
  line-height: 1;
}

.tabletop-hp-temporary {
  width: 100%;
  border-left: 3px solid var(--accent);
  color: inherit;
  box-shadow: none;
  text-align: center;
}

.tabletop-hp-temporary:hover,
.tabletop-hp-temporary:focus-visible,
.tabletop-hp-temporary[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tabletop-hp-temporary strong {
  color: var(--accent-strong);
  font-size: 1.8rem;
  line-height: 1;
}

.tabletop-life-form,
.tabletop-temporary-hp-form {
  margin: 0;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}

.tabletop-life-form > label,
.tabletop-temporary-hp-form > label {
  display: block;
  margin-bottom: 0.45rem;
}

.tabletop-life-controls {
  display: grid;
  grid-template-columns: minmax(6rem, 0.75fr) repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.tabletop-life-controls input,
.tabletop-temporary-hp-controls input {
  margin: 0;
}

.tabletop-action-button--damage {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.tabletop-action-button--heal {
  border-color: color-mix(in srgb, var(--success) 48%, var(--border));
  background: var(--success-soft);
  color: var(--success);
}

.tabletop-temporary-hp-controls {
  display: grid;
  grid-template-columns: minmax(6rem, 0.75fr) minmax(0, 1.35fr);
  gap: 0.5rem;
}

.tabletop-field-help,
.tabletop-field-error,
.tabletop-live-status,
.tabletop-condition-empty {
  margin: 0.4rem 0 0;
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.tabletop-field-help,
.tabletop-condition-empty {
  color: var(--text-muted);
}

.tabletop-field-error {
  min-height: 1.35em;
  color: var(--danger);
  font-weight: 750;
}

.tabletop-live-status {
  min-height: 2.8em;
  padding: 0.55rem 0.65rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-body);
  font-weight: 700;
}

.tabletop-live-status:empty {
  border-left-color: var(--border);
  background: transparent;
}

.tabletop-active-conditions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tabletop-condition-tag {
  width: auto;
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 3px 0 0 var(--accent);
  font-size: var(--fs-sm);
}

.tabletop-death-saves {
  border-top-color: var(--danger-border);
  background: color-mix(in srgb, var(--danger-soft) 58%, transparent);
}

.tabletop-death-grid {
  display: grid;
  gap: 0.6rem;
}

.tabletop-death-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.tabletop-death-row > span {
  color: var(--success);
  font-weight: 850;
}

.tabletop-death-row--failure > span {
  color: var(--danger);
}

.tabletop-death-slots {
  display: flex;
  gap: 0.5rem;
}

:where(html:not([data-ui-theme="warm"])) .tabletop-death-slots button {
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 999px;
  background: var(--surface-strong);
}

:where(html[data-ui-theme="warm"]) .tabletop-death-slots button {
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

:where(html:not([data-ui-theme="warm"])) .tabletop-death-slots button span {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--text-muted);
  border-radius: 999px;
  background: transparent;
}

:where(html[data-ui-theme="warm"]) .tabletop-death-slots button span {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--text-muted);
  border-radius: var(--radius-sm);
  background: transparent;
}

.tabletop-death-row:not(.tabletop-death-row--failure) .tabletop-death-slots button[aria-pressed="true"] {
  border-color: var(--success);
  background: var(--success-soft);
}

.tabletop-death-row:not(.tabletop-death-row--failure) .tabletop-death-slots button[aria-pressed="true"] span {
  border-color: var(--success);
  background: var(--success);
}

.tabletop-death-row--failure .tabletop-death-slots button[aria-pressed="true"] {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.tabletop-death-row--failure .tabletop-death-slots button[aria-pressed="true"] span {
  border-color: var(--danger);
  background: var(--danger);
}

.tabletop-death-stable {
  margin-top: 0.8rem;
  border-color: var(--border-strong);
}

.tabletop-death-stable.is-active {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
  box-shadow: inset 3px 0 0 var(--success);
}

.tabletop-condition-modal,
.app-dialog {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  display: grid;
  place-items: center;
  padding: max(0.75rem, env(safe-area-inset-top, 0px)) max(0.75rem, env(safe-area-inset-right, 0px)) max(0.75rem, env(safe-area-inset-bottom, 0px)) max(0.75rem, env(safe-area-inset-left, 0px));
  background: var(--overlay);
}

.tabletop-condition-modal__sheet,
.app-dialog__surface {
  display: flex;
  flex-direction: column;
  width: min(100%, 38rem);
  max-height: min(90vh, 48rem);
  max-height: min(90dvh, 48rem);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow-strong);
}

.app-dialog[data-variant="number"] .app-dialog__surface {
  width: min(100%, 24rem);
}

.tabletop-condition-modal__header,
.app-dialog__header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.tabletop-condition-modal__header h2,
.app-dialog__header h2 {
  font-size: var(--fs-xl);
}

.tabletop-condition-modal__close,
.app-dialog__close {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
}

#tabletop-condition-form {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
}

.tabletop-condition-modal__body,
.app-dialog__body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 1rem;
}

.tabletop-condition-modal__intro,
.app-dialog__body p {
  margin: 0;
  color: var(--text-body);
}

.app-dialog__body p {
  white-space: pre-line;
}

.tabletop-condition-fieldset {
  min-width: 0;
  margin: 1rem 0 0;
  padding: 0;
  border: 0;
}

.tabletop-condition-fieldset legend {
  margin-bottom: 0.55rem;
  color: var(--text);
  font-weight: 850;
}

.tabletop-condition-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.tabletop-condition-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.tabletop-condition-option label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  margin: 0;
  padding: 0.35rem 0.25rem;
  cursor: pointer;
}

.tabletop-condition-option label span {
  font-size: var(--fs-sm);
}

.tabletop-condition-info {
  align-self: center;
  width: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 0.35rem 0.55rem;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  box-shadow: none;
  font-size: var(--fs-xs);
}

.tabletop-exhaustion-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5rem;
  align-items: center;
  gap: 0.35rem 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
}

.tabletop-exhaustion-control label {
  margin: 0;
}

.tabletop-exhaustion-control input {
  margin: 0;
}

.tabletop-exhaustion-control span {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.tabletop-condition-reference {
  margin-top: 1rem;
}

.tabletop-condition-reference h3 {
  margin: 0 0 0.5rem;
  color: var(--text);
  font-size: var(--fs-base);
}

.tabletop-condition-reference .condition-display-card {
  background: var(--surface-soft);
}

.tabletop-condition-modal__actions,
.app-dialog__actions {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 0.55rem;
  padding: 0.85rem 1rem max(0.85rem, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--surface-strong);
}

.tabletop-condition-modal__actions button,
.app-dialog__actions button {
  width: auto;
  min-width: 7rem;
}

.tabletop-condition-modal__apply,
.app-dialog__button--primary {
  border-color: var(--accent-strong);
  background: var(--accent-gradient);
  color: var(--on-accent);
}

.app-dialog__body {
  display: grid;
  gap: 0.85rem;
}

.app-dialog__copy-label {
  display: grid;
  gap: 0.4rem;
  margin: 0;
}

.app-dialog__copy-value {
  min-height: 8rem;
  resize: none;
  overflow-wrap: anywhere;
}

.app-dialog__number-field {
  display: grid;
  gap: 0.42rem;
  margin: 0;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 850;
}

.app-dialog__number-input {
  width: 100%;
  min-height: 3.25rem;
  margin: 0;
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: var(--fs-xl);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.app-dialog__number-hint,
.app-dialog__number-error {
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.4;
}

.app-dialog__roll-note-field {
  display: grid;
  gap: 0.42rem;
  margin: 0;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 850;
}

.app-dialog__roll-note-input {
  width: 100%;
  min-height: 6rem;
  margin: 0;
  resize: vertical;
  color: var(--text);
  font-size: var(--fs-md);
  line-height: 1.5;
}

.app-dialog__number-hint {
  color: var(--text-muted);
}

.app-dialog__number-error {
  min-height: 1.1em;
  color: var(--danger);
}

.tabletop-cast-form {
  display: grid;
  gap: 0.8rem;
  min-width: 0;
}

.tabletop-cast-form__methods {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.tabletop-cast-form__methods legend,
.tabletop-cast-form__field > span {
  margin-bottom: 0.25rem;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 850;
}

.tabletop-cast-form__choice {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  min-height: 44px;
  margin: 0;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  cursor: pointer;
}

.tabletop-cast-form__choice input {
  flex: 0 0 auto;
  margin: 0;
}

.tabletop-cast-form__choice small {
  color: var(--text-muted);
}

.tabletop-cast-form__field {
  display: grid;
  gap: 0.32rem;
  min-width: 0;
  margin: 0;
}

.tabletop-cast-form__field select {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.tabletop-cast-form__single {
  padding: 0.6rem 0.7rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  font-weight: 800;
}

.tabletop-cast-summary {
  display: grid;
  gap: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tabletop-cast-summary__row {
  display: grid;
  grid-template-columns: minmax(5rem, 0.38fr) minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.48rem 0.58rem;
  border-bottom: 1px solid var(--border);
}

.tabletop-cast-summary__row:last-child {
  border-bottom: 0;
}

.tabletop-cast-summary dt,
.tabletop-cast-summary dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.tabletop-cast-summary dt {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 800;
}

.tabletop-cast-summary dd {
  color: var(--text-body);
  font-size: var(--fs-sm);
}

.tabletop-cast-form__error {
  min-height: 1.4em;
  color: var(--danger) !important;
  font-size: var(--fs-sm);
  font-weight: 750;
}

.app-dialog__button--danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--on-accent);
}

.app-toast {
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  left: max(0.75rem, env(safe-area-inset-left, 0px));
  z-index: var(--z-toast);
  width: min(32rem, calc(100vw - 1.5rem));
  margin-left: auto;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--shadow-strong);
  font-weight: 750;
}

.app-toast[data-tone="success"] {
  border-left-color: var(--success);
}

.app-toast[data-tone="error"] {
  border-left-color: var(--danger);
}

.app-toast[data-variant="dice-roll"] {
  right: auto;
  left: max(0.75rem, env(safe-area-inset-left, 0px), calc((100vw - var(--app-max-width)) / 2 + 0.75rem));
  margin-left: 0;
  border-left-color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.tabletop-primary-tabs,
.tabletop-action-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.25rem;
  padding: 0.45rem 0.55rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.tabletop-primary-tabs {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.tabletop-primary-tabs[data-visible-tab-count="4"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tabletop-primary-tabs button,
.tabletop-action-tabs button {
  min-height: 44px;
  margin: 0;
  padding: 0.45rem 0.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-body);
  box-shadow: none;
  font-size: var(--fs-sm);
  font-weight: 800;
  cursor: pointer;
}

.tabletop-primary-tabs button.is-active,
.tabletop-action-tabs button.is-active {
  border-color: var(--border-strong);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.tabletop-primary-tabs button:active,
.tabletop-action-tabs button:active,
.tabletop-action-option:active,
.tabletop-spell-button:active,
.tabletop-compact-button:active,
.tabletop-custom-resource button:active {
  transform: translateY(1px);
}

.tabletop-primary-tabs button:focus-visible,
.tabletop-action-tabs button:focus-visible,
.tabletop-action-option:focus-visible,
.tabletop-spell-button:focus-visible,
.tabletop-concentration__detail:focus-visible,
.tabletop-concentration__stop:focus-visible,
.tabletop-resource-row button:focus-visible,
.tabletop-resource-row input:focus-visible,
.tabletop-custom-resource button:focus-visible,
.tabletop-custom-resource input:focus-visible,
.tabletop-custom-resource-form input:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.tabletop-panel {
  min-width: 0;
}

.tabletop-panel-intro {
  padding: 1rem;
  border-left: 4px solid var(--accent);
}

.tabletop-panel-intro h2 {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-2xl);
}

.tabletop-panel-notice {
  margin: 0.45rem 0 0;
  color: var(--text-body);
  line-height: 1.5;
}

.tabletop-section-heading h3,
.tabletop-resource-row h4,
.tabletop-custom-resource h4,
.tabletop-spell-level h4,
.tabletop-weapon-row h4 {
  margin: 0;
  color: var(--text);
}

.tabletop-section-heading h3 {
  font-size: var(--fs-xl);
}

.tabletop-section-note {
  margin-left: auto;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 750;
  text-align: right;
}

.tabletop-concentration-list {
  display: grid;
  gap: 0.45rem;
}

.tabletop-concentration-list[hidden] {
  display: none;
}

.tabletop-concentration-list--overview {
  margin: 0 0.75rem 0.85rem;
}

.tabletop-concentration-list--spells {
  margin: 0.75rem 1rem 0;
}

.tabletop-concentration {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
}

.tabletop-concentration > div {
  min-width: 0;
}

.tabletop-concentration .tabletop-eyebrow {
  margin-bottom: 0.1rem;
}

.tabletop-concentration__detail {
  width: auto;
  min-height: 32px;
  margin: 0;
  padding: 0.1rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent-strong);
  box-shadow: none;
  text-align: left;
  cursor: pointer;
}

.tabletop-concentration__detail span {
  font-size: var(--fs-lg);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.tabletop-concentration__detail:disabled {
  color: var(--warning);
  cursor: default;
  opacity: 1;
}

.tabletop-concentration p {
  margin: 0.25rem 0 0;
  color: var(--text-body);
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.tabletop-concentration--ended {
  border-color: var(--warning-border);
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.tabletop-concentration--ended .tabletop-eyebrow,
.tabletop-concentration--ended .tabletop-concentration__detail {
  color: var(--warning);
}

.tabletop-concentration--ended .tabletop-concentration__stop {
  border-color: var(--warning-border);
  background: var(--surface);
  color: var(--warning);
}

.tabletop-concentration__stop,
.tabletop-compact-button {
  flex: 0 0 auto;
  width: auto;
  min-height: 44px;
  margin: 0;
  padding: 0.5rem 0.7rem;
  font-size: var(--fs-sm);
}

.tabletop-empty-state {
  margin: 0;
  padding: 0.85rem;
  border-left: 3px solid var(--accent);
  background: var(--surface-soft);
  color: var(--text-body);
  line-height: 1.5;
}

#tabletop-spells-empty {
  margin: 0 1rem 1rem;
}

.tabletop-empty-state strong {
  display: block;
  color: var(--text);
}

.tabletop-empty-state p {
  margin: 0.3rem 0 0;
}

.tabletop-empty-state .tabletop-compact-button {
  margin-top: 0.65rem;
}

.tabletop-inline-empty {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.tabletop-weapon-summary,
.tabletop-resource-list,
.tabletop-custom-resource-list,
.tabletop-spell-levels {
  display: grid;
  gap: 0;
}

.spell-prepared-counts {
  margin: 0.85rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.tabletop-metamagic-options {
  display: grid;
  gap: 0.5rem;
}

.tabletop-metamagic-option {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.tabletop-metamagic-option strong {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--text-heading);
}

.tabletop-metamagic-option p {
  margin: 0;
  color: var(--text-body);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.tabletop-weapon-row {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}

.tabletop-weapon-row:first-child {
  padding-top: 0;
}

.tabletop-weapon-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.tabletop-weapon-row__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  font-size: var(--fs-base);
}

.tabletop-weapon-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(4.5rem, 0.55fr) minmax(5rem, 0.75fr) minmax(0, 1.25fr);
  gap: 0.45rem;
  margin: 0.55rem 0 0;
}

.tabletop-weapon-field {
  min-width: 0;
}

.tabletop-weapon-field dt {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 800;
}

.tabletop-weapon-field dd {
  margin: 0.15rem 0 0;
  color: var(--text-body);
  font-weight: 750;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

:where(html:not([data-ui-theme="warm"])) .tabletop-source-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: 1.55rem;
  padding: 0.12rem 0.42rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

:where(html[data-ui-theme="warm"]) .tabletop-source-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: 1.55rem;
  padding: 0.12rem 0.42rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.tabletop-action-browser .tabletop-section-heading {
  margin-bottom: 0.55rem;
}

.tabletop-action-tabs {
  margin-inline: -1rem;
  padding-inline: 1rem;
  border-inline: 0;
}

.tabletop-action-panel {
  padding-top: 0.85rem;
}

.tabletop-action-notes textarea {
  display: block;
  min-height: 3.4rem;
  margin: 0;
  resize: vertical;
  overflow: auto;
}

.tabletop-action-context {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 4.2rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.tabletop-action-context > div {
  display: grid;
  gap: 0.2rem;
}

.tabletop-action-context strong {
  color: var(--text);
}

.tabletop-action-context span {
  color: var(--text-body);
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.tabletop-action-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 0.8rem;
  padding-top: 0.8rem;
}

.tabletop-action-options {
  display: grid;
  align-content: start;
  gap: 0.4rem;
}

.tabletop-action-option,
.tabletop-spell-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text-body);
  box-shadow: none;
  text-align: left;
  cursor: pointer;
}

.tabletop-action-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 3px 0 0 var(--accent);
}

.tabletop-action-description {
  min-height: 15rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.tabletop-action-description__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.tabletop-action-description__heading strong {
  color: var(--text);
  font-size: var(--fs-lg);
}

.tabletop-action-description__copy {
  color: var(--text-body);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tabletop-action-description__prompt {
  margin: 0;
  color: var(--text-muted);
}

.tabletop-casting-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0;
}

.tabletop-casting-summary__item {
  min-height: 4.2rem;
  padding: 0.6rem;
  border-top: 3px solid var(--accent);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--accent-soft);
  text-align: center;
}

.tabletop-casting-summary dt {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 800;
}

.tabletop-casting-summary dd {
  margin: 0.25rem 0 0;
  color: var(--accent-strong);
  font-size: var(--fs-lg);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.tabletop-resource-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 4.4rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.tabletop-resource-row:last-child {
  border-bottom: 0;
}

.tabletop-resource-row__copy {
  min-width: 0;
}

.tabletop-resource-row h4 {
  font-size: var(--fs-base);
}

.tabletop-resource-row p {
  margin: 0.22rem 0 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.tabletop-resource-row__controls,
.tabletop-resource-checks,
.tabletop-resource-stepper {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.tabletop-resource-checks {
  flex-wrap: nowrap;
  gap: 0.45rem;
}

.tabletop-resource-check {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.tabletop-resource-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text-body);
  cursor: pointer;
}

.tabletop-resource-check input,
.tabletop-resource-toggle input {
  margin: 0;
}

.tabletop-resource-stepper button,
.tabletop-custom-resource__stepper button {
  width: auto;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0.45rem 0.6rem;
}

.tabletop-resource-stepper output {
  min-width: 4.4rem;
  color: var(--text);
  font-size: var(--fs-lg);
  font-weight: 900;
  text-align: center;
}

.tabletop-resource-stepper__value {
  width: 4.6rem;
  min-height: 44px;
  margin: 0;
  padding-inline: 0.35rem;
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 900;
  text-align: center;
}

.tabletop-spell-level {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}

.tabletop-spell-level:first-child {
  padding-top: 0;
}

.tabletop-spell-level:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.tabletop-spell-level h4 {
  margin-bottom: 0.5rem;
  padding-left: 0.55rem;
  border-left: 3px solid var(--accent);
}

.tabletop-spell-list {
  display: grid;
  gap: 0.4rem;
}

.tabletop-spell-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  overflow: hidden;
}

.tabletop-spell-card > .tabletop-spell-button {
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.tabletop-spell-card__uses {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem 0.35rem 0.15rem;
}

.tabletop-spell-card__uses input {
  flex: 0 0 auto;
  margin: 0;
}

.tabletop-spell-button__names {
  display: grid;
  gap: 0.05rem;
  min-width: 0;
}

.tabletop-spell-button__names strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.tabletop-spell-button__names > span {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}

.tabletop-spell-detail__english {
  color: var(--text-muted) !important;
  font-weight: 750;
}

.tabletop-spell-detail__copy {
  color: var(--text-body);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tabletop-warning-text {
  color: var(--warning) !important;
  font-weight: 750;
}

.tabletop-custom-resource-form {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
  padding: 0.8rem;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.tabletop-custom-resource-form > label,
.tabletop-custom-resource-numbers label {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  color: var(--text-body);
  font-size: var(--fs-sm);
  font-weight: 750;
}

.tabletop-custom-resource-form input {
  width: 100%;
  min-height: 44px;
  margin: 0;
}

.tabletop-custom-resource-numbers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.tabletop-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.tabletop-form-actions button {
  width: auto;
  min-width: 7rem;
  min-height: 44px;
}

.tabletop-primary-button {
  border-color: var(--accent-strong);
  background: var(--accent-gradient);
  color: var(--on-accent);
}

.tabletop-custom-resource {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.tabletop-custom-resource:last-child {
  border-bottom: 0;
}

.tabletop-custom-resource__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.tabletop-custom-resource__heading > div {
  min-width: 0;
}

.tabletop-custom-resource h4 {
  overflow-wrap: anywhere;
}

.tabletop-custom-resource p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.tabletop-custom-resource__total {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: var(--fs-xl);
}

.tabletop-custom-resource__stepper,
.tabletop-custom-resource__actions,
.tabletop-custom-resource__exact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.tabletop-custom-resource__exact input {
  width: 6rem;
  min-height: 44px;
  margin: 0;
}

.tabletop-custom-resource__actions {
  justify-content: flex-end;
}

.tabletop-danger-button {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

@media (hover: hover) and (pointer: fine) {
  .tabletop-primary-tabs button:hover,
  .tabletop-action-tabs button:hover,
  .tabletop-action-option:hover,
  .tabletop-spell-button:hover,
  .tabletop-compact-button:hover,
  .tabletop-custom-resource button:hover,
  .tabletop-resource-row button:not(.tabletop-inline-roll):hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-strong);
  }

  .tabletop-concentration__detail:not(:disabled):hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 0.2rem;
  }
}

.tabletop-primary-tabs button:disabled,
.tabletop-action-tabs button:disabled,
.tabletop-action-option:disabled,
.tabletop-resource-row button:disabled,
.tabletop-custom-resource button:disabled {
  border-color: var(--border);
  background: var(--disabled-bg);
  color: var(--disabled-text);
  cursor: not-allowed;
  opacity: 0.72;
  transform: none;
}

html.tabletop-condition-modal-open,
html.app-dialog-open {
  overflow: hidden;
}

@media (max-width: 520px) {
  .tabletop-action-layout {
    grid-template-columns: 1fr;
  }

  .tabletop-action-description {
    min-height: 12rem;
  }

  .tabletop-life-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tabletop-life-controls input {
    grid-column: 1 / -1;
  }

  .tabletop-condition-modal,
  .app-dialog {
    place-items: end stretch;
    padding: 0;
  }

  .tabletop-condition-modal__sheet,
  .app-dialog__surface {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

@media (max-width: 380px) {
  .tabletop-summary,
  .tabletop-section,
  .tabletop-condition-modal__body,
  .app-dialog__body {
    padding-inline: 0.8rem;
  }

  .tabletop-key-stats {
    padding-inline: 0.55rem;
  }

  .tabletop-concentration-list--overview {
    margin-inline: 0.55rem;
  }

  .tabletop-concentration-list--spells {
    margin-inline: 0.8rem;
  }

  .tabletop-key-stat {
    padding-inline: 0.1rem;
  }

  .tabletop-primary-tabs,
  .tabletop-action-tabs {
    padding-inline: 0.35rem;
  }

  .tabletop-primary-tabs button,
  .tabletop-action-tabs button {
    padding-inline: 0.1rem;
    font-size: var(--fs-xs);
  }

  .tabletop-concentration,
  .tabletop-resource-row,
  .tabletop-custom-resource__heading {
    align-items: stretch;
    flex-direction: column;
  }

  .tabletop-concentration__stop,
  .tabletop-resource-row__controls {
    width: 100%;
  }

  .tabletop-resource-row__controls {
    justify-content: flex-start;
  }

  .tabletop-weapon-fields,
  .tabletop-casting-summary,
  .tabletop-custom-resource-numbers {
    grid-template-columns: 1fr;
  }

  .tabletop-weapon-fields {
    gap: 0.55rem;
  }

  .tabletop-casting-summary__item {
    min-height: 0;
    text-align: left;
  }

  .tabletop-custom-resource__exact input {
    flex: 1 1 7rem;
    width: auto;
  }

  .tabletop-hp-readout {
    grid-template-columns: minmax(0, 1fr) minmax(5.4rem, 0.48fr);
  }

  .tabletop-temporary-hp-controls,
  .tabletop-condition-options {
    grid-template-columns: 1fr;
  }

  .tabletop-condition-modal__actions,
  .app-dialog__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-inline: 0.8rem;
  }

  .tabletop-condition-modal__actions button,
  .app-dialog__actions button {
    width: 100%;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tabletop-mode *,
  .tabletop-condition-modal *,
  .app-dialog *,
  .app-toast {
    animation: none;
    transition: none;
  }
}

/* ===== Tabletop combat HUD: compact role-sheet treatment ===== */
:where(html:not([data-ui-theme="warm"])) .tabletop-sheet {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* ===== Tabletop combat HUD: compact role-sheet treatment ===== */
:where(html[data-ui-theme="warm"]) .tabletop-sheet {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.tabletop-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 0.08rem;
  padding: 0.55rem 1rem 0.45rem 2.75rem;
  border-left-width: 3px;
}

.tabletop-summary h1 {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  font-size: var(--fs-base);
  line-height: 1.2;
}

.tabletop-summary__name {
  cursor: pointer;
  overflow-wrap: anywhere;
}

.tabletop-summary__name.is-placeholder {
  color: var(--accent-strong);
}

.tabletop-summary__name:focus-visible {
  outline: 2px solid var(--focus-ring, var(--accent));
  outline-offset: 2px;
}

.tabletop-character-name-input {
  font-family: inherit;
  font-variant-numeric: normal;
  text-align: left;
}

.tabletop-summary p {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.35;
}

.tabletop-primary-tabs,
.tabletop-action-tabs {
  gap: 0.15rem;
  margin: 0 0.55rem 0.4rem;
  padding: 0.18rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.tabletop-primary-tabs button,
.tabletop-action-tabs button {
  min-height: 40px;
  padding: 0.35rem 0.18rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}

.tabletop-primary-tabs button.is-active,
.tabletop-action-tabs button.is-active {
  border-color: var(--border-strong);
  background: var(--surface-strong);
  color: var(--accent-strong);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.tabletop-key-stats {
  gap: 0.3rem;
  padding: 0 0.55rem 0.45rem;
}

.tabletop-ability-modifiers,
.tabletop-saving-throw-values {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0;
  justify-content: center;
}

.tabletop-ability-modifiers {
  margin: 0;
  padding: 0.18rem 0.7rem 0.42rem;
  border-top: 1px solid var(--border);
  color: var(--text-body);
}

.tabletop-ability-modifier,
.tabletop-saving-throw {
  display: inline-flex;
  align-items: baseline;
  gap: 0.22rem;
  padding: 0 0.52rem;
  border-right: 1px solid var(--border);
  font-size: var(--fs-sm);
  line-height: 1.45;
  white-space: nowrap;
}

.tabletop-ability-modifier:first-child,
.tabletop-saving-throw:first-child {
  padding-left: 0;
}

.tabletop-ability-modifier:last-child,
.tabletop-saving-throw:last-child {
  border-right: 0;
}

.tabletop-ability-modifier__label,
.tabletop-saving-throw__label {
  color: var(--text-muted);
  font-weight: 750;
}

.tabletop-ability-modifier__value,
.tabletop-saving-throw__value {
  color: var(--accent-strong);
  font-size: var(--fs-base);
  font-variant-numeric: tabular-nums;
}

.tabletop-inline-roll {
  display: inline-flex;
  align-items: baseline;
  gap: 0.22rem;
  width: auto;
  min-width: 0;
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  font: inherit;
  line-height: inherit;
  text-align: inherit;
}

.tabletop-inline-roll:not(:disabled) {
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--accent) 62%, transparent);
  cursor: pointer;
}

.tabletop-inline-roll:disabled {
  color: inherit;
  cursor: default;
  opacity: 1;
}

.tabletop-inline-roll:not(:disabled):focus-visible,
.tabletop-dice-expression:not(:disabled):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.tabletop-skill-value > .tabletop-inline-roll {
  display: grid;
  grid-template-columns: 1em minmax(0, 1fr) minmax(2.75rem, max-content);
  align-items: center;
  gap: 0.3rem;
  width: 100%;
  min-height: 44px;
  text-align: start;
}

.tabletop-skill-value > .tabletop-inline-roll:disabled {
  background: transparent;
  color: var(--text-body);
}

.tabletop-key-stat .tabletop-inline-roll,
.tabletop-death-roll {
  font-size: inherit;
  font-weight: inherit;
}

.tabletop-dice-expression {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-width: 0;
  min-height: 24px;
  margin: 0 0.08em;
  padding: 0 0.08em;
  border: 0;
  border-bottom: 1px dashed var(--accent);
  border-radius: 0;
  background: transparent;
  color: var(--accent-strong);
  box-shadow: none;
  font: inherit;
  font-weight: 850;
  line-height: inherit;
  vertical-align: baseline;
}

.tabletop-dice-expression:disabled {
  margin-inline: 0;
  padding-inline: 0;
  border-bottom-color: transparent;
  color: inherit;
  cursor: text;
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .tabletop-inline-roll:not(:disabled):hover,
  .tabletop-dice-expression:not(:disabled):hover {
    color: var(--accent);
  }
}

.tabletop-inline-roll--plain:not(:disabled),
.tabletop-inline-roll--plain:not(:disabled):hover {
  box-shadow: none;
  color: inherit;
}

.tabletop-saving-throw-values {
  padding-top: 0.05rem;
}

.tabletop-skills {
  container: tabletop-skills / inline-size;
}

.tabletop-skill-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.tabletop-skill-values {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border-top: 1px solid var(--border);
}

.tabletop-skill-value {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.15rem 0.08rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-body);
  font-size: var(--fs-sm);
}

.tabletop-skill-value__label {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.tabletop-skill-value__value {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: var(--fs-base);
  font-variant-numeric: tabular-nums;
  text-align: end;
  white-space: nowrap;
}

.tabletop-skill-value__rank {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.tabletop-skill-value[data-skill-rank="proficient"] .tabletop-skill-value__rank {
  color: var(--accent);
}

.tabletop-skill-value[data-skill-rank="expertise"] .tabletop-skill-value__rank {
  color: var(--accent);
}

html[data-theme="dark"] .tabletop-skill-value[data-skill-rank="expertise"] .tabletop-skill-value__rank {
  color: var(--accent);
}

.tabletop-skill-value > .tabletop-inline-roll:not(:disabled):active {
  background: var(--accent-soft);
}

@container tabletop-skills (min-width: 18.75rem) {
  .tabletop-skill-values { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabletop-skill-value { padding-inline: 0.5rem; }
  .tabletop-skill-value:nth-child(odd) { padding-inline-start: 0.08rem; border-right: 1px solid var(--border); }
  .tabletop-skill-value:nth-child(even) { padding-inline-end: 0.08rem; }
}

@container tabletop-skills (min-width: 30rem) {
  .tabletop-skill-values { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tabletop-skill-value:nth-child(n) { padding-inline: 0.5rem; border-right: 1px solid var(--border); }
  .tabletop-skill-value:nth-child(3n + 1) { padding-inline-start: 0.08rem; }
  .tabletop-skill-value:nth-child(3n) { padding-inline-end: 0.08rem; border-right: 0; }
}

.tabletop-defense-summary__list {
  display: grid;
}

.tabletop-defense-summary__item {
  margin: 0;
  padding: 0.48rem 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-body);
  line-height: 1.45;
}

@media (min-width: 720px) {
  .tabletop-defense-summary__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1.25rem;
  }
}

.tabletop-key-stat {
  display: grid;
  align-content: center;
  min-height: 3.25rem;
  padding: 0.32rem 0.12rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.tabletop-key-stat dt {
  font-size: clamp(0.65rem, 2.8vw, var(--fs-xs));
  line-height: 1.15;
}

.tabletop-key-stat dd {
  margin-top: 0.1rem;
  font-size: var(--fs-base);
}

.tabletop-section {
  padding: 0.65rem 0.7rem;
}

.tabletop-section-heading {
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}

.tabletop-section-heading h2,
.tabletop-section-heading h3 {
  font-size: var(--fs-base);
  line-height: 1.3;
}

.tabletop-section-heading__actions {
  gap: 0.3rem;
}

.tabletop-undo,
.tabletop-temporary-hp-toggle,
.tabletop-condition-manage,
.tabletop-death-reset {
  min-height: 36px;
  padding: 0.32rem 0.52rem;
  border-color: var(--border);
  background: transparent;
  box-shadow: none;
  font-size: var(--fs-xs);
}

.tabletop-hp-readout {
  grid-template-columns: minmax(0, 1fr) minmax(5.5rem, 0.42fr);
  gap: 0.4rem;
  padding-bottom: 0.45rem;
}

.tabletop-hp-primary,
.tabletop-hp-temporary {
  min-height: 3.8rem;
  padding: 0.45rem 0.62rem;
  border-radius: var(--radius-sm);
}

.tabletop-hp-label,
.tabletop-hp-temporary span {
  font-size: var(--fs-xs);
}

.tabletop-hp-primary strong {
  font-size: clamp(1.55rem, 7vw, 2rem);
}

.tabletop-hp-temporary {
  border-left-width: 2px;
}

.tabletop-hp-temporary strong {
  font-size: 1.4rem;
}

.tabletop-life-form,
.tabletop-temporary-hp-form {
  padding: 0.45rem 0 0;
}

.tabletop-life-form > label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.tabletop-temporary-hp-form > label {
  margin-bottom: 0.28rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.tabletop-life-controls {
  grid-template-columns: minmax(4.5rem, 0.55fr) repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.tabletop-life-controls input,
.tabletop-life-controls button,
.tabletop-temporary-hp-controls input,
.tabletop-temporary-hp-controls button {
  min-height: 42px;
}

.tabletop-life-controls input {
  grid-column: auto;
}

.tabletop-life-controls button {
  padding-inline: 0.25rem;
  box-shadow: none;
  font-size: var(--fs-sm);
}

.tabletop-temporary-hp-controls {
  grid-template-columns: minmax(5rem, 0.65fr) minmax(0, 1fr);
  gap: 0.35rem;
}

.tabletop-field-help,
.tabletop-field-error,
.tabletop-live-status,
.tabletop-condition-empty {
  margin-top: 0.28rem;
  font-size: var(--fs-xs);
  line-height: 1.35;
}

.tabletop-life-form .tabletop-field-error:empty,
.tabletop-temporary-hp-form .tabletop-field-error:empty,
.tabletop-live-status:empty {
  display: none;
}

.tabletop-live-status {
  min-height: 0;
  padding: 0.35rem 0.5rem;
}

.tabletop-concentration {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.42rem 0.55rem;
  border-left-width: 3px;
  border-radius: var(--radius-sm);
}

.tabletop-concentration .tabletop-eyebrow {
  display: none;
}

.tabletop-concentration__detail {
  min-height: 30px;
}

.tabletop-concentration__detail span {
  font-size: var(--fs-base);
}

.tabletop-concentration p {
  margin-top: 0.1rem;
  font-size: var(--fs-xs);
  line-height: 1.3;
}

.tabletop-concentration__stop,
.tabletop-compact-button {
  min-height: 38px;
  padding: 0.35rem 0.55rem;
  box-shadow: none;
  font-size: var(--fs-xs);
}

.tabletop-concentration__stop {
  width: auto;
}

.tabletop-conditions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.tabletop-conditions .tabletop-section-heading {
  display: contents;
}

.tabletop-conditions .tabletop-section-heading h2 {
  grid-column: 1;
  grid-row: 1;
  white-space: nowrap;
}

.tabletop-conditions .tabletop-condition-manage {
  grid-column: 3;
  grid-row: 1;
}

.tabletop-active-conditions {
  grid-column: 2;
  grid-row: 1;
  gap: 0.3rem;
}

.tabletop-condition-empty {
  margin: 0;
}

.tabletop-condition-tag {
  min-height: 36px;
  padding: 0.3rem 0.55rem;
  border-left-width: 2px;
  box-shadow: inset 2px 0 0 var(--accent);
  font-size: var(--fs-xs);
}

.tabletop-condition-detail {
  padding: 0.7rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--text-body);
  line-height: 1.5;
}

.tabletop-condition-detail .condition-display-card {
  padding: 0;
  border: 0;
  background: transparent;
}

.tabletop-death-saves {
  margin: 0.45rem 0.55rem;
  padding: 0.65rem;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
}

.tabletop-death-saves .tabletop-section-heading {
  margin-bottom: 0.4rem;
}

.tabletop-death-grid {
  gap: 0.35rem;
}

.tabletop-death-row {
  gap: 0.5rem;
}

.tabletop-death-slots {
  gap: 0.3rem;
}

.tabletop-death-slots button {
  flex-basis: 40px;
  width: 40px;
  min-width: 40px;
  min-height: 40px;
}

.tabletop-death-stable {
  width: auto;
  min-height: 38px;
  margin-top: 0.45rem;
  padding: 0.35rem 0.75rem;
  box-shadow: none;
}

.tabletop-panel-intro {
  padding: 0 0.7rem;
  border: 0;
}

.tabletop-panel-intro > .tabletop-eyebrow,
.tabletop-panel-intro > h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.tabletop-panel-notice {
  margin: 0.45rem 0;
  padding-left: 0.5rem;
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.35;
}

.tabletop-section-note {
  font-size: 0.68rem;
}

.tabletop-empty-state {
  padding: 0.6rem 0.7rem;
  border-left-width: 2px;
  font-size: var(--fs-sm);
}

#tabletop-spells-empty {
  margin: 0 0.7rem 0.55rem;
}

.tabletop-inline-empty {
  padding: 0.45rem 0;
  font-size: var(--fs-xs);
}

.tabletop-weapon-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  align-items: start;
  gap: 0.45rem;
  padding: 0.48rem 0;
}

.tabletop-weapon-row__heading {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.15rem;
  font-size: var(--fs-sm);
}

.tabletop-weapon-fields {
  grid-template-columns: minmax(0, 1.35fr) minmax(2.8rem, 0.42fr) minmax(4.2rem, 0.72fr);
  gap: 0.25rem 0.45rem;
  margin: 0;
}

.tabletop-weapon-field:nth-child(4) {
  grid-column: 1 / -1;
}

.tabletop-weapon-field dt {
  font-size: 0.66rem;
  line-height: 1.15;
}

.tabletop-weapon-field dd {
  margin-top: 0.05rem;
  font-size: var(--fs-sm);
  line-height: 1.3;
}

.tabletop-source-tag {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.tabletop-action-browser .tabletop-section-heading {
  margin-bottom: 0.35rem;
}

.tabletop-action-manage {
  width: auto;
  min-width: 3.25rem;
  min-height: 40px;
  margin: 0;
  padding: 0.35rem 0.55rem;
  border-color: transparent;
  background: transparent;
  color: var(--accent-strong);
  box-shadow: none;
  font-size: var(--fs-xs);
  font-weight: 800;
}

.tabletop-action-manage:focus-visible,
.tabletop-action-manager button:focus-visible,
.tabletop-action-manager input:focus-visible,
.tabletop-action-editor input:focus-visible,
.tabletop-action-editor select:focus-visible,
.tabletop-action-editor textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.app-dialog[data-variant="action-manager"] .app-dialog__surface,
.app-dialog[data-variant="action-editor"] .app-dialog__surface {
  width: min(100%, 42rem);
}

.tabletop-action-manager,
.tabletop-action-editor {
  min-width: 0;
}

.tabletop-action-manager__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.tabletop-action-manager__summary {
  flex: 1 1 15rem;
  color: var(--text-muted) !important;
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.tabletop-action-manager__toolbar-actions,
.tabletop-action-manager__row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tabletop-action-manager__toolbar-actions .tabletop-compact-button,
.tabletop-action-manager__row-actions .tabletop-compact-button {
  min-height: 40px;
  padding: 0.35rem 0.55rem;
}

.tabletop-action-manager__add {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.tabletop-action-manager__list {
  display: grid;
}

.tabletop-action-manager__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem 0.75rem;
  min-width: 0;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

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

.tabletop-action-manager__visibility {
  display: flex;
  flex: 1 1 12rem;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  cursor: pointer;
}

.tabletop-action-manager__visibility input {
  flex: 0 0 auto;
  margin: 0;
}

.tabletop-action-manager__copy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.tabletop-action-manager__copy strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.tabletop-action-manager__row-actions {
  flex: 0 0 auto;
}

.tabletop-action-manager__row-actions .tabletop-danger-button {
  color: var(--danger);
}

.tabletop-action-editor {
  display: grid;
  gap: 0.75rem;
}

.tabletop-action-editor__source {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 750;
}

.tabletop-action-editor__field {
  display: grid;
  gap: 0.32rem;
  margin: 0;
  color: var(--text-body);
  font-size: var(--fs-sm);
  font-weight: 750;
}

.tabletop-action-editor__field input,
.tabletop-action-editor__field select,
.tabletop-action-editor__field textarea {
  width: 100%;
  min-height: 44px;
  margin: 0;
}

.tabletop-action-editor__field textarea {
  min-height: 8rem;
  resize: vertical;
}

.tabletop-action-editor__error {
  min-height: 1.3em;
  color: var(--danger) !important;
  font-size: var(--fs-sm);
  font-weight: 750;
}

.tabletop-action-options__empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.55rem 0.1rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.tabletop-action-tabs {
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  margin: 0 0 0.4rem;
}

.tabletop-action-panel {
  padding-top: 0;
}

.tabletop-action-context {
  align-items: center;
  gap: 0.4rem;
  min-height: 0;
  padding: 0.28rem 0.1rem 0.4rem;
}

.tabletop-action-context > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.4rem;
}

.tabletop-action-context span {
  font-size: var(--fs-xs);
  line-height: 1.3;
}

.tabletop-action-layout {
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding-top: 0.5rem;
}

.tabletop-action-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.tabletop-spell-detail__source {
  color: var(--accent-strong) !important;
  font-size: var(--fs-sm);
  font-weight: 800;
}

.tabletop-action-spell-toggle,
.tabletop-action-spell-options {
  grid-column: 1 / -1;
}

.tabletop-action-spell-toggle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  min-height: 2.4rem;
  margin: 0.2rem 0 0;
  padding: 0.35rem 0.1rem 0.4rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  text-align: left;
  cursor: pointer;
}

.tabletop-action-spell-toggle:hover {
  color: var(--accent-strong);
}

.tabletop-action-spell-toggle:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.tabletop-action-spell-toggle__hint {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 650;
}

.tabletop-action-spell-toggle__icon {
  color: var(--accent-strong);
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 160ms ease;
}

.tabletop-action-spell-toggle[aria-expanded="true"] .tabletop-action-spell-toggle__icon {
  transform: rotate(180deg);
}

.tabletop-action-spell-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.tabletop-action-spell-options[hidden] {
  display: none;
}

.tabletop-action-options[data-action-mode="basic"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tabletop-action-option {
  align-content: center;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  gap: 0.08rem;
  min-height: 46px;
  padding: 0.38rem 0.5rem;
  box-shadow: none;
  font-size: var(--fs-sm);
  text-align: center;
}

.tabletop-action-option.is-selected {
  box-shadow: inset 3px 0 0 var(--accent);
}

.tabletop-action-description {
  min-height: 0;
  padding: 0.55rem 0.65rem;
  border-left-width: 2px;
}

.tabletop-action-description__heading {
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.tabletop-action-description__heading strong {
  font-size: var(--fs-base);
}

.tabletop-action-description__copy {
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.tabletop-action-resource-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.8rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.tabletop-action-resource-status {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.35;
}

:where(html:not([data-ui-theme="warm"])) .tabletop-action-resource-use {
  min-width: 8.25rem;
  min-height: 46px;
  margin: 0;
  padding: 0.55rem 0.9rem;
  border-color: transparent;
  background: var(--accent-gradient);
  color: var(--on-accent);
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 5px color-mix(in srgb, var(--accent-strong) 22%, transparent);
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

:where(html[data-ui-theme="warm"]) .tabletop-action-resource-use {
  min-width: 8.25rem;
  min-height: 46px;
  margin: 0;
  padding: 0.55rem 0.9rem;
  border-color: transparent;
  background: var(--accent-gradient);
  color: var(--on-accent);
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-soft);
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

:where(html:not([data-ui-theme="warm"])) .tabletop-action-resource-use:not(:disabled):hover {
  border-color: transparent;
  background: var(--accent-gradient);
  color: var(--on-accent);
  box-shadow: 0 4px 10px color-mix(in srgb, var(--accent-strong) 28%, transparent);
  transform: translateY(-1px);
}

:where(html[data-ui-theme="warm"]) .tabletop-action-resource-use:not(:disabled):hover {
  border-color: transparent;
  background: var(--accent-gradient);
  color: var(--on-accent);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

:where(html:not([data-ui-theme="warm"])) .tabletop-action-resource-use:not(:disabled):active {
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent-strong) 20%, transparent);
  transform: translateY(0);
}

:where(html[data-ui-theme="warm"]) .tabletop-action-resource-use:not(:disabled):active {
  box-shadow: var(--shadow-soft);
  transform: translateY(0);
}

.tabletop-action-resource-use:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.tabletop-action-resource-use:disabled {
  border-color: var(--border);
  background: var(--disabled-bg);
  color: var(--disabled-text);
  box-shadow: none;
  cursor: not-allowed;
}

@media (max-width: 520px) {
  .tabletop-action-resource-control {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .tabletop-action-resource-use {
    width: 100%;
  }
}

.tabletop-casting-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}

.tabletop-casting-summary__item {
  min-height: 3.2rem;
  padding: 0.35rem 0.2rem;
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  background: var(--surface-soft);
  text-align: center;
}

.tabletop-casting-summary dt {
  font-size: 0.66rem;
  line-height: 1.15;
}

.tabletop-casting-summary dd {
  margin-top: 0.08rem;
  font-size: var(--fs-base);
}

.tabletop-resource-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  min-height: 3.35rem;
  padding: 0.42rem 0;
}

.tabletop-resource-row h4 {
  font-size: var(--fs-sm);
}

.tabletop-resource-row p {
  margin-top: 0.08rem;
  font-size: 0.68rem;
  line-height: 1.25;
}

.tabletop-resource-row__controls,
.tabletop-resource-checks,
.tabletop-resource-stepper {
  gap: 0.25rem;
}

.tabletop-resource-row__controls {
  width: auto;
  justify-content: flex-end;
}

.tabletop-resource-inline-checks {
  padding: 0.35rem 0;
}

.tabletop-resource-check {
  min-width: 30px;
  min-height: 30px;
}

.tabletop-resource-toggle {
  min-width: 40px;
  min-height: 40px;
  padding: 0.25rem 0.5rem;
  font-size: var(--fs-xs);
}

.tabletop-resource-stepper button,
.tabletop-custom-resource__stepper button {
  min-width: 40px;
  min-height: 40px;
  padding: 0.32rem 0.5rem;
  box-shadow: none;
}

.tabletop-resource-stepper output {
  min-width: 3.7rem;
  font-size: var(--fs-base);
}

.tabletop-resource-stepper__value {
  width: 4.25rem;
  min-height: 40px;
}

.tabletop-spell-level {
  padding: 0.55rem 0;
}

.tabletop-spell-level h4 {
  margin-bottom: 0.35rem;
  padding-left: 0.42rem;
  border-left-width: 2px;
  font-size: var(--fs-sm);
}

.tabletop-spell-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.tabletop-spell-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  justify-items: start;
  gap: 0.12rem;
  min-height: 50px;
  padding: 0.38rem 0.5rem;
  box-shadow: none;
}

.tabletop-spell-button__names {
  gap: 0;
}

.tabletop-spell-button__names strong {
  font-size: var(--fs-sm);
  line-height: 1.25;
}

.tabletop-spell-button__names > span {
  font-size: 0.68rem;
  line-height: 1.2;
}

.tabletop-custom-resource-form {
  gap: 0.45rem;
  margin-bottom: 0.55rem;
  padding: 0.6rem;
}

.tabletop-custom-resource-form input {
  min-height: 40px;
}

.tabletop-custom-resource-numbers {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.tabletop-form-actions {
  gap: 0.35rem;
}

.tabletop-form-actions button {
  min-width: 6rem;
  min-height: 40px;
}

.tabletop-custom-resource {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.35rem 0.5rem;
  padding: 0.58rem 0;
}

.tabletop-custom-resource__heading,
.tabletop-custom-resource__stepper {
  grid-column: 1 / -1;
}

.tabletop-custom-resource__heading {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
}

.tabletop-custom-resource h4 {
  font-size: var(--fs-sm);
}

.tabletop-custom-resource p {
  margin-top: 0.08rem;
  font-size: 0.68rem;
  line-height: 1.25;
}

.tabletop-custom-resource__total {
  font-size: var(--fs-base);
}

.tabletop-custom-resource__stepper,
.tabletop-custom-resource__actions,
.tabletop-custom-resource__exact {
  gap: 0.3rem;
  margin-top: 0;
}

.tabletop-custom-resource__stepper button:not(.tabletop-compact-button) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tabletop-custom-resource__stepper .tabletop-compact-button,
.tabletop-custom-resource__exact button,
.tabletop-custom-resource__actions button {
  min-height: 36px;
  padding: 0.28rem 0.5rem;
  background: transparent;
  box-shadow: none;
}

.tabletop-custom-resource__exact {
  grid-column: 1;
}

.tabletop-custom-resource__exact input {
  flex: 0 0 4.75rem;
  width: 4.75rem;
  min-height: 36px;
}

.tabletop-custom-resource__actions {
  grid-column: 2;
  justify-content: flex-end;
}

.tabletop-custom-resource__actions .tabletop-danger-button {
  color: var(--danger);
}

@media (hover: hover) and (pointer: fine) {
  .tabletop-resource-toggle:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
  }

  .tabletop-spell-card:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
}

@media (max-width: 379px) {
  .tabletop-cast-summary__row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .feature-choice-card__invocation-pick {
    grid-template-columns: 1fr;
  }

  .invocation-target-select {
    min-width: 0;
    width: 100%;
  }
}

@media (min-width: 360px) {
  .tabletop-action-options,
  .tabletop-action-spell-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tabletop-action-options[data-action-mode="basic"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 620px) {
  .tabletop-spell-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #tabletop-built-in-resources {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 0.85rem;
  }
}

@media (min-width: 720px) {

  .tabletop-action-options,
  .tabletop-action-spell-options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tabletop-action-options[data-action-mode="basic"] {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
/* 手機：六大屬性與六項豁免固定 3 × 2 */
@media (max-width: 619px) {
  .tabletop-ability-modifiers,
  .tabletop-saving-throw-values {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.15rem 0;
  }

  .tabletop-ability-modifier,
  .tabletop-saving-throw {
    min-width: 0;
    justify-content: center;
    padding: 0 0.35rem;
  }

  .tabletop-ability-modifier:nth-child(3n),
  .tabletop-saving-throw:nth-child(3n) {
    border-right: 0;
  }
}
@media (max-width: 359px) {
  .tabletop-summary {
    padding-right: 0.8rem;
  }

  .tabletop-primary-tabs,
  .tabletop-action-tabs {
    margin-inline: 0.4rem;
  }

  .tabletop-primary-tabs button,
  .tabletop-action-tabs button {
    font-size: var(--fs-xs);
  }

  .tabletop-life-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tabletop-life-controls input {
    grid-column: 1 / -1;
  }

  .tabletop-conditions {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .tabletop-conditions .tabletop-condition-manage {
    grid-column: 2;
  }

  .tabletop-active-conditions {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .tabletop-weapon-row {
    grid-template-columns: 1fr;
  }

  .tabletop-weapon-row__heading {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .tabletop-custom-resource__exact,
  .tabletop-custom-resource__actions {
    grid-column: 1 / -1;
  }

  .tabletop-custom-resource__actions {
    justify-content: flex-start;
  }

  .tabletop-resource-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabletop-resource-row__controls {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ===== Tabletop resources: notched consumption rails ===== */
:where(html:not([data-ui-theme="warm"])) #tabletop-panel-resources {
  --resource-paper: #f8faff;
  --resource-ink: #16213d;
  --resource-caption: #62728e;
  --resource-active: #2852d6;
  --resource-track: #dce4f1;
  --resource-rule: rgba(76, 104, 168, 0.28);
}

/* ===== Tabletop resources: notched consumption rails ===== */
:where(html[data-ui-theme="warm"]) #tabletop-panel-resources {
  --resource-paper: var(--surface-strong);
  --resource-ink: var(--text);
  --resource-caption: var(--text-muted);
  --resource-active: var(--accent);
  --resource-track: var(--surface-muted);
  --resource-rule: var(--border);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] #tabletop-panel-resources {
  --resource-paper: #17243a;
  --resource-ink: #f1f7fd;
  --resource-caption: #97aac0;
  --resource-active: #38bdf8;
  --resource-track: #2a3b53;
  --resource-rule: rgba(148, 190, 222, 0.32);
}

html:where([data-ui-theme="warm"])[data-theme="dark"] #tabletop-panel-resources {
  --resource-paper: var(--surface-strong);
  --resource-ink: var(--text);
  --resource-caption: var(--text-muted);
  --resource-active: var(--accent);
  --resource-track: var(--surface-muted);
  --resource-rule: var(--border);
}

#tabletop-panel-resources .tabletop-section-heading {
  align-items: center;
}

#tabletop-panel-resources .tabletop-resource-list,
#tabletop-panel-resources .tabletop-custom-resource-list,
#tabletop-built-in-resources {
  grid-template-columns: 1fr;
  gap: 0;
}

#tabletop-panel-resources .tabletop-resource-row,
#tabletop-panel-resources .tabletop-custom-resource {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.48rem 1rem;
  min-height: 4.7rem;
  padding: 0.9rem 0.15rem;
  border-bottom: 1px solid var(--resource-rule);
}

#tabletop-panel-resources .tabletop-resource-row:last-child,
#tabletop-panel-resources .tabletop-custom-resource:last-child {
  border-bottom: 0;
}

#tabletop-panel-resources .tabletop-resource-row__copy,
#tabletop-panel-resources .tabletop-custom-resource__heading {
  min-width: 0;
}

#tabletop-panel-resources .tabletop-resource-row__copy h4,
#tabletop-panel-resources .tabletop-custom-resource h4 {
  color: var(--resource-ink);
  font-size: var(--fs-base);
  font-weight: 900;
  letter-spacing: 0.015em;
  line-height: 1.25;
}

.tabletop-hit-die-heading {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tabletop-hit-die-roll,
.tabletop-hit-die-heal {
  min-height: 2.25rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.tabletop-hit-die-roll {
  padding: 0.2rem 0.35rem;
  border-radius: var(--radius-sm);
  font-weight: 900;
}

.tabletop-hit-die-heal {
  min-width: 2.25rem;
  padding: 0.2rem;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
}

.tabletop-hit-die-roll:not(:disabled),
.tabletop-hit-die-heal:not(:disabled) {
  cursor: pointer;
}

.tabletop-hit-die-roll:not(:disabled):hover,
.tabletop-hit-die-heal:not(:disabled):hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.tabletop-hit-die-roll:disabled,
.tabletop-hit-die-heal:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.hit-die-recovery-log {
  display: grid;
  gap: 0.45rem;
  max-height: min(42vh, 18rem);
  overflow-y: auto;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-body);
  font-variant-numeric: tabular-nums;
  list-style: none;
}

.hit-die-recovery-result {
  margin-top: 0.8rem !important;
  font-weight: 800;
  color: var(--text-strong);
}

#tabletop-panel-resources .tabletop-resource-row p,
#tabletop-panel-resources .tabletop-custom-resource p {
  max-width: 38rem;
  margin-top: 0.2rem;
  color: var(--resource-caption);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.4;
}

#tabletop-panel-resources .tabletop-resource-row__controls,
#tabletop-panel-resources .tabletop-resource-stepper,
#tabletop-panel-resources .tabletop-custom-resource__stepper {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

:where(html:not([data-ui-theme="warm"])) .tabletop-number-stepper {
  display: grid;
  grid-template-columns: 2.65rem minmax(5.35rem, auto) 2.65rem;
  align-items: stretch;
  min-height: 2.75rem;
  border: 1px solid var(--resource-rule);
  border-radius: 0.42rem;
  background: var(--resource-paper);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--resource-track) 72%, transparent);
  overflow: hidden;
}

:where(html[data-ui-theme="warm"]) .tabletop-number-stepper {
  display: grid;
  grid-template-columns: 2.65rem minmax(5.35rem, auto) 2.65rem;
  align-items: stretch;
  min-height: 2.75rem;
  border: 1px solid var(--resource-rule);
  border-radius: var(--radius-sm);
  background: var(--resource-paper);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--resource-track) 72%, transparent);
  overflow: hidden;
}

#tabletop-panel-resources .tabletop-number-stepper__adjust,
#tabletop-panel-resources .tabletop-number-stepper__adjust:not(.tabletop-compact-button) {
  display: grid;
  place-items: center;
  width: 2.65rem;
  min-width: 2.65rem;
  min-height: 2.65rem;
  margin: 0;
  padding: 0 0 0.08rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--resource-active);
  box-shadow: none;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}

#tabletop-panel-resources .tabletop-number-stepper__adjust:first-child {
  border-right: 1px solid var(--resource-rule);
}

#tabletop-panel-resources .tabletop-number-stepper__adjust:last-child {
  border-left: 1px solid var(--resource-rule);
}

#tabletop-panel-resources .tabletop-number-stepper__adjust:disabled {
  border-color: var(--resource-rule);
  background: transparent;
  color: var(--disabled-text);
  opacity: 0.45;
}

#tabletop-panel-resources .tabletop-number-stepper__value {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  min-height: 2.65rem;
  margin: 0;
  padding: 0.2rem 0.7rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--resource-ink);
  box-shadow: none;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1.16rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
}

#tabletop-panel-resources button.tabletop-number-stepper__value {
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  transition: color 120ms ease, box-shadow 120ms ease;
}

#tabletop-panel-resources .tabletop-number-stepper button:focus-visible {
  outline: 0;
  box-shadow: inset 0 0 0 2px var(--resource-active);
}

:where(html:not([data-ui-theme="warm"])) .tabletop-resource-meter {
  position: relative;
  grid-column: 1 / -1;
  width: 100%;
  height: 0.38rem;
  border-radius: 1px;
  background: var(--resource-track);
  overflow: hidden;
}

:where(html[data-ui-theme="warm"]) .tabletop-resource-meter {
  position: relative;
  grid-column: 1 / -1;
  width: 100%;
  height: 0.38rem;
  border-radius: var(--radius-sm);
  background: var(--resource-track);
  overflow: hidden;
}

.tabletop-resource-meter::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(10% - 1px),
    color-mix(in srgb, var(--resource-paper) 80%, transparent) calc(10% - 1px),
    color-mix(in srgb, var(--resource-paper) 80%, transparent) 10%
  );
  pointer-events: none;
}

.tabletop-resource-meter__fill {
  display: block;
  width: var(--tabletop-resource-fill, 0%);
  height: 100%;
  background: var(--resource-active);
  clip-path: polygon(0 0, calc(100% - 0.28rem) 0, 100% 50%, calc(100% - 0.28rem) 100%, 0 100%);
}

.tabletop-resource-meter.is-empty .tabletop-resource-meter__fill {
  opacity: 0;
}

.tabletop-resource-meter.is-full .tabletop-resource-meter__fill {
  clip-path: none;
}

:where(html:not([data-ui-theme="warm"])) #tabletop-panel-resources .tabletop-resource-stepper > .tabletop-compact-button,
:where(html:not([data-ui-theme="warm"])) #tabletop-panel-resources .tabletop-custom-resource__stepper > .tabletop-compact-button {
  min-height: 2.65rem;
  padding: 0.35rem 0.62rem;
  border-color: transparent;
  border-radius: 0.42rem;
  background: transparent;
  color: var(--resource-caption);
  font-size: 0.72rem;
  font-weight: 850;
  box-shadow: inset 0 0 0 1px var(--resource-rule);
}

:where(html[data-ui-theme="warm"]) #tabletop-panel-resources .tabletop-resource-stepper > .tabletop-compact-button,
:where(html[data-ui-theme="warm"]) #tabletop-panel-resources .tabletop-custom-resource__stepper > .tabletop-compact-button {
  min-height: 2.65rem;
  padding: 0.35rem 0.62rem;
  border-color: transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--resource-caption);
  font-size: 0.72rem;
  font-weight: 850;
  box-shadow: inset 0 0 0 1px var(--resource-rule);
}

#tabletop-panel-resources .tabletop-custom-resource {
  padding-block: 1rem 0.82rem;
}

#tabletop-panel-resources .tabletop-custom-resource__heading {
  grid-column: 1;
  align-self: center;
}

#tabletop-panel-resources .tabletop-custom-resource__stepper {
  grid-column: 2;
  margin: 0;
}

#tabletop-panel-resources .tabletop-custom-resource__actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
  gap: 0.12rem;
  margin: -0.05rem 0 0;
}

:where(html:not([data-ui-theme="warm"])) #tabletop-panel-resources .tabletop-custom-resource__actions .tabletop-compact-button {
  min-height: 1.85rem;
  padding: 0.15rem 0.32rem;
  border-color: transparent;
  border-radius: 0.3rem;
  background: transparent;
  color: var(--resource-caption);
  font-size: 0.7rem;
  font-weight: 750;
  box-shadow: none;
}

:where(html[data-ui-theme="warm"]) #tabletop-panel-resources .tabletop-custom-resource__actions .tabletop-compact-button {
  min-height: 1.85rem;
  padding: 0.15rem 0.32rem;
  border-color: transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--resource-caption);
  font-size: 0.7rem;
  font-weight: 750;
  box-shadow: none;
}

#tabletop-panel-resources .tabletop-custom-resource__actions .tabletop-danger-button {
  color: var(--danger);
}

#tabletop-custom-resource-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border-color: var(--resource-rule);
  background: var(--resource-paper);
  color: var(--resource-active);
  box-shadow: none;
}

#tabletop-custom-resource-add::before {
  content: "+";
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1rem;
  line-height: 1;
}

#tabletop-custom-resource-add[aria-expanded="true"]::before {
  content: "×";
}

/* 桌邊武器沿用角色卡的攻擊欄位骨架；值改為擲骰按鈕。 */
#tabletop-panel-actions .tabletop-weapon-summary {
  gap: 0.65rem;
}

#tabletop-panel-actions .tabletop-weapon-attack-card {
  padding: 0.72rem;
}

#tabletop-panel-actions .tabletop-weapon-fields {
  grid-template-columns: minmax(0, 1.35fr) minmax(4.25rem, 0.72fr) minmax(5.25rem, 0.9fr);
  gap: 0.42rem;
  margin: 0;
}

#tabletop-panel-actions .tabletop-weapon-field {
  display: grid;
  min-width: 0;
}

#tabletop-panel-actions .tabletop-weapon-field:nth-child(4) {
  grid-column: 1 / -1;
}

#tabletop-panel-actions .tabletop-weapon-field dt {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 900;
  line-height: normal;
}

#tabletop-panel-actions .tabletop-weapon-field dd {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  margin: 0;
}

:where(html:not([data-ui-theme="warm"])) #tabletop-panel-actions .tabletop-inline-roll {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.65rem;
  margin: 0;
  padding: 0.5rem;
  border: 1px solid rgba(151, 168, 201, 0.34);
  border-radius: 0.95rem;
  background: linear-gradient(180deg, #f7faff 0%, #eef4ff 100%);
  color: var(--accent);
  box-shadow: none;
  font-size: var(--fs-sm);
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

:where(html[data-ui-theme="warm"]) #tabletop-panel-actions .tabletop-inline-roll {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.65rem;
  margin: 0;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--accent);
  box-shadow: none;
  font-size: var(--fs-sm);
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

#tabletop-panel-actions .tabletop-inline-roll:not(:disabled) {
  box-shadow: none;
}

:where(html:not([data-ui-theme="warm"])) #tabletop-panel-actions .tabletop-inline-roll:disabled {
  border-color: rgba(151, 168, 201, 0.34);
  background: var(--surface-muted);
  color: var(--text);
  cursor: default;
}

:where(html[data-ui-theme="warm"]) #tabletop-panel-actions .tabletop-inline-roll:disabled {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--text);
  cursor: default;
}

:where(html:not([data-ui-theme="warm"])) #tabletop-panel-actions .tabletop-weapon-field:nth-child(4) dd {
  min-height: 2.65rem;
  justify-content: center;
  padding: 0.5rem;
  border: 1px solid rgba(151, 168, 201, 0.34);
  border-radius: 0.95rem;
  background: #fff;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 800;
  line-height: 1.35;
}

:where(html[data-ui-theme="warm"]) #tabletop-panel-actions .tabletop-weapon-field:nth-child(4) dd {
  min-height: 2.65rem;
  justify-content: center;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 800;
  line-height: 1.35;
}

:where(html:not([data-ui-theme="warm"])) #tabletop-panel-actions .tabletop-weapon-field .tabletop-source-tag {
  justify-self: center;
  min-height: 0;
  padding: 0.18rem 0.55rem;
  border: 1px solid rgba(255, 128, 42, 0.58);
  border-radius: 999px;
  background: rgba(255, 128, 42, 0.12);
  color: #b84f08;
  font-size: var(--fs-xs);
  font-weight: 900;
}

:where(html[data-ui-theme="warm"]) #tabletop-panel-actions .tabletop-weapon-field .tabletop-source-tag {
  justify-self: center;
  min-height: 0;
  padding: 0.18rem 0.55rem;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: var(--fs-xs);
  font-weight: 900;
}

#tabletop-panel-actions .tabletop-weapon-field--note-with-mastery dd {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem;
}

#tabletop-panel-actions .tabletop-weapon-note-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#tabletop-panel-actions .tabletop-weapon-mastery {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  margin: 0;
  box-shadow: none;
  cursor: pointer;
}

#tabletop-panel-actions .tabletop-weapon-mastery:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (min-width: 500px) {
  #tabletop-panel-actions .tabletop-weapon-fields {
    grid-template-columns: minmax(7rem, 1.4fr) minmax(4.75rem, 0.7fr) minmax(6.5rem, 1fr);
    gap: 0.55rem;
  }
}

@media (max-width: 380px) {
  #tabletop-panel-actions .tabletop-weapon-fields {
    grid-template-columns: minmax(0, 1.35fr) minmax(4.25rem, 0.72fr) minmax(5.25rem, 0.9fr);
    gap: 0.42rem;
  }
}

html[data-theme="dark"] #tabletop-panel-actions .tabletop-inline-roll,
html[data-theme="dark"] #tabletop-panel-actions .tabletop-weapon-field:nth-child(4) dd {
  border-color: var(--border-strong);
}

html[data-theme="dark"] #tabletop-panel-actions .tabletop-inline-roll:not(:disabled) {
  background: var(--surface-soft);
  color: var(--accent-strong);
}

html[data-theme="dark"] #tabletop-panel-actions .tabletop-inline-roll:disabled,
html[data-theme="dark"] #tabletop-panel-actions .tabletop-weapon-field:nth-child(4) dd {
  background: var(--input-bg);
}

@media (hover: hover) and (pointer: fine) {
  #tabletop-panel-actions .tabletop-inline-roll:not(:disabled):hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
  }

  :where(html:not([data-ui-theme="warm"])) #tabletop-panel-actions .tabletop-weapon-mastery:hover {
    border-color: rgba(255, 128, 42, 0.85);
    background: rgba(255, 128, 42, 0.2);
    color: #8f3b05;
  }

  :where(html[data-ui-theme="warm"]) #tabletop-panel-actions .tabletop-weapon-mastery:hover {
    border-color: var(--warning-border);
    background: var(--warning-soft);
    color: var(--warning);
  }
}

:where(html:not([data-ui-theme="warm"])) #tabletop-panel-resources .tabletop-custom-resource-form {
  gap: 0.7rem;
  padding: 0.9rem;
  border: 1px solid var(--resource-rule);
  border-left: 3px solid var(--resource-active);
  border-radius: 0.42rem;
  background: var(--resource-paper);
  box-shadow: none;
}

:where(html[data-ui-theme="warm"]) #tabletop-panel-resources .tabletop-custom-resource-form {
  gap: 0.7rem;
  padding: 0.9rem;
  border: 1px solid var(--resource-rule);
  border-left: 3px solid var(--resource-active);
  border-radius: var(--radius-sm);
  background: var(--resource-paper);
  box-shadow: none;
}

#tabletop-panel-resources .tabletop-custom-resource-form > label,
#tabletop-panel-resources .tabletop-custom-resource-numbers label {
  color: var(--resource-caption);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.035em;
}

#tabletop-panel-resources .tabletop-custom-resource-form input {
  color: var(--resource-ink);
  font-size: var(--fs-sm);
  letter-spacing: normal;
}

:where(html:not([data-ui-theme="warm"])) #tabletop-custom-resources .tabletop-empty-state {
  padding: 1rem 0.85rem;
  border: 1px dashed var(--resource-rule);
  border-radius: 0.42rem;
  background: transparent;
}

:where(html[data-ui-theme="warm"]) #tabletop-custom-resources .tabletop-empty-state {
  padding: 1rem 0.85rem;
  border: 1px dashed var(--resource-rule);
  border-radius: var(--radius-sm);
  background: transparent;
}

@media (hover: hover) and (pointer: fine) {
  #tabletop-panel-resources .tabletop-number-stepper__adjust:not(:disabled):hover {
    background: var(--accent-soft);
    color: var(--resource-active);
  }

  #tabletop-panel-resources button.tabletop-number-stepper__value:hover {
    color: var(--resource-active);
    box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--resource-active) 62%, transparent);
  }

  #tabletop-panel-resources .tabletop-resource-stepper > .tabletop-compact-button:not(:disabled):hover,
  #tabletop-panel-resources .tabletop-custom-resource__stepper > .tabletop-compact-button:not(:disabled):hover {
    border-color: transparent;
    background: var(--resource-active);
    color: var(--on-accent);
  }

  #tabletop-panel-resources .tabletop-custom-resource__actions .tabletop-compact-button:not(:disabled):hover {
    border-color: transparent;
    background: var(--surface-muted);
    color: var(--resource-ink);
  }
}

@media (max-width: 600px) {
  #tabletop-panel-resources .tabletop-resource-row,
  #tabletop-panel-resources .tabletop-custom-resource {
    grid-template-columns: 1fr;
    align-items: start;
  }

  #tabletop-panel-resources .tabletop-resource-row__controls,
  #tabletop-panel-resources .tabletop-resource-stepper,
  #tabletop-panel-resources .tabletop-custom-resource__stepper {
    grid-column: 1;
    width: 100%;
    justify-self: stretch;
    justify-content: flex-start;
  }

  #tabletop-panel-resources .tabletop-number-stepper {
    flex: 1 1 auto;
    grid-template-columns: 2.75rem minmax(5.35rem, 1fr) 2.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  #tabletop-panel-resources .tabletop-number-stepper button {
    transition: none;
  }
}

/* ===== Dark theme component coverage ===== */
html[data-theme="dark"] body {
  color: var(--text-body);
}

html[data-theme="dark"] .feat-desc-subtitle {
  color: var(--text-body);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] #tab-basic #hp-display,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] #tab-basic #ac-display,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] #tab-basic .speed-current-display,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] #tab-basic .basic-display-checkbox,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] #tab-basic .tight-input,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] #tab-basic .hp-card input[type="number"] {
  border-color: var(--border-strong);
  background: var(--input-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html:where([data-ui-theme="warm"])[data-theme="dark"] #tab-basic #hp-display,
html:where([data-ui-theme="warm"])[data-theme="dark"] #tab-basic #ac-display,
html:where([data-ui-theme="warm"])[data-theme="dark"] #tab-basic .speed-current-display,
html:where([data-ui-theme="warm"])[data-theme="dark"] #tab-basic .basic-display-checkbox,
html:where([data-ui-theme="warm"])[data-theme="dark"] #tab-basic .tight-input,
html:where([data-ui-theme="warm"])[data-theme="dark"] #tab-basic .hp-card input[type="number"] {
  border-color: var(--border-strong);
  background: var(--input-bg);
  box-shadow: none;
}

html[data-theme="dark"] #tab-basic .basic-display-checkbox::after {
  border-color: var(--text-muted);
  background:
    linear-gradient(135deg, transparent 36%, var(--text-muted) 37%, var(--text-muted) 43%, transparent 44%) center/100% 100%,
    linear-gradient(225deg, transparent 36%, var(--text-muted) 37%, var(--text-muted) 43%, transparent 44%) center/100% 100%,
    linear-gradient(315deg, transparent 36%, var(--text-muted) 37%, var(--text-muted) 43%, transparent 44%) center/100% 100%,
    linear-gradient(45deg, transparent 36%, var(--text-muted) 37%, var(--text-muted) 43%, transparent 44%) center/100% 100%,
    var(--surface-soft);
  box-shadow: none;
}

html[data-theme="dark"] #tab-basic .basic-display-checkbox:checked {
  border-color: var(--accent);
  background: var(--accent-soft);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] #tab-basic .basic-display-checkbox:checked::after {
  content: "✓";
  display: grid;
  place-items: center;
  border-color: var(--accent);
  background: var(--accent);
  color: #071521;
  box-shadow: 0 0 0 3px var(--accent-soft);
  font-size: 1rem;
  font-weight: 950;
  line-height: 1;
}

html:where([data-ui-theme="warm"])[data-theme="dark"] #tab-basic .basic-display-checkbox:checked::after {
  content: "✓";
  display: grid;
  place-items: center;
  border-color: var(--accent);
  background: var(--action-fill);
  color: var(--on-accent);
  box-shadow: none;
  font-size: 1rem;
  font-weight: 950;
  line-height: 1;
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] #tab-basic .basic-display-checkbox:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

html:where([data-ui-theme="warm"])[data-theme="dark"] #tab-basic .basic-display-checkbox:focus-visible {
  border-color: var(--accent);
  box-shadow: none; outline: 2px solid var(--focus-ring); outline-offset: 2px;
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .tabs-shell {
  box-shadow: var(--shadow-strong), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html:where([data-ui-theme="warm"])[data-theme="dark"] .tabs-shell {
  box-shadow: var(--shadow-strong);
}

html[data-theme="dark"] .tab-button.active,
html[data-theme="dark"] .tabs-shell .tab-button.active:hover,
html[data-theme="dark"] .utility-menu__button--primary,
html[data-theme="dark"] .utility-menu__button--primary:hover,
html[data-theme="dark"] #legal-ack-btn {
  border-color: var(--accent-strong);
  background: var(--accent-gradient);
  color: var(--on-accent);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .utility-menu__button--danger,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .utility-menu__button--danger:hover {
  border-color: var(--danger-border);
  background: linear-gradient(180deg, var(--surface-strong) 0%, var(--danger-soft) 100%);
  color: var(--danger);
}

html:where([data-ui-theme="warm"])[data-theme="dark"] .utility-menu__button--danger,
html:where([data-ui-theme="warm"])[data-theme="dark"] .utility-menu__button--danger:hover {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

html[data-theme="dark"] #equipment-notes-section details,
html[data-theme="dark"] #equipment-notes-section details:hover,
html[data-theme="dark"] .selection-summary,
html[data-theme="dark"] .selection-summary-card,
html[data-theme="dark"] .ability,
html[data-theme="dark"] .modifier,
html[data-theme="dark"] .skill-legend,
html[data-theme="dark"] .action-help table,
html[data-theme="dark"] .weapon-automation-toggle,
html[data-theme="dark"] .weapon-attack-card,
html[data-theme="dark"] .equipment-loadout-summary,
html[data-theme="dark"] .weapon-attack-fields input.is-automated,
html[data-theme="dark"] .equipment-summary-row,
html[data-theme="dark"] .money-section,
html[data-theme="dark"] .money-balance-grid > div,
html[data-theme="dark"] .money-summary,
html[data-theme="dark"] .spell-entry--derived,
html[data-theme="dark"] .feat-entry--derived,
html[data-theme="dark"] .tool-proficiency-row--derived,
html[data-theme="dark"] .spell-slot-column,
html[data-theme="dark"] .invocation-prereq {
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--text-body);
  box-shadow: none;
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .equipment-summary-row .equipment-proficiency-warning {
  color: #ff9b9b;
}

html:where([data-ui-theme="warm"])[data-theme="dark"] .equipment-summary-row .equipment-proficiency-warning {
  color: var(--warning);
}

html[data-theme="dark"] .selection-summary-card,
html[data-theme="dark"] .ability-score,
html[data-theme="dark"] .skill-control-row input[type="text"],
html[data-theme="dark"] .legend-circle,
html[data-theme="dark"] .circle-checkbox,
html[data-theme="dark"] .weapon-attack-fields input,
html[data-theme="dark"] .weapon-attack-fields .weapon-attack-free-note,
html[data-theme="dark"] #attack-calculation-popup,
html[data-theme="dark"] .equipment-purchase-card,
html[data-theme="dark"] #tab-actions .form-row.small-text input,
html[data-theme="dark"] .spell-search-results,
html[data-theme="dark"] .equipment-search-results,
html[data-theme="dark"] .equipment-search-clear,
html[data-theme="dark"] .feat-icon-btn,
html[data-theme="dark"] .point-buy-row,
html[data-theme="dark"] .point-buy-step,
html[data-theme="dark"] .ability-choice-close,
html[data-theme="dark"] .default-ability-class-close,
html[data-theme="dark"] .point-buy-close,
html[data-theme="dark"] #legal-close-btn,
html[data-theme="dark"] .pdf-export-flow-modal__card .pdf-export-precheck-list__jump,
html[data-theme="dark"] .pdf-export-name-field__input,
html[data-theme="dark"] .pdf-export-flow-modal__card .pdf-export-choice-option,
html[data-theme="dark"] .pdf-export-flow-modal__card .pdf-export-race-option,
html[data-theme="dark"] .pdf-export-flow-modal__card .pdf-export-format-option,
html[data-theme="dark"] .pdf-export-flow-modal__button--secondary {
  border-color: var(--border-strong);
  background: var(--input-bg);
  color: var(--text);
}

html[data-theme="dark"] .equipment-purchase-balance {
  border: 1px solid var(--border-strong);
  background: var(--surface-muted);
  color: var(--text);
}

html[data-theme="dark"] .pdf-export-flow-modal__card .pdf-export-choice-option:hover,
html[data-theme="dark"] .pdf-export-flow-modal__card .pdf-export-choice-option:focus-visible {
  border-color: var(--accent-strong);
  background: var(--surface-muted);
}

html[data-theme="dark"] .equipment-catalog-table th,
html[data-theme="dark"] .class-feature-table th,
html[data-theme="dark"] .action-help th {
  background: var(--surface-muted);
  color: var(--text);
}

html[data-theme="dark"] .equipment-catalog-table tbody tr:nth-child(even),
html[data-theme="dark"] .class-feature-table tbody tr:nth-child(even),
html[data-theme="dark"] .money-log-list li {
  background: var(--accent-soft);
}

html[data-theme="dark"] #tab-basic .hp-card input[type="number"],
html[data-theme="dark"] .weapon-automation-toggle input::after,
html[data-theme="dark"] .money-detail-toggle input::after {
  background: var(--input-bg);
}

html[data-theme="dark"] .selection-summary-badge,
html[data-theme="dark"] #condition-button-grid .active-condition,
html[data-theme="dark"] .equipment-detail-tags span,
html[data-theme="dark"] .pdf-export-wait-note,
html[data-theme="dark"] .pdf-export-status--progress {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

html[data-theme="dark"] .share-mode-tip,
html[data-theme="dark"] .quick-build-source-warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .equipment-search-highlight {
  background: #735a12;
  color: #fff2b6;
}

html:where([data-ui-theme="warm"])[data-theme="dark"] .equipment-search-highlight {
  background: var(--warning-soft);
  color: var(--warning);
}

html[data-theme="dark"] .spell-highlight,
html[data-theme="dark"] .feat-icon-btn--delete,
html[data-theme="dark"] .pdf-export-flow-modal__error,
html[data-theme="dark"] .pdf-export-status--error .pdf-export-flow-modal__error {
  color: var(--danger);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .pdf-export-check-success {
  border-color: rgba(134, 239, 172, 0.5);
  background: #164b34;
  color: #dcfce7;
}

html:where([data-ui-theme="warm"])[data-theme="dark"] .pdf-export-check-success {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .pdf-export-check-success > span {
  background: #d1fae5;
  color: #166534;
}

html:where([data-ui-theme="warm"])[data-theme="dark"] .pdf-export-check-success > span {
  background: var(--success-soft);
  color: var(--success);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .pdf-export-check-success strong {
  color: #f0fdf4;
}

html:where([data-ui-theme="warm"])[data-theme="dark"] .pdf-export-check-success strong {
  color: var(--on-accent);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .pdf-export-check-success p {
  color: #bbf7d0;
}

html:where([data-ui-theme="warm"])[data-theme="dark"] .pdf-export-check-success p {
  color: var(--success);
}

html[data-theme="dark"] .money-modal,
html[data-theme="dark"] .equipment-purchase-modal,
html[data-theme="dark"] #equipment-detail-modal,
html[data-theme="dark"] #ability-choice-modal,
html[data-theme="dark"] #point-buy-modal,
html[data-theme="dark"] #default-ability-class-modal,
html[data-theme="dark"] #point-buy-exit-modal,
html[data-theme="dark"] #legal-modal,
html[data-theme="dark"] #legal-about-modal,
html[data-theme="dark"] .pdf-export-flow-modal {
  background: var(--overlay-strong);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .point-buy-modal-card,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .ability-choice-card,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .default-ability-class-card,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .point-buy-exit-card,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .legal-modal-card,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .legal-about-card,
html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] .pdf-export-flow-modal__card {
  border-color: var(--border-strong);
  background: linear-gradient(180deg, var(--surface-strong) 0%, var(--surface) 100%);
  color: var(--text-body);
  box-shadow: var(--shadow-strong);
}

html:where([data-ui-theme="warm"])[data-theme="dark"] .point-buy-modal-card,
html:where([data-ui-theme="warm"])[data-theme="dark"] .ability-choice-card,
html:where([data-ui-theme="warm"])[data-theme="dark"] .default-ability-class-card,
html:where([data-ui-theme="warm"])[data-theme="dark"] .point-buy-exit-card,
html:where([data-ui-theme="warm"])[data-theme="dark"] .legal-modal-card,
html:where([data-ui-theme="warm"])[data-theme="dark"] .legal-about-card,
html:where([data-ui-theme="warm"])[data-theme="dark"] .pdf-export-flow-modal__card {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  color: var(--text-body);
  box-shadow: var(--shadow-strong);
}

html[data-theme="dark"] .ability-choice-card h3,
html[data-theme="dark"] .default-ability-class-card h3,
html[data-theme="dark"] .point-buy-preset-copy strong,
html[data-theme="dark"] .point-buy-header h3,
html[data-theme="dark"] .point-buy-ability,
html[data-theme="dark"] .point-buy-value,
html[data-theme="dark"] .point-buy-total,
html[data-theme="dark"] .pdf-export-flow-modal__card h3,
html[data-theme="dark"] .pdf-export-wait-note strong,
html[data-theme="dark"] .pdf-export-name-field label,
html[data-theme="dark"] .legal-modal-meta-title {
  color: var(--text);
}

html[data-theme="dark"] .ability-choice-card p,
html[data-theme="dark"] .ability-choice-tip,
html[data-theme="dark"] .point-buy-header p,
html[data-theme="dark"] .point-buy-hint,
html[data-theme="dark"] .point-buy-table-head,
html[data-theme="dark"] .point-buy-value--bonus,
html[data-theme="dark"] .point-buy-summary,
html[data-theme="dark"] .point-buy-background,
html[data-theme="dark"] .default-ability-class-note,
html[data-theme="dark"] .default-ability-class-group h4,
html[data-theme="dark"] .point-buy-preset-copy span,
html[data-theme="dark"] .point-buy-preset-status,
html[data-theme="dark"] .legal-modal-meta,
html[data-theme="dark"] .pdf-export-flow-modal__eyebrow,
html[data-theme="dark"] .pdf-export-flow-modal__subtitle,
html[data-theme="dark"] .pdf-export-step-copy,
html[data-theme="dark"] .pdf-export-wait-note span,
html[data-theme="dark"] .pdf-export-choice-option span,
html[data-theme="dark"] .pdf-export-format-option__detail,
html[data-theme="dark"] .pdf-export-flow-modal__card .pdf-export-format-note {
  color: var(--text-muted);
}

html[data-theme="dark"] .point-buy-background select,
html[data-theme="dark"] .default-ability-class-grid button {
  border-color: var(--border-strong);
  background: var(--control-bg);
  color: var(--text);
}

html[data-theme="dark"] .point-buy-background select {
  background: var(--input-bg);
  color: var(--text);
  color-scheme: dark;
  -webkit-text-fill-color: var(--text);
}

html[data-theme="dark"] .point-buy-background select option,
html[data-theme="dark"] .point-buy-background select optgroup {
  background-color: var(--input-bg);
  color: var(--text);
}

html[data-theme="dark"] .default-ability-class-grid button:hover,
html[data-theme="dark"] .default-ability-class-grid button:focus-visible {
  background: var(--surface-muted);
}

html[data-theme="dark"] .default-ability-class-group h4::before,
html[data-theme="dark"] .default-ability-class-group h4::after {
  background: var(--border);
}

html[data-theme="dark"] .point-buy-preset {
  border-color: var(--border);
}

html[data-theme="dark"] .point-buy-preset-status.is-applied {
  color: var(--success);
}

html[data-theme="dark"] .point-buy-exit-card {
  color: var(--text-body);
}

html[data-theme="dark"] .point-buy-exit-card h3 {
  color: var(--danger);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] #point-buy-exit-confirm {
  border-color: rgba(248, 113, 113, 0.45);
  background: var(--danger-soft);
  color: var(--danger);
}

html:where([data-ui-theme="warm"])[data-theme="dark"] #point-buy-exit-confirm {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

html[data-theme="dark"] .legal-modal-meta,
html[data-theme="dark"] .pdf-export-flow-modal__header,
html[data-theme="dark"] .pdf-export-flow-modal__actions,
html[data-theme="dark"] .pdf-export-flow-modal__card .pdf-export-format-note {
  border-color: var(--border);
}

html[data-theme="dark"] .point-buy-row--bonus-locked,
html[data-theme="dark"] select:disabled,
html[data-theme="dark"] input:disabled,
html[data-theme="dark"] textarea:disabled,
html[data-theme="dark"] button:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-text);
}

html[data-theme="dark"] #tour-tooltip {
  border-color: var(--border-strong);
  background: var(--surface-strong);
  color: var(--text-body);
  box-shadow: var(--shadow-strong);
}

html:where(:not([data-ui-theme="warm"]))[data-theme="dark"] #tour-step-progress {
  border-color: rgba(122, 162, 255, 0.42);
  background: rgba(122, 162, 255, 0.16);
  color: #a9c1ff;
}

html:where([data-ui-theme="warm"])[data-theme="dark"] #tour-step-progress {
  border-color: var(--border);
  background: var(--accent-soft);
  color: var(--accent);
}

html[data-theme="dark"] #tour-step-text,
html[data-theme="dark"] #tour-prev-btn {
  color: var(--text-body);
}

html[data-theme="dark"] #tour-prev-btn {
  background: var(--control-bg);
}

html[data-theme="dark"] .site-footer a,
html[data-theme="dark"] .equipment-purchase-link,
html[data-theme="dark"] .feat-icon-btn--add {
  color: var(--accent);
}

/* The utility menu is an overlay, so its surface must remain opaque. */
.druid-operation, .druid-beast-detail { display: grid; gap: .75rem; min-width: 0; }
.druid-operation p, .druid-beast-detail p, .druid-status p { margin: .35rem 0; line-height: 1.65; overflow-wrap: anywhere; }
.druid-field { display: grid; gap: .4rem; font-weight: 600; }
.druid-field select, .druid-field input { width: 100%; min-width: 0; min-height: 42px; box-sizing: border-box; }
.druid-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .65rem; }
.druid-known-form { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; column-gap: .5rem; }
.druid-known-form > .druid-check { width: auto; margin: 0; }
.druid-known-form > small { grid-column: 2; }
.druid-beast-name { justify-self: start; width: auto; min-width: 0; min-height: 40px; margin: 0; padding: .35rem 0; color: inherit; font: inherit; background: none; border: 0; border-radius: 0; box-shadow: none; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.druid-beast-tooltip:not([hidden]) { display: block; }
.druid-beast-tooltip { max-height: min(65vh, 32rem); overflow-y: auto; cursor: auto; touch-action: auto; user-select: text; }
.druid-beast-tooltip > button { float: right; margin: 0 0 .4rem .4rem; }
.druid-shape-description { white-space: normal; }
.druid-shape-description p, .druid-shape-description ul { margin: .85rem 0; }
.druid-shape-description ul { padding-left: 1.4rem; }
.druid-shape-description li { margin: .4rem 0; }
.druid-check { display: flex; align-items: center; gap: .5rem; min-height: 40px; }
.druid-check input { flex: 0 0 auto; width: 18px; height: 18px; }
.druid-button-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .5rem 0; }
.druid-status .tabletop-compact-button, .tabletop-action-description > .tabletop-compact-button { margin: .2rem .35rem .2rem 0; }
:where(html:not([data-ui-theme="warm"])) .druid-resource-note { color: var(--text-muted, #64748b); }
:where(html[data-ui-theme="warm"]) .druid-resource-note { color: var(--text-muted, var(--text-muted)); }
:where(html:not([data-ui-theme="warm"])) .druid-error { color: var(--danger, #b42318); font-weight: 600; }
:where(html[data-ui-theme="warm"]) .druid-error { color: var(--danger, var(--warning)); font-weight: 600; }
.druid-beast-attacks { grid-column: 1 / -1; min-width: 0; }
.druid-beast-attacks > p { line-height: 1.7; }
#tabletop-druid-resources { margin-top: 1rem; }

:where(html:not([data-ui-theme="warm"])) .utility-menu {
  background: #fff;
}

:where(html[data-ui-theme="warm"]) .utility-menu {
  background: var(--surface-strong);
}

html[data-theme="dark"] .utility-menu {
  background: var(--surface-strong);
}

@media (min-width: 720px) {
  .spell-picked-content {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

:where(html:not([data-ui-theme="warm"])) .tabletop-class-choice-alert {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--warning-border);
  border-radius: 8px;
  color: var(--warning);
  background: var(--warning-soft);
}

:where(html[data-ui-theme="warm"]) .tabletop-class-choice-alert {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  color: var(--warning);
  background: var(--warning-soft);
}

/* 生命值、操作回饋與狀態共用右欄，頭像保留尺寸並垂直置中。 */
.tabletop-health-layout .tabletop-avatar {
  align-self: center;
}

.tabletop-health-controls .tabletop-conditions {
  grid-column: 1 / -1;
  margin: 0.28rem 0 0;
  padding: 0.35rem 0;
  grid-template-columns: minmax(0, 1fr) auto;
}

.tabletop-health-controls .tabletop-condition-manage {
  grid-column: 2;
}

.tabletop-health-controls .tabletop-active-conditions {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
}

.tabletop-health-controls .tabletop-hp-primary strong {
  white-space: nowrap;
}

@media (min-width: 720px) {
  .tabletop-health-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    align-content: start;
    column-gap: 0.4rem;
  }

  .tabletop-hp-readout {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    padding-bottom: 0;
  }

  .tabletop-health-controls .tabletop-hp-primary,
  .tabletop-health-controls .tabletop-hp-temporary,
  .tabletop-health-controls .tabletop-life-controls > * {
    height: 3rem;
    min-height: 3rem;
  }

  .tabletop-health-controls .tabletop-hp-primary,
  .tabletop-health-controls .tabletop-hp-temporary {
    padding: 0.2rem 0.4rem;
    gap: 0;
  }

  .tabletop-health-controls .tabletop-hp-primary strong,
  .tabletop-health-controls .tabletop-hp-temporary strong {
    font-size: 1.25rem;
  }

  .tabletop-health-controls .tabletop-hp-label {
    white-space: nowrap;
  }

  .tabletop-health-controls .tabletop-life-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tabletop-health-controls .tabletop-conditions {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .tabletop-health-controls .tabletop-condition-manage {
    grid-column: 3;
  }

  .tabletop-health-controls .tabletop-active-conditions {
    grid-column: 2;
    grid-row: 1;
  }

  .tabletop-life-form {
    padding-top: 0;
    border-top: 0;
  }

  .tabletop-temporary-hp-form,
  .tabletop-live-status {
    grid-column: 1 / -1;
  }
}

@media (min-width: 389px) and (max-width: 520px) {
  .tabletop-health-controls .tabletop-hp-primary strong {
    font-size: clamp(1.1rem, 5vw, 1.5rem);
  }
}

/* 圖片收起後，中型螢幕已有足夠空間容納同一列操作。 */
@media (min-width: 560px) and (max-width: 719px) {
  .tabletop-health-layout--avatar-collapsed .tabletop-health-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    align-content: start;
    column-gap: 0.4rem;
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-hp-readout {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    padding-bottom: 0;
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-hp-primary,
  .tabletop-health-layout--avatar-collapsed .tabletop-hp-temporary,
  .tabletop-health-layout--avatar-collapsed .tabletop-life-controls > * {
    height: 3rem;
    min-height: 3rem;
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-hp-primary,
  .tabletop-health-layout--avatar-collapsed .tabletop-hp-temporary {
    padding: 0.2rem 0.4rem;
    gap: 0;
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-hp-primary strong,
  .tabletop-health-layout--avatar-collapsed .tabletop-hp-temporary strong {
    font-size: 1.25rem;
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-life-form {
    padding-top: 0;
    border-top: 0;
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-life-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-life-controls input {
    grid-column: auto;
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-temporary-hp-form,
  .tabletop-health-layout--avatar-collapsed .tabletop-live-status {
    grid-column: 1 / -1;
  }
}

@media (min-width: 520px) {
  .tabletop-health-layout--avatar-collapsed .tabletop-conditions {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-condition-manage {
    grid-column: 3;
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-active-conditions {
    grid-column: 2;
    grid-row: 1;
  }
}

/* 小手機：圖片在左、四列操作在右；回饋與狀態接在兩者下方。 */
@media (max-width: 388px) {
  .tabletop-health-layout {
    container-type: inline-size;
    grid-template-columns: minmax(0, 1fr) 1.35rem minmax(0, 1fr);
  }

  .tabletop-health-layout--avatar-collapsed {
    grid-template-columns: 1.35rem minmax(0, 1fr);
  }

  .tabletop-health-layout .tabletop-avatar {
    max-width: max(5.75rem, 29cqw);
    justify-self: center;
  }

  .tabletop-health-controls {
    display: contents;
  }

  .tabletop-health-layout .tabletop-avatar,
  .tabletop-health-layout .tabletop-avatar-visibility-toggle {
    grid-row: 1 / 3;
  }

  .tabletop-health-layout .tabletop-hp-readout,
  .tabletop-health-layout .tabletop-life-form {
    grid-column: 3;
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-hp-readout,
  .tabletop-health-layout--avatar-collapsed .tabletop-life-form {
    grid-column: 2;
  }

  .tabletop-health-layout .tabletop-hp-readout {
    grid-row: 1;
    grid-template-columns: minmax(0, 1fr);
    padding-bottom: 0;
  }

  .tabletop-health-layout .tabletop-life-form {
    grid-row: 2;
    padding-top: 0;
    border-top: 0;
  }

  .tabletop-health-layout .tabletop-life-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tabletop-health-layout .tabletop-life-controls input {
    grid-column: 1 / -1;
  }

  .tabletop-health-layout .tabletop-temporary-hp-form,
  .tabletop-health-layout .tabletop-live-status,
  .tabletop-health-layout .tabletop-conditions {
    grid-column: 1 / -1;
    min-width: 0;
  }
}

/* 極窄螢幕：圖片獨立一列，操作使用全寬。 */
@media (max-width: 319px) {
  .tabletop-health-layout {
    grid-template-columns: minmax(0, 1fr) 1.35rem;
  }

  .tabletop-health-layout .tabletop-avatar {
    grid-column: 1;
    grid-row: 1;
    width: 5.75rem;
    justify-self: center;
  }

  .tabletop-health-layout .tabletop-avatar-visibility-toggle {
    grid-column: 2;
    grid-row: 1;
  }

  .tabletop-health-layout .tabletop-hp-readout,
  .tabletop-health-layout .tabletop-life-form {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .tabletop-health-layout--avatar-collapsed {
    grid-template-columns: 1.35rem minmax(0, 1fr);
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-avatar-visibility-toggle {
    grid-column: 1;
    grid-row: 1 / 3;
  }

  .tabletop-health-layout--avatar-collapsed .tabletop-hp-readout,
  .tabletop-health-layout--avatar-collapsed .tabletop-life-form {
    grid-column: 2;
  }
}

/* 小手機收起圖片時，HP 可並排；最窄螢幕仍保留單欄。 */
@media (min-width: 320px) and (max-width: 388px) {
  .tabletop-health-layout--avatar-collapsed .tabletop-hp-readout {
    grid-template-columns: minmax(0, 1fr) minmax(4.5rem, 0.55fr);
  }
}
