/* ============================================================
   static/theme.css  —  activities2-style design system for RPG Enabler
   ADDITIVE: loaded alongside the existing styles.css during
   migration. Screens are converted onto these tokens/components
   one at a time; the old styles.css is removed at the end.
   ============================================================ */

/* === ROOT TOKENS (light) === */
:root {
  color-scheme: light;

  /* Banner / brand (theme-stable) */
  --bg: #0f172a;
  --fg: #fff;
  --subbg: #111827;
  --link: #93c5fd;

  /* Action colors */
  --primary: #3b82f6;
  --primary-strong: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --secondary: #f3f4f6;

  /* Surfaces */
  --surface: #fff;
  --surface-alt: #f9fafb;
  --surface-inset: #f3f4f6;
  --surface-header: #111827;
  --highlight: #f0f4ff;
  --overlay: rgba(15, 23, 42, 0.45);

  /* Text */
  --text: #111;
  --text-soft: #374151;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  /* Borders */
  --border: #e5e7eb;
  --border-soft: #f3f4f6;
  --border-input: #d1d5db;

  /* Informational tints */
  --tint-info-bg: #eff6ff;
  --tint-info-border: #93c5fd;
  --tint-info-fg: #1d4ed8;
  --tint-info-fg-strong: #1e40af;
  --tint-warn-bg: #fffbeb;
  --tint-warn-border: #fde68a;
  --tint-warn-fg: #92400e;
  --tint-danger-bg: #fef2f2;
  --tint-danger-border: #fecaca;
  --tint-danger-fg: #991b1b;
  --tint-danger-fg-strong: #7f1d1d;

  /* Badges */
  --badge-green-bg: #dcfce7;
  --badge-green-fg: #15803d;
  --badge-blue-bg: #dbeafe;
  --badge-blue-fg: #1d4ed8;
  --badge-orange-bg: #ffedd5;
  --badge-orange-fg: #c2410c;
  --badge-purple-bg: #ede9fe;
  --badge-purple-fg: #6d28d9;

  /* Count pill */
  --count-badge-bg: #111827;
  --count-badge-fg: #fff;
}

/* === Dark theme — applied via data-theme on <html> === */
:root[data-theme="dark"] {
  color-scheme: dark;

  --link: #93c5fd;

  --primary: #60a5fa;
  --primary-strong: #3b82f6;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --secondary: #374151;

  --surface: #111827;
  --surface-alt: #1f2937;
  --surface-inset: #374151;
  --surface-header: #030712;
  --highlight: #1f2d47;
  --overlay: rgba(0, 0, 0, 0.6);

  --text: #f3f4f6;
  --text-soft: #d1d5db;
  --text-muted: #9ca3af;
  --text-faint: #6b7280;

  --border: #374151;
  --border-soft: #1f2937;
  --border-input: #4b5563;

  --tint-info-bg: #172554;
  --tint-info-border: #1e40af;
  --tint-info-fg: #93c5fd;
  --tint-info-fg-strong: #bfdbfe;
  --tint-warn-bg: #451a03;
  --tint-warn-border: #92400e;
  --tint-warn-fg: #fcd34d;
  --tint-danger-bg: #450a0a;
  --tint-danger-border: #7f1d1d;
  --tint-danger-fg: #fca5a5;
  --tint-danger-fg-strong: #fecaca;

  --badge-green-bg: #14532d;
  --badge-green-fg: #86efac;
  --badge-blue-bg: #1e3a8a;
  --badge-blue-fg: #93c5fd;
  --badge-orange-bg: #7c2d12;
  --badge-orange-fg: #fdba74;
  --badge-purple-bg: #4c1d95;
  --badge-purple-fg: #c4b5fd;

  --count-badge-bg: #374151;
  --count-badge-fg: #f3f4f6;
}

/* ============================================================
   BANNER & WELCOME CHROME
   The dashboard is now converted, so theme.css takes over the
   page background via tokens (white in light, midnight in dark),
   replacing the old teal body background from styles.css.
   ============================================================ */

body {
  background: var(--surface);
  color: var(--text);
}

.banner {
  position: relative;
  background: var(--bg);
  color: var(--fg);
  padding: 18px 20px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
}

.welcome {
  background: var(--subbg);
  color: var(--fg);
  padding: 10px 16px;
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.welcome a {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
}

.welcome a:hover {
  text-decoration: underline;
}

.welcome-nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* Theme toggle button in the banner */
.theme-toggle {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--fg);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

@media (pointer: coarse) {
  .theme-toggle {
    width: 42px;
    height: 42px;
  }
}

/* ============================================================
   TOAST NOTIFICATIONS  (floating flash messages)
   ============================================================ */

#toast-wrap {
  position: fixed;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 520px;
  background: #111;
  color: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  animation: toast-in 0.18s ease-out;
}

