/* ============================================================
   D&D 2024 Character Sheet — Styles
   Dark Fantasy Theme with Class-Based Color Schemes
   ============================================================ */

/* ============================================================
   CSS Custom Properties
   ============================================================ */
@font-face {
  font-family: 'Cinzel';
  src: url('assets/fonts/Cinzel-Variable.ttf') format('truetype');
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: 'Crimson Pro';
  src: url('assets/fonts/CrimsonPro-Variable.ttf') format('truetype');
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: 'Crimson Pro';
  src: url('assets/fonts/CrimsonPro-Italic-Variable.ttf') format('truetype');
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --bg:             #0b0e12;
  --bg-surface:     #11171d;
  --bg-card:        #171e25;
  --bg-card-hover:  #1e2730;
  --bg-input:       #0e141a;
  --border:         #2a343e;
  --border-strong:  #3e4b57;
  --text:           #e8edf2;
  --text-dim:       #b5c0ca;
  --text-heading:   #f7f9fa;
  --gold:           #d6b85a;
  --gold-dim:       #a08435;
  --red:            #c0392b;
  --green:          #27ae60;
  --blue:           #2a52be;

  --class-primary:  #7890a3;
  --class-accent:   #a67c4f;
  --class-readable: #afc3d2;
  --class-bg:       #0b0e12;
  --class-text:     #0b0e12; /* dark ink on filled class-color surfaces */

  --radius:         6px;
  --radius-lg:      10px;
  --transition:     0.2s ease;

  --font-heading:   'Cinzel', 'Times New Roman', serif;
  --font-body:      'Crimson Pro', 'Georgia', serif;
  --font-mono:      'Courier New', monospace;
}

/* Class palettes are defined once in data.js and applied by applyClassTheme().
   Shared neutral surfaces keep every class restrained; identity comes from the
   primary, secondary, and accessible readable-accent tokens. */

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--class-bg);
  color: var(--text);
  min-height: 100vh;
  transition: background-color 0.3s ease;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;

  background:
    radial-gradient(
      ellipse at 20% 50%,
      color-mix(in srgb, var(--class-primary) 12%, transparent) 0%,
      transparent 70%
    ),
    radial-gradient(
      ellipse at 80% 20%,
      color-mix(in srgb, var(--class-accent) 10%, transparent) 0%,
      transparent 60%
    );
}

body.home-active::before {
  background:
    radial-gradient(ellipse at 18% 42%, rgba(87, 149, 138, 0.13) 0%, transparent 68%),
    radial-gradient(ellipse at 82% 18%, rgba(171, 189, 185, 0.08) 0%, transparent 62%);
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--text-heading);
  letter-spacing: 0.03em;
}

/* ============================================================
   Home View
   ============================================================ */
.home-view {
  --home-accent: #6fb7aa;
  --home-accent-bright: #b8ece3;
  --home-text: #d7e5df;
  --home-muted: #819790;
  width: 100%;
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: clamp(1rem, 2.8vw, 3rem);
  color: var(--home-text);
  background:
    radial-gradient(circle at 10% 6%, rgba(111, 183, 170, 0.14), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(143, 166, 161, 0.1), transparent 24rem),
    linear-gradient(135deg, rgba(5, 11, 10, 0.99), rgba(10, 19, 17, 0.98) 48%, rgba(4, 8, 8, 0.99));
}

.home-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.7fr);
  gap: clamp(1rem, 3vw, 2rem);
  min-height: 320px;
  padding: clamp(1.15rem, 3vw, 2.2rem);
  border: 1px solid color-mix(in srgb, var(--home-accent) 30%, #1d2c29);
  border-radius: 26px;
  background:
    linear-gradient(115deg, rgba(8, 21, 19, 0.96), rgba(11, 24, 22, 0.92) 48%, rgba(17, 26, 26, 0.82)),
    repeating-linear-gradient(90deg, rgba(111, 183, 170, 0.035) 0 1px, transparent 1px 74px);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(184, 236, 227, 0.07);
}

.home-hero::before {
  content: "";
  position: absolute;
  inset: 12px;
  pointer-events: none;
  border: 1px solid rgba(111, 183, 170, 0.15);
  border-radius: 20px;
}

.home-hero-glow {
  position: absolute;
  width: 360px;
  height: 360px;
  right: -120px;
  top: -140px;
  pointer-events: none;
  background: radial-gradient(circle, rgba(111, 183, 170, 0.2), transparent 66%);
}

.home-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 820px;
}

.home-kicker {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--home-accent-bright);
  margin-bottom: 0.55rem;
}

.home-hero h1 {
  font-size: clamp(2.25rem, 6vw, 5rem);
  line-height: 0.92;
  margin: 0;
  color: #edf8f5;
  text-shadow: 0 4px 26px rgba(0, 0, 0, 0.48);
}

.home-lead {
  max-width: 760px;
  margin: 1rem 0 0;
  color: color-mix(in srgb, var(--home-text) 82%, #fff);
  font-size: clamp(0.98rem, 1.8vw, 1.16rem);
  line-height: 1.55;
}

.home-hero-badge {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--home-accent-bright);
  border: 1px solid rgba(184, 236, 227, 0.34);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: rgba(111, 183, 170, 0.1);
  width: fit-content;
}

.home-hero-actions {
  margin-top: 1.35rem;
  display: flex;
  gap: 0.5rem;
}

.home-primary-action {
  min-height: 52px;
  padding-inline: 1.55rem;
  font-size: 0.85rem;
  color: #03100e;
  border: 1px solid #d6fff8;
  background:
    linear-gradient(135deg, #d8fff8 0%, var(--home-accent-bright) 42%, var(--home-accent) 100%);
  box-shadow:
    0 0 0 1px rgba(184, 236, 227, 0.24),
    0 16px 36px rgba(111, 183, 170, 0.3),
    0 0 34px rgba(184, 236, 227, 0.16);
  letter-spacing: 0.08em;
}

.home-primary-action:hover {
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(216, 255, 248, 0.34),
    0 20px 42px rgba(111, 183, 170, 0.4),
    0 0 42px rgba(184, 236, 227, 0.24);
}

.home-hero-panel {
  position: relative;
  z-index: 1;
  align-self: center;
  justify-self: stretch;
  padding: 1rem;
  border: 1px solid rgba(111, 183, 170, 0.22);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(7, 15, 14, 0.7), rgba(7, 15, 14, 0.38)),
    rgba(184, 236, 227, 0.035);
}

.home-ledger-lines {
  display: grid;
  gap: 0.72rem;
  margin-top: 1rem;
}

.home-ledger-lines span {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  color: color-mix(in srgb, var(--home-text) 78%, transparent);
  font-size: 0.86rem;
}

.home-ledger-lines span::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 0.34rem;
  transform: rotate(45deg);
  border: 1px solid var(--home-accent);
  background: rgba(111, 183, 170, 0.16);
}

.home-ledger-lines strong {
  display: block;
  color: #edf8f5;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.home-ledger-lines small {
  display: block;
  grid-column: 2;
  margin-top: 0.12rem;
  color: var(--home-muted);
  font-size: 0.74rem;
  line-height: 1.25;
}

.home-roster {
  margin-top: 1.15rem;
  padding: clamp(1rem, 1.8vw, 1.4rem);
  border: 1px solid rgba(184, 236, 227, 0.24);
  border-radius: 24px;
  background:
    radial-gradient(circle at top left, rgba(111, 183, 170, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(10, 23, 21, 0.82), rgba(5, 12, 11, 0.76));
  box-shadow:
    inset 0 0 0 1px rgba(184, 236, 227, 0.055),
    0 20px 54px rgba(0, 0, 0, 0.28);
}

.home-section-heading {
  display: flex;
  align-items: end;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.home-section-heading h2 {
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.65rem);
  color: #edf8f5;
  text-shadow: 0 0 18px rgba(184, 236, 227, 0.14);
}

.home-section-rule {
  flex: 1;
  height: 1px;
  margin-bottom: 0.45rem;
  background: linear-gradient(90deg, rgba(111, 183, 170, 0.44), transparent);
}

.home-character-list {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.home-character-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem;
  border: 1px solid color-mix(in srgb, var(--home-char-accent, var(--home-accent)) 34%, rgba(184, 236, 227, 0.2));
  border-radius: 18px;
  background:
    radial-gradient(circle at left, color-mix(in srgb, var(--home-char-accent, var(--home-accent)) 15%, transparent), transparent 36%),
    linear-gradient(180deg, rgba(12, 27, 24, 0.94), rgba(6, 13, 12, 0.96));
  box-shadow:
    inset 0 0 0 1px rgba(184, 236, 227, 0.075),
    0 16px 34px rgba(0, 0, 0, 0.28);
}

.home-character-item:hover {
  border-color: color-mix(in srgb, var(--home-char-accent, var(--home-accent)) 52%, rgba(184, 236, 227, 0.28));
  transform: translateY(-1px);
  box-shadow:
    inset 0 0 0 1px rgba(184, 236, 227, 0.095),
    0 20px 42px rgba(0, 0, 0, 0.34);
}

.home-character-portrait {
  display: grid;
  place-items: center;
  width: 86px;
  aspect-ratio: 3/4;
  border: 1px solid color-mix(in srgb, var(--home-char-accent, var(--home-accent)) 28%, rgba(184, 236, 227, 0.18));
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(circle, color-mix(in srgb, var(--home-char-accent, var(--home-accent)) 8%, transparent), transparent 68%),
    rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 0 0 1px rgba(184, 236, 227, 0.06);
}

.home-character-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.home-character-portrait span {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: color-mix(in srgb, var(--home-char-accent, var(--home-accent)) 54%, #edf8f5);
  text-shadow: 0 0 18px rgba(184, 236, 227, 0.14);
}

.home-character-name {
  font-family: var(--font-heading);
  color: #edf8f5;
  font-size: clamp(1.05rem, 1.6vw, 1.32rem);
}

.home-character-name span {
  color: color-mix(in srgb, var(--home-accent-bright) 76%, var(--home-muted));
  font-size: 0.78em;
  white-space: nowrap;
}

.home-character-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.home-character-detail-grid span {
  display: grid;
  gap: 0.12rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(184, 236, 227, 0.09);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.028);
  color: color-mix(in srgb, var(--home-text) 82%, transparent);
  font-size: 0.8rem;
}

.home-character-detail-grid strong {
  color: var(--home-muted);
  font-family: var(--font-heading);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-character-time {
  color: var(--home-muted);
  font-size: 0.72rem;
}

.home-character-time {
  margin-top: 0.35rem;
}

.home-character-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.home-character-actions .btn.gold {
  color: #061311;
  border-color: color-mix(in srgb, var(--home-accent-bright) 78%, var(--home-char-accent, var(--home-accent)));
  background: linear-gradient(135deg, var(--home-accent-bright), color-mix(in srgb, var(--home-accent) 82%, var(--home-char-accent, var(--home-accent))));
  box-shadow: 0 10px 22px rgba(111, 183, 170, 0.18);
}

.home-character-actions .btn.gold:hover {
  box-shadow: 0 14px 28px rgba(111, 183, 170, 0.28);
}

@media (max-width: 760px) {
  .home-view {
    padding: 0.8rem;
  }
  .home-hero {
    grid-template-columns: 1fr;
  }
  .home-character-list {
    grid-template-columns: 1fr;
  }
  .home-character-item {
    grid-template-columns: auto 1fr;
  }
  .home-character-portrait {
    width: 72px;
  }
  .home-character-detail-grid {
    grid-template-columns: 1fr;
  }
  .home-character-actions {
    grid-column: 1 / -1;
    flex-wrap: wrap;
  }
}

/* ============================================================
   Tab Bar
   ============================================================ */
.tab-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border-bottom: 2px solid var(--border);
  padding: 0 1rem;
  position: relative;
  z-index: 50;
}

.tab-bar-main {
  display: flex;
}

.tab-btn {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--text);
  background: var(--bg-card);
}

.tab-btn.active {
  color: var(--class-readable);
  border-bottom-color: var(--class-primary);
  transition: color 0.3s, border-color 0.3s;
}

.tab-home-btn {
  font-size: 0.66rem;
  padding: 0.28rem 0.6rem;
}

.tab-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.tab-pending-btn {
  font-size: 0.62rem;
  color: var(--class-readable);
  border-color: color-mix(in srgb, var(--class-primary) 60%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 13%, transparent);
}

.tab-manual-btn {
  font-size: 0.62rem;
  color: var(--text-dim);
  border-color: var(--border);
  background: var(--bg-card);
  transition: all var(--transition);
}

.tab-manual-btn.active {
  color: var(--class-text);
  border-color: color-mix(in srgb, var(--class-primary) 68%, var(--border));
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--class-primary) 92%, #000 8%),
    color-mix(in srgb, var(--class-primary) 76%, #000 24%)
  );
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--class-primary) 38%, transparent);
}

@media (max-width: 760px) {
  .tab-bar {
    flex-wrap: wrap;
    gap: 0.15rem 0.4rem;
    padding: 0 0.5rem 0.4rem;
  }

  .tab-bar-main,
  .tab-bar-actions {
    flex: 1 1 100%;
    min-width: 0;
  }

  .tab-bar-main {
    justify-content: stretch;
  }

  .tab-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.55rem 0.35rem;
    white-space: normal;
  }

  .tab-bar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .tab-pending-btn,
  .tab-manual-btn,
  .tab-home-btn {
    white-space: nowrap;
  }
}

.pending-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  background: var(--class-primary);
  color: var(--class-text);
  font-size: 0.58rem;
  margin-left: 0.2rem;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================================
   Buttons
   ============================================================ */
button, .btn {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.rest-btn {
  border: 1px solid var(--class-primary);
  color: var(--class-readable);
  background: color-mix(in srgb, var(--class-primary) 10%, transparent);
  font-weight: 600;
  transition: all 0.2s ease;
}

.rest-btn:hover {
  background: color-mix(in srgb, var(--class-primary) 20%, transparent);
  color: var(--text-heading);
  border-color: var(--class-primary);
}

button:hover, .btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}
button.gold, .btn.gold {
  background: linear-gradient(135deg, var(--class-primary), var(--class-accent));
  color: var(--class-text);
  border-color: var(--class-primary);
  font-weight: 700;
}
button.gold:hover, .btn.gold:hover { filter: brightness(1.15); }
button.danger { border-color: var(--red); color: var(--red); }
button.danger:hover { background: var(--red); color: #fff; }

.add-btn {
  width: 100%;
  margin-top: 0.4rem;
  font-size: 0.7rem;
  padding: 0.35rem;
  border-style: dashed;
  color: var(--text-dim);
}
.add-btn:hover { color: var(--text); border-color: var(--class-primary); }

.btn-remove {
  background: none;
  border: none;
  color: #ff3b30;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.2rem;
  opacity: 1;
  line-height: 1;
}

.btn-remove:hover {
  color: #ff1f1f;
  background: none;
  transform: scale(1.08);
}

/* ============================================================
   Form Controls
   ============================================================ */
input, select, textarea {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--class-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--class-primary) 25%, transparent);
}
input[type="number"] { width: 55px; text-align: center; }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 50px; width: 100%; }

/* ============================================================
   TOP BAR — Identity + Level + AC + HP
   ============================================================ */
.top-bar {
  position: relative;
  z-index: 120;
  overflow: visible;
  background: var(--bg-surface);
  border-bottom: 2px solid var(--class-primary);
  padding: 0.8rem 1rem;
  transition: border-color 0.3s ease;
}

.top-bar-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  overflow: visible;
}

/* Identity block */
.identity-block {
  flex: 1 1 0;
  min-width: 260px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: visible;
}

.char-name-input {
  font-family: var(--font-heading);
  font-size: 1.55rem;
  color: var(--class-readable);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border);
  padding: 0.3rem 0;
  width: 100%;
  margin-bottom: 0.6rem;
  transition: color 0.3s, border-color var(--transition);
}
.char-name-input:focus { border-color: var(--class-primary); box-shadow: none; }
.char-name-input::placeholder { color: var(--text-dim); }

.identity-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  width: 100%;
  overflow: visible;
}

.id-field {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  overflow: visible;
}

.id-field label {
  font-family: var(--font-heading);
  font-size: 0.55rem;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}
.id-field input, .id-field select {
  font-size: 0.9rem;
  padding: 0.32rem 0.45rem;
  width: 100%;
}
.id-field input[type="number"] { width: 60px; }

.id-field.is-disabled {
  opacity: 0.5;
}

.id-field.is-manual-locked {
  position: relative;
}

.id-field.is-manual-locked label::after {
  content: " \00b7 locked";
  color: color-mix(in srgb, var(--text-dim) 74%, var(--class-readable));
  font-size: 0.82em;
  letter-spacing: 0.04em;
}

.id-field.is-manual-locked .select-trigger,
.select-enhanced.is-manual-locked .select-trigger {
  cursor: not-allowed;
  color: color-mix(in srgb, var(--text) 72%, var(--text-dim));
  background:
    linear-gradient(90deg, rgba(255,255,255,0.018), transparent),
    var(--bg-input);
  border-color: color-mix(in srgb, var(--border) 84%, var(--text-dim));
  opacity: 0.78;
}

.id-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
  overflow: visible;
}

/* Level + AC center wrapper */
.level-ac-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  flex: 0 0 auto;
  align-self: center;
}

/* Level block */
.level-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.level-block label {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--class-readable);
}

.level-up-btn {
  font-size: 0.62rem;
  padding: 0.25rem 0.5rem;
  margin-top: 0.1rem;
  width: 100%;
}

.xp-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  margin-top: 0.15rem;
  padding-top: 0.15rem;
  border-top: 1px solid var(--border);
  min-width: 64px;
}
.xp-row label {
  font-family: var(--font-heading);
  font-size: 0.55rem;
  text-transform: uppercase;
  color: var(--class-readable);
  letter-spacing: 0.06em;
}
.xp-input {
  width: 60px;
  font-size: 0.75rem;
  text-align: center;
  padding: 0.15rem;
}

/* AC block */
.ac-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.ac-shield-shape {
  width: 60px;
  height: 68px;
  background: var(--bg-card);
  border: 3px solid var(--class-primary);
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.3s;
}

.ac-input {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  text-align: center;
  padding: 0;
  margin: 0;
}
.ac-input:focus { box-shadow: none; }

.ac-block > label {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--class-readable);
}

.ac-mode-badge {
  font-family: var(--font-heading);
  font-size: 0.55rem;
  line-height: 1.3;
  padding: 0.12rem 0.4rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 45%, var(--border));
  border-radius: 999px;
  color: var(--class-readable);
  background: color-mix(in srgb, var(--class-primary) 12%, var(--bg-card));
}

.ac-warning-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ffdede;
  border: 1px solid #ff5f5f;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  background: linear-gradient(180deg, rgba(255,95,95,0.26), rgba(255,95,95,0.14));
  white-space: nowrap;
}

/* HP block */
.hp-block {
  flex: 1 1 0;
  min-width: min(100%, 480px);
}

.hp-exhaustion-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.hp-main-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.hp-numbers {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.hp-current-wrap, .hp-max-wrap, .hp-temp-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
}
.hp-current-wrap label, .hp-max-wrap label, .hp-temp-wrap label {
  font-family: var(--font-heading);
  font-size: 0.5rem;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hp-current-input {
  width: 46px;
  max-width: 100%;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--green);
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.1rem;
}

.hp-slash {
  color: var(--text-dim);
  font-size: 1.2rem;
  margin: 0 0.1rem;
  align-self: flex-start;
  margin-top: 0.3rem;
}

.hp-max-input {
  width: 48px;
  font-size: 1rem;
  text-align: center;
  color: var(--text-dim);
}

.hp-temp-input {
  width: 42px;
  font-size: 0.85rem;
  text-align: center;
  margin-left: 0.3rem;
}

.hp-bar-track {
  flex: 1;
  position: relative;
  height: 18px;
  background: var(--bg-input);
  border-radius: 6px;
  overflow: hidden;
  min-width: 80px;
}

.hp-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  background: linear-gradient(90deg, var(--green), #2ecc71);
  border-radius: 6px;
  transition: width 0.3s, background 0.3s;
  z-index: 1;
}

.hp-threshold-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-heading);
  font-size: 0.52rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease;
  z-index: 2;
  white-space: nowrap;
  text-shadow:
    0 0 2px rgba(0,0,0,0.8),
    0 0 4px rgba(0,0,0,0.6);
}

/* 0–25% sáv közepe */
.hp-threshold-critical {
  left: 0;
  width: 25%;
}

/* 26–50% sáv közepe */
.hp-threshold-wounded {
  left: 25%;
  width: 25%;
}

.hp-bar-fill.wounded { background: linear-gradient(90deg, #e67e22, #f39c12); }
.hp-bar-fill.critical { background: linear-gradient(90deg, var(--red), #e74c3c); }

.hp-bottom-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

/* Hit Dice */
.hit-dice-block {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
}
.hd-label {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--text-dim);
}
.hd-type {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 600;
}
.hd-spent {
  width: 32px;
  font-size: 0.95rem;
  padding: 0.15rem;
  text-align: center;
  font-family: var(--font-heading);
  font-weight: 700;
  color: #ffffff;
}
.hd-sep { color: var(--text-dim); }
.hd-max {font-family: var(--font-heading); color: #ffffff; font-weight: 700;}

/* Death Saves */
.hp-panel-title-with-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}
.death-save-rule-badge {
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--class-readable, var(--accent)) 52%, transparent);
  border-radius: 999px;
  padding: 0.12rem 0.38rem;
  background: color-mix(in srgb, var(--class-readable, var(--accent)) 12%, transparent);
  color: var(--class-readable, var(--accent));
  font-family: var(--font-heading);
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.death-saves-block {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.ds-label {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--text-dim);
}
.ds-row {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
.ds-tag {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  font-weight: 700;
}
.success-tag { color: var(--green); }
.fail-tag { color: var(--red); margin-left: 0.3rem; }
.ds-dots {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.ds-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  cursor: pointer;
  transition: all var(--transition);
}
.ds-dot.success.active { background: var(--green); border-color: var(--green); }
.ds-dot.fail.active { background: var(--red); border-color: var(--red); }

/* Rest Buttons */
.rest-buttons {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.4rem;
}
.rest-buttons .rest-btn {
  font-size: 0.65rem;
  padding: 0.3rem 0.6rem;
}

/* HP Panels (3-panel layout) */
.hp-panels {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.hp-panel {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.hp-panel-title {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--class-readable);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hp-panel-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  flex: 1;
}

.hp-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  flex-shrink: 0;
}

.hp-sub-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: center;
}

.hp-stack {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: center;
}

.hp-small-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
}
.hp-small-wrap label {
  font-family: var(--font-heading);
  font-size: 0.48rem;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.hp-small-input {
  width: 34px;
  max-width: 100%;
  font-size: 0.8rem;
  text-align: center;
  padding: 0.1rem;
}

.hp-small-static {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  width: 38px;
  text-align: center;
  line-height: 1.6;
}

#hit-dice-max {
  font-family: var(--font-heading);
  color: #ffffff;
  font-weight: 700;
}

/* Death saves within panel */
.hp-ds-body {
  flex: 1;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.25rem;
  width: 100%;
}

.ds-group-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
}

.ds-group-row + .ds-group-row {
  margin-top: 0.3rem;
}

.ds-group-label {
  font-family: var(--font-heading);
  font-size: 0.56rem;
  font-weight: 700;
  text-transform: uppercase;
  width: 62px;
  flex-shrink: 0;
  letter-spacing: 0.04em;
  text-align: left;
}

/* Hit Dice panel rest buttons */
.hd-rest-btns {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}
.hd-rest-btns .rest-btn {
  width: 100%;
  font-size: 0.6rem;
  padding: 0.25rem 0.3rem;
}

/* Death Saves panel — exhaustion sub-section */
.ds-exhaustion {
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ds-exhaustion-label {
  font-family: var(--font-heading);
  font-size: 0.62rem;
  text-transform: uppercase;
  color: var(--class-readable);
  letter-spacing: 0.06em;
  font-weight: 700;
  margin-bottom: 0.16rem;
  text-align: center;
}
.ds-exhaustion .exhaustion-pips {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.ds-resistances {
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ds-resistances-title {
  font-family: var(--font-heading);
  font-size: 0.62rem;
  text-transform: uppercase;
  color: var(--class-readable);
  letter-spacing: 0.06em;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.08rem;
}

.mini-btn {
  padding: 0.16rem 0.35rem;
  font-size: 0.58rem;
  min-height: 0;
  line-height: 1.3;
}

.ds-res-row {
  display: grid;
  grid-template-columns: 66px 1fr;
  gap: 0.25rem;
  align-items: center;
}

.ds-res-label {
  font-family: var(--font-heading);
  font-size: 0.54rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  line-height: 1.5;
}

.res-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  min-height: 1.15rem;
  align-items: center;
}

.res-chip {
  font-family: var(--font-heading);
  font-size: 0.56rem;
  line-height: 1.2;
  padding: 0.12rem 0.3rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--class-primary) 55%, var(--border));
  color: var(--text-heading);
  background: color-mix(in srgb, var(--class-primary) 10%, var(--bg-card));
}

.res-chip-empty {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-style: italic;
}

.res-manage-btn {
  align-self: center;
  margin-top: 0.12rem;
}

.resistance-option-list {
  max-height: 260px;
}

.resistance-edit-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: none;
  overflow: visible;
  padding-right: 0.15rem;
}

.resistance-edit-row {
  display: grid;
  grid-template-columns: minmax(110px, 140px) minmax(130px, 1fr) minmax(130px, 1fr) 28px;
  gap: 0.3rem;
  align-items: center;
}

.resistance-edit-row input,
.resistance-edit-row select {
  font-size: 0.76rem;
  padding: 0.2rem 0.3rem;
}

.resistance-edit-row .select-enhanced {
  min-width: 0;
}

.resistance-edit-row .select-trigger {
  min-height: 30px;
  padding: 0.2rem 0.3rem;
  font-size: 0.76rem;
}

