/* Combat simulator: design tokens + components.
   Theme: light/dark via color-scheme + light-dark(); [data-theme] overrides the OS. */

:root {
  color-scheme: light dark;

  /* Brand */
  --hope: light-dark(#b08f1c, #e7c74b);
  --hope-soft: light-dark(rgba(176, 143, 28, 0.12), rgba(231, 199, 75, 0.16));
  --fear: light-dark(#6a57c9, #9d8ff0);
  --fear-soft: light-dark(rgba(106, 87, 201, 0.10), rgba(157, 143, 240, 0.16));

  /* Chart series (validated: lightness band, CVD, contrast) */
  --series-players: light-dark(#b08f1c, #b08f1c);
  --series-enemies: light-dark(#6a57c9, #7f70d8);
  --series-other: light-dark(#9aa0a8, #6b7280);

  /* Surfaces and ink */
  --bg: light-dark(#f6f6f8, #0f1014);
  --surface: light-dark(#ffffff, #17181d);
  --surface-2: light-dark(#f1f1f4, #1f2027);
  --surface-3: light-dark(#e8e8ed, #272830);
  --border: light-dark(#e2e3e8, #2a2b33);
  --border-strong: light-dark(#c8cad2, #3a3b45);
  --text: light-dark(#17181c, #ececf0);
  --text-2: light-dark(#4b4e57, #b4b7c0);
  --text-muted: light-dark(#7a7e88, #858892);

  /* Status */
  --success: light-dark(#1f8a4c, #4cc277);
  --success-soft: light-dark(rgba(31, 138, 76, 0.10), rgba(76, 194, 119, 0.14));
  --danger: light-dark(#c8382f, #ef6b63);
  --danger-soft: light-dark(rgba(200, 56, 47, 0.10), rgba(239, 107, 99, 0.14));
  --info: light-dark(#2563eb, #7aa2ff);

  /* Scales */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 14px;
  --radius-pill: 999px;

  --text-xs: 0.75rem;
  --text-s: 0.8125rem;
  --text-m: 0.9375rem;
  --text-l: 1.125rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;

  --shadow-1: light-dark(0 1px 2px rgba(16, 17, 20, 0.06), 0 1px 2px rgba(0, 0, 0, 0.5));
  --shadow-2: light-dark(0 8px 24px rgba(16, 17, 20, 0.08), 0 8px 24px rgba(0, 0, 0, 0.5));
  --focus: 0 0 0 3px light-dark(rgba(106, 87, 201, 0.30), rgba(157, 143, 240, 0.40));

  --font: "Inter", "SF Pro Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --toolbar-h: 56px;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* Reset */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-m);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, p { margin: 0; }
h1, h2, h3, h4, h5 { line-height: 1.25; letter-spacing: -0.01em; }
h2 { font-size: var(--text-xl); font-weight: 650; }
h3 { font-size: var(--text-l); font-weight: 600; }
h4 { font-size: var(--text-m); font-weight: 600; }
h5 { font-size: var(--text-s); font-weight: 600; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

:focus-visible { outline: none; box-shadow: var(--focus); }

/* App shell */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  height: var(--toolbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  min-width: 0;
}

.brand-mark {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--hope) 50%, var(--fear) 50%);
  transform: rotate(45deg);
  align-self: center;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: var(--text-l);
  font-weight: 650;
  white-space: nowrap;
}

.brand-meta {
  font-size: var(--text-s);
  color: var(--text-muted);
  white-space: nowrap;
}

.header-actions { display: flex; align-items: center; gap: var(--space-2); }

.app-main {
  flex: 1;
  width: 100%;
  min-width: 0;
}

.app-footer {
  padding: var(--space-4) var(--space-5);
  color: var(--text-muted);
  font-size: var(--text-s);
  border-top: 1px solid var(--border);
  text-align: center;
}

.app-footer p + p { margin-top: var(--space-2); font-size: var(--text-xs); }
.app-footer a { color: inherit; }

/* Help overlay */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: var(--space-6) var(--space-4);
  overflow: auto;
  background: rgba(10, 11, 14, 0.55);
}

.help-overlay:focus-visible { box-shadow: none; }

.help-card {
  width: 100%;
  max-width: 720px;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-2);
}

.help-card h3 { margin: var(--space-5) 0 var(--space-2); }
.help-card ol, .help-card ul { margin: 0; padding-left: var(--space-5); }
.help-card li { margin-bottom: var(--space-2); color: var(--text-2); }
.help-card li strong { color: var(--text); }
.help-lead { margin-bottom: var(--space-4); color: var(--text-2); }
.help-card p + ul { margin-top: var(--space-2); }

/* Toolbar: tabs + run controls */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border-radius: var(--radius-m);
  overflow-x: auto;
  max-width: 100%;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.4rem 0.9rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-s);
  color: var(--text-2);
  font-size: var(--text-s);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tab.active .tab-count { background: var(--hope-soft); color: var(--hope); }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--text-s);
  white-space: nowrap;
}

.status-chip.running::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hope);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

/* Workspace: builder, optionally with a results panel beside it */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  padding: var(--space-5);
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.workspace.has-results { max-width: 1680px; }

@media (min-width: 1280px) {
  .workspace.has-results { grid-template-columns: minmax(0, 6fr) minmax(0, 7fr); }

  .workspace.has-results .results-panel {
    position: sticky;
    top: calc(var(--toolbar-h) + var(--space-3));
    align-self: start;
    max-height: calc(100vh - var(--toolbar-h) - var(--space-5));
    overflow: auto;
  }
}

.builder { min-width: 0; }

.error-message {
  color: var(--danger);
  padding: var(--space-3) var(--space-4);
  background: var(--danger-soft);
  border-radius: var(--radius-s);
  margin: 0 auto var(--space-4);
  font-size: var(--text-s);
}

/* Cards */
.tab-content,
.results-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: var(--space-5);
  min-width: 0;
}

.tab-content > h2 { margin-bottom: var(--space-4); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 1rem;
  font-size: var(--text-s);
  font-weight: 500;
  line-height: 1.2;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-muted); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--hope);
  border-color: var(--hope);
  color: light-dark(#ffffff, #1b1500);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: light-dark(#9a7c16, #f0d35f);
  border-color: light-dark(#9a7c16, #f0d35f);
}

.btn-secondary {
  background: var(--fear-soft);
  border-color: transparent;
  color: var(--fear);
}

.btn-secondary:hover:not(:disabled) { background: var(--fear-soft); border-color: var(--fear); }

.btn-danger {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: transparent; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }

.btn-small { padding: 0.3rem 0.65rem; font-size: var(--text-xs); }

/* Forms */
.form-group { margin-bottom: var(--space-3); min-width: 0; }

.form-group label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 500;
  font-size: var(--text-xs);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font-size: var(--text-s);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover { border-color: var(--text-muted); }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--fear);
  box-shadow: var(--focus);
}

.form-group textarea { font-family: var(--mono); font-size: var(--text-xs); }

.form-group input[type="number"] { max-width: 120px; font-variant-numeric: tabular-nums; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.form-group.has-error input,
.form-group.has-error select { border-color: var(--danger); }

.validation-error {
  display: block;
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: var(--space-1);
  font-weight: 500;
}

.validation-info {
  font-size: var(--text-s);
  color: var(--success);
  margin-top: var(--space-1);
}

.form-help,
.form-hint {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-section {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}

.form-section:first-child { padding-top: 0; }
.form-section:last-child { border-bottom: none; padding-bottom: 0; }

.form-section h3 { margin-bottom: var(--space-3); }

.form-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.35rem 0.5rem;
  margin: 0 -0.5rem;
  cursor: pointer;
  border-radius: var(--radius-s);
  font-size: var(--text-s);
}

.checkbox-label:hover { background: var(--surface-2); }

/* Checkbox labels read as sentences, not field captions */
.form-group label.checkbox-label {
  display: flex;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: var(--text-s);
  color: var(--text);
  margin-bottom: 0;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--fear);
}

.summon-pool-picker {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: var(--space-2);
  background: var(--surface);
}

.summon-controls {
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--surface-2);
  border-radius: var(--radius-s);
}

.summon-controls h5 { margin-bottom: var(--space-2); }

.empty-pool,
.empty-state,
.empty-abilities {
  color: var(--text-muted);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  font-size: var(--text-s);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-m);
}

.empty-pool { padding: var(--space-3); border: none; }

/* Lists */
.combatant-list,
.adversary-list { min-width: 0; }

.list-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.list-header h3 { flex: 1; }

.combatant-items,
.adversary-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.combatant-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  transition: border-color 0.15s;
}

.combatant-item:hover { border-color: var(--border-strong); }

.combatant-info,
.adversary-info { flex: 1; min-width: 0; }

.item-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  margin-bottom: var(--space-1);
  flex-wrap: wrap;
}

.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); }

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.chip-label {
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.65rem;
}

.tag {
  display: inline-flex;
  padding: 0.05rem 0.45rem;
  border-radius: var(--radius-s);
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--fear-soft);
  color: var(--fear);
}

.tag-muted { background: var(--surface-3); color: var(--text-2); }
.tag-modelled { background: var(--success-soft); color: var(--success); }

.item-actions { display: flex; gap: var(--space-1); flex-shrink: 0; }

/* Add / import forms */
.add-form {
  background: var(--surface-2);
  padding: var(--space-4);
  border-radius: var(--radius-m);
  margin-bottom: var(--space-4);
  border: 1px solid var(--border);
}

.add-form h4 { margin-bottom: var(--space-3); }

.add-form > p { font-size: var(--text-s); color: var(--text-2); margin-bottom: var(--space-3); }

/* Adversary library picker */
.library-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.library-filters {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--space-2);
}