.toast.success { background: #065f46; }
.toast.info    { background: #1e40af; }
.toast.warning { background: #92400e; }
.toast.error   { background: #991b1b; }
/* Map common Flask flash categories to toast colours */
.toast.message { background: #1e40af; }
.toast.danger  { background: #991b1b; }

.toast .close {
  margin-left: auto;
  opacity: 0.8;
  cursor: pointer;
}

.toast .close:hover { opacity: 1; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -40%) scale(0.98); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ============================================================
   CORE COMPONENTS  (available for screens as they convert)
   ============================================================ */

/* Buttons */
.btn {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid;
  text-decoration: none;
  display: inline-block;
  font-weight: 600;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary-strong); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-success { background: var(--success); color: #fff; border-color: #0ea5a0; }
.btn-success:hover { background: #0ea5a0; }
.btn-warning { background: var(--warning); color: #111; border-color: #d97706; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--surface-inset); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

.btn-row { display: flex; gap: 8px; justify-content: flex-end; }

/* Icon buttons */
.btn-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; line-height: 1;
  color: #fff; cursor: pointer; text-decoration: none;
}
.btn-icon:hover { filter: brightness(0.90); }
.btn-icon.btn-green { background: var(--success); border-color: #0ea5a0; }
.btn-icon.btn-blue  { background: var(--primary); border-color: var(--primary-strong); }
.btn-icon.btn-red   { background: var(--danger); border-color: #dc2626; }

/* Forms */
.form-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; display: block; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px;
  border: 1px solid var(--border-input); border-radius: 6px;
  font-family: inherit; background: var(--surface); color: var(--text);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-grid { display: grid; gap: 14px; max-width: 780px; }
.form-inline { display: flex; gap: 8px; align-items: center; }
.form-checkbox-label { display: flex; align-items: center; gap: 6px; }

/* Filter bar */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field select, .filter-field input {
  padding: 6px; border: 1px solid var(--border-input); border-radius: 6px;
  background: var(--surface); color: var(--text);
}
.filter-actions { display: flex; gap: 8px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead tr { text-align: left; border-bottom: 1px solid var(--border); }
.data-table thead th { padding: 8px 6px; font-weight: 600; }
.data-table tbody tr { border-bottom: 1px solid var(--border-soft); }
.data-table tbody td { padding: 8px 6px; }
/* Preserve newlines authored in trait descriptions (DB text column). */
.data-table td.trait-desc { white-space: pre-line; }
.table-container { overflow-x: auto; }

/* Cards */
.card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); color: var(--text); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-title { font-weight: 800; font-size: 18px; }
.card-meta { font-size: 12px; color: var(--text-muted); }

/* Alerts */
.alert { margin: 10px 0; padding: 10px; border: 1px solid; border-radius: 8px; }
.alert-warning { border-color: var(--tint-warn-border); background: var(--tint-warn-bg); color: var(--tint-warn-fg); }
.alert-info { border-color: var(--tint-info-border); background: var(--tint-info-bg); color: var(--tint-info-fg-strong); }
.alert-danger { border-color: var(--tint-danger-border); background: var(--tint-danger-bg); color: var(--tint-danger-fg); }

/* Danger zone */
.danger-zone { border: 1px solid var(--tint-danger-border); background: var(--tint-danger-bg); border-radius: 8px; padding: 12px; margin-top: 16px; }
.danger-zone-title { font-weight: 700; color: var(--tint-danger-fg); margin-bottom: 6px; }
.danger-zone-text { margin: 0 0 10px; color: var(--tint-danger-fg-strong); }

/* Tabs */
.tabs {
  border-bottom: 1px solid var(--border);
  display: flex; gap: 16px; margin-bottom: 16px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; white-space: nowrap;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 8px 0; text-decoration: none; color: var(--text-muted); flex-shrink: 0; }
.tab.active { color: var(--text); border-bottom: 3px solid var(--primary-strong); font-weight: 600; }

/* Chips / badges */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.chip { background: var(--surface-inset); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--text); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 8px; background: var(--count-badge-bg); color: var(--count-badge-fg); font-weight: 700; border-radius: 9999px; font-size: 14px; }
.badge-green { background: var(--badge-green-bg); color: var(--badge-green-fg); }
.badge-blue { background: var(--badge-blue-bg); color: var(--badge-blue-fg); }
.badge-orange { background: var(--badge-orange-bg); color: var(--badge-orange-fg); }
.badge-purple { background: var(--badge-purple-bg); color: var(--badge-purple-fg); }

/* ============================================================
   RESPONSIVE / MOBILE
   ============================================================ */

@media (pointer: coarse) {
  .btn-icon { width: 42px; height: 42px; }
  .btn-row { gap: 10px; }
  .tab { padding: 12px 0; }
  .form-select, .form-input, .filter-field select, .filter-field input { min-height: 42px; }
}

@media (max-width: 640px) {
  .filter-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .filter-field select, .filter-field input {
    width: 100%; min-width: 0; box-sizing: border-box;
  }

  /* Table → stacked cards. Tag a table .responsive-cards and give
     each <td> a data-label attribute for the row heading. */
  .responsive-cards thead { display: none; }
  .responsive-cards, .responsive-cards tbody { display: block; width: 100%; }
  .responsive-cards tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }
  .responsive-cards tbody td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 3px 0; border: none;
  }
  .responsive-cards tbody td::before {
    content: attr(data-label);
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.03em; color: var(--text-faint); flex-shrink: 0;
  }
  .responsive-cards tbody td.cell-title {
    display: block; font-size: 1.05rem; font-weight: 600; padding: 2px 0 6px;
  }
  .responsive-cards tbody td.cell-title::before { content: none; }
  .responsive-cards tbody td.cell-actions {
    display: block; border-top: 1px solid var(--border-soft);
    margin-top: 8px; padding-top: 8px;
  }
  .responsive-cards tbody td.cell-actions::before { content: none; }
  .responsive-cards tbody td.cell-actions .btn-row { justify-content: flex-end; }

  .card { width: 100%; box-sizing: border-box; }
}


/* ============================================================
   DASHBOARD-SPECIFIC COMPONENTS (converted from styles.css)
   ============================================================ */

/* Dashboard layout: single column of cards with breathing room */
.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1000px;
  margin: 0 auto;
}

/* ── Dice Roller ── */
/* Override the cream (#FFFDD0) background the old styles.css sets on
   #dice-form and .total-box, which read as yellow and don't dark-mode. */
#dice-form,
#dice-container {
  background: transparent;
  margin-top: 0;
}
.dice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  margin-bottom: 0;
  flex-wrap: wrap;
  background: transparent;
  border-bottom: 1px solid var(--border-soft);
}
.dice-row:last-child { border-bottom: none; }
.dice-label {
  font-weight: 700;
  min-width: 42px;
  color: var(--text);
}
.dice-select { width: auto; min-width: 64px; }
.result-box {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
  color: var(--text-soft);
}
.dice-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
}
.total-box {
  font-weight: 700;
  color: var(--text);
  background: transparent;
}

/* ── Initiative Tracker ── */
.panel-titles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.panel-titles h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-soft);
}
.initiative-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  padding: 10px;
  min-height: 120px;
}
.panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.panel li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.panel li.placeholder {
  border-style: dashed;
  color: var(--text-faint);
  background: transparent;
  justify-content: center;
}
.panel-footer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ── Modal (add NPC / others) ──
   The old styles.css styled .modal itself as a small centered white box
   (width:400px; left/top:50%; transform). This theme uses the overlay +
   .modal-content pattern instead, so every one of those old properties
   must be explicitly reset here or the box renders mispositioned. */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform: none;
  background: var(--overlay);
  border-radius: 0;
  box-shadow: none;
  padding: 16px;
  z-index: 1000;
  overflow-y: auto;
}
/* JS opens the modal via inline style="display:block". Center the
   content with margin so it works whether display is block or flex. */