/* Diamond death save shapes */
.ds-diamond {
  width: 11px;
  height: 11px;
  transform: rotate(45deg);
  border: 2px solid var(--border-strong);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.ds-diamond.success.active { background: var(--green); border-color: var(--green); }
.ds-diamond.fail.active { background: var(--red); border-color: var(--red); }

.character-senses { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem; margin-top: 0.2rem; }
.character-senses .sense-badge { font-size: 0.64rem; padding: 0.12rem 0.3rem; line-height: 1.25; white-space: normal; }
/* ============================================================
   Cards & Sections
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.7rem;
  margin-bottom: 0;
  transition: background 0.3s, border-color 0.3s;
}

.sec {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--class-readable);
  font-weight: 700;
  padding-bottom: 0.35rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: color 0.3s;
}

.sec::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 36px;
  height: 2px;
  background: var(--class-primary);
  transition: background 0.3s;
}

/* ============================================================
   LEFT COLUMN — Proficiency Bonus
   ============================================================ */
.prof-bonus-block {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 0;
}

.prof-value {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--class-readable);
  transition: color 0.3s;
  min-width: 32px;
  text-align: center;
}

.prof-label {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--class-readable);
  letter-spacing: 0.05em;
  font-weight: 700;
}

/* ============================================================
   LEFT COLUMN — Ability Blocks (2-column)
   ============================================================ */
.ability-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  align-items: start;
}

#ability-blocks-left,
#ability-blocks-right {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
  align-items: stretch;
}

#ability-blocks-left {
  height: 100%;
}

.ability-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.55rem;
  margin-bottom: 0;
  transition: background 0.3s, border-color 0.3s;
}

.ab-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.ab-header > div {
  min-width: 0;
  flex: 1;
}

.ab-mod-circle {
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  border-radius: 50%;
  border: 2px solid var(--class-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-heading);
  background: var(--bg-surface);
  flex: 0 0 40px;
  aspect-ratio: 1 / 1;
  transition: border-color 0.3s;
}

.ab-label {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--class-readable);
  transition: color 0.3s;
  font-weight: 700;
}

.ab-score-input {
  width: 36px;
  height: 24px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  margin-left: auto;
  margin-top: 0.1rem;
}

/* Skills within ability block */
.ab-skills {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-top: 0.2rem;
  border-top: 1px solid var(--border);
  margin-top: 0.2rem;
}

.ab-skill-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  padding: 0.1rem 0;
}

.ab-skill-row:hover { background: var(--bg-card-hover); border-radius: 3px; }

.prof-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.prof-dot.active {
  background: var(--class-primary);
  border-color: var(--class-primary);
}
.prof-dot.expert {
  background: var(--class-accent);
  border-color: var(--class-accent);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--class-accent);
}

.prof-dot.is-locked {
  cursor: default;
  opacity: 0.62;
}

.skill-mod {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  width: 22px;
  text-align: right;
  color: var(--text-dim);
}

.skill-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Save row in ability block */
.ab-save-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  padding: 0.15rem 0 0.1rem;
  font-weight: 600;
  color: var(--text-heading);
}

.ab-skill-row,
.ab-save-row {
  min-width: 0;
}

.skill-advdis-badge {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  line-height: 1;
  padding: 0.12rem 0.34rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: color-mix(in oklab, var(--bg-elev-2) 86%, transparent);
  flex-shrink: 0;
}

.skill-advdis-badge.adv {
  border-color: #2ca46f;
  color: #7ee8bc;
  background: color-mix(in oklab, #2ca46f 14%, transparent);
}

.skill-advdis-badge.dis {
  border-color: #c15656;
  color: #ffb8b8;
  background: color-mix(in oklab, #c15656 14%, transparent);
}

.skill-advdis-badge.fail {
  border-color: #d4a017;
  color: #ffe49a;
  background: color-mix(in oklab, #d4a017 18%, transparent);
}

/* Heroic Inspiration */
.insp-box {
  position: relative;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;

  padding: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);

  cursor: pointer;
  margin-top: 0;
  flex: 1;
  min-height: 0;
  text-align: center;
  overflow: hidden;
}

.insp-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;

  width: 20px;
  height: 20px;

  border-top: 2px solid var(--class-primary);
  border-left: 2px solid var(--class-primary);

  border-top-left-radius: var(--radius-lg);
}

.insp-gem {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--class-primary);
  background: transparent;
  transition: all var(--transition);
}

.insp-gem.active {
  background: transparent;
  border-color: var(--class-primary);
}

.insp-gem.active::before,
.insp-gem.active::after {
  content: "";
  position: absolute;
  width: 60%;
  height: 2px;
  background: var(--class-primary);
  top: 50%;
  left: 50%;
  transform-origin: center;
}

.insp-gem.active::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.insp-gem.active::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.insp-label {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--text-heading);
  letter-spacing: 0.05em;
  line-height: 1.2;
  text-align: center;
}

/* ============================================================
   CENTER COLUMN — Level + AC row
   ============================================================ */
.center-level-ac {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  justify-content: center;
  padding: 0.6rem 0.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 0.7rem;
  transition: background 0.3s, border-color 0.3s;
}

/* ============================================================
   CENTER COLUMN — Stats Row
   ============================================================ */
.center-stats-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.center-stat {
  flex: 1;
  min-width: 80px;
  text-align: center;
  padding: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.center-stat-main {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.center-stat-value {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-heading);
  padding-top: 5px;
}

.center-stat-input {
  width: 50px;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-heading);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.center-stat-input:focus { border-color: var(--class-primary); box-shadow: none; }

.center-stat-label {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--class-readable);
  font-weight: 700;
}

.condition-action-warning {
  margin-top: 0.45rem;
  margin-bottom: 0.2rem;
  padding: 0.38rem 0.55rem;
  border-radius: 10px;
  border: 1px solid color-mix(in oklab, #c15656 28%, var(--border));
  background: color-mix(in oklab, #c15656 10%, transparent);
  color: #ffd2d2;
  font-size: 0.74rem;
  line-height: 1.35;
}

/* ============================================================
   RIGHT - Class Resources
   ============================================================ */
.class-resource-card {
  padding: 0.62rem;
}

#class-resources-body {
  width: 100%;
  display: grid;
  gap: 0.3rem;
}

.class-resource-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.28rem;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--class-primary) 14%, var(--border));
  background: transparent;
}

.class-resource-row-meta {
  border: none;
  padding-left: 0;
  padding-right: 0;
}

.class-resource-row-main {
  align-items: center;
  border: none;
  padding-left: 0;
  padding-right: 0;
  flex-wrap: nowrap;
}

.class-resource-label {
  min-width: 0;
  font-family: var(--font-heading);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.class-resource-main-right {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.12rem;
  min-width: 0;
  max-width: 100%;
}

.class-resource-control {
  display: inline-flex;
  align-items: center;
  gap: 0.16rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.class-resource-btn {
  width: 0.98rem;
  height: 0.98rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  line-height: 1;
  border-radius: 6px;
  flex: 0 0 auto;
}

.class-resource-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.35rem;
  height: 1.05rem;
  text-align: center;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  padding: 0 0.16rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 35%, var(--border));
  border-radius: 6px;
  background: color-mix(in srgb, var(--bg-input) 85%, transparent);
  color: var(--text-heading);
  flex: 0 0 auto;
  white-space: nowrap;
}

.class-resource-value {
  font-size: 0.72rem;
  color: var(--text);
}

.class-resource-value-primary {
  display: inline-block;
  min-width: 2.4ch;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--class-readable);
  letter-spacing: 0.01em;
}

.class-resource-note {
  display: block;
  font-size: 0.56rem;
  color: #fff;
  opacity: 0.9;
  text-align: right;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Exhaustion */
.exhaustion-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
  padding: 0.3rem 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.exhaustion-label {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--text-dim);
}
.exhaustion-pips { display: flex; gap: 0.2rem; }
.exhaustion-pip {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 2px solid var(--border-strong);
  cursor: pointer;
  transition: all var(--transition);
}
.exhaustion-pip.active { background: var(--red); border-color: var(--red); }
.exhaustion-effect { font-size: 0.8rem; color: var(--red); font-style: italic; }

/* ============================================================
   CENTER — Attacks
   ============================================================ */
.attack-legend {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 0.45rem;
}

.attack-section {
  margin-bottom: 0.65rem;
}

.attack-section:last-child {
  margin-bottom: 0;
}

.attack-section-title {
  font-family: var(--font-heading);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--class-readable);
  margin-bottom: 0.28rem;
}

.attack-section-title-collapsible {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.22rem;
}

.attack-empty {
  font-size: 0.72rem;
  color: var(--text-dim);
  padding: 0.22rem 0;
}

.attack-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.3rem 0.36rem;
  margin-bottom: 0.22rem;
  background: rgba(255,255,255,0.01);
}

.attack-row:last-child {
  margin-bottom: 0;
}

.attack-row.available {
  opacity: 1;
}
.attack-row.available > :not(.attack-action-row) { opacity: 0.62; }
.attack-row.available.is-unavailable { opacity: 1; }

.attack-row[data-attack-reaction] {
  margin-top: 0.85rem;
  border-top: 2px solid color-mix(in srgb, var(--class-primary) 45%, var(--border));
}

.attack-row[data-attack-reaction] .attack-row-top {
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.attack-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.attack-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  margin-bottom: 0.32rem;
  padding: 0.34rem 0.38rem;
}

.attack-group:last-child {
  margin-bottom: 0;
}

.attack-group.available {
  opacity: 1;
}
.attack-group.available > .attack-group-head { opacity: 0.62; }

.attack-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.24rem;
  padding-bottom: 0.22rem;
  border-bottom: 1px dashed var(--border);
}

.attack-group-head-left {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.attack-group-head-right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
}

.attack-group-head-right .attack-meta {
  justify-content: flex-end;
}

.attack-group .attack-name {
  font-size: 0.8rem;
}

.attack-collapse-btn {
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  border-radius: 6px;
  font-size: 0.62rem;
  line-height: 1;
  padding: 0.1rem 0.22rem;
  min-width: 20px;
  min-height: 18px;
  cursor: pointer;
}

.attack-collapse-btn:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
}

.attack-section-collapse-btn {
  border: none;
  background: transparent;
  color: var(--class-readable);
  min-width: auto;
  min-height: auto;
  padding: 0;
}

.attack-section-collapse-btn:hover {
  color: var(--class-readable);
  border: none;
  opacity: 0.88;
}

.attack-drag-btn {
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  border-radius: 6px;
  font-size: 0.62rem;
  line-height: 1;
  padding: 0.08rem 0.24rem;
  min-width: 22px;
  min-height: 18px;
  cursor: grab;
}

.attack-drag-btn:active {
  cursor: grabbing;
}

.attack-group.draggable.dragging {
  opacity: 0.45;
  outline: 1px dashed var(--class-primary);
}

.attack-name {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--text-main);
}

.attack-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}

.attack-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.06rem 0.36rem;
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--font-heading);
}

.attack-badge.adv {
  border-color: #2ca46f;
  color: #7ee8bc;
}

.attack-badge.dis {
  border-color: #c15656;
  color: #ffb8b8;
}

.attack-badge.warn {
  border-color: #b88c3e;
  color: #ffd38f;
}

.attack-row-bottom {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.3rem;
}

.attack-row-stat {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.18rem 0.26rem;
}

.attack-row-stat-label {
  display: block;
  font-size: 0.56rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.06rem;
}

.attack-row-stat-value {
  display: block;
  font-size: 0.78rem;
  color: var(--text-main);
  font-family: var(--font-heading);
}

.attack-row-stat-inline {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.3rem;
}

.attack-reach-value {
  color: var(--class-readable);
  font-weight: 700;
}

.attack-row-tags {
  margin-top: 0.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.18rem;
  align-items: center;
}

.attack-mini-tag {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.06rem 0.32rem;
  font-size: 0.6rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.02);
}

.attack-available-note {
  margin-top: 0.2rem;
  font-size: 0.63rem;
  color: var(--text-dim);
}

.attack-options-row {
  margin-top: 0.24rem;
}

.attack-options-label {
  display: block;
  font-size: 0.56rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.08rem;
}

.attack-options-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.16rem;
}

.attack-option-chip {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.06rem 0.34rem;
  font-size: 0.6rem;
  color: var(--text-main);
  background: color-mix(in srgb, var(--bg-surface) 82%, transparent);
  font-family: var(--font-heading);
  cursor: pointer;
}

.attack-option-chip:hover {
  border-color: color-mix(in srgb, var(--class-primary) 55%, var(--border));
}

.attack-option-chip.locked {
  opacity: 0.66;
  border-style: dashed;
  color: var(--text-dim);
}

.fighter-combat-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.32rem;
  margin-bottom: 0.58rem;
  padding: 0.38rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 24%, var(--border));
  border-radius: 7px;
  background: color-mix(in srgb, var(--class-primary) 5%, var(--bg-surface));
}

.fighter-combat-overview-item {
  min-width: 0;
  padding: 0.34rem 0.42rem;
  border-left: 1px solid color-mix(in srgb, var(--class-primary) 18%, var(--border));
}

.fighter-combat-overview-item:first-child {
  border-left: 0;
}

.fighter-combat-overview-item > span {
  display: block;
  margin-bottom: 0.12rem;
  color: var(--text-dim);
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  line-height: 1.2;
  text-transform: uppercase;
}

.fighter-combat-overview-item > strong {
  display: block;
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 0.69rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.fighter-combat-mastery-action {
  appearance: none;
  display: grid;
  justify-items: start;
  gap: 0.05rem;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.fighter-combat-mastery-action strong {
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 0.69rem;
  line-height: 1.25;
}

.fighter-combat-mastery-action small {
  color: color-mix(in srgb, var(--class-readable) 78%, var(--text-dim));
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.025em;
}

.fighter-combat-mastery-action:hover strong,
.fighter-combat-mastery-action:hover small {
  color: var(--class-readable);
}

.fighter-combat-overview-styles > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}

.fighter-combat-style-entry {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
}

.fighter-combat-style {
  appearance: none;
  max-width: 100%;
  padding: 0.08rem 0.3rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 32%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--class-primary) 9%, transparent);
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 0.6rem;
  line-height: 1.2;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.fighter-combat-style:hover {
  border-color: color-mix(in srgb, var(--class-primary) 58%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 14%, transparent);
}

.fighter-combat-style-entry:has(.fighter-combat-style-change) .fighter-combat-style {
  border-radius: 999px 0 0 999px;
}

.fighter-combat-style-change {
  appearance: none;
  padding: 0.08rem 0.28rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 32%, var(--border));
  border-left: 0;
  border-radius: 0 999px 999px 0;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.5rem;
  line-height: 1.2;
  cursor: pointer;
}

.fighter-combat-style-change:hover {
  color: var(--class-readable);
  background: color-mix(in srgb, var(--class-primary) 10%, transparent);
}

.fighter-combat-overview-empty {
  color: var(--text-dim);
  font-size: 0.63rem;
  font-style: italic;
}

@media (max-width: 760px) {
  .attack-row-bottom {
    grid-template-columns: 1fr;
  }

  .fighter-combat-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fighter-combat-overview-item:nth-child(3) {
    border-left: 0;
  }
}

/* Shared attack actions: class policy supplies preview and availability. */
.attack-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-top: 0.6rem;
  padding: 0.6rem 0 0;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}
.attack-action-copy { display: grid; gap: 0.25rem; min-width: 0; }
.attack-action-copy strong { color: var(--class-readable); font-size: 0.8rem; }
.attack-action-copy small { color: var(--text-dim); font-size: 0.7rem; }
.attack-action-copy > span { font-size: 0.85rem; overflow-wrap: anywhere; }
.attack-action-row > .btn { flex-shrink: 0; }
.attack-action-row.is-unavailable { opacity: 0.55; }
.attack-action-row.is-unavailable > .btn { cursor: not-allowed; }
.attack-action-row.combat-option-row { display: grid; grid-template-columns: minmax(0, 1fr); align-items: stretch; gap: 0.4rem; }
.combat-option-heading { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; }
.combat-option-heading > .btn { flex-shrink: 0; margin-left: auto; }
.combat-option-resources { color: var(--text-dim); font-size: 0.75rem; line-height: 1.4; overflow-wrap: anywhere; }
.combat-option-details > summary { cursor: pointer; font-size: 0.75rem; color: var(--text-dim); }
.combat-option-body { font-size: 0.8rem; line-height: 1.45; display: grid; gap: 0.4rem; padding-top: 0.4rem; }
.combat-option-body p { margin: 0; }
.combat-option-body .attack-option-chip { justify-self: start; }
.combat-option-row.is-unavailable { opacity: 1; }
.combat-option-row.is-unavailable .combat-option-heading > .btn { opacity: 0.55; cursor: not-allowed; }
.combat-option-unavailable { color: var(--class-readable) !important; }
.combat-option-heading strong > .attack-badge { margin-left: 0.35rem; vertical-align: middle; }
.combat-option-row[data-attack-reaction] .combat-option-heading strong { color: var(--text); }
.combat-character-options .combat-option-row + .combat-option-row { margin-top: 0.55rem; }
.combat-option-body .attack-damage-type-label { margin-top: 0; }
.combat-option-details > summary:focus-visible { outline: 2px solid var(--class-readable); outline-offset: 3px; }
.combat-option-group { margin-top: 0.65rem; padding-top: 0.55rem; border-top: 1px solid var(--border); }
.combat-option-group > summary { color: var(--text); font-family: var(--font-heading); font-size: 0.8rem; }
.combat-option-group .combat-option-row { margin-left: 0.2rem; }
.attack-row.is-unavailable { opacity: 0.55; }
.attack-row-note { display: grid; gap: 0.2rem; margin-top: 0.45rem; overflow-wrap: anywhere; }
.attack-row-note strong { color: var(--class-readable); font-size: 0.8rem; }
.attack-row-note span { font-size: 0.8rem; }
.attack-row-note small { color: var(--text-dim); font-size: 0.7rem; }
.attack-reaction-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; font-size: 0.75rem; }
.attack-damage-type-label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-dim);
}
/* ============================================================
   CENTER — Spellcasting
   ============================================================ */
.spell-header-stats {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.spell-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.spell-stat-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--class-readable);
  transition: color 0.3s;
}

.spell-stat-separator {
  width: 1px;
  height: 0.8em;
  background: color-mix(in srgb, var(--class-primary) 35%, var(--border));
}

.spell-stat-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--font-heading);
}

.spell-slots-panel {
  margin: 0.15rem 0 0.75rem;
  padding: 0.65rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 28%, var(--border));
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--class-primary) 9%, transparent), transparent 55%),
    color-mix(in srgb, var(--bg-surface) 88%, var(--bg-input));
}

.spell-slots-head,
.spell-slot-card-head,
.spell-slot-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.spell-slots-head {
  margin-bottom: 0.55rem;
}

.spell-slots-title,
.spell-slot-level {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.spell-slots-title {
  font-size: 0.72rem;
}

.spell-slots-total {
  margin-top: 0.08rem;
  color: var(--text-dim);
  font-size: 0.64rem;
}

.spell-slots-total strong,
.spell-slot-count strong {
  color: var(--class-readable);
  font-family: var(--font-heading);
}

.spell-slots-recharge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0.12rem 0.42rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 35%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--class-primary) 10%, var(--bg-input));
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.52rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.spell-slots-head-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.spell-slots-manage {
  min-height: 24px;
  padding: 0.15rem 0.42rem;
  font-size: 0.52rem;
}

.spell-slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.45rem;
}

.spell-slot-card {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.5rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 26%, var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: color-mix(in srgb, var(--bg-input) 88%, transparent);
  transition: border-color 0.2s ease, opacity 0.2s ease;
}

.spell-slot-card.is-empty {
  border-color: var(--border);
}

.spell-slot-level {
  font-size: 0.62rem;
}

.spell-slot-count {
  color: var(--text-dim);
  font-size: 0.64rem;
  white-space: nowrap;
}

.spell-slot-pips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-height: 12px;
}

.spell-slot-pip {
  width: 11px;
  height: 11px;
  border: 1px solid color-mix(in srgb, var(--class-primary) 58%, var(--border));
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--bg-input) 85%, transparent);
}

.spell-slot-pip.is-available {
  background: var(--class-primary);
  box-shadow: 0 0 8px color-mix(in srgb, var(--class-primary) 32%, transparent);
}

.spell-slot-pip.is-spent {
  opacity: 0.35;
}

.spell-slot-actions {
  justify-content: flex-start;
}

.spell-slot-actions .btn {
  min-height: 27px;
  padding: 0.2rem 0.45rem;
  font-size: 0.54rem;
  white-space: nowrap;
}

.spell-slot-actions .spell-slot-spend {
  margin-left: auto;
}

.spell-slot-actions .btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.spell-slots-note {
  margin-top: 0.5rem;
  color: var(--text-dim);
  font-size: 0.58rem;
  line-height: 1.45;
}

.cast-modal-time {
  margin: 0 0 1rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.cast-section-title {
  margin: 0 0 0.5rem;
  color: var(--text-heading);
  font-size: 0.8rem;
}

.cast-resource-section { margin-bottom: 1rem; }

.cast-resource-copy small,
.slot-manage-row small {
  color: var(--text-dim);
  font-size: 0.7rem;
}

.cast-spell-rules {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
}

.cast-spell-rules > summary {
  padding: 0.7rem 0;
  color: var(--class-readable);
  font-size: 0.8rem;
  cursor: pointer;
}

.cast-spell-rules .spell-detail-rules { margin: 0.6rem 0 0; }

.cast-resource-list,
.slot-manage-list {
  display: grid;
  gap: 0.4rem;
}

.cast-resource-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.cast-resource-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-input) 88%, transparent);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.cast-resource-option:hover,
.cast-resource-option.is-selected {
  border-color: color-mix(in srgb, var(--class-primary) 65%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 12%, var(--bg-input));
}

.cast-resource-option.is-unavailable {
  opacity: 0.48;
  cursor: not-allowed;
}

.cast-resource-option.is-ritual {
  border-color: color-mix(in srgb, #8ec8f4 42%, var(--border));
}

.cast-resource-option.is-ritual:hover,
.cast-resource-option.is-ritual.is-selected {
  border-color: #8ec8f4;
  background: color-mix(in srgb, #8ec8f4 11%, var(--bg-input));
}

.cast-resource-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.cast-resource-marker {
  width: 16px;
  height: 16px;
  border: 1px solid color-mix(in srgb, var(--class-primary) 55%, var(--border));
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px var(--bg-input);
}

.cast-resource-option.is-selected .cast-resource-marker {
  background: var(--class-primary);
}

.cast-resource-copy {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}

.cast-resource-copy strong {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.cast-reminder {
  margin-top: 0.45rem;
  padding: 0.45rem 0.55rem;
  border-left: 3px solid color-mix(in srgb, var(--class-primary) 52%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 7%, var(--bg-input));
  color: var(--text-dim);
  font-size: 0.66rem;
}

.cast-reminder.is-warning {
  border-left-color: #f0b35a;
  background: rgba(240, 179, 90, 0.08);
}

.cast-reminder.is-ritual {
  border-left-color: #8ec8f4;
  background: rgba(142, 200, 244, 0.08);
}

.active-concentration-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  margin: 0.65rem 0;
  padding: 0.62rem 0.7rem;
  border: 1px solid rgba(240, 179, 90, 0.5);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 10% 50%, rgba(240, 179, 90, 0.14), transparent 42%),
    color-mix(in srgb, var(--bg-input) 90%, #f0b35a 4%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.concentration-orb {
  width: 18px;
  height: 18px;
  border: 2px solid #f0b35a;
  border-radius: 50%;
  background: rgba(240, 179, 90, 0.18);
  box-shadow: 0 0 12px rgba(240, 179, 90, 0.35), inset 0 0 0 3px var(--bg-input);
}

.active-concentration-copy {
  display: grid;
  gap: 0.06rem;
  min-width: 0;
}

.active-concentration-copy > span {
  color: #f0b35a;
  font-family: var(--font-heading);
  font-size: 0.52rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.active-concentration-copy strong {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 0.76rem;
  text-transform: uppercase;
}

#active-effects-list .active-effect-target {
  color: var(--class-readable);
  overflow-wrap: anywhere;
}

.active-concentration-copy small {
  color: var(--text-dim);
  font-size: 0.58rem;
}

.active-concentration-end {
  border-color: rgba(240, 179, 90, 0.45);
  color: #f0b35a;
}

.concentration-end-confirm {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem;
  border: 1px solid rgba(240, 179, 90, 0.4);
  border-radius: var(--radius);
  background: rgba(240, 179, 90, 0.07);
}

.concentration-end-confirm strong {
  color: var(--text-heading);
  font-family: var(--font-heading);
  text-transform: uppercase;
}

.concentration-end-confirm p {
  margin: 0.2rem 0 0;
  color: var(--text-dim);
  font-size: 0.68rem;
}

.slot-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
}

.slot-manage-row > span {
  display: grid;
  gap: 0.06rem;
}

.slot-manage-row input {
  width: 74px;
  text-align: center;
}

@media (max-width: 520px) {
  .spell-slot-grid {
    grid-template-columns: 1fr;
  }

  .spell-slot-actions .btn {
    flex: 1;
  }

  .cast-resource-list { grid-template-columns: 1fr; }
}

/* Spell entry rows */
.spell-entry {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  column-gap: 0.9rem;
  row-gap: 0.45rem;
  align-items: center;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-input) 78%, transparent);
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}
.spell-entry:last-of-type { margin-bottom: 0; }

.spell-entry.is-concentrating {
  border-color: rgba(240, 179, 90, 0.5);
  background: color-mix(in srgb, var(--bg-input) 84%, #f0b35a 7%);
  box-shadow: inset 3px 0 0 rgba(240, 179, 90, 0.75);
}

.spell-entry-main {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.spell-entry-name-row {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.45rem;
}

.spell-entry-name {
  min-width: 0;
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.spell-entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.spell-chip,
.spell-tag {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--class-primary) 32%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 10%, var(--bg-surface));
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.08rem 0.34rem;
}

.spell-chip.source {
  color: var(--class-readable);
}

.spell-chip.subclass-source {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.spell-chip.free-cast {
  border-color: rgba(105, 210, 184, 0.48);
  background: rgba(105, 210, 184, 0.1);
  color: #9ce6d2;
}

.spell-chip.free-cast.is-spent {
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg-surface) 90%, #0a0d12);
  color: var(--text-dim);
  opacity: 0.72;
}

.spell-chip.ability.empty,
.spell-entry-unlinked {
  color: var(--text-dim);
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg-surface) 92%, #0a0d12);
}

.spell-tag.concentration {
  color: #f6b26b;
  border-color: rgba(246, 178, 107, 0.45);
  background: rgba(246, 178, 107, 0.09);
}

.spell-tag.concentration-active {
  color: #1a1308;
  border-color: #f0b35a;
  background: #f0b35a;
}