.library-filters input,
.library-filters select {
  padding: 0.4rem 0.6rem;
  font-size: var(--text-s);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
}

.library-filters input { flex: 1; min-width: 180px; }

.tabs-compact { background: var(--surface-3); }
.tabs-compact .tab { padding: 0.3rem 0.6rem; font-size: var(--text-xs); }

.library-count { font-size: var(--text-xs); color: var(--text-muted); margin-bottom: var(--space-2); }

.library-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-height: 440px;
  overflow: auto;
  padding-right: 2px;
}

.library-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
}

.library-row:hover { border-color: var(--border-strong); }

.library-main { flex: 1; min-width: 0; }

.library-filters .checkbox-label { margin: 0; white-space: nowrap; }
.library-filters .checkbox-label input { flex: none; min-width: 0; }

.btn.active { background: var(--surface-3); border-color: var(--text-muted); }

/* Strategy settings */
.strategy-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
}

.strategy-column h4 { margin-bottom: var(--space-2); }

/* Results */
.results-overview,
.results-statistics,
.results-chart { margin-bottom: var(--space-5); }

.results-overview h3,
.results-statistics h3,
.results-chart h3,
.combat-log-header h3 {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-2);
}

.stat-card {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-m);
  background: var(--surface-2);
  border-left: 3px solid var(--border-strong);
  min-width: 0;
}

