/**
 * Shared Widgets — reusable UI patterns that live above the base layer
 * but are used across multiple feature pages.
 *
 * Chrome primitives (.button, .badge, .form-field, .admin-table,
 * .section-panel, .entity-card, etc.) have moved to base.css (Layer 2).
 * This file holds domain-agnostic widgets that don't fit neatly into
 * any single feature file.
 */

/* =============================================================================
   Roll Button — dice-specific action button
   ============================================================================= */

.roll-btn {
  background: transparent;
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

.roll-btn:hover {
  background: var(--accent-red);
  color: #ffffff;
}

/* =============================================================================
   Catalog Layout Helpers — game-systems catalog pages
   ============================================================================= */

/* Nested editor sections in catalog cards (ranks, enhancements, etc.) */
.catalog-nested-editor {
  margin-top: 0.5rem;
}

.catalog-nested-editor > label {
  font-weight: bold;
  display: block;
  margin-bottom: 0.5rem;
}

/* Catalog page layout helpers */
.catalog-flex-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.catalog-spacer-top {
  margin-top: 1rem;
}

.catalog-subtitle {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* =============================================================================
   Dice Roller
   ============================================================================= */

.dice-roller-controls {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

.dice-roller-controls .form-field {
  flex: 0 0 auto;
}

.dice-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding-bottom: 0.5rem;
}

.dice-result {
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
}

.dice-total {
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.dice-breakdown {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.dice-group {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.die-face {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--bg-primary);
  border: 2px solid var(--border-primary);
  border-radius: 4px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.die-face.wild {
  border-color: var(--warning);
  color: var(--warning);
}

.die-face.complication {
  border-color: var(--error);
  color: var(--error);
}

.dice-pips {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-left: 0.25rem;
}

.dice-history {
  margin-top: 1.5rem;
}

/* =============================================================================
   Tags
   ============================================================================= */

.tags-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.form-field .tags-inline {
  margin-top: 0.5rem;
}

.tags-active {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-primary);
}

.tag-removable {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.tag-removable .tag-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 0.75em;
  line-height: 1;
}

.tag-removable .tag-remove:hover {
  opacity: 1;
}

.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.tag-suggestion {
  cursor: pointer;
  opacity: 0.7;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
}

.tag-suggestion:hover {
  opacity: 1;
}

.tag-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.25rem;
}

.tag-input-row input {
  flex: 1;
  max-width: 250px;
}

/* =============================================================================
   Banner Image — overview page hero
   ============================================================================= */

.banner-image-section {
  margin-bottom: 1.5rem;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-primary);
}

.banner-image {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  display: block;
}

/* Campaign banner placeholder — shown when no banner image is set.
   A slim coloured strip keyed to a deterministic hash of the campaign
   name, so GMs with many campaigns still get a per-campaign visual
   marker without a full image. The gradient itself is applied inline
   via :style; this rule only owns the layout. */
.campaign-banner-placeholder {
  height: 2em;
  border-radius: 6px;
  border: 1px solid var(--border-primary);
  margin-bottom: 1.5rem;
}

/* =============================================================================
   Overview Field Sections — public note, URLs, private notes
   ============================================================================= */

.overview-field-section {
  margin-bottom: 1.25rem;
}

.overview-field-section h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.overview-field-text {
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
}

.urls-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.urls-list li a {
  color: var(--accent-red);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.urls-list li a:hover {
  background: var(--bg-hover);
  border-color: var(--accent-red);
}

.private-notes-section {
  margin-bottom: 1.25rem;
  padding: 0.75rem;
  background: var(--info-bg);
  border: 1px solid var(--info-bg);
  border-radius: 4px;
}

.private-notes-section h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
  color: var(--info);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Overview Fields Edit Form */
.overview-fields-edit {
  margin-bottom: 1.5rem;
}

.overview-fields-edit h3 {
  margin: 0 0 1rem 0;
}

.url-entries {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.url-entry-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.url-entry-row input:first-child {
  flex: 1;
  max-width: 200px;
}

.url-entry-row input:nth-child(2) {
  flex: 2;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* =============================================================================
   Image Upload Components
   ============================================================================= */

.image-file-input {
  display: none;
}

.image-preview {
  max-width: 300px;
  max-height: 200px;
  border-radius: 6px;
  border: 1px solid var(--border-primary);
  object-fit: cover;
}

.image-placeholder {
  width: 300px;
  height: 160px;
  border-radius: 6px;
  border: 2px dashed var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
}

.image-placeholder .placeholder-icon {
  font-size: 2rem;
  color: var(--text-muted);
}

.image-field {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 320px;
}

.image-field-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Banner-sized image variant */
.image-field.banner .image-preview,
.image-field.banner .image-placeholder {
  max-width: 100%;
  width: 100%;
  height: 200px;
}

.image-field.banner {
  max-width: 100%;
}

/* Small avatar variant */
.image-field.avatar .image-preview {
  width: 80px;
  height: 80px;
  max-width: 80px;
  max-height: 80px;
  border-radius: 50%;
}

.image-field.avatar .image-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
}

.image-field.avatar {
  max-width: 120px;
  align-items: center;
}

/* =============================================================================
   Skill Groups (consolidated from characters.css)
   ============================================================================= */

/* Two-column column-major layout for OpenD6/SWD6 1E session view
   (session 295). Skills are central to play; the paper character sheet
   uses two columns of attribute-grouped skills.

   The paper-sheet layout is *asymmetric* between systems:
     - SWD6 1E:        3 rows × 2 cols (6 attrs, balanced)
     - D6 Adv/Fan/Spa: 4 rows × 2 cols, with col 1 the body/movement
                       block (always 4) and col 2 the mind/social block
                       + optional extranormals (2–4 visible depending
                       on which Magic/Psionics/Miracles the PC has).

   CSS `column-count: 2` auto-balances, which is wrong for the
   asymmetric case. Instead we use an explicit grid with a per-system
   row count set via the `.rows-N` modifier class. The seed-driven
   attribute order plus `grid-auto-flow: column` fills col 1 first,
   then col 2, in seed order — matching the paper sheet.

   Narrow viewport falls back to a single column. */
.skill-groups-2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(var(--skill-rows, 3), auto);
  grid-auto-flow: column;
  column-gap: 1rem;
  row-gap: 0.5rem;
}

@media (max-width: 768px) {
  .skill-groups-2col {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-flow: row;
  }
}

/* Private Session Notes section (session 296) — per-character journal
   stream. Editor + entries list. */
.private-notes-section .private-note-editor {
  margin-bottom: 0.75rem;
}
.private-note-input {
  width: 100%;
  min-height: 4.5rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 0.25rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}
.private-note-input:focus {
  border-color: var(--accent-red);
  outline: none;
}
.private-note-editor-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.4rem;
}
.private-note-save-status {
  font-size: 0.75rem;
  transition: opacity 0.2s ease-in;
}
.private-note-save-status.is-saving {
  color: var(--text-secondary);
  font-style: italic;
}
.private-note-save-status.is-saved {
  color: var(--success);
  font-weight: 500;
}
.private-note-save-status.is-failed {
  color: var(--error);
  font-weight: 500;
}
.private-note-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.private-note-entry {
  padding: 0.5rem 0.7rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 0.25rem;
}
.private-note-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.private-note-ts {
  font-weight: 500;
}
.private-note-tag {
  display: inline-flex;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--border-primary);
  border-radius: 0.65rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.private-note-tag.is-current {
  border-color: var(--success);
  color: var(--success);
}
.private-note-tag.is-between {
  color: var(--text-muted);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
}
.private-note-body {
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Cross-session grouping (UC-1.18 — 2026-05-26). Each session group
   has its own header + chevron + collapsible body. Current session
   expanded by default; past sessions and between-session groups
   collapse by default. */
.private-note-groups {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.private-note-session-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.private-note-session-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.25rem 0.25rem 0.25rem 0;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-primary);
}
.private-note-session-header:hover {
  background: var(--bg-hover);
}
.private-note-session-header:focus-visible {
  outline: 2px solid var(--accent-red);
  outline-offset: 2px;
}
.private-note-session-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.private-note-session-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}
.private-note-session-chevron {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Collapsible section header (session 296 P1) — for sections that
   surrender chevron-toggle UI to their own header rather than the
   section-container wrapper. Used by Class Features today; pattern
   ready for any section that wants default-collapsed at-table reading.
   Reset native button styling, then style as a full-width header bar. */
.cs-section-collapsible-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0;
  margin: 0 0 0.5rem 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
  font: inherit;
  text-align: left;
}
.cs-section-title-text {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cs-section-collapse-count {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.cs-section-collapsible-header svg {
  margin-left: auto;
}
.cs-section-collapsible-header:hover .cs-section-title-text {
  color: var(--accent-red);
}

/* Unified Spells section (session 296) — slot pool + prepared/memorized
   spell chips in one display. Replaces the prior Spell Slots + Prepared
   Spells split. */
.spells-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.spells-level-group {
  padding: 0.4rem 0;
  border-top: 1px solid var(--border-primary);
}
.spells-level-group:first-of-type {
  border-top: none;
}
.spells-cantrips {
  /* Cantrips row is "at-will" and visually anchored above the leveled
     slot groups; the header treats it identically. */
}
.spells-level-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}
.spells-level-label {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.spells-level-slots {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.spells-level-use {
  margin-left: auto;
}
.spells-level-spells {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.15rem 0;
}
.spells-spell-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 0.85rem;
  font-size: 0.85rem;
  color: var(--text-primary);
}
/* Clickable chip — cantrip rows stay non-clickable (at-will, no slot
   consumption). Leveled spells become buttons that open the cast-confirm
   modal. Hover gives a clear "this does something" affordance. */
.spells-spell-chip--clickable {
  cursor: pointer;
  font: inherit;
}
.spells-spell-chip--clickable:hover:not(:disabled) {
  border-color: var(--accent-red);
}
.spells-spell-chip--clickable:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Cast-confirm modal — small panel with spell name, level/cost tags,
   description, and Cancel / Cast (danger) buttons. */
.cast-confirm-panel {
  max-width: 480px;
  width: 90vw;
}
.cast-confirm-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.cast-confirm-tag {
  display: inline-flex;
  padding: 0.15rem 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.cast-confirm-desc {
  margin-top: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.4;
}
.spells-spell-count {
  margin-left: 0.2rem;
  color: var(--text-secondary);
  font-weight: 600;
}
.spells-level-empty {
  padding: 0.15rem 0;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
}

/* Untrained skill rows show the parent attribute die code as default;
   muted text-color so trained skills pop visually (session 295). */
.cs-skill-row.cs-skill-default {
  opacity: 0.7;
}
.cs-skill-row.cs-skill-default .cs-skill-die {
  color: var(--text-muted);
}

.skill-group {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
}

.skill-group-locked {
  opacity: 0.6;
}

.skill-group-force {
  border-left: 3px solid var(--accent-purple);
}
.skill-group-force .skill-group-header {
  color: var(--accent-purple);
}

.skill-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-primary);
}

.skill-group-attr-code {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* =============================================================================
   Info Tip — inline contextual help icon with tooltip
   ============================================================================= */

.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 0.4rem;
  cursor: help;
}

.info-tip-icon {
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.15s;
}

.info-tip:hover .info-tip-icon {
  color: var(--info);
}

.info-tip-content {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 0.5rem);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: normal;
  line-height: 1.4;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.info-tip-content::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border-primary);
}