.spell-tag.ritual {
  color: #9bd3ff;
  border-color: rgba(155, 211, 255, 0.4);
  background: rgba(155, 211, 255, 0.08);
}

.spell-tag.material {
  color: #c3d69b;
  border-color: rgba(195, 214, 155, 0.4);
  background: rgba(195, 214, 155, 0.08);
}

.spell-entry-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
}

.spell-entry-action {
  min-height: 24px;
  padding: 0.18rem 0.4rem;
  font-size: 0.56rem;
}

.btn[data-cast-unavailable="true"] {
  opacity: 0.58;
  cursor: help;
  filter: saturate(0.75);
}

.spell-entry-source, .spell-choice-overlap {
  display: block;
  margin-top: .2rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.spell-cast-action:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  filter: saturate(0.75);
}

.spell-entry-unlinked {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-family: var(--font-heading);
  font-size: 0.52rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.08rem 0.34rem;
}

.spell-level-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--class-primary) 18%, var(--bg-surface));
  border: 1px solid color-mix(in srgb, var(--class-primary) 58%, var(--border));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--class-readable);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--class-primary) 10%, transparent);
}

.spell-check {
  display: flex;
  align-items: center;
  justify-content: center;
}
.spell-check input { accent-color: var(--class-primary); }
.spell-check-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--font-heading);
}

.spell-species-ability {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--class-primary) 42%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 15%, var(--bg-surface));
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0 0.3rem;
}

.spell-species-ability-empty {
  color: var(--text-dim);
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg-surface) 90%, #0a0d12);
}

@media (max-width: 700px) {
  .spell-entry {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .spell-entry-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .spell-entry-name-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.15rem;
  }
}

.no-spellcasting {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-style: italic;
  padding: 0.5rem 0;
}

/* Optional hit context in the common Cast Spell window. */
.cast-attack-context { margin-bottom: 0.85rem; }
.cast-attack-controls { display: flex; gap: 0.7rem; align-items: flex-end; flex-wrap: wrap; }
.cast-attack-controls .profile-field { flex: 1 1 9rem; margin: 0; }
.cast-attack-controls .creation-check-option { flex: 1 1 9rem; margin: 0; }
.cast-attack-controls .profile-field > select,
.cast-attack-controls .select-trigger,
.cast-attack-controls .creation-check-option.is-compact {
  height: 2rem;
  min-height: 2rem;
}
.cast-attack-controls .creation-check-option.is-compact { padding: 0 0.56rem; }
.cast-attack-controls .creation-check-option:hover { transform: none; }
.cast-damage-preview {
  display: grid;
  gap: 0.3rem;
  padding: 0.75rem;
  margin: 0.65rem 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-input);
  overflow-wrap: anywhere;
}
.cast-damage-preview strong { color: var(--class-readable); font-size: 1rem; }
.cast-damage-preview small { color: var(--text-dim); }
/* Shared, saved spell contributions; Spellbook controls retain their layout. */
.inline-spell-modifier {
  display: inline-flex;
  margin: 2px 3px;
  padding: 2px 5px;
  border: 1px solid rgba(201, 169, 86, .3);
  border-radius: 4px;
  color: var(--gold);
  font-size: .68rem;
  line-height: 1.3;
}
.spell-modifier-sources { display: flex; flex-wrap: wrap; justify-content: center; }
.spell-sheet-modifiers-panel { margin: 8px 0; }
.spell-modifier-list { display: grid; gap: 6px; }
.spell-sheet-modifier-row { margin: 0; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; }
.spell-sheet-modifier-row .active-concentration-end { justify-self: end; width: auto; }
.spell-sheet-modifier-changes { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .76rem; }
.spell-sheet-modifier-row .active-concentration-copy { min-width: 0; }
.spell-sheet-modifier-row .active-concentration-copy small { white-space: normal; }
.ab-save-row:has(.inline-spell-modifier), .ab-skill-row:has(.inline-spell-modifier) { flex-wrap: wrap; }
.cast-effect-section {
  margin: .65rem 0;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
}
.cast-effect-heading { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .8rem; margin-bottom: .6rem; }
.cast-effect-heading .cast-section-title { margin: 0; }
.cast-effect-formula { color: var(--class-readable); font-size: .85rem; line-height: 1.4; }
.cast-effect-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .65rem; }
.cast-effect-fields .profile-field { margin: 0; min-width: 0; align-self: end; }
.cast-effect-fields .select-trigger, .cast-effect-fields input[type="number"] { height: 2.25rem; box-sizing: border-box; }
.cast-effect-optional .cast-effect-fields:not(:has(#cast-healing-amount)) > .profile-field:first-child { grid-column: 1 / -1; }
.cast-effect-optional .cast-effect-fields:has(#cast-healing-amount) { grid-template-columns: minmax(0, 1fr) max-content; }
.cast-effect-optional .cast-effect-fields input#cast-healing-amount { width: 100%; }
.cast-effect-detail, .cast-effect-notes { color: var(--text-dim); font-size: .78rem; line-height: 1.5; }
.cast-effect-detail { margin: .4rem 0; }
.cast-effect-notes { margin-top: .65rem; border-top: 1px solid var(--border); padding-top: .5rem; }
.cast-effect-notes summary { color: var(--class-readable); cursor: pointer; }
.cast-effect-notes p { margin: .5rem 0 0; }
@media (max-width: 480px) {
  .cast-effect-fields,
  .cast-effect-optional .cast-effect-fields:has(#cast-healing-amount) { grid-template-columns: minmax(0, 1fr); }
}

/* Manual gameplay results need enough room for the empty-field prompt. */
input.manual-result-input[type="number"] {
  width: 10rem;
  max-width: 100%;
  box-sizing: border-box;
  text-align: left;
}
.cast-effect-description { font-size: .78rem; line-height: 1.5; color: var(--text-dim); }
.cast-effect-description p { margin: .4rem 0; }
.cast-effect-description .spell-detail-rules { margin: .6rem 0 0; }

.spell-overlap-control {
  display: grid;
  gap: .45rem;
  padding: .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
}
.spell-overlap-control p { margin: 0; color: var(--text-dim); font-size: .75rem; line-height: 1.45; }
.spell-overlap-control .btn { white-space: normal; }
/* ============================================================
   CENTER — Features
   ============================================================ */
.feature-card {
  padding: 0.4rem;
  margin-bottom: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 3px solid var(--class-primary);
  transition: border-left-color 0.3s;
  align-self: stretch;
  display: flex;
  cursor: pointer;
}

.feature-card.is-insufficient-resource {
  opacity: 0.58;
  border-left-color: color-mix(in srgb, var(--border) 78%, var(--class-primary));
}

#features-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  align-items: stretch;
}

.features-filter-panel,
.feature-reminders,
.feature-empty-state {
  grid-column: 1 / -1;
}

.feature-reminders { display: grid; gap: 0.45rem; }
.feature-reminders .active-concentration-copy { overflow-wrap: anywhere; }
.feature-reminders .active-concentration-copy small { font-size: 0.68rem; line-height: 1.45; }
.feature-reminders .active-concentration-copy strong + small { font-size: 0.8rem; color: var(--text); }
.feature-reminder-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.35rem; }
.feature-reminder-actions .btn { font-size: 0.75rem; padding: 0.22rem 0.5rem; }
.feature-reminders .is-suspended .active-concentration-copy,
.feature-reminders .effect-suspended-benefit { opacity: 0.62; }
@media (max-width: 560px) {
  .active-concentration-panel:has(> .feature-reminder-actions) { grid-template-columns: minmax(0, 1fr); }
}

.features-filter-panel {
  display: grid;
  gap: 0.45rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-panel) 82%, #000 18%);
}

.features-filter-group {
  display: grid;
  gap: 0.22rem;
}

.features-filter-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.features-filter-action-row {
  align-items: center;
}

.features-filter-reset-btn {
  margin-left: auto;
  font-size: 0.62rem;
  padding: 0.16rem 0.42rem;
}

.feature-filter-chip.is-active {
  border-color: color-mix(in srgb, var(--class-primary) 60%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 16%, transparent);
  color: var(--class-readable);
}

.feature-empty-state {
  padding: 0.85rem 0.7rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.8rem;
  text-align: center;
}

.feature-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.45rem;
  cursor: pointer;
  width: 100%;
}

.feature-title-block {
  min-width: 0;
  display: grid;
  gap: 0.22rem;
  flex: 1 1 auto;
}

.feature-name {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--text-heading);
}

.feature-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.18rem;
}

.feature-meta-badge {
  font-size: 0.56rem;
}

.feature-meta-badge-action {
  border-color: color-mix(in srgb, var(--class-primary) 58%, var(--border));
  color: var(--class-readable);
}

.feature-meta-cue {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text);
  margin: 0;
  overflow-wrap: anywhere;
}

.feature-meta-cue.is-empty,
.feature-usage-row.is-empty {
  visibility: hidden;
}

.feature-usage-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.24rem;
}

.feature-usage-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.1rem;
  padding: 0.08rem 0.34rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 82%, var(--class-primary));
  background: color-mix(in srgb, var(--bg-panel) 84%, #000 16%);
  color: var(--text-dim);
  font-size: 0.56rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.features-filter-details > summary { cursor: pointer; color: var(--text-heading); font-size: 0.8rem; }
.features-filter-content { display: grid; gap: 0.65rem; padding-top: 0.65rem; }
#features-list .feature-header { display: grid; gap: 0.3rem; position: relative; }
#features-list .feature-title-block { grid-column: 1 / -1; padding-right: 2rem; }
#features-list .feature-header > .feature-hide-btn { position: absolute; top: 0; right: 0; }
.feature-controls-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.35rem; margin-top: auto; }
.feature-card-controls { grid-column: 2; display: flex; align-items: center; gap: 0.25rem; }
#features-list .feature-card-controls .btn { font-size: 0.64rem; min-height: 1.3rem; padding: 0.1rem 0.3rem; line-height: 1.2; }
#features-list .feature-controls-row .feature-usage-row { min-width: 0; }
#features-list .feature-hide-btn { min-width: 1.5rem; height: 1.3rem; }
#features-list .feature-meta-badge { font-size: 0.53rem; padding: 0.03rem 0.26rem; letter-spacing: 0.025em; }
.feature-level, .feature-upgrade-note, .feature-unavailable-reason { color: var(--text-dim); font-size: 0.75rem; line-height: 1.4; overflow-wrap: anywhere; }
.feature-level { margin-right: 0.3rem; }
.feature-unavailable-reason { color: var(--class-readable); }
.feature-card :is(.btn, summary):focus-visible { outline: 2px solid var(--class-readable); outline-offset: 3px; }
#features-list .feature-card { padding: 0.5rem 0.6rem; flex-direction: column; align-self: stretch; gap: 0.35rem; min-width: 0; cursor: default; }
#features-list .feature-card.is-insufficient-resource { opacity: 1; }
#features-list .feature-name { font-size: 0.9rem; }
#features-section { container-type: inline-size; }

.feature-use-shared-btn {
  min-height: 1.55rem;
  padding: 0.12rem 0.48rem;
  font-size: 0.68rem;
  line-height: 1;
  white-space: nowrap;
}

.feature-upgrade-badge {
  border-color: color-mix(in srgb, var(--class-secondary) 55%, var(--border));
  color: var(--text-heading);
}

.resource-use-confirm-list {
  display: grid;
  gap: 0.32rem;
  margin-top: 0.55rem;
}

.resource-use-confirm-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.16rem 0.6rem;
  align-items: center;
  padding: 0.42rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 20%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-panel) 88%, #000 12%);
}

.resource-use-confirm-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-heading);
  font-weight: 700;
}

.resource-use-confirm-values {
  white-space: nowrap;
  font-family: var(--font-heading);
  color: var(--class-readable);
  font-weight: 700;
}

.resource-use-confirm-reset {
  grid-column: 1 / -1;
  font-size: 0.68rem;
  color: var(--text-dim);
}

.feature-restore-row .resource-use-confirm-label {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.feature-restore-row .resource-use-confirm-values {
  white-space: normal;
  text-align: right;
}
@media (max-width: 480px) {
  .feature-restore-row { grid-template-columns: minmax(0, 1fr); }
  .feature-restore-row .resource-use-confirm-values { text-align: left; }
  .feature-restore-row .btn { justify-self: start; }
}

.feature-body {
  font-size: 0.78rem;
  color: var(--text);
  padding-top: 0.3rem;
  line-height: 1.45;
  display: none;
}
.feature-card.open .feature-body { display: block; }
.feature-desc-readonly {
  white-space: pre-wrap;
}

.feature-hide-btn {
  min-width: 1.7rem;
  height: 1.4rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.eye-icon {
  position: relative;
  font-size: 0.9rem;
  line-height: 1;
}

.feature-hide-btn.is-hidden .eye-icon::after {
  content: '';
  position: absolute;
  left: -0.08rem;
  right: -0.08rem;
  top: 50%;
  height: 1.6px;
  background: currentColor;
  transform: rotate(-27deg);
  opacity: 0.95;
}

.sec-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.features-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}

.features-controls .btn {
  font-size: 0.58rem;
  padding: 0.18rem 0.38rem;
}

#btn-features-show-hidden.active {
  border-color: color-mix(in srgb, var(--class-primary) 65%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 16%, transparent);
  color: var(--class-readable);
}

#modal-feature-detail .modal-content {
  max-width: 680px;
}

.feature-detail-body {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  white-space: normal;
  max-height: min(62vh, 560px);
  overflow-y: auto;
  padding-right: 0.2rem;
}

.feature-detail-body p {
  margin: 0 0 0.62rem;
}

.feature-detail-body p:last-child {
  margin-bottom: 0;
}

.feature-detail-list {
  margin: 0 0 0.62rem 1.1rem;
  padding: 0;
}

.feature-detail-list li {
  margin: 0 0 0.22rem;
}

.feature-detail-tabs {
  margin-bottom: 0.45rem;
}

.attack-rule-body {
  display: grid;
  gap: 0.72rem;
}

.attack-rule-nav {
  display: flex;
  justify-content: flex-start;
}

.attack-rule-back-btn {
  min-width: 92px;
}

.attack-rule-full h4,
.attack-rule-related h4 {
  margin: 0 0 0.36rem;
  font-size: 0.72rem;
  color: var(--class-readable);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.attack-rule-meta {
  border: 1px solid color-mix(in srgb, var(--border) 74%, transparent);
  border-radius: 10px;
  padding: 0.48rem 0.58rem;
  background: color-mix(in srgb, var(--panel-soft) 62%, transparent);
}

.attack-rule-meta p {
  margin: 0;
}

.attack-rule-meta p + p {
  margin-top: 0.28rem;
}

.attack-rule-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
}

.attack-rule-link-btn {
  background: color-mix(in srgb, var(--panel-soft) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 76%, transparent);
  color: var(--text);
  border-radius: 999px;
  padding: 0.18rem 0.56rem;
  font-size: 0.68rem;
  line-height: 1.2;
  cursor: pointer;
}

.attack-rule-link-btn:hover {
  border-color: color-mix(in srgb, var(--class-primary) 64%, var(--border));
  color: var(--class-readable);
}

@media (max-width: 980px) {
  #features-list { grid-template-columns: 1fr; }
  .sec-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .features-controls {
    width: 100%;
    flex-wrap: wrap;
  }
}


/* Shared creature stat blocks: full detail, Cast preview and Summons overview. */
.stat-block {
  --creature-accent: var(--class-readable);
  min-width: 0;
  color: var(--text);
  font: 0.88rem/1.55 'Segoe UI', Arial, sans-serif;
  overflow-wrap: anywhere;
}
.stat-block[data-creature-type="Celestial"] { --creature-accent: #e7c775; }
.stat-block[data-creature-type="Fey"] { --creature-accent: #77d9c3; }
.stat-block[data-creature-type="Fiend"] { --creature-accent: #ef9292; }
.stat-block-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 1rem;
  border-top: 3px solid var(--creature-accent);
  border-radius: 8px 8px 0 0;
  background: linear-gradient(120deg, color-mix(in srgb, var(--creature-accent) 12%, var(--bg-card)), var(--bg-input));
}
.stat-block-header > div { min-width: 0; flex: 1 1 230px; }
.stat-block .stat-block-header h3 {
  margin: 0;
  color: var(--text-heading);
  font-size: 1.3em;
  line-height: 1.3;
  letter-spacing: 0;
}
.stat-block .stat-block-subtitle {
  margin: 0.45rem 0 0;
  color: var(--text-dim);
  font-size: 0.9em;
  line-height: 1.6;
}
.stat-block-type, .stat-block-recharge {
  display: inline-flex;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--creature-accent) 45%, var(--border));
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  color: var(--creature-accent);
  background: color-mix(in srgb, var(--creature-accent) 8%, var(--bg-input));
  font-size: 0.9em;
}
.stat-block-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0.9rem 0;
}
.stat-block-stat {
  min-width: 0;
  padding: 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}
.stat-block-stat dt {
  color: var(--text-dim);
  font-size: 0.9em;
}
.stat-block-stat dd {
  margin-top: 0.25rem;
  color: var(--text-heading);
  font-size: 1.5em;
  font-weight: 650;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-block-stat > span { display: block; color: var(--text-dim); font-size: 0.9em; margin-top: 0.35rem; }
.stat-block-reference { display: grid; gap: 0.5rem; font-size: 1em; }
.stat-block-reference > div { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; }
.stat-block-reference dt { color: var(--text-dim); min-width: 6rem; }
.stat-block-reference dd { color: var(--text); }
.stat-block-group { margin-top: 1.3rem; }
.stat-block .stat-block-group h4 {
  margin: 0 0 0.65rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid color-mix(in srgb, var(--creature-accent) 35%, var(--border));
  color: var(--creature-accent);
  font-size: 1.05em;
}
.stat-block-abilities {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.stat-block-abilities table { width: 100%; border-collapse: collapse; background: var(--bg-input); font-size: 1em; }
.stat-block-abilities th, .stat-block-abilities td { padding: 0.55rem; text-align: center; border-bottom: 1px solid var(--border); }
.stat-block-abilities thead th { color: var(--text-dim); font-size: 0.9em; font-weight: 500; }
.stat-block-abilities tbody th { color: var(--text-heading); text-align: left; }
.stat-block-abilities td { font-variant-numeric: tabular-nums; }
.stat-block-action { padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)); }
.stat-block-action + .stat-block-action { margin-top: 0.7rem; }
.stat-block-action-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; }
.stat-block .stat-block-action h5 { font: 650 1em/1.4 'Segoe UI', Arial, sans-serif; color: var(--text-heading); letter-spacing: 0; }
.stat-block .stat-block-action p { margin: 0.55rem 0 0; font-size: 1em; line-height: 1.6; }
.stat-block-action-facts { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 0.75rem; margin-top: 0.8rem; }
.stat-block-action-facts dt { color: var(--text-dim); font-size: 0.9em; }
.stat-block-action-facts dd { color: var(--text-heading); font-size: 1.05em; font-weight: 600; }
.stat-block-rules details { border: 1px solid var(--border); border-radius: 6px; margin-top: 0.65rem; }
.stat-block-rules summary { cursor: pointer; padding: 0.75rem; color: var(--text-heading); font-weight: 600; }
.stat-block .stat-block-rules p { margin: 0; padding: 0 0.9rem 0.9rem; line-height: 1.6; font-size: 1em; }
.stat-block-rules summary:focus-visible { outline: 2px solid var(--creature-accent); outline-offset: 2px; }
#summons-card { grid-column: 1 / -1; }
#summons-list { display: grid; gap: 1rem; }
.summon-entry { min-width: 0; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.stat-block-compact, .stat-block-summary { font-size: 0.8rem; }
.stat-block-compact .stat-block-stat { padding: 0.55rem 0.65rem; }
.stat-block-compact .stat-block-stat dd { font-size: 1.15em; }
.stat-block-summary .stat-block-header { padding: 0.8rem; }
.stat-block-summary .stat-block-header h3 { font-size: 0.88rem; }
.stat-block-summary .stat-block-stats { margin: 0.75rem; gap: 0.5rem; }
.stat-block-summary .stat-block-stat { padding: 0.65rem; }
.stat-block-summary .stat-block-stat dd { font-size: 1.1rem; }
.summon-entry-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.65rem; padding: 0.75rem; border-top: 1px solid var(--border); }
.summon-entry-footer > span { color: var(--text-dim); font: 0.78rem/1.5 'Segoe UI', Arial, sans-serif; }
.summon-entry-footer .btn { font-size: 0.78rem; min-height: 36px; padding: 0.45rem 0.8rem; }
.summon-empty { padding: 1rem; background: var(--bg-input); }
.summon-empty h3 { font-size: 0.88rem; }
.summon-empty p { margin-top: 0.45rem; color: var(--text-dim); font: 0.8rem/1.5 'Segoe UI', Arial, sans-serif; }
@media (max-width: 620px) {
  .stat-block-abilities { grid-template-columns: minmax(0, 1fr); }
  .stat-block-action-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-block-action-facts > div:last-child { grid-column: 1 / -1; }
}
@media (max-width: 380px) {
  .stat-block-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-block-stat:last-child { grid-column: 1 / -1; }
}

.summon-detail-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem; margin-bottom: 1rem; }
.summon-detail-tools .btn { font-size: 0.8rem; min-height: 36px; max-width: 100%; white-space: normal; }

/* Shared creature tracker controls use the existing button/modal fields. */
.summon-controls { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.65rem; }
.summon-controls .btn { font-size: 0.8rem; min-height: 32px; max-width: 100%; white-space: normal; }
.summon-entry-footer .summon-controls { margin-top: 0; }
.summon-entry-status { padding: 0 0.75rem 0.65rem; color: var(--text-dim); font: 0.78rem/1.5 Segoe UI, Arial, sans-serif; }
/* ============================================================
   RIGHT COLUMN
   ============================================================ */

/* Armor Training */
.armor-training {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.armor-training-label {
  flex: 0 0 100%;
  font-family: var(--font-heading);
  font-size: 0.55rem;
  text-transform: uppercase;
  color: var(--text-dim);
}
.armor-check {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.armor-check input { accent-color: var(--class-primary); }

.prof-text-block {
  margin-bottom: 0.4rem;
}
.prof-text-block label {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.55rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.1rem;
}
.training-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.34rem;
  min-height: 1.65rem;
}

.training-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel-soft) 72%, transparent);
  color: var(--text);
  font-size: 0.66rem;
  font-family: var(--font-heading);
  padding: 0.16rem 0.52rem;
  line-height: 1.25;
}

.training-chip.none {
  color: var(--text-dim);
}

.select-search-wrap {
  padding: 0.28rem 0.28rem 0.22rem;
  border-bottom: 1px solid var(--border);
}

.select-search-input {
  width: 100%;
  min-height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.74rem;
  padding: 0.2rem 0.45rem;
}

/* Species Traits / Feats — dynamic lists */
.trait-entry, .feat-entry {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.3rem;
  margin-bottom: 0.2rem;
  border-bottom: 1px solid var(--border);
}
.trait-entry:last-of-type, .feat-entry:last-of-type { border-bottom: none; }
.trait-entry input, .feat-entry input { font-size: 0.8rem; }
.trait-entry textarea, .feat-entry textarea { font-size: 0.78rem; min-height: 32px; }

#feats-list {
  display: grid;
  gap: 0.32rem;
}

#species-traits-list {
  display: grid;
  gap: 0.32rem;
}

.species-trait-card {
  border-left-width: 2px;
  cursor: pointer;
}

.species-trait-card,
.feat-card {
  display: grid;
  gap: 0.22rem;
}

.species-trait-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
  color: var(--text-dim);
  font-size: 0.62rem;
  font-family: var(--font-heading);
  text-transform: uppercase;
  margin-top: 0.12rem;
}

.species-trait-preview {
  margin-top: 0.22rem;
  font-size: 0.74rem;
  color: var(--text);
  line-height: 1.35;
}

.species-trait-resource {
  margin-top: 0.22rem;
  padding-top: 0.2rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
}

.feat-resource-list {
  display: grid;
  gap: 0.28rem;
  width: 100%;
}

.feat-resource-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
}

.species-resource-title {
  font-size: 0.54rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--font-heading);
}

.species-resource-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.species-resource-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.species-resource-btn {
  width: 1.15rem;
  height: 1.15rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0;
  transition: border-color var(--transition), background var(--transition), color var(--transition), transform var(--transition);
}

.species-resource-btn:hover:not(:disabled) {
  border-color: var(--class-primary);
  background: color-mix(in srgb, var(--class-primary) 16%, var(--bg-input));
  color: var(--text-heading);
}

.species-resource-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.species-resource-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.species-resource-btn.is-use {
  width: auto;
  min-width: 3.2rem;
  height: 1.35rem;
  border-radius: 999px;
  padding: 0 0.55rem;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-heading);
}

.species-resource-btn.is-use:hover:not(:disabled) {
  background: color-mix(in srgb, var(--class-primary) 28%, var(--bg-input));
}

.species-resource-value {
  min-width: 3.1rem;
  text-align: center;
  font-size: 0.76rem;
  font-weight: 600;
}

.species-resource-reset {
  margin-top: 0.08rem;
  font-size: 0.56rem;
  color: var(--text-dim);
  text-align: right;
}

.feat-card {
  border-left-width: 2px;
}

.entry-header {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}
.entry-header input { flex: 1; font-weight: 600; }

.equip-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 32px 62px;
  gap: 0.18rem;
  align-items: center;
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--border);
}
.equip-entry:last-of-type { border-bottom: none; }
.equip-entry input { font-size: 0.8rem; padding: 0.15rem 0.3rem; }
.equip-name-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}
.equip-name-col input[type="text"] {
  width: 100%;
}