.modal-content {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  width: 480px;
  max-width: 94vw;
  margin: 6vh auto;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.modal-content h3 { margin-top: 0; }
.modal-content .form-input,
.modal-content .form-textarea { margin-bottom: 8px; }
.modal-content .form-textarea { min-height: 3em; resize: vertical; }
.close-modal {
  float: right;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}
.close-modal:hover { color: var(--text); }

/* NPC table: keep it scrollable on desktop, cards on mobile */
.npc-table-wrapper { margin-top: 8px; }

/* ============================================================
   CHARACTER CARD — re-themed onto tokens (full rebuild)
   Overrides the burgundy .cc-* rules from styles.css so the
   cards dark-mode correctly.
   ============================================================ */
.cc-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  margin-bottom: 12px;
}
.cc-editable:hover { border-bottom-color: var(--primary); background: var(--highlight); }
.cc-inline-input { border: 1px solid var(--primary); background: var(--surface); color: var(--text); }

.cc-effect { background: var(--surface-alt); border-color: var(--border); }
.cc-effect-score { color: var(--primary); }

.cc-pip { border-color: var(--primary); }
.cc-pip-filled { background: var(--primary); }
.cc-pip-btn { background: var(--primary); color: #fff; }
.cc-pip-btn:hover { background: var(--primary-strong); }
.cc-pip-btn:disabled { background: var(--border); }

.cc-linkbtn { color: var(--primary); }
.cc-linkbtn:hover { color: var(--primary-strong); }
.cc-danger { color: var(--danger); }

.cc-trait-score { color: var(--primary); }
.cc-trait-score:hover { border-bottom-color: var(--primary); background: var(--highlight); }
.cc-unassigned { color: var(--warning); }

.cc-modal-box {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}


/* ============================================================
   UI UPDATES BATCH — tabs, layout balance, description label,
   initiative alignment, NPC mobile fix
   ============================================================ */

/* Page title above tabs (Dashboard) */
.page-title {
  margin: 0 0 12px 0;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}

/* --- Dashboard tab panels (client-side show/hide) --- */
.tab-panel { display: none; }
.tab-panel.active { display: block; }
#dashboard-tabs .tab { cursor: pointer; }

/* --- Character card layout balance --- */
/* Give the card a sensible max width and lay stats/traits to use the
   horizontal space instead of hugging the left edge. */
.cc-card {
  max-width: 860px;
}
.cc-header {
  margin-bottom: 10px;
}
.cc-desc-wrap {
  margin-top: 6px;
}
.cc-field-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  margin-bottom: 2px;
}
.cc-desc {
  margin: 0;
  min-height: 1.2em;
}
.cc-desc-empty {
  color: var(--text-faint);
  font-style: italic;
}
/* Stats + traits stretch to fill the card width */
.cc-stat-table,
.cc-trait-table {
  width: 100%;
}
.cc-stat-table td,
.cc-stat-table th {
  text-align: center;
}
/* On wider screens, place stats and traits side by side to balance
   the empty right-hand space. */