/* =============================================================================
   About This Page — collapsible help block
   ============================================================================= */

.about-this-page {
  margin-top: 2rem;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  background: var(--bg-primary);
}

.about-this-page-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: color 0.15s;
}

.about-this-page-header:hover {
  color: var(--text-secondary);
}

.about-this-page-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  border: 1px solid var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.about-this-page-title {
  flex: 1;
  font-weight: 500;
}

.about-this-page-toggle {
  font-size: 1rem;
  font-weight: 600;
}

.about-this-page-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border-primary);
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

.about-this-page-body p {
  margin: 0.75rem 0 0;
}

/* Section Help Text — inline contextual hint at the top of a section */
.section-help-text {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--border-primary);
}

/* =============================================================================
   Entity Import Wizard
   ============================================================================= */

.entity-import-wizard textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.entity-import-review {
  max-height: 400px;
  overflow-y: auto;
}

.entity-import-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-primary);
}

.entity-import-item:last-child {
  border-bottom: none;
}

.entity-import-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* =============================================================================
   Placeholder Page — centered empty state for stub/coming-soon pages
   ============================================================================= */

.placeholder-page {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.placeholder-page h2 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.placeholder-page p {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-style: italic;
}

/* =============================================================================
   Mobile Responsive — Shared Widgets
   ============================================================================= */

@media (max-width: 480px) {
  /* Image fields: responsive */
  .image-placeholder,
  .image-field {
    max-width: 100%;
  }

  /* Info tip: narrower on mobile */
  .info-tip-content {
    max-width: 220px;
    font-size: 0.75rem;
  }

  /* Dice roller: stack controls */
  .dice-roller-controls {
    flex-wrap: wrap;
  }

  .dice-roller-controls .form-field {
    flex: 1 1 100%;
  }

  .dice-result {
    padding: 1rem;
  }
}

/* =============================================================================
   Tier Badges — subscription tier indicators on features
   ============================================================================= */

.tier-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  margin-left: 0.4rem;
}