.inventory-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 32px 62px;
  gap: 0.18rem;
  align-items: center;
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--border);
}
.inventory-entry:last-of-type { border-bottom: none; }
.dropped-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 32px 62px;
  gap: 0.18rem;
  align-items: center;
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--border);
}
.dropped-entry:last-of-type { border-bottom: none; }
.item-list-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 32px 62px;
  gap: 0.18rem;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0.08rem 0 0.22rem;
  margin-bottom: 0.15rem;
}
.item-list-head span {
  font-family: var(--font-heading);
  font-size: 0.54rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.item-list-head span:nth-child(2),
.item-list-head span:nth-child(3),
.item-list-head span:nth-child(4) {
  text-align: center;
}
.inventory-entry input {
  font-size: 0.8rem;
  padding: 0.15rem 0.3rem;
}
.dropped-entry input {
  font-size: 0.8rem;
  padding: 0.15rem 0.3rem;
}
.inventory-entry input[type="number"] {
  text-align: center;
  width: 34px;
  min-width: 34px;
  padding: 0.1rem 0.1rem;
  font-size: 0.74rem;
}
.equip-entry input[type="number"] {
  text-align: center;
  width: 34px;
  min-width: 34px;
  padding: 0.1rem 0.1rem;
  font-size: 0.74rem;
}
.dropped-entry input[type="number"] {
  text-align: center;
  width: 34px;
  min-width: 34px;
  padding: 0.1rem 0.1rem;
  font-size: 0.74rem;
}
.item-actions-cell {
  display: flex;
  justify-content: flex-end;
  position: relative;
}

.item-name-btn {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  padding: 0.14rem 0.24rem;
  font-size: 0.66rem;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.12;
  word-break: break-word;
}

.item-weight-cell {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
  white-space: nowrap;
}

.item-actions-menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.item-actions-menu .btn {
  width: 100%;
  justify-content: flex-start;
}

.item-actions-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 70;
  min-width: 148px;
  background: color-mix(in srgb, var(--bg-card) 94%, #0b1017);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  padding: 0.26rem;
}

.item-actions-dropdown.hidden {
  display: none;
}

.item-actions-dropdown .btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.item-detail-meta {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.42rem;
  background: color-mix(in srgb, var(--bg-surface) 86%, #0d1118);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.3rem 0.55rem;
}

.item-detail-row {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}

.item-detail-row .k {
  font-size: 0.62rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.item-detail-row .v {
  font-size: 0.83rem;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.item-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.24rem;
}

.item-detail-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0.04rem 0.34rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-surface) 90%, #0b1018);
  color: var(--text);
  font-size: 0.7rem;
  line-height: 1.1;
}

.item-detail-actions {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.item-detail-actions .btn {
  min-height: 30px;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
}

input.qty-readonly {
  cursor: default;
}

.item-detail-top-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 0.85fr);
  gap: 0.45rem;
  align-items: end;
}

.item-action-btn {
  min-height: 24px;
  padding: 0.09rem 0.2rem;
  font-size: 0.54rem;
  letter-spacing: 0.01em;
}

#modal-equip-item .modal-content {
  max-width: 420px;
}

.add-item-value-inline {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 0.28rem;
  align-items: center;
  max-width: 260px;
}

#modal-add-item .g2,
#modal-add-item .g3,
#modal-add-item .g4,
#modal-add-item .g5 {
  display: grid;
  gap: 0.36rem;
}

#modal-add-item .profile-field {
  min-width: 0;
}

#modal-add-item .select-enhanced,
#modal-add-item .select-trigger,
#modal-add-item .select-options {
  width: 100%;
  max-width: 100%;
}

#modal-add-item .select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin-top: 0;
  max-height: 220px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.36);
}

#modal-add-item .add-item-top-row .select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin-top: 0;
  max-height: 220px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.36);
}

#modal-add-item .add-item-top-row .select-enhanced.is-open {
  z-index: 9000;
}

#modal-add-item .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#modal-add-item .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#modal-add-item .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#modal-add-item .g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
#modal-add-item .profile-field > label {
  display: block;
  min-height: 0;
  line-height: 1.2;
  margin-bottom: 0.16rem;
}
#modal-add-item .modal-content {
  max-width: 780px;
  overflow: visible;
}

#modal-add-item.modal-overlay {
  align-items: center;
  overflow-y: auto;
  padding: 0;
}

#modal-add-item .add-item-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.4rem;
  align-items: start;
}

#modal-add-item .add-item-top-row .profile-field {
  width: 100%;
}

#modal-add-item #add-item-qty-wrap {
  max-width: 220px;
  margin-top: 0.3rem;
}

#modal-add-item #add-item-qty-wrap > label {
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.05em;
}

#modal-add-item #add-item-qty-wrap #add-item-qty {
  width: 118px;
  text-align: center;
  text-align-last: center;
  font-family: var(--font-heading);
  font-size: 0.92rem;
  border-color: color-mix(in srgb, var(--class-primary) 52%, var(--border));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--class-primary) 20%, transparent);
}

#modal-add-item input:not([type="checkbox"]):not([type="radio"]),
#modal-add-item select,
#modal-add-item .select-trigger {
  min-height: 34px;
  width: 100%;
}

#modal-add-item .armor-check {
  align-items: center;
  margin-top: 0.05rem;
}

#modal-add-item .armor-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  min-height: 0;
  margin: 0;
}

#modal-add-item .add-item-custom-core-grid {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) minmax(90px, 0.8fr) minmax(100px, 0.9fr) minmax(160px, 1.2fr);
  gap: 0.36rem;
}

#modal-add-item .add-item-custom-core-grid.weapon-layout {
  grid-template-columns:
    minmax(0, 30fr)
    minmax(0, 15fr)
    minmax(0, 15fr)
    minmax(0, 10fr)
    minmax(0, 10fr)
    minmax(0, 10fr)
    minmax(0, 10fr);
  gap: 0.14rem;
}

#modal-add-item .add-item-custom-core-grid.armor-layout {
  grid-template-columns:
    minmax(0, 25fr)
    minmax(0, 25fr)
    minmax(0, 12.5fr)
    minmax(0, 12.5fr)
    minmax(0, 12.5fr)
    minmax(0, 12.5fr);
  gap: 0.14rem;
}

#modal-add-item .add-item-custom-core-grid.shield-layout {
  grid-template-columns:
    minmax(0, 35fr)
    minmax(0, 15fr)
    minmax(0, 10fr)
    minmax(0, 10fr)
    minmax(0, 10fr)
    minmax(0, 10fr);
  gap: 0.14rem;
}

#modal-add-item .add-item-custom-core-grid.simple-layout {
  grid-template-columns:
    minmax(0, 40fr)
    minmax(0, 15fr)
    minmax(0, 15fr)
    minmax(0, 15fr)
    minmax(0, 15fr);
  gap: 0.14rem;
}

#modal-add-item #add-item-custom-weapon-fields {
  display: grid;
  gap: 0.14rem;
  margin-top: 0.08rem;
}

#modal-add-item #add-item-custom-weapon-fields .g5,
#modal-add-item #add-item-custom-weapon-fields .g2 {
  gap: 0.14rem;
}

#modal-add-item #add-item-custom-armor-fields .g3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.14rem;
}

#modal-add-item .add-item-custom-core-grid.weapon-layout .profile-field > label,
#modal-add-item #add-item-custom-weapon-fields .g5 .profile-field > label {
  min-height: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#modal-add-item #add-item-custom-notes-wrap {
  margin-top: 0.1rem;
}

#modal-add-item #add-item-custom-notes {
  width: 100%;
}

#add-item-custom-dice-count + .select-enhanced .select-trigger,
#add-item-custom-dice-type + .select-enhanced .select-trigger {
  text-align: center;
}

#add-item-custom-dice-count + .select-enhanced .select-options .select-option,
#add-item-custom-dice-type + .select-enhanced .select-options .select-option {
  text-align: center;
}

#add-item-custom-dice-count,
#add-item-custom-dice-type {
  text-align: center;
  text-align-last: center;
}

#add-item-custom-dice-count option,
#add-item-custom-dice-type option {
  text-align: center;
}

#modal-add-item :is(
  #add-item-custom-weapon-tier,
  #add-item-custom-weapon-usage,
  #add-item-custom-cost-coin,
  #add-item-custom-damage-type,
  #add-item-custom-dice-count,
  #add-item-custom-dice-type,
  #add-item-custom-armor-type,
  #add-item-custom-stealth-dis
) + .select-enhanced .select-trigger {
  border-color: var(--border);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg-input) 90%, var(--bg-surface)),
    color-mix(in srgb, var(--bg-card) 94%, #0d1117)
  );
}

#modal-add-item :is(
  #add-item-custom-weapon-tier,
  #add-item-custom-weapon-usage,
  #add-item-custom-cost-coin,
  #add-item-custom-damage-type,
  #add-item-custom-dice-count,
  #add-item-custom-dice-type,
  #add-item-custom-armor-type,
  #add-item-custom-stealth-dis
) + .select-enhanced .select-trigger:hover {
  border-color: var(--border-strong);
}

#modal-add-item :is(
  #add-item-custom-weapon-tier,
  #add-item-custom-weapon-usage,
  #add-item-custom-cost-coin,
  #add-item-custom-damage-type,
  #add-item-custom-dice-count,
  #add-item-custom-dice-type,
  #add-item-custom-armor-type,
  #add-item-custom-stealth-dis
) + .select-enhanced .select-options {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--bg-surface) 95%, #0a0d12);
}

#modal-add-item :is(
  #add-item-custom-weapon-tier,
  #add-item-custom-weapon-usage,
  #add-item-custom-cost-coin,
  #add-item-custom-damage-type,
  #add-item-custom-dice-count,
  #add-item-custom-dice-type,
  #add-item-custom-armor-type,
  #add-item-custom-stealth-dis
) + .select-enhanced .select-option {
  border-color: color-mix(in srgb, var(--border) 82%, transparent);
  background: color-mix(in srgb, var(--bg-card) 88%, transparent);
}

#modal-add-item :is(
  #add-item-custom-weapon-tier,
  #add-item-custom-weapon-usage,
  #add-item-custom-cost-coin,
  #add-item-custom-damage-type,
  #add-item-custom-dice-count,
  #add-item-custom-dice-type,
  #add-item-custom-armor-type,
  #add-item-custom-stealth-dis
) + .select-enhanced .select-option:hover,
#modal-add-item :is(
  #add-item-custom-weapon-tier,
  #add-item-custom-weapon-usage,
  #add-item-custom-cost-coin,
  #add-item-custom-damage-type,
  #add-item-custom-dice-count,
  #add-item-custom-dice-type,
  #add-item-custom-armor-type,
  #add-item-custom-stealth-dis
) + .select-enhanced .select-option.is-selected {
  border-color: color-mix(in srgb, var(--border-strong) 92%, var(--class-primary) 8%);
}

.add-item-results {
  max-height: 230px;
}

.add-item-table {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.add-item-table-head,
.add-item-table-row {
  display: grid;
  align-items: center;
  gap: 0.36rem;
}

.add-item-table-weapon .add-item-table-head,
.add-item-table-weapon .add-item-table-row {
  grid-template-columns: minmax(172px, 1.45fr) 62px minmax(100px, 0.95fr) minmax(190px, 2.15fr) 68px 56px 68px;
}

.add-item-table-armor .add-item-table-head,
.add-item-table-armor .add-item-table-row {
  grid-template-columns: minmax(170px, 1.3fr) 78px 84px minmax(105px, 1fr) 76px 72px 72px 80px;
}

.add-item-table-tool .add-item-table-head,
.add-item-table-tool .add-item-table-row {
  grid-template-columns: minmax(180px, 1.6fr) minmax(120px, 1fr) 72px 80px;
}

.add-item-table-adventuring_gear .add-item-table-head,
.add-item-table-adventuring_gear .add-item-table-row {
  grid-template-columns: minmax(220px, 1.8fr) 80px 84px;
}

.add-item-table-head {
  padding: 0.2rem 0.42rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.add-item-table-row {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-input) 76%, transparent);
  color: var(--text);
  text-align: left;
  font-size: 0.72rem;
  padding: 0.26rem 0.42rem;
  cursor: pointer;
}

.add-item-table-row .c-name {
  font-weight: 600;
}

.add-item-table-weapon .add-item-table-row .c-type,
.add-item-table-weapon .add-item-table-row .c-props {
  white-space: normal;
  line-height: 1.2;
}

.add-item-table-row.selected {
  border-color: var(--border-strong);
  background: linear-gradient(90deg, rgba(244,161,56,0.2), rgba(244,161,56,0.06));
  box-shadow: inset 2px 0 0 var(--class-primary);
}

.inventory-add-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.36rem;
}

.inventory-add-actions .rest-btn {
  width: 100%;
  font-size: 0.6rem;
  padding: 0.25rem 0.3rem;
}

.load-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.28rem;
}

.load-k {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-family: var(--font-heading);
}

.load-v {
  font-size: 0.82rem;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.load-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 104px;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-heading);
  border: 1px solid var(--border);
}

.load-status-within {
  color: #b9e8c9;
  border-color: color-mix(in srgb, #8fdfaa 38%, var(--border));
  background: color-mix(in srgb, #8fdfaa 12%, transparent);
}

.load-status-over {
  color: #ffd9d9;
  border-color: #ff4d4d;
  background: linear-gradient(180deg, rgba(255,77,77,0.28), rgba(255,77,77,0.14));
  box-shadow: 0 0 0 1px rgba(255,77,77,0.3) inset;
}

.load-bar-track {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-input) 86%, transparent);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 0.2rem;
}

.load-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, color-mix(in srgb, var(--class-primary) 75%, #ffffff 25%), var(--class-primary));
  transition: width 180ms ease;
}

#load-card.over-capacity .load-bar-fill {
  background: linear-gradient(90deg, #ff5e5e, #d21f1f);
}

.add-item-cell-trunc {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.multi-select {
  position: relative;
}

.multi-select-trigger {
  width: 100%;
  text-align: left;
  padding: 0.36rem 0.46rem;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.76rem;
  cursor: pointer;
}

.multi-select-trigger:focus-visible {
  outline: 1px solid color-mix(in srgb, var(--class-primary) 76%, white 24%);
  outline-offset: 1px;
}

.multi-select-menu {
  position: absolute;
  z-index: 2500;
  left: 0;
  right: 0;
  margin-top: 0.2rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  max-height: 220px;
  overflow: auto;
  padding: 0.25rem;
  box-shadow: 0 8px 22px rgba(0,0,0,0.35);
}

#modal-add-item .multi-select-menu {
  position: absolute;
  left: 0;
  right: 0;
  margin-top: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.36);
}

.multi-select-search-wrap {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  padding-bottom: 0.2rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
  z-index: 1;
}

.multi-select-search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.72rem;
  padding: 0.2rem 0.3rem;
}

.multi-select-search:focus-visible {
  outline: 1px solid color-mix(in srgb, var(--class-primary) 76%, white 24%);
  outline-offset: 1px;
}

.multi-select-options-list {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.74rem;
  padding: 0.16rem 0.2rem;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
}

.multi-select-option:hover {
  background: rgba(255,255,255,0.05);
}

.multi-select-option:has(input:checked) {
  border-color: var(--border-strong);
  background: linear-gradient(90deg, rgba(244,161,56,0.16), rgba(244,161,56,0.05));
}

.multi-select-option input[type="checkbox"] {
  accent-color: var(--class-primary);
}

.multi-select-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: 0.25rem;
}

.multi-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.24rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.08rem 0.34rem;
  font-size: 0.68rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.03);
}

.multi-chip button {
  all: unset;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
}

#modal-add-item .multi-select-trigger {
  min-height: 34px;
  border-radius: var(--radius);
  border-color: var(--border);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg-input) 90%, var(--bg-surface)),
    color-mix(in srgb, var(--bg-card) 94%, #0d1117)
  );
  color: var(--text);
  font-size: 0.8rem;
}

#modal-add-item .multi-select-trigger:hover {
  border-color: var(--border-strong);
}

#modal-add-item .multi-select-menu {
  border-color: var(--border-strong);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-surface) 95%, #0a0d12);
}

#modal-add-item .multi-select-search-wrap {
  background: color-mix(in srgb, var(--bg-surface) 95%, #0a0d12);
}

#modal-add-item .multi-select-search {
  border-color: color-mix(in srgb, var(--border) 84%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-input) 90%, var(--bg-surface));
  color: var(--text);
}

#modal-add-item .multi-select-option {
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: color-mix(in srgb, var(--bg-card) 88%, transparent);
}

#modal-add-item .multi-select-option:hover {
  border-color: color-mix(in srgb, var(--border-strong) 90%, transparent);
  background: color-mix(in srgb, var(--bg-card-hover) 74%, transparent);
}

#modal-add-item .multi-select-option:has(input:checked) {
  border-color: color-mix(in srgb, var(--border-strong) 92%, var(--class-primary) 8%);
  background: color-mix(in srgb, var(--class-primary) 8%, var(--bg-card));
}

@media (max-width: 860px) {
  #modal-add-item .add-item-top-row,
  #modal-add-item .g2,
  #modal-add-item .g3,
  #modal-add-item .g4,
  #modal-add-item .g5,
  #modal-add-item .add-item-custom-core-grid {
    grid-template-columns: 1fr;
  }
  .add-item-value-inline {
    grid-template-columns: 1fr 76px;
    max-width: 100%;
  }
  #modal-add-item .profile-field > label {
    min-height: auto;
  }
  .add-item-table-head {
    display: none;
  }
  .add-item-table-weapon .add-item-table-row,
  .add-item-table-armor .add-item-table-row,
  .add-item-table-tool .add-item-table-row,
  .add-item-table-adventuring_gear .add-item-table-row {
    grid-template-columns: 1fr;
    gap: 0.14rem;
  }
}

/* Coins */
.currency-row {
  display: flex;
  gap: 0.4rem;
  justify-content: space-between;
}
.currency-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
}
.currency-item input { width: 42px; font-size: 0.8rem; text-align: center; }
.currency-item label {
  font-size: 0.55rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--font-heading);
}

/* ============================================================
   PROFILE TAB
   ============================================================ */
.profile-container {
  max-width: 800px;
  margin: 1rem auto;
  padding: 0 1rem;
  position: relative;
  z-index: 1;
}

.profile-image-card {
  max-width: 300px;
}

.portrait-area {
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-input);
  border: 2px dashed var(--border-strong);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.portrait-placeholder {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem;
}
.portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.creation-portrait-area {
  width: min(100%, 260px);
  aspect-ratio: 1 / 1;
}

.item-detail-rule-reference {
  margin-top: 0.5rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.45;
}

.item-detail-reference-label {
  margin-bottom: 0.25rem;
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.portrait-img.is-dragging {
  cursor: grabbing;
}

.profile-select {
  width: 100%;
  font-size: 0.9rem;
}

.profile-field {
  margin-bottom: 0.5rem;
}
.profile-field label {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.15rem;
}

.appearance-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.appear-field label {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.55rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.1rem;
}
.appear-field input { width: 100%; font-size: 0.85rem; }

/* ============================================================
   Modals
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

#modal-action-confirm.active {
  z-index: 12000;
}

/* Complete gameplay bodies opt in; excluded modal layouts keep their styles. */
.gameplay-action-body { display: grid; gap: .65rem; min-width: 0; }
.gameplay-action-body .cast-effect-section { margin: 0; }
.gameplay-action-body .cast-effect-detail,
.gameplay-action-body .cast-effect-description { font-size: .8rem; line-height: 1.55; }
.gameplay-action-body .cast-effect-heading { margin-bottom: .4rem; }
.gameplay-action-body .cast-effect-fields { margin-bottom: .5rem; }
.gameplay-action-body .cast-reminder { margin: 0; font-size: .8rem; }
.gameplay-action-body .cast-spell-rules { margin: 0; }
.gameplay-action-body .resource-use-confirm-label,
.gameplay-action-body .resource-use-confirm-reset { overflow-wrap: anywhere; white-space: normal; overflow: visible; min-width: 0; }
.gameplay-action-body .feature-restore-row { margin-top: .6rem; }
@media (max-width: 480px) {
  .gameplay-action-body .feature-restore-row { display: flex; flex-wrap: wrap; gap: .45rem; }
  .gameplay-action-body .feature-restore-row .btn { margin-left: auto; }
}

/* Spell widgets provide their own headings inside the shared choices section. */
.gameplay-action-body [data-gameplay-section="choices"] > .cast-effect-section > #cast-healing-fields > .cast-effect-section,
.gameplay-action-body [data-gameplay-section="choices"] > .cast-effect-section > #cast-sheet-effect-fields > .cast-effect-section { border: 0; padding: 0; background: none; }

/* Keep the included Wish option readable without changing other spell pickers. */
@media (max-width: 700px) {
  .greater-divine-intervention-option .spell-library-card-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: .25rem; }
  .greater-divine-intervention-option .spell-library-cast-time { text-align: left; white-space: normal; }
}

/* Shared compact checkbox group; reuses the existing checkbox widget. */
.gameplay-action-body .gameplay-check-field { grid-column: 1 / -1; }
.gameplay-action-body .gameplay-field-group { grid-column: 1 / -1; min-width: 0; }
.gameplay-action-body .gameplay-fields-stack { grid-template-columns: minmax(0, 1fr); }
.gameplay-action-body .gameplay-check-field > .creation-check-option { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; margin: 0; }
.gameplay-check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; }
.gameplay-action-body .gameplay-check-grid .creation-check-option { display: grid; align-items: center; grid-template-columns: 16px minmax(0, 1fr); min-height: 34px; padding: .35rem .45rem; gap: .4rem; }
.gameplay-check-grid .creation-check-indicator { width: 16px; height: 16px; }
.gameplay-check-grid .creation-check-option.is-compact .creation-check-copy strong { font-size: .78rem; }
.gameplay-check-grid .creation-check-option:focus-within { outline: 2px solid var(--class-primary); outline-offset: 2px; }
@media (max-width: 480px) {
  .gameplay-check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Common Cast needs room for attack controls and optional own-state effects. */
#modal-action-confirm .modal-content:has(#cast-summary-preview) {
  max-width: 760px;
}

#modal-action-confirm .modal-content.divine-intervention-mode {
  width: min(94vw, 920px);
  max-width: 920px;
}

.divine-intervention-picker {
  display: grid;
  gap: 0.7rem;
}

.greater-divine-intervention-option {
  border-color: color-mix(in srgb, var(--class-accent) 72%, var(--border));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--class-primary) 18%, var(--bg-surface)), var(--bg-surface));
}

.greater-divine-intervention-option .spell-library-name,
.greater-divine-intervention-option .spell-library-cast-time {
  color: var(--class-accent);
}

.divine-intervention-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 0.32fr);
  gap: 0.55rem;
}

.divine-intervention-controls input,
.divine-intervention-controls select {
  width: 100%;
}

.divine-intervention-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(300px, 1.2fr);
  gap: 0.7rem;
  min-height: 320px;
}

.divine-intervention-grid .spell-library-list {
  max-height: 360px;
}

.divine-intervention-grid .spell-library-preview {
  min-height: 0;
  max-height: 360px;
  overflow-y: auto;
}

@media (max-width: 700px) {
  .divine-intervention-controls,
  .divine-intervention-grid {
    grid-template-columns: 1fr;
  }

  .divine-intervention-grid {
    min-height: 0;
  }

  .divine-intervention-grid .spell-library-list,
  .divine-intervention-grid .spell-library-preview {
    max-height: 260px;
  }
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 600px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

#modal-creation .modal-content {
  max-width: 1040px;
  width: min(96vw, 1040px);
  max-height: none;
  overflow: visible;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--class-primary) 18%, transparent), transparent 42%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg-card) 92%, #0e1117) 0%, var(--bg-card) 100%);
  border-color: color-mix(in srgb, var(--class-primary) 36%, var(--border));
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.56),
    inset 0 1px 0 color-mix(in srgb, var(--class-accent) 18%, transparent);
}

/* Before a class is selected, pair the home teal with a restrained warm accent. */
#modal-creation:not([data-class-selected="true"]) .creation-panel {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--class-accent) 7%, var(--bg-surface)), var(--bg-surface));
}

#modal-creation .select-enhanced.is-open {
  z-index: 9000;
}

#modal-creation.modal-overlay,
#modal-levelup-summary.modal-overlay,
#modal-add-item.modal-overlay {
  overflow-y: auto;
}

#modal-creation.modal-overlay {
  align-items: safe center;
  padding-block: clamp(0.65rem, 2vh, 1.25rem);
}

#modal-level-choice.modal-overlay {
  overflow: hidden;
}

#modal-level-choice .modal-content,
#modal-levelup-summary .modal-content {
  overflow: visible;
}

#modal-level-choice .modal-content {
  display: flex;
  flex-direction: column;
  width: min(94vw, 980px);
  max-width: 980px;
  max-height: 92vh;
  overflow: hidden;
}

#modal-level-choice:has(.dropdown-escape-mode) {
  overflow-y: auto;
  padding-block: 4vh;
}

#modal-level-choice .modal-content.dropdown-escape-mode {
  max-height: none;
  overflow: visible;
}

#modal-level-choice .modal-content.dropdown-escape-mode #level-choice-body {
  flex: 0 1 auto;
  overflow: visible;
  padding-right: 0;
}

/* Origin spell choices reuse the full spell picker; let its outer modal scroll. */
#modal-level-choice:has(.origin-feat-choice:not([hidden])) {
  align-items: safe center;
}

#modal-level-choice .modal-content.dropdown-escape-mode:has(.origin-feat-choice:not([hidden])) {
  flex-shrink: 0;
  max-height: none;
}

#modal-level-choice .modal-content.dropdown-escape-mode .select-enhanced.is-open,
#modal-level-choice .modal-content.dropdown-escape-mode .feat-combobox:focus-within {
  z-index: 9000;
}

.creation-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.creation-hero h2 {
  margin-bottom: 0.15rem;
}

.creation-hero-badge {
  font-family: var(--font-heading);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--class-primary) 85%, var(--text));
  border: 1px solid color-mix(in srgb, var(--class-primary) 45%, var(--border));
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  background: color-mix(in srgb, var(--class-primary) 10%, transparent);
}

.creation-progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-input) 85%, #0a0d12);
  border: 1px solid color-mix(in srgb, var(--class-primary) 28%, var(--border));
  overflow: hidden;
  margin-bottom: 0.55rem;
}

.creation-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, color-mix(in srgb, var(--class-primary) 80%, #d89e00), color-mix(in srgb, var(--class-accent) 85%, #e6cf6a));
  transition: width 0.28s ease;
}

.creation-step-nav {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.creation-step-pill {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-surface) 85%, #0f1117);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 0.28rem 0.45rem;
  font-family: var(--font-heading);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 0.2s ease;
}

.creation-step-pill.active {
  color: var(--class-readable);
  border-color: color-mix(in srgb, var(--class-primary) 55%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 12%, var(--bg-surface));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--class-primary) 24%, transparent);
}

.creation-step-pill.done {
  color: color-mix(in srgb, var(--class-accent) 85%, var(--text));
  border-color: color-mix(in srgb, var(--class-accent) 55%, var(--border));
  background: color-mix(in srgb, var(--class-accent) 10%, var(--bg-surface));
}