@media (min-width: 720px) {
  .cc-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
}

/* --- Initiative: right-align the delete icon in the creatures panel
   to match the initiative-order panel. --- */
#creatures-list li,
#initiative-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}
#creatures-list li .remove-btn,
#initiative-list li .remove-btn {
  margin-left: auto;
}
#initiative-list li .initiative-name {
  flex-grow: 1;
}

/* ============================================================
   NPC REGISTRY — ALWAYS CARDS (not a wide scrolling table)
   The registry has 11 prose-heavy columns that never fit
   comfortably as a table, so every row renders as a stacked
   card at all viewport widths — the same treatment other
   tables use only under .responsive-cards on mobile.

   The NPC script in base.html already emits data-label on every
   <td> and cell-title on the First Name cell, so no markup or JS
   changes are needed: this is purely presentational.
   ============================================================ */

/* Drop the tabular display; header row is redundant once labels
   live on each cell. */
.npc-detailed-table thead { display: none; }
.npc-detailed-table,
.npc-detailed-table tbody { display: block; width: 100%; }

/* Each NPC row becomes a card. */
.npc-detailed-table tbody tr {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Each field stacks: small uppercase label above its value.
   pre-wrap preserves the line breaks authored into prose fields. */
.npc-detailed-table tbody td {
  display: block;
  width: auto;
  padding: 4px 0;
  border: none;
  color: var(--text);
  white-space: pre-wrap;
}
.npc-detailed-table tbody td::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
}
/* Blank fields still render (label + empty value) so they can be
   clicked to edit; min-height gives the empty value a click target. */
.npc-detailed-table tbody td[data-label]:not(.cell-title) { min-height: 2.2em; }
/* Empty-state / error rows have no data-label — render them plainly. */
.npc-detailed-table tbody td:not([data-label])::before { content: none; }

/* First Name keeps its "First Name" label (from the rule above) but
   renders its value larger/bolder as the card's headline field. */
.npc-detailed-table tbody td.cell-title {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 2px 0 8px;
}
/* The NPC table also carries .responsive-cards, whose mobile rule
   suppresses the title label; re-assert it here for all widths. */
.npc-detailed-table tbody td.cell-title::before { content: attr(data-label); }

/* On wider screens, flow the cards into a responsive grid so desktop
   space isn't wasted on a single tall column. */
@media (min-width: 900px) {
  #npc-table-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 12px;
    align-items: start;
  }
  .npc-detailed-table tbody tr { margin-bottom: 0; }
  /* Empty-state / error message spans the full width of the grid. */
  .npc-detailed-table tbody tr:has(td[colspan]) { grid-column: 1 / -1; }
}