.tier-badge-gm {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success);
}

.tier-badge-designer {
  background: var(--accent-purple-bg);
  color: var(--accent-purple);
  border: 1px solid var(--accent-purple);
}

.tier-badge-addon {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid var(--info);
}

/* =============================================================================
   Account Deletion Section
   ============================================================================= */

.account-deletion-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-primary);
}

.account-deletion-section h3 {
  color: var(--error);
}

.deletion-details {
  margin-top: 1rem;
}

.deletion-summary {
  margin: 1rem 0;
}

.deletion-summary h4 {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.deletion-summary ul {
  list-style: disc;
  padding-left: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.deletion-summary li {
  margin-bottom: 0.25rem;
}

.deletion-confirm {
  margin-top: 1rem;
}

.deletion-confirm p {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.deletion-confirm input {
  max-width: 320px;
  margin-bottom: 0.75rem;
}

/* =============================================================================
   Table Roller — floating roll-or-select panel attached to form fields
   ============================================================================= */

/* The table-popup icon button inline with a label or field */
.table-roll-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
  color: var(--info);
  opacity: 0.55;
  transition: opacity 0.15s;
  vertical-align: middle;
  line-height: 1;
}

.table-roll-icon:hover {
  opacity: 1;
}

.table-roll-icon--disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

/* Fixed full-screen overlay (click outside = close) */
.table-roller-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The panel itself */
.table-roller-panel {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  padding: 1rem;
  max-width: 520px;
  width: 92%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* Header row */
.table-roller-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-primary);
  padding-bottom: 0.5rem;
}

.table-roller-title {
  margin: 0;
  flex: 1;
  font-size: 1rem;
  color: var(--text-primary);
}

.table-roller-die {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.table-roller-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  padding: 0 0.1rem;
  transition: color 0.15s;
}

.table-roller-close:hover {
  color: var(--text-primary);
}

/* Roll button row */
.table-roller-actions {
  margin-bottom: 0.75rem;
}

/* Rows container */
.table-roller-rows {
  margin-top: 0.5rem;
}

/* Individual row (random type) */
.table-roller-row {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.85rem;
}

.table-roller-row:hover {
  background: var(--bg-hover);
}

/* Matched row uses compound-class specificity (0,2,0) to beat
   `.table-roller-row:hover` instead of `!important`. The :hover variant is
   listed alongside so a hovered matched-row keeps its accent color. */
.table-roller-row.table-roller-row-matched,
.table-roller-row.table-roller-row-matched:hover {
  background: var(--accent-red-bg);
  border: 1px solid var(--accent-red);
}

.table-roller-row-range {
  color: var(--text-muted);
  font-size: 0.78rem;
  min-width: 2.5rem;
  flex-shrink: 0;
}

.table-roller-row-text {
  color: var(--text-primary);
}

/* d66 roll result display */
.table-roller-d66-result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background: var(--bg-secondary);
  border-radius: 4px;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.table-roller-die-values {
  color: var(--text-secondary);
}

.table-roller-result-value {
  color: var(--accent-red);
  font-weight: 600;
}

/* d66 grid layout */
.table-roller-d66-grid {
  overflow-x: auto;
}

.table-roller-d66-header,
.table-roller-d66-row {
  display: flex;
}

.table-roller-d66-cell {
  flex: 1;
  min-width: 5rem;
  max-width: 9rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border-primary);
  font-size: 0.75rem;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.12s;
  word-break: break-word;
}