.creation-step-help {
  margin: -0.2rem 0 0.8rem;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.45;
}

.creation-setup-strip {
  display: grid;
  grid-template-columns: minmax(110px, 150px) minmax(130px, 170px) minmax(240px, 1fr);
  gap: 0.7rem;
  align-items: start;
  margin-bottom: 0.8rem;
}

.creation-check-option {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 0.58rem;
  min-width: 0;
  min-height: 68px;
  padding: 0.58rem 0.64rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 20%, var(--border));
  border-radius: 6px;
  background:
    linear-gradient(110deg, color-mix(in srgb, var(--class-primary) 5%, transparent), transparent 68%),
    color-mix(in srgb, var(--bg-card) 90%, #0c1116);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition), transform var(--transition);
}

.creation-check-option:hover {
  border-color: color-mix(in srgb, var(--class-primary) 52%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 8%, var(--bg-card));
  transform: translateY(-1px);
}

.creation-check-option input[type="checkbox"],
.creation-check-option input[type="radio"] {
  position: absolute;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.creation-check-indicator {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid color-mix(in srgb, var(--class-primary) 34%, var(--border-strong));
  border-radius: 5px;
  color: transparent;
  background: color-mix(in srgb, var(--bg-input) 92%, #000);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.creation-check-indicator span {
  transform: translateY(-0.5px);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
}

.creation-check-copy {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}

.creation-check-copy small {
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.creation-check-copy strong {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  letter-spacing: 0.025em;
}

.creation-check-copy > span {
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.3;
}

.creation-check-option.is-selected,
.creation-check-option:has(input:checked) {
  border-color: color-mix(in srgb, var(--class-primary) 72%, var(--border));
  background:
    linear-gradient(110deg, color-mix(in srgb, var(--class-primary) 14%, transparent), transparent 72%),
    color-mix(in srgb, var(--class-primary) 7%, var(--bg-card));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--class-primary) 12%, transparent);
}

.creation-check-option.is-selected .creation-check-indicator,
.creation-check-option:has(input:checked) .creation-check-indicator {
  border-color: var(--class-primary);
  color: var(--class-text);
  background: var(--class-readable);
}

.creation-check-option.is-disabled,
.creation-check-option:has(input:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.creation-check-option.is-compact {
  min-height: 46px;
  padding: 0.46rem 0.56rem;
}

.creation-check-option.is-compact .creation-check-copy strong {
  font-family: var(--font-body);
  font-size: 0.86rem;
  letter-spacing: 0;
}

.creation-class-layout {
  display: grid;
  grid-template-columns: minmax(230px, 0.8fr) minmax(320px, 1.2fr);
  gap: 0.9rem;
}

.creation-class-picker-panel .profile-field {
  max-width: 260px;
}

.creation-class-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.creation-class-tile {
  display: grid;
  gap: 0.15rem;
  min-height: 64px;
  padding: 0.58rem 0.62rem;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--class-primary) 22%, var(--border));
  border-radius: 14px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg-surface) 90%, var(--class-bg)), var(--bg-card));
  color: var(--text);
}

.creation-class-tile strong {
  font-family: var(--font-heading);
  color: var(--text-heading);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.creation-class-tile span {
  color: var(--text-dim);
  font-size: 0.66rem;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.level-choice-option-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: stretch;
}

.level-choice-option-grid .creation-class-tile {
  border-radius: 8px;
  min-width: 0;
  min-height: 86px;
}

.level-choice-option-grid .creation-class-tile strong,
.level-choice-option-grid .creation-class-tile span {
  min-width: 0;
  white-space: normal;
}

.battle-master-choice-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.45rem 1rem;
  margin: 0.55rem 0 0.75rem;
  padding: 0.58rem 0.72rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 28%, var(--border));
  border-radius: 7px;
  background: color-mix(in srgb, var(--class-primary) 7%, var(--bg-input));
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.weapon-mastery-choice-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 0.65rem;
  margin: 0.55rem 0 0.72rem;
}

.weapon-mastery-choice-summary {
  width: fit-content;
  margin-left: auto;
  padding: 0.38rem 0.58rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 30%, var(--border));
  border-radius: 5px;
  background: color-mix(in srgb, var(--class-primary) 7%, var(--bg-input));
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.weapon-mastery-choice-search {
  display: grid;
  gap: 0.2rem;
  width: min(330px, 48%);
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.58rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.weapon-mastery-choice-search input {
  min-height: 38px;
  padding: 0.42rem 0.58rem;
  border-color: color-mix(in srgb, var(--class-primary) 30%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 5%, var(--bg-input));
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: none;
}

.weapon-mastery-choice-search input:focus {
  border-color: var(--class-readable);
}

.weapon-mastery-choice-empty {
  margin-bottom: 0.55rem;
  padding: 0.72rem;
  border: 1px dashed color-mix(in srgb, var(--class-primary) 36%, var(--border));
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.78rem;
  text-align: center;
}

.weapon-mastery-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.46rem;
  max-height: min(57vh, 570px);
  padding-right: 0.25rem;
  overflow-y: auto;
}

.weapon-mastery-current > .spell-review-selected-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.weapon-mastery-current .spell-review-selected-name {
  white-space: normal;
  overflow-wrap: anywhere;
}

.weapon-mastery-choice-grid .creation-check-option {
  align-items: start;
  min-height: 64px;
  padding: 0.4rem 0.48rem;
}

.weapon-mastery-choice-grid .creation-check-indicator {
  margin-top: 0.1rem;
}

.weapon-mastery-choice-grid .creation-check-copy > span {
  font-size: 0.68rem;
  line-height: 1.3;
}

.weapon-mastery-choice-grid .creation-check-copy small {
  font-size: 0.57rem;
  line-height: 1.25;
}

.battle-master-maneuver-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  max-height: min(54vh, 560px);
  padding-right: 0.25rem;
  overflow-y: auto;
}

.battle-master-maneuver-grid .creation-check-option {
  align-items: start;
  min-height: 94px;
  padding: 0.5rem 0.56rem;
}

.battle-master-maneuver-grid .creation-check-indicator {
  margin-top: 0.12rem;
}

.battle-master-maneuver-grid .creation-check-copy > span {
  font-size: 0.69rem;
  line-height: 1.28;
}

.battle-master-training-grid {
  align-items: start;
  margin-top: 0.8rem;
}

.fighting-style-browser {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  gap: 0.72rem;
  width: 100%;
  min-width: 0;
  height: min(330px, 48vh);
  margin-top: 0.8rem;
  overflow-x: hidden;
}

.fighting-style-list {
  display: grid;
  align-content: start;
  gap: 0.28rem;
  padding: 0.38rem;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: color-mix(in srgb, var(--bg-input) 90%, #05080a);
}

.fighting-style-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.48rem 0.58rem;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.fighting-style-list-item:hover,
.fighting-style-list-item.is-previewed {
  border-color: color-mix(in srgb, var(--class-primary) 38%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 7%, var(--bg-card));
}

.fighting-style-list-item.is-selected {
  border-color: color-mix(in srgb, var(--class-primary) 70%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 13%, var(--bg-card));
  color: var(--text-heading);
}

.fighting-style-list-item > span {
  min-width: 0;
  font-family: var(--font-heading);
  font-size: 0.76rem;
  letter-spacing: 0.035em;
}

.fighting-style-list-item > small {
  color: var(--text-dim);
  font-size: 0.63rem;
  white-space: nowrap;
}

.fighting-style-list-item:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.fighting-style-preview {
  min-width: 0;
  padding: 0.78rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 30%, var(--border));
  border-radius: 7px;
  background:
    linear-gradient(125deg, color-mix(in srgb, var(--class-primary) 8%, transparent), transparent 55%),
    var(--bg-card);
}

.fighting-style-preview-kicker {
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-size: 0.64rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.fighting-style-preview-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0.28rem 0 0.62rem;
  padding-bottom: 0.58rem;
  border-bottom: 1px solid color-mix(in srgb, var(--class-primary) 22%, var(--border));
}

.fighting-style-preview-head h3 {
  margin: 0;
  color: var(--text-heading);
  font-size: 1.25rem;
}

.fighting-style-preview-head span {
  padding: 0.18rem 0.42rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 42%, var(--border));
  border-radius: 999px;
  color: var(--class-readable);
  font-size: 0.62rem;
  text-transform: uppercase;
}

.fighting-style-preview-rules {
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.55;
}

.fighting-style-preview-rules p:first-child {
  margin-top: 0;
}

.fighting-style-preview-note {
  margin-top: 0.85rem;
  padding: 0.52rem 0.6rem;
  border-left: 2px solid var(--class-primary);
  background: color-mix(in srgb, var(--class-primary) 7%, var(--bg-input));
  color: var(--text-dim);
  font-size: 0.75rem;
}

@media (max-width: 720px) {
  .battle-master-maneuver-grid {
    grid-template-columns: 1fr;
  }

  .fighting-style-browser {
    grid-template-columns: 1fr;
    height: auto;
  }

  .fighting-style-list {
    max-height: 240px;
  }
}

@media (max-width: 600px) {
  .weapon-mastery-choice-grid,
  .weapon-mastery-current > .spell-review-selected-list {
    grid-template-columns: 1fr;
  }

  .weapon-mastery-choice-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .weapon-mastery-choice-search {
    width: 100%;
  }

  .weapon-mastery-choice-summary {
    margin-left: 0;
  }
}

.creation-class-tile.active {
  border-color: color-mix(in srgb, var(--class-primary) 78%, var(--border));
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--class-primary) 20%, transparent), transparent 58%),
    color-mix(in srgb, var(--class-bg) 70%, var(--bg-card));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--class-primary) 18%, transparent),
    0 12px 26px rgba(0, 0, 0, 0.24);
}

.creation-class-tile.locked {
  opacity: 0.58;
  cursor: pointer;
  filter: grayscale(0.42);
}

.creation-class-tile.locked:hover,
.creation-class-tile.locked:focus-visible {
  opacity: 0.78;
  border-color: color-mix(in srgb, var(--class-primary) 50%, var(--border));
}

.creation-class-tile.locked.active {
  opacity: 0.9;
  filter: grayscale(0.12);
}

.creation-class-detail-panel {
  overflow: hidden;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--class-primary) 14%, transparent), transparent 40%),
    color-mix(in srgb, var(--bg-surface) 86%, var(--class-bg));
  border-color: color-mix(in srgb, var(--class-primary) 36%, var(--border));
}

.creation-class-empty {
  min-height: 280px;
  display: grid;
  align-content: center;
  gap: 0.45rem;
  text-align: center;
  padding: 1rem;
}

.creation-class-empty h3 {
  margin: 0;
  color: var(--text-heading);
  font-size: clamp(1.25rem, 2.6vw, 1.8rem);
}

.creation-class-empty p {
  max-width: 440px;
  margin: 0 auto;
  color: var(--text-dim);
  line-height: 1.45;
}

.creation-class-detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.65rem;
}

.creation-class-detail-head h3 {
  margin: 0;
  color: var(--text-heading);
  font-size: clamp(1.35rem, 3vw, 2.1rem);
}

.creation-class-status {
  border: 1px solid color-mix(in srgb, var(--class-primary) 45%, var(--border));
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  color: var(--class-readable);
  background: color-mix(in srgb, var(--class-primary) 12%, transparent);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.creation-class-status.locked {
  color: var(--text-dim);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.creation-class-detail-lead {
  margin: 0 0 0.8rem;
  color: color-mix(in srgb, var(--text) 82%, var(--text-dim));
  line-height: 1.45;
}

.creation-class-role-list,
.creation-class-info-grid,
.creation-class-stat-grid,
.creation-class-info-list {
  display: grid;
  gap: 0.45rem;
}

.creation-class-section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.38rem;
}

.creation-class-section-label strong {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.creation-class-section-label span {
  color: var(--text-dim);
  font-size: 0.68rem;
}

.creation-class-role-list {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  margin-bottom: 0.75rem;
}

.creation-class-role-list span,
.creation-class-info-grid div,
.creation-subclass-row {
  border: 1px solid color-mix(in srgb, var(--class-primary) 22%, var(--border));
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.creation-class-role-list span {
  padding: 0.38rem 0.5rem;
  color: color-mix(in srgb, var(--text) 86%, var(--class-primary));
  font-size: 0.76rem;
}

.creation-class-info-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 0.85rem;
}

.creation-class-stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0.45rem;
}

.creation-class-stat,
.creation-class-info-row {
  border: 1px solid color-mix(in srgb, var(--class-primary) 22%, var(--border));
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.025);
}

.creation-class-stat {
  display: grid;
  align-content: center;
  gap: 0.16rem;
  min-height: 62px;
  padding: 0.5rem 0.58rem;
}

.creation-class-info-list {
  margin-bottom: 0.85rem;
}

.creation-class-info-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.34fr) minmax(0, 1fr);
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.46rem 0.58rem;
}

.creation-class-stat strong,
.creation-class-info-row strong {
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.creation-class-stat span,
.creation-class-info-row span {
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.35;
}

.creation-class-stat span {
  color: var(--text-heading);
  font-size: 0.9rem;
}

.creation-class-info-grid div {
  display: grid;
  gap: 0.15rem;
  padding: 0.52rem 0.58rem;
}

.creation-class-info-grid strong,
.creation-subclass-title {
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.creation-class-info-grid span,
.creation-subclass-row span {
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.35;
}

.creation-subclass-preview {
  display: grid;
  gap: 0.45rem;
}

.creation-subclass-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(0, 1.4fr);
  gap: 0.5rem;
  padding: 0.5rem 0.58rem;
}

.creation-subclass-row strong {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 0.78rem;
}

.creation-required-panel {
  margin-top: 0.85rem;
}
.modal-content h2 {
  font-size: 1rem;
  color: var(--class-readable);
  margin-bottom: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.modal-content-compact {
  max-width: 520px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.rest-modal-body {
  display: grid;
  gap: 0.72rem;
}

.rest-preview-section {
  display: grid;
  gap: 0.28rem;
}

.rest-preview-title {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--class-readable);
}

.rest-preview-empty,
.rest-preview-note {
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.45;
}

.rest-mastery-validation {
  padding: 0.5rem 0.6rem;
  border-left: 3px solid var(--class-readable);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--class-readable) 10%, transparent);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.45;
}

.rest-change-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.34rem;
}

.rest-change-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.56rem 0.62rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 44%, var(--border));
  border-radius: var(--radius);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--class-primary) 9%, var(--bg-card)),
    color-mix(in srgb, var(--bg-card) 90%, #0f1117)
  );
}

.rest-change-label {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 0.82rem;
}

.rest-change-values {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Long Rest countdowns keep the label above the before/after values. */
.rest-change-row.is-lockout {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 0.25rem;
}

.rest-change-row.is-lockout .rest-change-values {
  flex-wrap: wrap;
  font-size: 0.86rem;
  line-height: 1.4;
}

/* Verbose counter transitions use the full row instead of squeezing the label. */
.rest-change-row.is-wide {
  grid-column: 1 / -1;
  grid-template-columns: max-content minmax(0, 1fr);
}

.rest-change-row.is-wide .rest-change-values {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  justify-content: end;
  font-size: 0.82rem;
  line-height: 1.4;
}

@media (max-width: 600px) {
  .rest-change-row.is-wide {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }

  .rest-change-row.is-wide .rest-change-values {
    grid-template-columns: repeat(2, max-content);
    justify-content: start;
  }

  .rest-change-row.is-wide .rest-change-values > span:first-child {
    grid-column: 1 / -1;
  }
}

.rest-change-arrow {
  color: var(--class-readable);
}

.rest-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.rest-retune-section {
  display: grid;
  gap: 0.35rem;
  padding: 0.55rem 0.62rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 30%, var(--border));
  border-radius: var(--radius);
  background: rgba(255,255,255,0.018);
}

.rest-reminder-section {
  display: grid;
  gap: 0.36rem;
  padding: 0.62rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 36%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--class-primary) 8%, rgba(255,255,255,0.018));
}

.rest-reminder-list {
  display: grid;
  gap: 0.32rem;
}

.rest-reminder-row {
  display: grid;
  gap: 0.12rem;
  padding: 0.42rem 0.48rem;
  border-radius: calc(var(--radius) - 4px);
  background: rgba(0,0,0,0.16);
}

.rest-reminder-label {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 0.78rem;
}

.rest-reminder-text {
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.42;
}

@media (max-width: 560px) {
  .rest-change-list,
  .rest-input-grid {
    grid-template-columns: 1fr;
  }
}

.modal-tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}
.modal-tabs button { font-size: 0.65rem; padding: 0.3rem 0.6rem; }
.modal-tabs button.active {
  background: var(--class-primary);
  color: var(--class-text);
  border-color: var(--class-primary);
}

.point-buy-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.4rem;
  text-align: center;
}
.pb-ability { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 0.2rem; min-height: 104px; padding: 0.48rem 0.38rem; border: 1px solid color-mix(in srgb, var(--class-primary) 18%, var(--border)); border-radius: 6px; background: rgba(255,255,255,0.018); }
.pb-ability label { font-family: var(--font-heading); font-size: 0.65rem; text-transform: uppercase; color: var(--text-dim); }
.pb-controls { display: flex; align-items: center; gap: 0.15rem; }
.pb-controls button { width: 22px; height: 22px; padding: 0; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; }
.pb-score { font-size: 1rem; font-weight: 700; width: 26px; text-align: center; }
.pb-mod { font-size: 0.75rem; color: var(--text-dim); }

.pb-score-comparison {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.18rem;
  min-height: 24px;
}

#modal-feature-detail .modal-content:has(.stat-block) {
  max-width: 900px;
  width: min(94vw, 900px);
}

.rest-fighter-mastery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.rest-fighter-mastery-grid .profile-field,
.rest-fighter-mastery-grid .select-enhanced {
  min-width: 0;
}

@media (max-width: 560px) {
  .rest-fighter-mastery-grid {
    grid-template-columns: 1fr;
  }
}

.pb-score-comparison .pb-score {
  width: auto;
}

.pb-score-base {
  color: var(--text-dim);
}

.pb-score-arrow {
  color: var(--class-readable);
  font-size: 0.72rem;
}

.pb-score-final,
.pb-background-total {
  color: var(--class-readable);
}

.pb-background-total {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
}

.pb-background-bonus {
  min-height: 14px;
  padding: 0.08rem 0.3rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 34%, var(--border));
  border-radius: 999px;
  color: color-mix(in srgb, var(--class-readable) 88%, var(--text));
  background: color-mix(in srgb, var(--class-primary) 8%, transparent);
  font-family: var(--font-heading);
  font-size: 0.54rem;
  letter-spacing: 0.04em;
  line-height: 1.25;
  white-space: nowrap;
}
.pb-remaining { text-align: center; font-family: var(--font-heading); font-size: 0.85rem; color: var(--gold); margin-bottom: 0.4rem; }

.modal-option-list { display: flex; flex-direction: column; gap: 0.2rem; max-height: 300px; overflow-y: auto; }
.modal-option { display: flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.4rem; border-radius: var(--radius); cursor: pointer; }
.modal-option:hover { background: var(--bg-card-hover); }
.modal-option input[type="checkbox"], .modal-option input[type="radio"] { accent-color: var(--class-primary); }
.modal-option.is-disabled {
  opacity: 0.58;
  cursor: not-allowed;
}
.modal-option.is-disabled:hover {
  background: transparent;
}

#level-choice-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.25rem;
}

/* A Paladin spell preview must not squeeze its scrollable choices to zero height. */
#level-choice-body:has(#paladin-spell-preview) > .weapon-mastery-choice-grid {
  flex-shrink: 0;
}

#modal-level-choice .modal-content > h2,
#modal-level-choice .modal-actions {
  flex: 0 0 auto;
}

#modal-level-choice .modal-actions {
  flex-wrap: wrap;
  margin-top: 0.8rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}
#modal-levelup-summary .modal-content {
  max-width: 760px;
}

#modal-levelup-summary .modal-content.feat-mode,
#modal-level-choice .modal-content.feat-mode {
  max-width: 780px;
  width: min(94vw, 780px);
  max-height: 92vh;
}

#modal-levelup-summary:has(.feat-mode, .rest-retune-mode) {
  align-items: safe center;
  padding-block: 4vh;
}

#modal-levelup-summary .modal-content.feat-mode,
#modal-levelup-summary .modal-content.rest-retune-mode {
  max-height: none;
  flex-shrink: 0;
}

#modal-levelup-summary .modal-content.feat-mode .modal-actions,
#modal-levelup-summary .modal-content.rest-retune-mode .modal-actions {
  flex-wrap: wrap;
}

#modal-level-choice .modal-content.species-mode {
  max-width: 700px;
  width: min(94vw, 700px);
  max-height: 92vh;
}

#levelup-summary-title {
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  margin-bottom: 0.9rem;
}

#levelup-summary-body { margin-bottom: 0.85rem; }
#levelup-choice-body { display: flex; flex-direction: column; gap: 0.6rem; }

.option-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.small {
  font-size: 0.74rem;
}

.select-native-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  margin: -1px !important;
  padding: 0 !important;
}

.select-enhanced {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  z-index: 140;
}

.select-enhanced.is-open {
  z-index: 7000;
}

.select-trigger {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-align: left;
  padding: 0.48rem 0.62rem;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--class-primary) 38%, var(--border));
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg-input) 88%, var(--class-primary) 6%),
    color-mix(in srgb, var(--bg-card) 92%, #0d1117)
  );
  color: var(--text);
  font-size: 0.82rem;
  font-family: var(--font-body);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-trigger:hover {
  border-color: var(--class-primary);
}

.select-trigger.is-placeholder {
  color: color-mix(in srgb, var(--text-dim) 88%, var(--text));
}

.select-trigger.is-number {
  text-align: center;
  font-family: var(--font-heading);
}

.select-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  z-index: 5000;
  max-height: 260px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.3rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 42%, var(--border-strong));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-surface) 94%, #0a0d12);
  box-shadow: 0 12px 24px rgba(0,0,0,0.36);
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

#modal-level-choice .modal-content.fighting-style-mode {
  width: min(94vw, 820px);
  max-width: 820px;
}

#modal-level-choice .modal-content.fighting-style-mode #level-choice-body {
  overflow-x: hidden;
}

/* Modal dropdowns use viewport positioning so scroll containers cannot clip them. */
.select-options.is-modal-floating {
  position: fixed !important;
  z-index: 12050;
  margin: 0;
}

#modal-level-choice .modal-content.feat-mode .select-options,
#modal-levelup-summary .modal-content.feat-mode .select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin-top: 0;
  max-height: 280px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.36);
}

#modal-level-choice .modal-content.species-mode .select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin-top: 0;
  max-height: 280px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.36);
}

#creation-standard-scores .select-enhanced .select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin-top: 0;
  max-height: 220px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.36);
}

#creation-start-level + .select-enhanced {
  max-width: 96px;
}

#creation-ability-method + .select-enhanced {
  max-width: 240px;
}

#creation-language-selects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 240px));
  gap: 0.45rem 0.6rem;
}

#creation-language-selects .profile-field {
  margin-bottom: 0;
}

#creation-language-selects .select-enhanced {
  max-width: 240px;
}

#creation-language-selects .select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin-top: 0;
  max-height: 210px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.36);
}

.select-option {
  width: 100%;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--class-primary) 18%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-card) 86%, transparent);
  color: var(--text);
  font-size: 0.8rem;
  padding: 0.34rem 0.46rem;
  cursor: pointer;
}

.select-option.is-number {
  text-align: center;
  justify-content: center;
  font-family: var(--font-heading);
}

.select-option:hover {
  border-color: var(--class-primary);
}

.select-option.is-selected {
  border-color: var(--class-primary);
  background: color-mix(in srgb, var(--class-primary) 15%, var(--bg-card));
}

.select-option.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.feat-picker-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  align-items: start;
}

.feat-picker-left,
.feat-picker-right {
  border: 1px solid color-mix(in srgb, var(--class-primary) 35%, var(--border));
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--class-primary) 10%, transparent), transparent 45%),
    color-mix(in srgb, var(--bg-card) 92%, #0f1117);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--class-primary) 14%, transparent);
}

.feat-combobox {
  position: relative;
}

.feat-combobox input {
  width: 100%;
  font-size: 0.86rem;
  font-weight: 600;
}

.feat-combobox-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin-top: 0;
  z-index: 7000;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid color-mix(in srgb, var(--class-primary) 42%, var(--border-strong));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-surface) 92%, #0a0d12);
  box-shadow: 0 12px 24px rgba(0,0,0,0.36);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.feat-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--class-primary) 18%, var(--border));
  border-radius: var(--radius);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg-card) 86%, transparent),
    color-mix(in srgb, var(--bg-card) 72%, #0f1117)
  );
  color: var(--text);
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.feat-option:hover {
  border-color: var(--class-primary);
}

.feat-option.is-selected {
  border-color: var(--class-primary);
  background: color-mix(in srgb, var(--class-primary) 18%, var(--bg-card));
}

.feat-option.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.feat-option-name {
  font-size: 0.86rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.01em;
}

.feat-option-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.feat-option-empty {
  color: var(--text-dim);
  font-size: 0.78rem;
  padding: 0.3rem 0.35rem;
}

.feat-detail-title {
  font-family: var(--font-heading);
  font-size: 1.02rem;
  color: var(--text-heading);
  margin-bottom: 0.35rem;
  text-transform: none;
  letter-spacing: 0.01em;
}

.feat-detail-prereq {
  margin-bottom: 0.35rem;
}

.feat-detail-body {
  margin: 0;
  line-height: 1.35;
  font-size: 0.8rem;
  color: var(--text);
  max-height: 280px;
  overflow-y: auto;
  font-family: var(--font-body);
  padding-right: 0.2rem;
}

.feat-detail-line {
  margin: 0 0 0.45rem;
}

.feat-detail-line:last-child {
  margin-bottom: 0;
}

.levelup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.levelup-rest-section {
  margin-top: 0.95rem;
  padding-top: 0.85rem;
  border-top: 1px solid color-mix(in srgb, var(--class-primary) 36%, transparent);
}

.levelup-card {
  border: 1px solid color-mix(in srgb, var(--class-primary) 48%, var(--border));
  border-radius: var(--radius);
  padding: 0.7rem 0.75rem;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--class-primary) 10%, var(--bg-card)),
    color-mix(in srgb, var(--bg-card) 88%, #0f1117)
  );
}

.levelup-card-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  color: var(--text-heading);
  margin-bottom: 0.32rem;
}