.stat-card.stat-success { border-left-color: var(--series-players); }
.stat-card.stat-danger { border-left-color: var(--series-enemies); }

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
  font-weight: 500;
}

.stat-value {
  font-size: var(--text-xl);
  font-weight: 650;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat-sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

/* Stacked win-rate bar */
.stacked-bar {
  display: flex;
  gap: 2px;
  height: 14px;
  border-radius: var(--radius-s);
  overflow: hidden;
  background: var(--surface-3);
}

.stacked-seg { height: 100%; transition: width 0.3s ease; }
.seg-players { background: var(--series-players); }
.seg-enemies { background: var(--series-enemies); }
.seg-other { background: var(--series-other); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-2);
  font-size: var(--text-s);
  color: var(--text-2);
}

.legend-item { display: inline-flex; align-items: center; gap: var(--space-2); }

.legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

.legend-value { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Combat log: its own full-width card under the workspace */
.log-panel {
  margin: 0 var(--space-5) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: var(--space-5);
  min-width: 0;
}

.combat-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.combat-log-header h2 { margin-bottom: 0; }

.log-controls { display: flex; gap: var(--space-1); align-items: center; flex-wrap: wrap; }

.run-indicator {
  padding: 0.3rem 0.7rem;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.log-info {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
  font-size: var(--text-s);
  color: var(--text-2);
}

.outcome-player-win { color: var(--series-players); font-weight: 600; }
.outcome-enemy-win { color: var(--series-enemies); font-weight: 600; }
.outcome-draw { color: var(--text-muted); font-weight: 600; }

.log-table {
  overflow: auto;
  max-height: 80vh;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
}

.log-row {
  display: grid;
  grid-template-columns: 56px 176px 150px 176px minmax(200px, 1fr) minmax(280px, 1.7fr) minmax(220px, 1.2fr) 160px;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-xs);
  /* The columns' own minimums plus gaps and padding: narrower than this and cells would spill past the row's background */
  min-width: calc(56px + 176px + 150px + 176px + 200px + 280px + 220px + 160px + 7 * var(--space-2) + 2 * var(--space-3));
  align-items: start;
}

.log-row:last-child { border-bottom: none; }

.log-row.log-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.65rem;
}