.table-roller-d66-cell:hover {
  background: var(--bg-hover);
}

.table-roller-d66-corner {
  cursor: default;
  background: var(--bg-secondary);
}

.table-roller-d66-col-head,
.table-roller-d66-row-head {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: default;
}

.table-roller-d66-highlight {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.table-roller-d66-highlight-row {
  background: rgba(230, 57, 70, 0.06);
}

.table-roller-d66-highlight-col {
  background: rgba(230, 57, 70, 0.06);
}

/* Compound-class specificity (0,2,0) beats .table-roller-d66-cell:hover. */
.table-roller-d66-cell.table-roller-d66-active,
.table-roller-d66-cell.table-roller-d66-active:hover {
  background: var(--accent-red-bg);
  border-color: var(--accent-red);
  font-weight: 600;
}

/* Mobile: narrower panel, smaller cells */
@media (max-width: 480px) {
  .table-roller-panel {
    max-width: 98%;
    padding: 0.75rem;
  }

  .table-roller-d66-cell {
    min-width: 3.5rem;
    font-size: 0.7rem;
    padding: 0.2rem 0.25rem;
  }
}

/* =============================================================================
   Scope Filter / Custom Fields / Accordion
   ============================================================================= */

/* Scope filter bar */
.scope-filter-bar { margin-bottom: 1rem; }

/* Custom Fields — wrapper for section heading */
.custom-fields-wrapper { margin-top: 0.75rem; }
.custom-fields-heading { margin: 0 0 0.25rem; }

/* Custom Fields — generic editor for entity :content :custom-fields */
.custom-fields-section { margin-top: 0.5rem; }
.custom-fields-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }
.custom-field-row {
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  padding: 0.5rem;
  background: var(--bg-secondary);
}
.custom-field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.custom-field-label button { font-size: 0.7rem; padding: 0 0.3rem; line-height: 1.2; }
.custom-field-value input,
.custom-field-value textarea,
.custom-field-value select { width: 100%; }
.custom-field-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.custom-field-checkbox input { width: auto; }
.custom-field-add {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}
.custom-field-add input { flex: 1; min-width: 0; }
.custom-field-add select { width: auto; }