.levelup-card-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.levelup-arrow {
  color: var(--class-readable);
}

.levelup-feature-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.levelup-feature-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text);
  font-size: 0.86rem;
}

.levelup-card-note {
  color: var(--text-dim);
  font-size: 0.86rem;
}

.levelup-choice-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--class-readable);
}

.levelup-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
}

@media (max-width: 760px) {
  .levelup-grid {
    grid-template-columns: 1fr;
  }
  #modal-levelup-summary .modal-content.feat-mode,
  #modal-level-choice .modal-content.feat-mode {
    width: min(98vw, 98vw);
  }
  #creation-start-level + .select-enhanced,
  #creation-ability-method + .select-enhanced,
  #creation-language-selects .select-enhanced {
    max-width: 100%;
  }
}

.creation-step { display: none; }
.creation-step.active {
  display: block;
  animation: creationFadeIn 0.22s ease;
}

@keyframes creationFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.creation-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: start;
}

.creation-panel {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--class-primary) 9%, transparent);
}

.creation-panel::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: linear-gradient(180deg, var(--class-primary), color-mix(in srgb, var(--class-accent) 70%, var(--class-primary)));
}

.creation-panel .profile-field:last-child {
  margin-bottom: 0;
}

.creation-review-block {
  margin-bottom: 0.8rem;
  padding: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 35%, var(--border));
  border-radius: var(--radius-lg);
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--class-primary) 8%, var(--bg-surface)) 0%,
      var(--bg-surface) 100%
    );
}

.creation-review-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--class-readable);
  margin-bottom: 0.45rem;
  letter-spacing: 0.05em;
}

.creation-review-line {
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.55;
}

#creation-review-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

@media (max-width: 900px) {
  .creation-layout,
  .creation-class-layout,
  .creation-setup-strip,
  #modal-creation .g2 {
    grid-template-columns: 1fr;
  }

  .creation-step-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .creation-subclass-row {
    grid-template-columns: 1fr;
  }
}

.creation-equipment-section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 82%, var(--class-primary) 18%);
}

.creation-detail-section {
  margin-top: 0.95rem;
  padding-top: 0.75rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 82%, var(--class-primary) 18%);
}

.creation-details-card {
  max-height: min(68vh, 620px);
  overflow-y: auto;
  padding-right: 0.45rem;
}

.creation-details-card::-webkit-scrollbar {
  width: 5px;
}

.creation-details-card::-webkit-scrollbar-track {
  background: var(--bg-input);
}

.creation-details-card::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.creation-detail-section.first {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.creation-detail-heading {
  margin-bottom: 0.45rem;
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.creation-detail-subheading {
  margin-top: 0.75rem;
}

.creation-identity-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 1.25rem;
  align-items: start;
}

.creation-portrait-column {
  justify-self: center;
  width: min(100%, 260px);
}

.creation-portrait-help {
  font-size: 0.74rem;
  margin-top: 0.25rem;
}

#creation-character-name {
  width: 100%;
}

#creation-appearance {
  min-height: 184px;
  resize: vertical;
}

#btn-creation-remove-portrait {
  margin-top: 0.35rem;
}

@media (max-width: 900px) {
  .creation-identity-grid {
    grid-template-columns: 1fr;
  }

  .creation-portrait-column {
    justify-self: stretch;
    width: 100%;
  }
}

.creation-alignment-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.creation-alignment-tile {
  min-height: 72px;
  padding: 0.65rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text);
  font-family: var(--font-heading);
  font-size: clamp(0.72rem, 1.5vw, 0.9rem);
  line-height: 1.2;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.creation-alignment-tile:hover {
  border-color: color-mix(in srgb, var(--class-primary) 62%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 8%, var(--bg-surface));
  transform: translateY(-1px);
}

.creation-alignment-tile.active {
  border-color: var(--class-primary);
  background: color-mix(in srgb, var(--class-primary) 16%, var(--bg-card));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--class-accent) 42%, transparent);
  color: var(--text-heading);
}

@media (max-width: 860px) {
  #creation-review-area {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .creation-step-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .creation-hero {
    align-items: flex-start;
    flex-direction: column;
  }
}

#creation-step-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--class-primary) 45%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 10%, var(--bg-card));
  font-family: var(--font-heading);
  letter-spacing: 0.04em;
}

#creation-source-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.42rem;
  max-height: none;
  overflow: visible;
}

#creation-skill-list,
#creation-bg-skill-list,
#creation-bg-even-picks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.4rem;
  max-height: 300px;
  padding-right: 0.15rem;
}

@media (max-width: 700px) {
  #creation-source-list {
    grid-template-columns: 1fr;
  }

  .creation-class-stat-grid {
    grid-template-columns: 1fr;
  }

  .creation-class-info-row {
    grid-template-columns: 1fr;
    gap: 0.16rem;
  }
}

#modal-creation .modal-actions {
  position: sticky;
  bottom: 0;
  background: color-mix(in srgb, var(--bg-card) 88%, transparent);
  backdrop-filter: blur(2px);
  border-top: 1px solid color-mix(in srgb, var(--class-primary) 24%, var(--border));
  padding-top: 0.7rem;
}

#modal-creation .modal-actions .btn.gold {
  background: linear-gradient(135deg, color-mix(in srgb, var(--class-primary) 24%, transparent), color-mix(in srgb, var(--class-accent) 18%, transparent));
  border-color: color-mix(in srgb, var(--class-primary) 55%, var(--border));
}

.levelup-choice-progress {
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  flex-shrink: 0;
}

.levelup-progress-heading {
  color: var(--text);
  font-weight: 600;
  margin-bottom: 0.55rem;
}

.levelup-progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.levelup-progress-step {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-dim);
  font-size: 0.75rem;
}

.levelup-progress-step small {
  display: block;
  font-size: 0.65rem;
}

.levelup-progress-dot {
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
}

.levelup-progress-step.is-current {
  color: var(--class-readable);
}

.levelup-progress-step.is-current .levelup-progress-dot {
  border-color: var(--class-readable);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--class-primary) 18%, transparent);
}

.levelup-progress-step.is-complete .levelup-progress-dot {
  color: var(--bg-card);
  background: var(--class-readable);
  border-color: var(--class-readable);
}

.levelup-progress-step.is-deferred .levelup-progress-dot {
  border-style: dashed;
}

/* Slim, class-aware scrollbars. Their 6px footprint is smaller than the
   platform default and does not reserve any additional layout space. */
* {
  scrollbar-width: thin;
  scrollbar-color:
    color-mix(in srgb, var(--class-primary) 58%, var(--border-strong))
    color-mix(in srgb, var(--bg-input) 72%, transparent);
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--bg-input) 72%, transparent);
}

*::-webkit-scrollbar-thumb {
  border: 1px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--class-primary) 58%, var(--border-strong));
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--class-readable) 68%, var(--class-primary));
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

/* Informational rest rows stack their prose instead of squeezing a numeric grid. */
.rest-change-row.is-note { grid-template-columns: minmax(0, 1fr); gap: .25rem; align-items: start; }
.rest-change-row.is-note .rest-change-values { display: block; white-space: normal; font-size: .8rem; line-height: 1.5; font-weight: 400; }

/* Shared gameplay notices retain emphasis without a tinted box or side stripe. */
#modal-action-confirm .gameplay-notice {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  margin-top: .65rem;
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
}
.gameplay-notice > div { min-width: 0; }
.gameplay-notice-icon {
  flex: 0 0 1.1rem;
  color: var(--class-readable);
  font-size: 1.1rem;
  line-height: 1.3;
  text-align: center;
}
.gameplay-notice-title {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: .7rem;
  letter-spacing: .035em;
  text-transform: uppercase;
}
#modal-action-confirm .gameplay-notice .cast-effect-detail { margin: .2rem 0 0; overflow-wrap: anywhere; }
.gameplay-notice.is-warning .gameplay-notice-icon,
.gameplay-notice.is-warning .gameplay-notice-title { color: #f0b35a; }

/* Give long target choices room without increasing other confirmation widths. */
#modal-action-confirm .modal-content:has(#fighter-bulwark-self) {
  max-width: 760px;
}

.gameplay-action-body .cast-effect-fields:has(#fighter-bulwark-self) {
  grid-template-columns: minmax(0, 1fr);
}

#fighter-bulwark-feedback .gameplay-notice { margin-top: 0; }

@media (min-width: 801px) {
  .gameplay-action-body .cast-effect-section:has(#fighter-bulwark-self) {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: .4rem .65rem;
    align-items: start;
  }

  .cast-effect-section:has(#fighter-bulwark-self) > .cast-effect-heading {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0;
  }

  .gameplay-action-body .cast-effect-fields:has(#fighter-bulwark-self) {
    display: contents;
  }

  .profile-field:has(#fighter-bulwark-self) {
    grid-column: 1;
    grid-row: 2;
  }

  #fighter-bulwark-feedback {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

/* File import: shared confirmation, one row per conflicting character. */
.import-conflict { margin-top: .9rem; padding-top: .7rem; border-top: 1px solid var(--border); }
.import-conflict .import-conflict-name { font-size: .95rem; letter-spacing: 0; text-transform: none; color: var(--text); overflow-wrap: anywhere; }
.import-conflict small { display: block; margin: .2rem 0 .4rem; line-height: 1.5; }
/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  max-width: min(32rem, calc(100vw - 2rem));
  box-sizing: border-box;
  overflow-wrap: anywhere;
  top: 1rem;
  right: 1rem;
  background: var(--bg-card);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--class-primary);
  font-family: var(--font-heading);
  font-size: 0.75rem;
  z-index: 2000;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.warning {
  border-color: #ff9f43;
  background: color-mix(in srgb, #ff9f43 18%, var(--bg-card));
  color: #ffe2bf;
  box-shadow: 0 0 0 1px color-mix(in srgb, #ff9f43 35%, transparent);
}

/* ============================================================
   Utility
   ============================================================ */
.storage-alert {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(44rem, calc(100% - 2rem));
  max-height: 45vh;
  overflow: auto;
  z-index: 3000;
  padding: 0.85rem 1rem;
  border: 1px solid #cda568;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 4px 18px #0008;
}
.storage-alert-list { margin: 0 0 0.65rem; padding-left: 1.2rem; overflow-wrap: anywhere; }
.storage-alert-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.storage-alert-actions .btn { white-space: normal; }

.hidden { display: none !important; }
.text-dim { color: var(--text-dim); }
.mb-1 { margin-bottom: 0.5rem; }

.center-top-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.level-circle-input {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  text-align: center;
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  border: 3px solid var(--class-primary);
  background: var(--bg-card);
  color: var(--text-heading);
  padding: 0;
  transition: border-color 0.3s;
}
.level-circle-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--class-primary) 30%, transparent);
}
.level-circle-input::-webkit-outer-spin-button,
.level-circle-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.level-circle-input[type=number] { -moz-appearance: textfield; }

/* ============================================================
   HP Panel - Split layout with Conditions
   ============================================================ */
.hp-panel-split {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.hp-panel-top {
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.hp-panel-bottom {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.hp-subsection-title {
  font-family: var(--font-heading);
  font-size: 0.58rem;
  text-transform: uppercase;
  color: var(--class-readable);
  letter-spacing: 0.06em;
  font-weight: 700;
  text-align: center;
}

#conditions-list {
  container-type: inline-size;
  container-name: conditions-list;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.condition-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px;
  gap: 0.18rem;
  align-items: center;
}

.condition-type {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.18rem;
  min-width: 0;
}
.condition-type label { grid-column: 1 / -1; }
.condition-type label,
.condition-origin label { font-size: 0.65rem; color: var(--text-dim); }
.condition-type > .select-enhanced { grid-column: 1; }
.condition-type .select-options {
  width: max(100%, 11rem);
  max-width: calc(100vw - 2rem);
  right: auto;
}
.condition-entry .select-option,
.condition-entry .select-option span {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.condition-entry select {
  font-size: 0.75rem;
  padding: 0.15rem 0.25rem;
  min-width: 0;
  width: 100%;
}

.condition-entry .select-enhanced {
  min-width: 0;
}

.condition-entry .select-trigger {
  white-space: normal;
  overflow-wrap: anywhere;
  min-height: 28px;
  padding: 0.15rem 0.25rem;
  font-size: 0.75rem;
}

.condition-save-badge {
  justify-self: center;
  white-space: nowrap;
  min-width: 0;
  max-width: none;
  text-align: center;
  padding: 0.1rem 0.18rem;
  font-size: 0.56rem;
  letter-spacing: 0;
}

.condition-save-placeholder {
  display: none;
}

.condition-entry .btn-remove {
  grid-column: -2 / -1;
  grid-row: 1;
  align-self: end;
  width: 22px;
  min-width: 22px;
  padding: 0.1rem;
  justify-self: end;
}

.condition-suppression-note {
  grid-column: 1 / -1;
  color: var(--class-readable);
  font-size: 0.65rem;
  line-height: 1.35;
}

.condition-origin {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 0.18rem;
  min-width: 0;
}
.condition-origin .select-trigger,
.condition-origin .select-option,
.condition-origin .select-option span {
  white-space: nowrap;
  overflow-wrap: normal;
}
.condition-origin .select-options {
  width: max(100%, 8.5rem);
  max-width: calc(100vw - 2rem);
  right: auto;
}
.condition-origin-notice {
  grid-column: 1 / -1;
  font-size: 0.65rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  color: var(--text-dim);
}

@container conditions-list (min-width: 280px) {
  .condition-entry:has(.condition-origin) {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 22px;
    align-items: end;
  }
  .condition-origin { grid-column: -3 / -2; grid-row: 1; }
}


.condition-empty {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-style: italic;
}

#btn-add-condition {
  margin-top: 0.1rem;
}

/* Number input spinner arrows kikapcsolása */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

/* Minden fontos számos mező legyen középre igazítva és egységesebb */
.ac-input,
.hp-current-input,
.hp-small-input,
.ab-score-input,
.center-stat-input,
.level-circle-input,
.xp-input,
.currency-item input {
  text-align: center;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-heading);
  padding-left: 0;
  padding-right: 0;
}

.hp-threshold-label {
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.45);
}

/* Proficiency Bonus - enhanced */
.prof-bonus-block {
  position: relative;
  border-color: color-mix(in srgb, var(--class-primary) 45%, var(--border));
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--class-primary) 10%, var(--bg-card)) 0%,
      var(--bg-card) 100%
    );
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--class-primary) 12%, transparent),
    0 0 10px color-mix(in srgb, var(--class-primary) 12%, transparent);
}

.prof-value {
  min-width: 38px;
  text-shadow: 0 0 6px color-mix(in srgb, var(--class-primary) 18%, transparent);
}

/* Heroic Inspiration - enhanced */
.insp-box {
  position: relative;
  border-color: color-mix(in srgb, var(--class-accent) 45%, var(--border));
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--class-accent) 8%, var(--bg-card)) 0%,
      var(--bg-card) 100%
    );
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--class-primary) 10%, transparent),
    0 0 10px rgba(197, 168, 0, 0.12);
}

.insp-box:hover {
  border-color: var(--class-accent);
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--class-accent) 14%, var(--bg-card)) 0%,
      var(--bg-card-hover) 100%
    );
}

.insp-gem {
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--gold) 18%, transparent),
    0 0 8px rgba(197, 168, 0, 0.10);
}

.insp-label {
  color: color-mix(in srgb, var(--class-accent) 70%, var(--text));
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Auto-derived, protected fields */
input[readonly].ab-score-input,
input[readonly].hp-small-input,
input[readonly].center-stat-input,
input[readonly].level-circle-input {
  background: color-mix(in srgb, var(--bg-elev) 86%, var(--class-primary) 14%);
  border-color: color-mix(in srgb, var(--border) 72%, var(--class-primary) 28%);
  color: color-mix(in srgb, var(--text-heading) 88%, var(--class-primary) 12%);
  cursor: default;
}

input[readonly].level-circle-input {
  background: var(--bg-card);
  border-color: var(--class-primary);
  color: var(--text-heading);
}


/* PHB Spell Library */
.spell-library-open-btn {
  margin-top: 0.45rem;
}

.spell-library-modal-content {
  width: min(1120px, 94vw);
  max-width: min(1120px, 94vw);
  height: min(760px, 88vh);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.spell-add-modal-content {
  width: min(1040px, 94vw);
  max-width: min(1040px, 94vw);
  height: min(760px, 88vh);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.spell-review-modal-content {
  width: min(1120px, 96vw);
  max-width: min(1120px, 96vw);
  height: min(800px, 90vh);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.spell-library-modal-header {
  margin-bottom: 0.65rem;
}

.spell-library-modal-head {
  align-items: center;
}

.spell-library-head {
  display: flex;
  justify-content: space-between;
  gap: 0.65rem;
  align-items: flex-start;
  margin-bottom: 0.55rem;
}

.spell-library-title {
  font-family: var(--font-heading);
  color: var(--text-heading);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.spell-library-subtitle {
  margin-top: 0.12rem;
  font-size: 0.68rem;
  color: var(--text-dim);
  line-height: 1.35;
}

.spell-library-count {
  flex: 0 0 auto;
  padding: 0.2rem 0.42rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--class-primary) 38%, var(--border));
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.thaumaturge-cantrip-picker {
  display: grid;
  grid-template-columns: minmax(210px, 0.85fr) minmax(260px, 1.15fr);
  gap: 0.65rem;
  min-height: 320px;
  max-height: min(460px, 52vh);
  overflow: hidden;
}

.thaumaturge-cantrip-picker .spell-library-list-wrap,
.thaumaturge-cantrip-picker .spell-library-preview {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.thaumaturge-cantrip-picker .spell-library-preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem;
  background: color-mix(in srgb, var(--bg-panel) 88%, transparent);
}

.spell-library-filters {
  display: grid;
  grid-template-columns: minmax(210px, 1.6fr) repeat(3, minmax(120px, 0.9fr));
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.55rem;
}

.spell-add-source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.spell-add-source-grid .profile-field {
  min-width: 0;
  width: 100%;
  margin-bottom: 0;
}

.spell-add-source-grid .profile-field > label {
  color: var(--class-readable);
  margin-bottom: 0.16rem;
}

.spell-add-source-note {
  grid-column: 1 / -1;
}

.spell-add-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(130px, 0.4fr) auto;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.55rem;
}

.spell-review-context {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 42%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--class-primary) 8%, var(--bg-card));
}

.spell-review-context-text {
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.45;
}

.cleric-spell-choice-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem;
}

.spell-choice-review,
.cleric-starting-spell-review {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding-top: 0.1rem;
}

.spell-choice-review .spell-review-current-summary,
.cleric-starting-spell-review .spell-review-current-summary {
  margin: 0 0 0.5rem;
}

.spell-choice-tabs,
.cleric-starting-spell-tabs {
  flex: 0 0 auto;
}

.spell-choice-grid,
.cleric-starting-spell-grid {
  flex: 1 1 auto;
  height: min(450px, 48vh);
  min-height: 300px;
  overflow: hidden;
}

.origin-feat-choice .spell-choice-grid {
  flex: 0 0 auto;
}

.spell-choice-grid .spell-library-list-wrap,
.cleric-starting-spell-grid .spell-library-list-wrap,
.spell-choice-grid .spell-library-list,
.cleric-starting-spell-grid .spell-library-list,
.spell-choice-grid .spell-library-detail-pane,
.cleric-starting-spell-grid .spell-library-detail-pane {
  min-height: 0;
  height: 100%;
}

.spell-choice-status,
.cleric-starting-spell-status {
  flex: 0 0 auto;
  align-self: flex-start;
  width: auto;
  max-width: 100%;
  margin-top: 0.5rem;
  margin-right: 0;
  padding: 0.34rem 0.52rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
}

.cleric-spell-choice-section {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.cleric-spell-choice-section + .cleric-spell-choice-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.cleric-spell-choice-library {
  display: grid;
  grid-template-columns: minmax(230px, 0.9fr) minmax(300px, 1.1fr);
  gap: 0.65rem;
  min-height: 0;
  max-height: none;
  overflow: visible;
}

.cleric-spell-choice-library .spell-library-list-wrap,
.cleric-spell-choice-library .spell-library-preview {
  min-width: 0;
  min-height: 0;
}

.cleric-spell-choice-library .spell-library-list-wrap {
  overflow: visible;
}

.cleric-spell-choice-library .spell-library-list {
  overflow: visible;
}

.cleric-spell-choice-library .spell-library-preview {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem;
  background: color-mix(in srgb, var(--bg-panel) 88%, transparent);
}

.cleric-spell-choice-list {
  max-height: none;
}

.cleric-spell-choice-preview {
  max-height: none;
}

.spell-library-card.is-disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.spell-library-card.is-disabled:hover {
  transform: none;
  border-color: var(--border);
}

.spell-library-meta.locked-note {
  display: block;
  margin-top: 0.16rem;
  color: var(--text-dim);
  font-size: 0.62rem;
}

.spell-review-scope-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  padding: 0.18rem 0.48rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 52%, var(--border));
  border-radius: 999px;
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.spell-review-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(520px, 1.45fr);
  gap: 0.8rem;
  min-height: 0;
  flex: 1;
}

.spell-review-grid.class-review-mode {
  grid-template-columns: minmax(270px, 0.72fr) minmax(0, 1.7fr);
  overflow: hidden;
}

.spell-review-grid.class-review-mode .spell-review-current {
  display: flex;
  flex-direction: column;
  padding-right: 0.7rem;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.spell-review-grid.class-review-mode .spell-review-replacement {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.spell-review-current,
.spell-review-replacement {
  min-width: 0;
  min-height: 0;
}

.spell-review-section-title {
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.spell-review-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.spell-review-section-head .spell-review-section-title {
  margin-bottom: 0;
}

.spell-review-toggle-selected {
  padding: 0.26rem 0.48rem;
  font-size: 0.64rem;
}

.spell-review-current-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.38rem;
}

.spell-review-current-summary span {
  padding: 0.24rem 0.46rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-panel);
  color: var(--text-dim);
  font-size: 0.69rem;
}

.spell-review-current-summary strong {
  color: var(--class-readable);
}

.spell-review-grid.class-review-mode #spell-review-current-card {
  min-height: 0;
  margin-top: 0.48rem;
  padding-right: 0.18rem;
  overflow-y: auto;
}

.spell-review-grid.class-review-mode .spell-review-current-card {
  margin-top: 0.48rem;
  max-height: none;
  overflow: visible;
}

.spell-review-tabs,
.spell-review-level-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.spell-review-tabs {
  margin-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
}

.spell-review-tab {
  margin-bottom: -1px;
  padding: 0.48rem 0.68rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.spell-review-tab.active {
  border-bottom-color: var(--class-primary);
  color: var(--class-readable);
}

.spell-review-tab span {
  margin-left: 0.25rem;
  font-size: 0.6rem;
}

.spell-review-level-filters {
  margin-bottom: 0.48rem;
}

.spell-review-level-filter {
  padding: 0.3rem 0.52rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 0.65rem;
  cursor: pointer;
}

.spell-review-level-filter.active {
  border-color: var(--class-primary);
  background: color-mix(in srgb, var(--class-primary) 13%, var(--bg-input));
  color: var(--class-readable);
}

.spell-review-gained {
  color: var(--text-heading);
  font-size: 0.78rem;
}

.spell-review-gained strong {
  color: var(--class-readable);
}

.spell-review-modal-content > .modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  background: var(--bg-card);
}

.spell-review-status {
  flex: 1 1 240px;
  margin-right: auto;
  color: var(--text-dim);
  font-size: 0.72rem;
}

.spell-review-status.spell-choice-status,
.cleric-starting-spell-status {
  flex: 0 0 auto;
}

.spell-review-current-card {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 40%, var(--border));
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--class-primary) 8%, var(--bg-card)), var(--bg-card));
}

.spell-review-current-name {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 1.03rem;
  letter-spacing: 0.04em;
}

.spell-review-current-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.spell-review-selection-heading {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.spell-review-selected-group:not(:first-child) {
  margin-top: 0.5rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
}

.spell-review-selection-heading strong {
  color: var(--class-readable);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.spell-review-selected-list {
  display: grid;
  gap: 0.32rem;
  margin-top: 0.38rem;
}

.spell-review-selected-spell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
  align-items: center;
  padding: 0.32rem;
  border: 1px solid color-mix(in srgb, var(--class-primary) 36%, var(--border));
  border-radius: 7px;
  background: color-mix(in srgb, var(--class-primary) 8%, var(--bg-card));
}

.spell-review-selected-main {
  display: grid;
  flex: 1 1 12rem;
  gap: 0.1rem;
  min-width: 0;
  padding: 0.12rem 0.2rem;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.spell-review-selected-name {
  min-width: 0;
  color: var(--text-heading);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
}

.spell-review-selected-meta {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--text-dim);
  font-size: 0.61rem;
}

.spell-review-selected-actions {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  margin-left: auto;
  justify-content: flex-end;
  gap: 0.22rem;
  align-items: center;
}

.spell-review-selected-details,
.spell-review-selected-remove {
  padding: 0.22rem 0.34rem;
  font-size: 0.58rem;
}

.spell-review-selected-remove {
  color: var(--danger, #c85d5d);
}

.spell-review-selected-remove[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.spell-review-selected-locked {
  min-width: 3.2rem;
  color: var(--text-dim);
  font-size: 0.58rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spell-review-selection-empty {
  color: var(--text-dim);
  font-size: 0.74rem;
  line-height: 1.4;
}

.spell-review-level-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.spell-review-level-breakdown-label {
  width: 100%;
  color: var(--text-dim);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.spell-review-level-count {
  padding: 0.18rem 0.38rem;
  border-radius: 999px;
  background: var(--bg-panel);
  color: var(--text);
  font-size: 0.66rem;
}

.spell-review-replacement-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.45rem;
}

.spell-review-replacement-head input {
  width: min(360px, 44%);
  min-width: 220px;
  font-size: 0.76rem;
  padding: 0.42rem 0.5rem;
}

.spell-review-preview-title {
  margin-bottom: 0.55rem;
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.spell-review-replacement-grid {
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(320px, 1.15fr);
  gap: 0.7rem;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.spell-library-filters input,
.spell-library-filters select,
.spell-add-source-grid input,
.spell-add-source-grid select,
.spell-add-filters input,
.spell-add-filters select {
  min-width: 0;
  width: 100%;
  font-size: 0.72rem;
  padding: 0.34rem 0.45rem;
}

.spell-library-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-heading);
  font-size: 0.56rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  white-space: nowrap;
}

.spell-library-toggle input { accent-color: var(--class-primary); }

.spell-library-list {
  display: grid;
  gap: 0.35rem;
  align-content: start;
  grid-auto-rows: max-content;
  min-width: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.18rem;
}

.spell-library-card {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  min-width: 0;
  text-align: left;
  display: grid;
  align-content: start;
  gap: 0.25rem;
  padding: 0.48rem 0.55rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-input) 82%, transparent);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), background var(--transition);
}

.spell-library-card:hover {
  border-color: color-mix(in srgb, var(--class-primary) 60%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 10%, var(--bg-input));
  transform: translateY(-1px);
}

.spell-library-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.45rem;
  align-items: center;
  min-width: 0;
}