.log-row:not(.log-header):hover { background: var(--surface-2); }

.log-row-critical { background: var(--hope-soft); box-shadow: inset 3px 0 0 var(--hope); }
.log-row-feature { background: var(--fear-soft); box-shadow: inset 3px 0 0 var(--fear); }

.log-col-turn { white-space: nowrap; }
.log-col-pools .log-state { white-space: normal; }

.log-col-turn { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.log-col-actor { font-weight: 500; }

.log-col-actor,
.log-col-target,
.log-col-action,
.log-col-dice,
.log-col-damage,
.log-col-result { white-space: normal; overflow-wrap: break-word; line-height: 1.4; }

.log-damage-roll,
.log-note { display: block; }
.log-damage-marked { font-weight: 700; }
.log-severity { color: var(--text-2); font-weight: 400; }

.log-state {
  display: block;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-muted);
}

.log-col-result { color: var(--text-2); }

.log-col-dice,
.log-col-pools { font-family: var(--mono); font-size: 0.7rem; }

.dice-hope { color: var(--hope); }
.dice-fear { color: var(--fear); }
.dice-winner { font-weight: 700; text-decoration: underline; }

.log-col-damage { font-weight: 500; color: var(--danger); font-variant-numeric: tabular-nums; }

/* Accordion */
.accordion-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  margin-bottom: var(--space-2);
  user-select: none;
  transition: border-color 0.15s;
}

.accordion-header:hover { border-color: var(--border-strong); }

.accordion-header h5 { font-size: var(--text-s); }

.accordion-indicator {
  transition: transform 0.15s;
  font-size: 0.6rem;
  color: var(--text-muted);
}

.accordion-indicator.open { transform: rotate(90deg); }

.accordion-body { padding: var(--space-1) 0 var(--space-3); }

.form-subsection {
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
}

.form-subsection h5 {
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ability-add-form {
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  margin-top: var(--space-3);
}

.ability-add-form h4 { margin-bottom: var(--space-3); }

.ability-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.ability-list { display: flex; flex-direction: column; gap: var(--space-1); }

.ability-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  font-size: var(--text-s);
  background: var(--surface);
}

.ability-item:hover { border-color: var(--border-strong); }

.ability-info { min-width: 0; }

.ability-effect,
.ability-desc { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

.ability-item.editing,
.combatant-item.editing { border-color: var(--fear); background: var(--fear-soft); }

/* Responsive */
@media (max-width: 768px) {
  .app-header { padding: 0 var(--space-4); }
  .brand-meta { display: none; }

  .toolbar {
    flex-wrap: wrap;
    padding: var(--space-2) var(--space-4);
  }

  .toolbar .tabs { width: 100%; }
  .tab { flex: 1; justify-content: center; padding: 0.4rem 0.5rem; }

  .toolbar-actions { width: 100%; justify-content: space-between; }
  .toolbar-actions .btn-primary { flex: 1; }

  .workspace { padding: var(--space-3); gap: var(--space-3); }
  .tab-content, .results-panel { padding: var(--space-4); border-radius: var(--radius-m); }

  .strategy-row, .form-row-3 { grid-template-columns: 1fr; }

  .combatant-item { flex-direction: column; align-items: stretch; }
  .item-actions { justify-content: flex-end; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: var(--text-l); }

  .log-table { max-height: 70vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