/* Custom Fields — read-only display */
.custom-fields-display { margin-top: 0.5rem; }
.custom-field-display-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-primary);
}
.custom-field-display-row:last-child { border-bottom: none; }
.custom-field-display-label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 120px;
  flex-shrink: 0;
}
.custom-field-display-value { color: var(--text-primary); flex: 1; }

/* Accordion List — collapsible items with search filter */
.accordion-list { }
.accordion-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}
.accordion-search {
  flex: 1;
  min-width: 0;
}
.accordion-buttons {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}
.accordion-item {
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.accordion-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  background: var(--bg-secondary);
  user-select: none;
}
.accordion-header:hover { background: var(--bg-hover); }
.accordion-arrow {
  width: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.65rem;
  flex-shrink: 0;
}
.accordion-title {
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}
.accordion-body {
  padding: 0.75rem;
  border-top: 1px solid var(--border-primary);
}

@media (max-width: 480px) {
  .accordion-controls { flex-wrap: wrap; }
  .accordion-search { min-width: 100%; }
  .accordion-buttons { width: 100%; justify-content: flex-end; }
}

/* =============================================================================
   Utility Classes
   ============================================================================= */

/* Utility: pointer cursor for clickable non-button elements */
.clickable {
  cursor: pointer;
}

/* Inline form row: flex row with gap for inputs + button combos */
.inline-form-row {
  display: flex;
  gap: 0.5rem;
}

/* Form field with top spacing */
.form-field.spaced {
  margin-top: 1rem;
}

/* Section divider with standard border color */
hr.section-divider {
  border-color: var(--border-primary);
  margin: 1.5rem 0;
}

/* Text muted with no top margin */
.text-muted.no-margin {
  margin-top: 0;
}