.spell-library-card-top > span:first-child {
  min-width: 0;
}

.spell-library-name {
  display: block;
  min-width: 0;
  font-family: var(--font-heading);
  color: var(--text-heading);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  overflow-wrap: anywhere;
}

.spell-library-meta,
.spell-library-card-top {
  font-size: 0.64rem;
  color: var(--text-dim);
}

.spell-library-cast-time {
  flex: 0 0 auto;
  max-width: 44%;
  text-align: right;
  font-family: var(--font-heading);
  font-size: 0.58rem;
  color: var(--class-readable);
  text-transform: uppercase;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.spell-detail-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0.08rem 0.34rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--class-primary) 34%, var(--border));
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spell-detail-badge.concentration { color: #f0b35a; border-color: color-mix(in srgb, #f0b35a 42%, var(--border)); }
.spell-detail-badge.ritual { color: #8fc9ff; border-color: color-mix(in srgb, #8fc9ff 42%, var(--border)); }

.spell-library-modal-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.88fr) minmax(0, 1.35fr);
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.spell-add-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.25fr);
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.spell-add-list {
  min-height: 0;
}

.spell-library-detail-pane {
  max-height: none;
  overflow-y: auto;
  padding: 0.7rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-input) 70%, transparent);
}

.spell-add-preview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.spell-library-card.is-selected {
  border-color: color-mix(in srgb, var(--class-primary) 72%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 15%, var(--bg-input));
}

.spell-review-list .spell-library-card.is-disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.spell-review-list .spell-library-card.is-disabled:hover {
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg-input) 82%, transparent);
}

.spell-library-empty {
  padding: 0.65rem;
  color: var(--text-dim);
  font-size: 0.76rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.spell-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.55rem;
  margin-bottom: 0.7rem;
}

.spell-detail-subtitle {
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.spell-detail-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.42rem;
  margin-bottom: 0.6rem;
}

.spell-detail-summary-grid div {
  padding: 0.45rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-input) 80%, transparent);
}

.spell-detail-summary-grid span {
  display: block;
  margin-bottom: 0.16rem;
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.spell-detail-summary-grid strong {
  color: var(--text-heading);
  font-size: 0.74rem;
}

.spell-detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.7rem;
}

.spell-detail-section {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.spell-detail-section-title {
  margin-bottom: 0.35rem;
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.spell-detail-rules {
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.55;
}

.spell-detail-rules p { margin: 0 0 0.62rem; }
.spell-detail-rules p:last-child { margin-bottom: 0; }
.spell-detail-rules strong { color: var(--text-heading); }
.spell-detail-muted { color: var(--text-dim); }

@media (max-width: 760px) {
  .spell-library-filters,
  .spell-add-source-grid,
  .spell-add-filters,
  .spell-add-grid,
  .cleric-spell-choice-grid,
  .cleric-spell-choice-library,
  .spell-review-grid,
  .spell-review-replacement-grid,
  .spell-detail-summary-grid,
  .spell-library-modal-grid { grid-template-columns: 1fr; }
  .spell-library-head,
  .spell-review-replacement-head,
  .spell-detail-header { flex-direction: column; }
  .spell-review-replacement-head input { width: 100%; }
  .spell-library-list,
  .spell-library-detail-pane { max-height: 42vh; }
  .spell-review-modal-content { height: min(800px, 94vh); max-height: 94vh; }
  .spell-review-grid.class-review-mode {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(180px, 34vh) auto;
    overflow-y: auto;
  }
  .spell-review-grid.class-review-mode .spell-review-current {
    padding-right: 0;
    padding-bottom: 0.55rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .spell-review-grid.class-review-mode .spell-review-replacement { display: block; overflow: visible; }
  .spell-review-grid.class-review-mode .spell-review-replacement-grid { overflow: visible; }
  .spell-review-status { flex-basis: 100%; }
  .spell-review-modal-content > .modal-actions { flex-wrap: wrap; }
  .spell-choice-grid,
.cleric-starting-spell-grid {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .spell-choice-grid .spell-library-list,
.cleric-starting-spell-grid .spell-library-list,
  .spell-choice-grid .spell-library-detail-pane,
.cleric-starting-spell-grid .spell-library-detail-pane {
    height: auto;
    max-height: 34vh;
  }
}

/* Premium theme polish: retain each class identity while improving depth and
   small-text contrast on the shared dark-fantasy surface. */
body:not(.home-active) {
  background:
    radial-gradient(circle at 14% -10%, color-mix(in srgb, var(--class-primary) 12%, transparent), transparent 34rem),
    radial-gradient(circle at 92% 8%, color-mix(in srgb, var(--class-accent) 8%, transparent), transparent 30rem),
    linear-gradient(155deg, color-mix(in srgb, var(--class-bg) 92%, #000 8%), var(--class-bg));
}

.top-bar {
  background:
    linear-gradient(115deg,
      color-mix(in srgb, var(--bg-surface) 94%, var(--class-primary) 6%),
      color-mix(in srgb, var(--bg-surface) 96%, #000 4%));
  border-bottom-color: color-mix(in srgb, var(--class-primary) 88%, var(--class-accent));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 5%, transparent),
    0 10px 28px rgba(0, 0, 0, 0.24);
}

.card,
.prof-bonus-block,
.center-level-ac,
.center-stat {
  border-color: color-mix(in srgb, var(--border) 82%, var(--class-primary) 18%);
  background:
    linear-gradient(145deg,
      color-mix(in srgb, var(--bg-card) 94%, #fff 6%),
      color-mix(in srgb, var(--bg-card) 97%, #000 3%));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 5%, transparent),
    0 7px 18px rgba(0, 0, 0, 0.13);
}

input,
select,
textarea {
  border-color: color-mix(in srgb, var(--border) 88%, var(--text-dim) 12%);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--bg-input) 96%, #fff 4%),
    var(--bg-input));
}

.sec {
  color: color-mix(in srgb, var(--class-primary) 92%, #fff 8%);
  border-bottom-color: color-mix(in srgb, var(--border) 82%, var(--class-primary) 18%);
  text-shadow: 0 1px 10px color-mix(in srgb, var(--class-primary) 12%, transparent);
}

.sec::after {
  width: 42px;
  background: linear-gradient(90deg, var(--class-primary), var(--class-accent));
  box-shadow: 0 0 9px color-mix(in srgb, var(--class-primary) 24%, transparent);
}

button.gold,
.btn.gold {
  border-color: color-mix(in srgb, var(--class-primary) 82%, #fff 18%);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--class-primary) 92%, #fff 8%),
    color-mix(in srgb, var(--class-primary) 72%, var(--class-accent) 28%));
  color: var(--class-text);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 34%, transparent),
    0 3px 10px color-mix(in srgb, var(--class-primary) 16%, transparent);
}

.center-stat-label-stacked {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  line-height: 1.05;
  text-align: center;
}

#speed-value,
#speed-value:focus {
  width: 4.5rem;
  max-width: 100%;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding-bottom: 0;
}

/* Release-quality typography baseline. Dense metadata stays compact, but no
   primary label or action should rely on near-microscopic type. */
.id-field label {
  font-size: 0.74rem;
}

.hp-current-wrap label,
.hp-max-wrap label,
.hp-temp-wrap label,
.hp-small-wrap label,
.hp-threshold-label {
  font-size: 0.72rem;
}

.hp-subsection-title,
.ds-group-label,
.ds-res-label,
.res-chip,
.res-manage-btn,
.species-resource-title,
.species-resource-reset,
.attack-section-title,
.attack-row-stat-label,
.attack-options-label,
.spell-stat-label,
.spell-slots-note,
.feature-meta-badge,
.feature-usage-chip,
.prof-text-block label,
.currency-item label {
  font-size: 0.72rem;
}

.xp-row label,
.class-resource-note {
  font-size: 0.7rem;
}

.class-resource-label {
  font-size: 0.72rem;
}

.spell-slots-recharge,
.spell-slots-manage,
.spell-chip,
.spell-tag,
.spell-entry-unlinked,
.spell-entry-action,
.item-list-head span,
.item-action-btn {
  font-size: 0.7rem;
}


.spell-review-selected-spell.is-selected { border-color: var(--class-accent); background: var(--bg-hover); }
.spell-choice-review > .spell-review-current-card { max-height: 180px; overflow-y: auto; margin-bottom: 0.5rem; }

/* Explicit replacement reviews retain readable current rows above the picker.
   The parent modal scrolls instead of shrinking these rows into the library. */
.spell-choice-with-current,
.spell-choice-with-current > .spell-review-current-card,
.spell-choice-with-current > .spell-choice-grid {
  flex: 0 0 auto;
}

.spell-choice-with-current .spell-review-selected-meta {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .spell-choice-with-current > .spell-choice-grid {
    display: block;
  }

  .spell-choice-with-current .spell-library-list-wrap {
    height: auto;
  }

  .spell-choice-with-current .spell-library-detail-pane {
    margin-top: 0.7rem;
  }
}

/* Shared review shells must retain a usable library on narrow screens, even
   when the current list and trigger context take several lines. */
@media (max-width: 760px) {
  .spell-review-grid,
  .spell-review-grid.class-review-mode {
    display: block;
    overflow-y: auto;
  }

  .spell-review-grid .spell-review-current {
    display: flex;
    flex-direction: column;
    max-height: 34vh;
    overflow: hidden;
  }

  .spell-review-grid #spell-review-current-card {
    min-height: 0;
    overflow-y: auto;
  }

  .spell-review-grid .spell-review-replacement,
  .spell-review-grid .spell-review-replacement-grid {
    display: block;
    overflow: visible;
  }

  .spell-review-grid #spell-review-list {
    height: 32vh;
    min-height: 180px;
    max-height: 32vh;
    overflow-y: auto;
  }

  .spell-review-grid #spell-review-preview {
    max-height: 42vh;
    margin-top: 0.7rem;
    overflow-y: auto;
  }
}

.spell-review-selected-remove.is-replacement {
  color: var(--text);
  border-color: var(--border);
}

/* Keep class-colored spell cards on a neutral group surface. Typography,
   badges, filters and scrollbars retain their accepted colors. */
:is(.spell-review-modal-content, .spell-choice-review, .cleric-starting-spell-review)
.spell-review-context {
  border-color: color-mix(in srgb, var(--class-primary) 32%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 5%, var(--bg-card));
}

:is(.spell-review-modal-content, .spell-choice-review, .cleric-starting-spell-review)
.spell-review-current-card {
  border-color: var(--border);
  background: var(--bg-surface);
}

:is(.spell-review-modal-content, .spell-choice-review, .cleric-starting-spell-review)
.spell-review-selected-spell:not(.is-selected) {
  border-color: color-mix(in srgb, var(--class-primary) 27%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 4%, var(--bg-card));
}

:is(.spell-review-modal-content, .spell-choice-review, .cleric-starting-spell-review)
.spell-library-card.is-selected {
  border-color: color-mix(in srgb, var(--class-primary) 54%, var(--border));
  background: color-mix(in srgb, var(--class-primary) 9%, var(--bg-input));
}
/* ============================================================
   Premium entry experience — Home + Character Creation
   ============================================================ */
.home-view {
  --home-accent: #7890a3;
  --home-accent-bright: #afc3d2;
  --home-warm: #b28a57;
  --home-warm-bright: #dbc08d;
  --home-text: #e8edf2;
  --home-muted: #aab5bf;
  padding: clamp(0.85rem, 2.4vw, 2.25rem);
  background:
    radial-gradient(circle at 12% 0%, rgba(120, 144, 163, 0.1), transparent 32rem),
    radial-gradient(circle at 92% 4%, rgba(178, 138, 87, 0.07), transparent 28rem),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.009) 0 1px, transparent 1px 4px),
    #090d11;
}

.home-hero,
.home-roster {
  width: min(100%, 1520px);
  margin-inline: auto;
}

.home-hero {
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  min-height: 300px;
  padding: clamp(1.4rem, 3.6vw, 3.25rem);
  border: 1px solid #2b3640;
  border-radius: 12px;
  background:
    linear-gradient(105deg, rgba(120, 144, 163, 0.055), transparent 42%),
    linear-gradient(180deg, #12181e, #0e1419);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.home-hero::before {
  inset: 10px;
  border-color: rgba(175, 195, 210, 0.1);
  border-radius: 7px;
}

.home-hero::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, transparent, var(--home-warm), transparent);
  opacity: 0.78;
}

.home-hero-glow {
  width: 440px;
  height: 440px;
  right: -180px;
  top: -220px;
  background: radial-gradient(circle, rgba(120, 144, 163, 0.16), transparent 68%);
}

.home-hero-content {
  max-width: 760px;
}

.home-kicker {
  margin-bottom: 0.7rem;
  color: var(--home-accent-bright);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
}

.home-kicker > span {
  margin-inline: 0.3rem;
  color: var(--home-warm-bright);
}

.home-hero h1 {
  max-width: 720px;
  font-size: clamp(2.65rem, 5vw, 4.65rem);
  line-height: 0.94;
  letter-spacing: 0.015em;
  color: #f4f6f7;
  text-shadow: 0 8px 32px rgba(0, 0, 0, 0.42);
}

.home-hero h1 span {
  display: block;
}

.home-hero h1 span:last-child {
  color: color-mix(in srgb, var(--home-accent-bright) 80%, #fff);
}

.home-lead {
  max-width: 660px;
  margin-top: 1rem;
  color: #c2cbd3;
  font-size: clamp(1rem, 1.5vw, 1.12rem);
  line-height: 1.55;
}

.home-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.45rem;
}

.home-view .home-primary-action {
  min-height: 48px;
  padding-inline: 1.35rem;
  border: 1px solid color-mix(in srgb, var(--home-warm-bright) 72%, #fff);
  border-radius: 5px;
  background: linear-gradient(135deg, #ead6a9, var(--home-warm-bright) 55%, #b98d53);
  color: #151006;
  box-shadow: 0 14px 32px rgba(178, 138, 87, 0.18);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.home-view .home-primary-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 38px rgba(178, 138, 87, 0.26);
}

.home-hero-panel {
  padding: 1.1rem 1.15rem;
  border: 1px solid #303b45;
  border-radius: 8px;
  background: rgba(8, 12, 16, 0.52);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.home-hero-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.home-hero-badge {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--home-warm-bright);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
}

.home-hero-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--home-muted);
  font-family: var(--font-heading);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-hero-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #78a88a;
  box-shadow: 0 0 10px rgba(120, 168, 138, 0.5);
}

.home-ledger-lines {
  gap: 0;
  margin-top: 0.7rem;
}

.home-ledger-lines span {
  gap: 0.58rem;
  padding: 0.66rem 0;
  border-top: 1px solid rgba(175, 195, 210, 0.1);
  color: #cbd3da;
}

.home-ledger-lines span::before {
  width: 6px;
  height: 6px;
  margin-top: 0.38rem;
  border-color: var(--home-warm);
  background: rgba(178, 138, 87, 0.16);
}

.home-ledger-lines strong {
  color: #e6eaed;
  font-size: 0.75rem;
}

.home-ledger-lines small {
  color: var(--home-muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.home-roster {
  margin-top: 1rem;
  padding: clamp(1rem, 2vw, 1.6rem);
  border: 1px solid #29343d;
  border-radius: 10px;
  background:
    linear-gradient(120deg, rgba(120, 144, 163, 0.035), transparent 32%),
    #0f151a;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.27);
}

.home-section-heading {
  margin-bottom: 1rem;
  align-items: center;
}

.home-section-heading h2 {
  color: #eef2f4;
  font-size: clamp(1.25rem, 2.2vw, 1.75rem);
  text-shadow: none;
}

.home-section-rule {
  background: linear-gradient(90deg, rgba(175, 195, 210, 0.3), transparent);
}

.home-character-list {
  gap: 0.7rem;
}

.home-character-item {
  position: relative;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem 0.9rem;
  padding: 0.8rem;
  border: 1px solid color-mix(in srgb, var(--home-char-border, var(--home-accent)) 22%, #33404a);
  border-radius: 8px;
  background:
    linear-gradient(105deg, color-mix(in srgb, var(--home-char-border, var(--home-accent)) 6%, transparent), transparent 40%),
    #151c22;
  box-shadow:
    inset 3px 0 0 color-mix(in srgb, var(--home-char-border, var(--home-accent)) 76%, transparent),
    0 12px 28px rgba(0, 0, 0, 0.22);
}

.home-character-item:hover {
  border-color: color-mix(in srgb, var(--home-char-border, var(--home-accent)) 44%, #3b4751);
  transform: translateY(-1px);
  background:
    linear-gradient(105deg, color-mix(in srgb, var(--home-char-border, var(--home-accent)) 8%, transparent), transparent 44%),
    #182028;
  box-shadow:
    inset 3px 0 0 var(--home-char-border, var(--home-accent)),
    0 16px 32px rgba(0, 0, 0, 0.28);
}

.home-character-portrait {
  width: 72px;
  border: 1px solid color-mix(in srgb, var(--home-char-border, var(--home-accent)) 32%, #3a4650);
  border-radius: 6px;
  background: color-mix(in srgb, var(--home-char-border, var(--home-accent)) 5%, #0d1216);
  box-shadow: none;
}

.home-character-portrait span {
  color: var(--home-char-accent, var(--home-accent-bright));
  font-size: 1.75rem;
  text-shadow: none;
}

.home-character-name {
  color: #f0f3f5;
  font-size: clamp(1rem, 1.45vw, 1.22rem);
}

.home-character-name span {
  color: var(--home-char-accent, var(--home-accent-bright));
  font-size: 0.7em;
}

.home-character-detail-grid {
  gap: 0.3rem;
  margin-top: 0.42rem;
}

.home-character-detail-grid span {
  gap: 0.08rem;
  padding: 0.34rem 0.42rem;
  border-color: #28333c;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.018);
  color: #d0d7dd;
  font-size: 0.78rem;
}

.home-character-detail-grid strong {
  color: #aeb9c2;
  font-size: 0.74rem;
  letter-spacing: 0.07em;
}

.home-character-time {
  color: #98a5af;
  font-size: 0.74rem;
}

.home-character-actions {
  grid-column: 2;
  justify-content: flex-start;
  gap: 0.35rem;
}

.home-character-actions .btn {
  min-height: 34px;
  padding: 0.38rem 0.68rem;
  border-radius: 4px;
  border-color: #36424c;
  background: #11171c;
  color: #c7d0d7;
  font-size: 0.67rem;
}

.home-character-actions .btn:hover {
  border-color: #52606b;
  background: #1b242b;
  color: #f0f3f5;
}

.home-character-actions .btn.gold {
  border-color: color-mix(in srgb, var(--home-char-border, var(--home-accent)) 64%, #dbe3e8);
  background: var(--home-char-accent, var(--home-accent-bright));
  color: var(--home-char-ink, #0b0e12);
  box-shadow: none;
}

.home-character-actions .btn.gold:hover {
  filter: brightness(1.06);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--home-char-border, var(--home-accent)) 18%, transparent);
}

/* Character Creation uses the same neutral foundation as the sheet. */
#modal-creation.modal-overlay {
  padding: clamp(0.65rem, 2vw, 1.5rem);
  background: rgba(4, 7, 10, 0.82);
  backdrop-filter: blur(10px);
}

body #modal-creation.modal-overlay .modal-content {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  width: min(96vw, 1180px);
  max-width: 1180px;
  max-height: calc(100dvh - clamp(1.3rem, 4vw, 3rem));
  padding: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--class-primary) 22%, #34404a);
  border-radius: 12px;
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--class-primary) 4%, transparent), transparent 36%),
    #0d1217;
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.creation-shell-header {
  position: relative;
  z-index: 20;
  padding: 1rem clamp(1rem, 2.6vw, 1.8rem) 0.85rem;
  border-bottom: 1px solid #29343d;
  border-radius: 11px 11px 0 0;
  background: color-mix(in srgb, #10161b 94%, transparent);
  backdrop-filter: blur(12px);
}

.creation-hero {
  margin-bottom: 0.72rem;
}

.creation-eyebrow {
  margin-bottom: 0.18rem;
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#modal-creation .creation-hero h2 {
  margin: 0;
  padding: 0;
  border: 0;
  color: #f2f5f7;
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  line-height: 1.1;
}

#creation-step-indicator {
  margin-top: 0.28rem;
  color: #adb8c1;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.creation-hero-badge {
  padding: 0.28rem 0.58rem;
  border-color: color-mix(in srgb, var(--class-primary) 30%, #3a4650);
  border-radius: 4px;
  background: color-mix(in srgb, var(--class-primary) 7%, #12181e);
  color: var(--class-readable);
  font-size: 0.67rem;
}

.creation-progress-shell {
  position: relative;
}

.creation-progress-track {
  height: 3px;
  margin: 0 0 0.68rem;
  border: 0;
  border-radius: 0;
  background: #27323b;
}

.creation-progress-fill {
  background: linear-gradient(90deg, var(--class-primary), var(--class-readable));
  box-shadow: 0 0 12px color-mix(in srgb, var(--class-primary) 30%, transparent);
}

.creation-step-nav {
  display: flex;
  gap: 0;
  margin: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.creation-step-nav::-webkit-scrollbar {
  display: none;
}

.creation-step-pill {
  position: relative;
  flex: 1 0 108px;
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-height: 40px;
  padding: 0.35rem 0.5rem;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #9da9b3;
  font-size: 0.65rem;
  letter-spacing: 0.045em;
  white-space: nowrap;
}

.creation-step-pill::before {
  content: attr(data-cw-nav-step);
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border: 1px solid #3b4751;
  border-radius: 50%;
  color: #aeb8c0;
  background: #11171c;
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0;
}

.creation-step-pill:hover {
  color: #e3e8ec;
  background: rgba(255, 255, 255, 0.018);
}

.creation-step-pill.active {
  border-color: var(--class-primary);
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--class-primary) 7%, transparent));
  color: var(--class-readable);
  box-shadow: none;
}

.creation-step-pill.active::before {
  border-color: var(--class-readable);
  background: var(--class-primary);
  color: var(--class-text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--class-primary) 12%, transparent);
}

.creation-step-pill.done {
  border-color: color-mix(in srgb, var(--class-primary) 28%, transparent);
  background: transparent;
  color: #c4cdd4;
}

.creation-step-pill.done::before {
  content: "✓";
  border-color: color-mix(in srgb, var(--class-primary) 56%, #44515b);
  color: var(--class-readable);
  background: color-mix(in srgb, var(--class-primary) 10%, #11171c);
}

.creation-stage {
  min-height: 0;
  padding: clamp(0.85rem, 2vw, 1.35rem) clamp(0.85rem, 2.6vw, 1.8rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

#modal-creation .creation-step > .card {
  margin: 0 !important;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#modal-creation .creation-step > .card > .sec {
  margin-bottom: 0.22rem;
  padding: 0;
  border: 0;
  color: #f0f3f5;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

.creation-step-help {
  margin: 0 0 0.85rem;
  color: #adb8c1;
  font-size: 0.8rem;
}

.creation-panel {
  padding: 0.82rem;
  border: 1px solid #2c3740;
  border-radius: 7px;
  background: #12191f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.022);
}

.creation-panel::before {
  width: 2px;
  border-radius: 7px 0 0 7px;
  background: linear-gradient(180deg, var(--class-primary), transparent 88%);
  opacity: 0.8;
}

#modal-creation:not([data-class-selected="true"]) .creation-panel {
  background: #12191f;
}

#modal-creation .profile-field label,
#modal-creation .creation-detail-heading,
#modal-creation .creation-review-title {
  color: var(--class-readable);
  font-size: max(0.72rem, 11px);
}

#modal-creation input,
#modal-creation select,
#modal-creation textarea,
#modal-creation .select-trigger {
  min-height: 40px;
  border-color: #35414b;
  border-radius: 4px;
  background: #0c1217;
  color: #e6ebef;
}

#modal-creation .point-buy-grid {
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
}

#modal-creation textarea {
  padding: 0.58rem 0.65rem;
}

.creation-class-layout {
  grid-template-columns: minmax(250px, 0.76fr) minmax(420px, 1.24fr);
  gap: 0.72rem;
}

.creation-class-tile-grid {
  gap: 0.36rem;
  margin-top: 0;
}

.creation-class-tile {
  position: relative;
  min-height: 62px;
  padding: 0.58rem 0.62rem 0.58rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--tile-primary, var(--class-primary)) 20%, #34404a);
  border-radius: 5px;
  background:
    linear-gradient(100deg, color-mix(in srgb, var(--tile-primary, var(--class-primary)) 5%, transparent), transparent 65%),
    #10171c;
}

.creation-class-tile::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px 0;
  width: 2px;
  background: var(--tile-primary, var(--class-primary));
  opacity: 0.45;
}

.creation-class-tile:hover,
.creation-class-tile:focus-visible {
  border-color: color-mix(in srgb, var(--tile-primary, var(--class-primary)) 48%, #46535e);
  background:
    linear-gradient(100deg, color-mix(in srgb, var(--tile-primary, var(--class-primary)) 9%, transparent), transparent 68%),
    #151d23;
}

.creation-class-tile strong {
  color: #e9edf0;
  font-size: 0.78rem;
}

.creation-class-tile span {
  color: #aab5be;
  font-size: 0.74rem;
}

.creation-class-tile.active {
  border-color: color-mix(in srgb, var(--tile-primary, var(--class-primary)) 76%, #5a6873);
  background:
    linear-gradient(100deg, color-mix(in srgb, var(--tile-primary, var(--class-primary)) 14%, transparent), transparent 72%),
    #182128;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tile-primary, var(--class-primary)) 10%, transparent);
}

.creation-class-tile.active::before {
  width: 3px;
  opacity: 1;
}

.creation-class-tile.active strong {
  color: var(--tile-readable, var(--class-readable));
}

.creation-class-tile.locked {
  opacity: 0.66;
  filter: saturate(0.72);
}

.creation-class-tile.locked.active {
  opacity: 1;
  filter: none;
}

.creation-class-detail-panel {
  background:
    linear-gradient(125deg, color-mix(in srgb, var(--class-primary) 6%, transparent), transparent 48%),
    #12191f;
  border-color: color-mix(in srgb, var(--class-primary) 25%, #34404a);
}

.creation-class-basics-list {
  display: grid;
  margin-bottom: 0.85rem;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--class-primary) 20%, #34404a);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.016);
}

.creation-class-basic-row {
  display: grid;
  grid-template-columns: minmax(132px, 0.3fr) minmax(0, 1fr);
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.48rem 0.64rem;
}

.creation-class-basic-row + .creation-class-basic-row {
  border-top: 1px solid color-mix(in srgb, var(--class-primary) 13%, #2c3740);
}

.creation-class-basic-row strong {
  color: #aeb9c2;
  font-family: var(--font-heading);
  font-size: 0.65rem;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.creation-class-basic-row span {
  color: #dce2e6;
  font-size: 0.8rem;
  line-height: 1.38;
}

.creation-class-role-list span,
.creation-class-info-grid div,
.creation-class-stat,
.creation-class-info-row,
.creation-subclass-row,
.creation-review-block {
  border-color: color-mix(in srgb, var(--class-primary) 16%, #34404a);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.018);
}

.creation-class-info-grid strong,
.creation-class-stat strong,
.creation-class-info-row strong,
.creation-subclass-title {
  color: #aeb9c2;
  font-size: 0.74rem;
}

.creation-class-info-grid span,
.creation-class-stat span,
.creation-class-info-row span,
.creation-subclass-row span {
  color: #d7dee3;
  font-size: 0.82rem;
}

#modal-creation .modal-actions {
  position: relative;
  z-index: 20;
  margin: 0;
  padding: 0.78rem clamp(0.85rem, 2.6vw, 1.8rem);
  border-top: 1px solid #2a353e;
  border-radius: 0 0 11px 11px;
  background: color-mix(in srgb, #10161b 94%, transparent);
  backdrop-filter: blur(12px);
}

#modal-creation .modal-actions .btn {
  min-height: 40px;
  border-radius: 4px;
  border-color: #3a4650;
  background: #151c22;
  color: #cbd3d9;
}

#modal-creation .modal-actions .btn:hover {
  border-color: #53616c;
  background: #1c252c;
  color: #f0f3f5;
}

#modal-creation .modal-actions .btn.gold {
  border-color: color-mix(in srgb, var(--class-primary) 62%, #dce4e9);
  background: var(--class-readable);
  color: var(--class-text);
  box-shadow: 0 9px 22px color-mix(in srgb, var(--class-primary) 16%, transparent);
}

@media (max-width: 900px) {
  .home-hero {
    grid-template-columns: 1fr;
  }

  .home-hero-panel {
    align-self: stretch;
  }

  .creation-class-layout {
    grid-template-columns: 1fr;
  }

  .creation-class-tile-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .creation-step-nav {
    grid-template-columns: none;
  }
}

@media (max-width: 760px) {
  .home-view {
    padding: 0.65rem;
  }

  .home-hero {
    min-height: 0;
    padding: 1.25rem 1rem;
    border-radius: 9px;
  }

  .home-hero::before {
    display: none;
  }

  .home-hero h1 {
    font-size: clamp(2.35rem, 13vw, 3.5rem);
  }

  .home-roster {
    padding: 0.8rem;
  }

  .home-character-item {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .home-character-portrait {
    width: 64px;
  }

  .home-character-detail-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .home-character-actions {
    grid-column: 1 / -1;
  }

  body #modal-creation.modal-overlay .modal-content {
    width: min(98vw, 1180px);
    max-height: calc(100dvh - 1rem);
    border-radius: 8px;
  }

  .creation-shell-header {
    padding: 0.8rem 0.75rem 0.65rem;
    border-radius: 7px 7px 0 0;
  }

  .creation-hero {
    flex-direction: row;
    align-items: center;
  }

  .creation-hero-badge {
    display: none;
  }

  .creation-step-pill {
    flex-basis: 100px;
    min-height: 42px;
  }

  .creation-stage {
    padding: 0.8rem 0.7rem;
  }

  .creation-class-tile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #modal-creation .modal-actions {
    padding: 0.65rem 0.7rem;
  }
}

@media (max-width: 560px) {
  .creation-class-basic-row {
    grid-template-columns: 1fr;
    gap: 0.12rem;
  }
}

@media (max-width: 480px) {
  .home-character-detail-grid {
    grid-template-columns: 1fr;
  }

  .home-character-actions .btn {
    flex: 1 1 auto;
  }

  .creation-class-tile-grid {
    grid-template-columns: 1fr 1fr;
  }

  #creation-skill-list,
  #creation-bg-skill-list,
  #creation-bg-even-picks {
    grid-template-columns: 1fr;
  }
}


.home-view .home-secondary-action {
  min-height: 48px;
  padding-inline: 1.1rem;
}
/* ============================================================
   Modern sheet — wide modular character workspace
   ============================================================ */
.modern-layout-root,
.modern-spellbook-actions {
  display: none;
}

body.sheet-layout-modern {
  --bg: #0b0e11;
  --bg-surface: #11161a;
  --bg-card: #171d22;
  --bg-card-hover: #1c252b;
  --bg-input: #0d1215;
  --border: #303941;
  --border-strong: #4b5963;
  --text: #ebe7df;
  --text-dim: #aeb5b7;
  --text-heading: #fffdf7;
  --radius: 7px;
  --radius-lg: 11px;
  background:
    radial-gradient(circle at 18% -18%, color-mix(in srgb, var(--class-primary) 5%, transparent), transparent 38%),
    radial-gradient(circle at 82% -12%, color-mix(in srgb, var(--class-accent) 9%, transparent), transparent 44%),
    #0b0e11;
}

body.sheet-layout-modern::before {
  opacity: 0.5;
  background:
    linear-gradient(110deg, color-mix(in srgb, var(--class-accent) 6%, transparent), transparent 35%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 5px);
}

body.sheet-layout-modern .tab-bar {
  position: sticky;
  top: 0;
  z-index: 500;
  min-height: 48px;
  padding-inline: clamp(0.65rem, 1.35vw, 1.5rem);
  border-bottom: 1px solid var(--border);
  background: rgba(13, 18, 21, 0.96);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

body.sheet-layout-modern .top-bar {
  padding-inline: clamp(0.7rem, 1.35vw, 1.6rem);
}

body.sheet-layout-modern .top-bar-inner {
  max-width: 1920px;
}

body.sheet-layout-modern .sheet-main {
  position: relative;
  z-index: 1;
  display: block;
  width: min(calc(100% - clamp(1.2rem, 2.6vw, 3rem)), 1920px);
  max-width: none;
  margin-inline: auto;
  padding: clamp(0.8rem, 1.4vw, 1.4rem) 0 2rem;
}

body.sheet-layout-modern .modern-layout-root.is-mounted {
  display: grid;
  gap: clamp(0.8rem, 1.2vw, 1.2rem);
  min-width: 0;
}

.modern-core-grid {
  display: grid;
  grid-template-columns: minmax(390px, 0.7fr) minmax(600px, 1.3fr);
  gap: clamp(0.8rem, 1.2vw, 1.2rem);
  align-items: start;
}

.modern-character-rail {
  display: grid;
  gap: clamp(0.7rem, 1vw, 0.95rem);
  min-width: 0;
  align-content: start;
}

.modern-abilities-shell,
.modern-combat-readout-shell,
.modern-primary-workspace,
.modern-inventory-suite {
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--class-accent) 34%, var(--border));
  border-radius: 14px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--class-primary) 4%, transparent), transparent 28%),
    linear-gradient(325deg, color-mix(in srgb, var(--class-accent) 8%, transparent), transparent 38%),
    color-mix(in srgb, var(--bg-surface) 94%, black);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
}

.modern-abilities-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.75rem;
  align-items: start;
}

body.sheet-layout-modern .modern-abilities-shell .prof-bonus-block {
  min-height: 68px;
  flex-direction: row;
  justify-content: center;
  gap: 0.25rem;
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg-card) 72%, var(--bg-input));
}

body.sheet-layout-modern .modern-abilities-shell .prof-value {
  font-size: 2.15rem;
}

body.sheet-layout-modern .modern-abilities-shell .prof-label {
  text-align: left;
  font-size: 0.72rem;
  line-height: 1.35;
}

body.sheet-layout-modern .modern-abilities-shell .ability-columns {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 0.55rem;
}

body.sheet-layout-modern .modern-abilities-shell #ability-blocks-left,
body.sheet-layout-modern .modern-abilities-shell #ability-blocks-right {
  gap: 0.55rem;
}

body.sheet-layout-modern .modern-abilities-shell .ability-block,
body.sheet-layout-modern .modern-abilities-shell .insp-box {
  border-color: color-mix(in srgb, var(--class-accent) 22%, var(--border));
  box-shadow: none;
}

body.sheet-layout-modern .modern-abilities-shell .ability-block {
  padding: 0.62rem;
}

body.sheet-layout-modern .modern-abilities-shell .ab-header {
  gap: 0.52rem;
  margin-bottom: 0.38rem;
}

body.sheet-layout-modern .modern-abilities-shell .ab-mod-circle {
  width: 46px;
  min-width: 46px;
  max-width: 46px;
  height: 46px;
  min-height: 46px;
  max-height: 46px;
  flex-basis: 46px;
  font-size: 1.28rem;
}

body.sheet-layout-modern .modern-abilities-shell .ab-label {
  font-size: 0.78rem;
}

body.sheet-layout-modern .modern-abilities-shell .ab-score-input {
  width: 42px;
  height: 28px;
  font-size: 0.94rem;
}

body.sheet-layout-modern .modern-abilities-shell .ab-skill-row,
body.sheet-layout-modern .modern-abilities-shell .ab-save-row {
  gap: 0.3rem;
  font-size: 0.8rem;
  line-height: 1.3;
}

body.sheet-layout-modern .modern-abilities-shell .skill-mod {
  width: 25px;
  font-size: 0.8rem;
}

body.sheet-layout-modern .modern-abilities-shell .skill-name {
  overflow: visible;
  text-overflow: clip;
}

body.sheet-layout-modern .modern-abilities-shell .prof-dot {
  width: 11px;
  height: 11px;
}

body.sheet-layout-modern .modern-abilities-shell .insp-label {
  font-size: 0.7rem;
}

.modern-combat-readout-shell {
  display: grid;
  grid-template-rows: repeat(3, auto);
  gap: 0.75rem;
  padding: 0.75rem;
}

body.sheet-layout-modern .center-stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

body.sheet-layout-modern .center-stat {
  min-width: 0;
  min-height: 92px;
  justify-content: center;
  border-color: color-mix(in srgb, var(--class-accent) 24%, var(--border));
  background: var(--bg-card);
}

body.sheet-layout-modern .center-stat-label {
  font-size: 0.76rem;
}

body.sheet-layout-modern .center-stat-value,
body.sheet-layout-modern .center-stat-input {
  font-size: 1.55rem;
}

#modern-resource-shell:empty,
#modern-resource-shell:has(#class-resources-card.hidden) {
  display: none;
}

body.sheet-layout-modern #class-resources-card {
  height: 100%;
  margin: 0;
  padding: 0.75rem;
  border-color: color-mix(in srgb, var(--class-accent) 42%, var(--border));
  background:
    linear-gradient(105deg, color-mix(in srgb, var(--class-primary) 4%, transparent), transparent 45%),
    linear-gradient(285deg, color-mix(in srgb, var(--class-accent) 11%, transparent), transparent 58%),
    var(--bg-card);
}

body.sheet-layout-modern #class-resources-body {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.55rem;
}

body.sheet-layout-modern .class-resource-row {
  min-height: 58px;
  padding: 0.45rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--class-accent) 28%, var(--border));
  background: color-mix(in srgb, var(--bg-input) 72%, transparent);
}

.modern-primary-workspace,
.modern-inventory-suite {
  padding: clamp(0.75rem, 1.1vw, 1.05rem);
}

.modern-workspace-heading,
.modern-suite-heading,
.modern-spellbook-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Secondary actions should read as buttons, while filled primary actions remain stronger. */
body.sheet-layout-modern .modern-primary-workspace :is(.btn:not(.gold):not(.danger), .attack-option-chip:not(.locked):not(.feature-filter-chip), .fighter-combat-style-change, .fighter-combat-mastery-action):not(:disabled):not([aria-disabled="true"]),
body.sheet-layout-modern .modern-primary-workspace .feature-card-controls .btn {
  border-color: color-mix(in srgb, var(--class-primary) 42%, var(--border-strong));
  background: color-mix(in srgb, var(--class-primary) 12%, var(--bg-card));
  color: var(--text-heading);
  font-weight: 600;
}

body.sheet-layout-modern .modern-primary-workspace .feature-card-controls .btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

body.sheet-layout-modern .modern-primary-workspace :is(.btn:not(.gold):not(.danger), .attack-option-chip:not(.locked):not(.feature-filter-chip), .fighter-combat-style-change, .fighter-combat-mastery-action):not(:disabled):not([aria-disabled="true"]):hover {
  border-color: color-mix(in srgb, var(--class-primary) 65%, var(--border-strong));
  background: color-mix(in srgb, var(--class-primary) 22%, var(--bg-card));
}

body.sheet-layout-modern .modern-primary-workspace :is(.btn:not(.gold):not(.danger), .attack-option-chip:not(.locked):not(.feature-filter-chip), .fighter-combat-style-change, .fighter-combat-mastery-action):not(:disabled):not([aria-disabled="true"]):focus-visible {
  outline: 2px solid var(--class-readable);
  outline-offset: 2px;
}

.modern-workspace-heading,
.modern-suite-heading {
  margin-bottom: 0.8rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.modern-workspace-heading h2,
.modern-suite-heading h2,
.modern-spellbook-preview-head h3 {
  margin: 0.08rem 0 0;
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.modern-eyebrow {
  display: block;
  color: var(--class-readable);
  font-family: var(--font-heading);
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.modern-customize-btn {
  font-size: 0.72rem;
  padding: 0.25rem 0.5rem;
  min-height: 1.6rem;
  line-height: 1.2;
  border-color: color-mix(in srgb, var(--class-accent) 52%, var(--border));
  background: color-mix(in srgb, var(--class-accent) 12%, var(--bg-card));
  color: var(--text-heading);
}

.modern-module-stack {
  display: grid;
  gap: 0.8rem;
}

.module-toggle { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0; border: none; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; text-align: left; }
.module-collapse-indicator { font-size: 0.62rem; }
.module-toggle:hover { color: var(--class-readable); }
.module-toggle:focus-visible { outline: 2px solid var(--class-readable); outline-offset: 3px; }
.modern-module-stack > .card.is-collapsed > :not(.sec) { display: none !important; }
.modern-module-stack > .card.is-collapsed > .sec { margin-bottom: 0; }

body.sheet-layout-modern .modern-module-stack > .card {
  margin: 0;
  padding: 0.8rem;
  border-color: color-mix(in srgb, var(--class-accent) 24%, var(--border));
  background: color-mix(in srgb, var(--bg-card) 92%, black);
  box-shadow: none;
}

body.sheet-layout-modern .modern-module-stack .sec {
  font-size: 0.76rem;
}

body.sheet-layout-modern .modern-module-stack .attack-section-title {
  font-size: 0.66rem;
}

body.sheet-layout-modern .modern-module-stack .attack-name,
body.sheet-layout-modern .modern-module-stack .attack-group .attack-name {
  font-size: 0.88rem;
}

body.sheet-layout-modern .modern-module-stack .attack-row-stat-label {
  font-size: 0.62rem;
}

body.sheet-layout-modern .modern-module-stack .attack-row-stat-value {
  font-size: 0.86rem;
}

body.sheet-layout-modern .spell-slots-panel {
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg-card) 78%, var(--bg-input));
}

body.sheet-layout-modern .spell-slots-total strong,
body.sheet-layout-modern .spell-slot-count strong {
  color: var(--text-heading);
}

body.sheet-layout-modern .spell-slots-recharge,
body.sheet-layout-modern .spell-slot-card {
  border-color: var(--border);
}

body.sheet-layout-modern .spell-slots-recharge {
  background: var(--bg-input);
}

body.sheet-layout-modern .spell-slot-pip {
  border-color: color-mix(in srgb, var(--class-primary) 30%, var(--border));
}

body.sheet-layout-modern .spell-slot-pip.is-available {
  background: color-mix(in srgb, var(--class-primary) 64%, var(--bg-card));
  box-shadow: none;
}

body.sheet-layout-modern .modern-module-hidden,
body.sheet-layout-modern .modern-tab-inactive {
  display: none !important;
}

body.sheet-layout-modern #spells-section #spells-list,
body.sheet-layout-modern #spells-section #btn-add-spell,
body.sheet-layout-modern #spells-section #btn-open-spell-library {
  display: none;
}

body.sheet-layout-modern .modern-spellbook-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 0.65rem;
  padding: 0.65rem;
  border: 1px solid color-mix(in srgb, var(--class-accent) 34%, var(--border));
  border-radius: 9px;
  background: color-mix(in srgb, var(--class-accent) 9%, var(--bg-input));
}

.modern-spellbook-count {
  color: var(--text-dim);
  font-size: 0.73rem;
}

.modern-spellbook-open-btn {
  min-width: 150px;
}

body.sheet-layout-modern #features-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

body.sheet-layout-modern #features-list > .features-filter-panel,
body.sheet-layout-modern #features-list > .feature-empty-state {
  grid-column: 1 / -1;
}

body.sheet-layout-modern .feature-card {
  min-width: 0;
  margin: 0;
}

.modern-spellbook-toolbar input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  padding: 0.58rem 0.7rem;
}

.feature-source-badge {
  border-color: color-mix(in srgb, var(--class-accent) 52%, var(--border));
  color: var(--class-readable);
}

.modern-inventory-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  width: 100%;
}

body.sheet-layout-modern .modern-inventory-summary > .card {
  margin: 0;
  padding: 0.55rem;
  box-shadow: none;
  background: var(--bg-card);
}

.modern-inventory-summary .currency-row {
  flex-wrap: wrap;
}

.modern-inventory-tabs {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.65rem;
}

.modern-inventory-tabs button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0.38rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.modern-inventory-tabs button.active {
  border-color: color-mix(in srgb, var(--class-accent) 62%, var(--border));
  background: color-mix(in srgb, var(--class-accent) 16%, color-mix(in srgb, var(--class-primary) 6%, var(--bg-card)));
  color: var(--text-heading);
}

.modern-inventory-content > .card {
  margin: 0;
  padding: 0.75rem;
  box-shadow: none;
  background: var(--bg-card);
}

.modern-inventory-content {
  display: grid;
  gap: 0.55rem;
}

.modern-secondary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.7rem, 1vw, 1rem);
  align-items: start;
}

body.sheet-layout-modern .modern-secondary-grid > .card {
  margin: 0;
  min-width: 0;
  padding: 0.62rem;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16);
}

body.sheet-layout-modern #modern-inventory-content > #equipment-training-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "heading heading"
    "armor weapon"
    "tool mastery";
  gap: 0.5rem 0.7rem;
  align-items: start;
  padding: 0.62rem;
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg-card) 72%, var(--bg-input));
}

body.sheet-layout-modern #equipment-training-card > .sec {
  grid-area: heading;
  margin-bottom: 0;
}

body.sheet-layout-modern #equipment-training-card .armor-training {
  grid-area: armor;
  gap: 0.34rem;
  min-width: 0;
  margin-bottom: 0;
}

body.sheet-layout-modern #equipment-training-card .equipment-training-weapon {
  grid-area: weapon;
}

body.sheet-layout-modern #equipment-training-card .equipment-training-tool {
  grid-area: tool;
}

body.sheet-layout-modern #equipment-training-card .equipment-training-mastery {
  grid-area: mastery;
}

body.sheet-layout-modern #equipment-training-card .prof-text-block {
  min-width: 0;
  margin-bottom: 0;
}

body.sheet-layout-modern #equipment-training-card .armor-training-label {
  font-size: 0.6rem;
}

body.sheet-layout-modern #equipment-training-card .armor-check {
  display: none;
}

body.sheet-layout-modern #equipment-training-card .armor-check:has(input:checked) {
  display: inline-flex;
  padding: 0.16rem 0.52rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel-soft) 72%, transparent);
  font-family: var(--font-heading);
  font-size: 0.68rem;
  line-height: 1.25;
  cursor: default;
}

body.sheet-layout-modern #equipment-training-card .armor-check input {
  display: none;
}

body.sheet-layout-modern #equipment-training-card .armor-training:not(:has(input:checked))::after {
  content: "None";
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.68rem;
}

body.sheet-layout-modern .modern-character-rail .modern-suite-heading {
  align-items: stretch;
  flex-direction: column;
  gap: 0.65rem;
}

body.sheet-layout-modern .modern-character-rail .modern-inventory-tabs {
  gap: 0.28rem;
}

body.sheet-layout-modern .modern-character-rail .modern-inventory-tabs button {
  padding-inline: 0.58rem;
  font-size: 0.6rem;
}

body.sheet-layout-modern .modern-character-rail .modern-inventory-content > .card {
  padding: 0.62rem;
}

body.sheet-layout-modern .modern-character-rail .item-list-head span {
  font-size: 0.58rem;
}

body.sheet-layout-modern .modern-character-rail .inventory-entry input,
body.sheet-layout-modern .modern-character-rail .equip-entry input,
body.sheet-layout-modern .modern-character-rail .dropped-entry input {
  font-size: 0.78rem;
}

.modern-layout-modal-content {
  width: min(680px, calc(100vw - 2rem));
}

.modern-layout-module-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.modern-layout-module-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.72rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-card);
}

.modern-layout-module-row strong,
.modern-layout-module-row small {
  display: block;
}

.modern-layout-module-row small {
  margin-top: 0.15rem;
  color: var(--text-dim);
  font-size: 0.67rem;
}

.modern-layout-visible-toggle,
.modern-layout-order-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.modern-layout-visible-toggle {
  color: var(--text-dim);
  font-size: 0.7rem;
}

.modern-spellbook-modal-content {
  width: min(1080px, calc(100vw - 2rem));
  max-width: none;
  height: min(780px, calc(100vh - 2rem));
  max-height: none;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  overflow: hidden;
}

.modern-spellbook-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px auto auto auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.75rem 0;
}

.modern-spellbook-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
}

.modern-spellbook-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1.28fr);
  gap: 0.8rem;
  padding-top: 0.8rem;
}

.modern-spellbook-grid > .spell-library-list,
.modern-spellbook-grid > .spell-library-detail-pane {
  min-height: 0;
  overflow-y: auto;
}

.modern-spellbook-card .spell-library-meta {
  line-height: 1.35;
}

.modern-spellbook-preview-head {
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 1180px) {
  .modern-core-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .modern-character-rail {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .modern-character-rail .modern-secondary-grid {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.sheet-layout-modern #features-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modern-suite-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .modern-inventory-summary {
    width: 100%;
  }
}

@media (max-width: 760px) {
  body.sheet-layout-modern .sheet-main {
    width: min(calc(100% - 1rem), 1920px);
    padding-top: 0.55rem;
  }

  .modern-abilities-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .modern-character-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .modern-character-rail .modern-secondary-grid {
    grid-column: auto;
  }

  body.sheet-layout-modern .modern-abilities-shell .prof-bonus-block {
    min-height: 72px;
    flex-direction: row;
  }

  body.sheet-layout-modern .center-stats-row,
  .modern-secondary-grid,
  body.sheet-layout-modern #features-list,
  .modern-inventory-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .features-filter-panel {
    min-width: 0;
  }

  .modern-spellbook-modal-content {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  .modern-spellbook-toolbar {
    grid-template-columns: minmax(0, 1fr) 145px;
  }

  .modern-spellbook-toolbar .btn {
    min-width: 0;
  }

  .modern-spellbook-toolbar .spell-library-count {
    grid-column: 1 / -1;
  }

  .modern-spellbook-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .modern-spellbook-grid > .spell-library-list {
    max-height: 34vh;
  }

  .modern-layout-module-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .modern-layout-order-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 480px) {
  body.sheet-layout-modern #modern-inventory-content > #equipment-training-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "heading"
      "armor"
      "weapon"
      "tool"
      "mastery";
  }
}

/* Give own HP controls room and keep Death Saves complete on narrow phones. */
@media (max-width: 360px) {
  .hp-panels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hp-panel:last-child {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-view *,
  #modal-creation * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Panel width also matters when Customize Sheet or the rail narrows it. */
@container (max-width: 580px) {
  body.sheet-layout-modern #features-list { grid-template-columns: minmax(0, 1fr); }
}
@container (min-width: 581px) {
  body.sheet-layout-modern #features-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (min-width: 780px) {
  body.sheet-layout-modern #features-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* A confirmation opened from another modal must own the interaction layer.
   The source modal remains visible as context, but cannot intercept the choice. */
body:has(#modal-action-confirm.active) .modal-overlay.active:not(#modal-action-confirm) {
  pointer-events: none;
}

#modal-action-confirm.active {
  z-index: 20000;
  pointer-events: auto;
  isolation: isolate;
}

#modal-action-confirm.active .modal-content {
  position: relative;
  z-index: 1;
}

/* Dense sheet labels need structural room rather than smaller typography.
   Keep the HP sub-panels and the class-resource rail readable in both
   supported layouts, including the narrow desktop breakpoint. */
.ds-group-row {
  grid-template-columns: 74px minmax(0, 1fr);
}

.ds-group-label {
  width: auto;
}

.ds-res-row {
  grid-template-columns: 76px minmax(0, 1fr);
}

.hp-panel:nth-child(1) {
  flex: 1.08 1 0;
}

.hp-panel:nth-child(2) {
  flex: 0.82 1 0;
}

.hp-panel:nth-child(3) {
  flex: 1.1 1 0;
}

.class-resource-label {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
}

@media (max-width: 480px) {
  .ds-group-row,
  .ds-res-row {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 0.12rem;
  }

  .ds-group-label,
  .ds-res-label {
    width: auto;
    text-align: center;
  }

  #btn-add-condition {
    padding-inline: 0.2rem;
    white-space: normal;
    line-height: 1.2;
  }
}
