/* ============================================================
   ElaraVTT Portal
   Dark fantasy: charcoal background, gold accents.
   Character-centric layout.
   ============================================================ */

:root {
  --ink: #0e0c0a;
  --ink-soft: #1a1510;
  --ink-soft-2: #251e17;
  --paper: #e0d0c0;
  --paper-dim: #b6a795;
  --gold: #b89d6a;
  --gold-bright: #d4b97e;
  --border: #3a3228;
  --serif: 'Cormorant Garamond', 'EB Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================
   Top bar
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--paper);
  text-decoration: none;
}

.brand-dice {
  height: 36px;
  width: 36px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.brand-name {
  font-family: var(--serif);
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  color: var(--gold);
}

.brand-section {
  font-family: var(--sans);
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-dim);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topnav-link,
.logout {
  font-family: var(--sans);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-dim);
  text-decoration: none;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 2px;
  transition: color 200ms, border-color 200ms, background 200ms;
}

.topnav-link:hover,
.logout:hover { color: var(--gold); border-color: var(--gold); }

/* Logout is visually softer so the main-site/wiki nav reads as primary */
.logout { opacity: 0.85; }

/* ============================================================
   Main / loader
   ============================================================ */

main {
  flex: 1;
  padding: 32px 24px 48px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.loader {
  text-align: center;
  padding: 80px 0;
  color: var(--paper-dim);
  font-style: italic;
}

/* ============================================================
   Character tabs (only shown if user has >1 character)
   ============================================================ */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  overflow-x: auto;
}

.tab {
  padding: 10px 22px;
  font-family: var(--serif);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  color: var(--paper-dim);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 200ms, border-color 200ms;
  white-space: nowrap;
}

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

.tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ============================================================
   Character hero
   ============================================================ */

.character {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 40px;
}

.portrait {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  background: var(--ink-soft);
}

.portrait-placeholder {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  background: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 4rem;
}

.character-name {
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 600;
  color: var(--gold);
  margin-top: 18px;
  letter-spacing: 0.04em;
}

.character-meta {
  font-family: var(--sans);
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin-top: 6px;
}

.character-tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--paper);
  opacity: 0.85;
  margin-top: 14px;
  max-width: 480px;
}

/* ============================================================
   Stats card (HP + survival)
   ============================================================ */

.stats-card {
  border: 1px solid var(--border);
  background: var(--ink-soft);
  padding: 22px 26px;
  border-radius: 2px;
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Ability score grid (STR DEX CON INT WIS CHA) */
.ability-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.ability-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 6px 10px;
  background: var(--ink);
  border: 1px solid var(--border);
  border-radius: 2px;
  text-align: center;
}

.ability-name {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  color: var(--paper-dim);
  margin-bottom: 4px;
}

.ability-value {
  font-family: var(--serif);
  font-size: 1.6rem;
  color: var(--gold);
  line-height: 1;
}

.ability-mod {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--paper);
  margin-top: 4px;
  opacity: 0.85;
}

/* Two-column block grid for traits/proficiencies */
.trait-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.trait-block {
  padding: 12px 14px;
  background: var(--ink);
  border: 1px solid var(--border);
  border-radius: 2px;
}

.trait-title {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.trait-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.trait-pill {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--paper);
  background: var(--ink-soft-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.stat-row {
  display: grid;
  grid-template-columns: 100px 1fr 80px;
  align-items: center;
  gap: 14px;
}

.stat-label {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-dim);
}

.stat-bar {
  height: 12px;
  background: var(--ink);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.stat-bar-fill {
  height: 100%;
  transition: width 200ms;
}

.stat-bar-ok { background: var(--gold); }
.stat-bar-low { background: #c89a4d; }
.stat-bar-crit { background: #a05a3a; }
.stat-bar-xp { background: #7a8da3; }

.xp-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-subtext {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--paper-dim);
  text-align: right;
}

.stat-suffix {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin-left: 6px;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--paper);
  text-align: right;
  letter-spacing: 0.04em;
}

/* HP row variant when there's no max to show — drop the bar, just show value */
.stat-row-novalue {
  grid-template-columns: 100px 1fr;
}

.stat-value-large {
  font-family: var(--serif);
  font-size: 1.6rem;
  color: var(--gold);
  text-align: right;
  line-height: 1;
}

.stats-updated {
  text-align: center;
  margin-top: 16px;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--paper-dim);
  letter-spacing: 0.05em;
  font-style: italic;
}

/* ============================================================
   Action cards
   ============================================================ */

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 32px;
}

.action-card {
  border: 1px solid var(--border);
  background: var(--ink-soft);
  padding: 22px;
  border-radius: 2px;
  display: flex;
  flex-direction: column;
}

.action-card h2 {
  font-family: var(--serif);
  font-size: 1.4rem;
  color: var(--gold);
  margin-bottom: 12px;
  letter-spacing: 0.04em;
}

.action-card p {
  color: var(--paper);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 16px;
  opacity: 0.92;
}

.action-card .field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--paper-dim);
}

.action-card .field code {
  background: var(--ink);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 2px;
  color: var(--paper);
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reveal-btn,
.copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--paper-dim);
  padding: 4px 10px;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: color 200ms, border-color 200ms;
}

.reveal-btn:hover,
.copy-btn:hover { color: var(--gold); border-color: var(--gold); }

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  padding: 12px 20px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 2px;
  transition: background 200ms, color 200ms, transform 150ms;
}

.action-btn:hover {
  background: var(--gold);
  color: var(--ink);
  transform: translateY(-1px);
}

/* ============================================================
   Empty state (no characters configured)
   ============================================================ */

.empty {
  text-align: center;
  padding: 60px 24px;
  border: 1px dashed var(--border);
  border-radius: 2px;
  background: var(--ink-soft);
  color: var(--paper-dim);
}

.empty h2 {
  font-family: var(--serif);
  color: var(--paper);
  margin-bottom: 12px;
}

.empty .session {
  margin-top: 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  background: var(--ink);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: 2px;
  text-align: left;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  color: var(--paper-dim);
}

.empty .session strong { color: var(--gold); }

/* ============================================================
   Footer
   ============================================================ */

.footer {
  text-align: center;
  padding: 20px;
  border-top: 1px solid var(--border);
  color: var(--paper-dim);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.footer a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px dotted var(--gold);
}

.footer a:hover { color: var(--gold-bright); border-color: var(--gold-bright); }

.sep { margin: 0 12px; opacity: 0.5; }

/* ============================================================
   Small screens
   ============================================================ */

@media (max-width: 540px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .brand-section { display: none; }
  .topnav { gap: 6px; }
  .topnav-link, .logout { padding: 5px 10px; font-size: 0.75rem; letter-spacing: 0.06em; }
  main { padding: 24px 16px 32px; }
  .portrait, .portrait-placeholder { width: 160px; height: 160px; }
  .action-grid { grid-template-columns: 1fr; }
  .ability-grid { grid-template-columns: repeat(3, 1fr); }
  .ability-value { font-size: 1.4rem; }
}

/* ============================================================
   Level-up bar — buttons under the stats card
   ============================================================ */

.levelup-bar {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 28px auto 16px;
  max-width: 720px;
}

.levelup-btn {
  flex: 1 1 0;
  padding: 14px 22px;
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(14, 12, 10, 0.72);
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 2px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, transform 120ms ease;
}

.levelup-btn:hover {
  background: var(--gold);
  color: var(--ink);
  transform: translateY(-1px);
}

.levelup-btn-secondary { opacity: 0.85; }

/* ============================================================
   Modal — backdrop + box
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 999;
  padding: 5vh 16px;
  overflow-y: auto;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 640px;
  background: var(--ink-soft);
  border: 1px solid var(--gold);
  border-radius: 3px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
  padding: 28px 28px 22px;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.modal-close:hover { color: var(--gold-bright); }

.modal-body { color: var(--paper); }

/* ============================================================
   Level-up form
   ============================================================ */

.lvlup-title {
  font-family: var(--serif);
  color: var(--gold);
  margin: 0 0 4px;
  font-size: 1.55rem;
}

.lvlup-subtitle {
  font-family: var(--serif);
  font-style: italic;
  color: var(--paper);
  opacity: 0.75;
  margin: 0 0 18px;
  font-size: 0.95rem;
}

.lvlup-form { display: flex; flex-direction: column; gap: 18px; }

.lvlup-field { display: flex; flex-direction: column; gap: 6px; }

.lvlup-label {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.lvlup-input {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid rgba(184, 157, 106, 0.4);
  border-radius: 2px;
  padding: 9px 11px;
  font-family: var(--sans);
  font-size: 0.95rem;
}

.lvlup-input:focus {
  outline: none;
  border-color: var(--gold);
}

.lvlup-hint { font-size: 0.8rem; opacity: 0.65; }

.lvlup-radio-stack { display: flex; flex-direction: column; gap: 6px; }

.lvlup-radio-row { display: flex; flex-wrap: wrap; gap: 10px; }

.lvlup-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(184, 157, 106, 0.3);
  border-radius: 2px;
  background: rgba(14, 12, 10, 0.4);
  cursor: pointer;
  font-size: 0.92rem;
}

.lvlup-radio:hover { border-color: var(--gold); }

.lvlup-radio input { accent-color: var(--gold); }

.lvlup-kind {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.7;
  margin-left: 4px;
}

.lvlup-auto {
  background: rgba(184, 157, 106, 0.08);
  border-left: 3px solid var(--gold);
  padding: 10px 14px;
  border-radius: 2px;
}

.lvlup-auto-title {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}

.lvlup-auto ul { margin: 0; padding-left: 16px; font-size: 0.88rem; }

.lvlup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.lvlup-btn-cancel, .lvlup-btn-submit {
  padding: 10px 22px;
  font-family: var(--serif);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 2px;
  cursor: pointer;
  border: 1px solid var(--gold);
}

.lvlup-btn-cancel { background: transparent; color: var(--gold); }
.lvlup-btn-cancel:hover { background: rgba(184, 157, 106, 0.1); }

.lvlup-btn-submit { background: var(--gold); color: var(--ink); font-weight: 600; }
.lvlup-btn-submit:hover { background: var(--gold-bright); }

.lvlup-status {
  margin-top: 4px;
  padding: 8px 12px;
  border-radius: 2px;
  background: rgba(159, 197, 102, 0.12);
  color: #c8e8a0;
  font-size: 0.9rem;
  border-left: 3px solid #9fc566;
}

.lvlup-status-error {
  background: rgba(220, 90, 90, 0.12);
  color: #f0c5c5;
  border-left-color: #dc5a5a;
}

/* ============================================================
   Re-apply form — level cards stacked
   ============================================================ */

.reapply-levels {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid rgba(184, 157, 106, 0.15);
  border-radius: 2px;
  background: rgba(14, 12, 10, 0.35);
}

.reapply-level {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(184, 157, 106, 0.05);
  border-left: 2px solid var(--gold);
  border-radius: 2px;
}

.reapply-level-label {
  font-family: var(--serif);
  color: var(--gold);
  font-size: 1.05rem;
  min-width: 30px;
}

.reapply-cell { display: flex; flex-direction: column; gap: 3px; flex: 0 0 auto; }

.reapply-cell span {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.75;
}

.reapply-cell .lvlup-input { padding: 5px 8px; font-size: 0.86rem; min-width: 80px; }

.reapply-cell-talent { flex: 1 1 200px; min-width: 180px; }
.reapply-cell-talent .lvlup-input { width: 100%; }

.reapply-auto {
  flex: 1 0 100%;
  font-size: 0.78rem;
  opacity: 0.7;
  margin-top: -2px;
  padding-left: 2px;
}

@media (max-width: 600px) {
  .modal { padding: 22px 18px 18px; }
  .reapply-level { flex-direction: column; align-items: stretch; }
  .reapply-cell, .reapply-cell-talent { width: 100%; flex: 1 1 auto; }
}

/* ============================================================
   Level-up form — section headers
   ============================================================ */

.lvlup-section-header {
  font-family: var(--serif);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid rgba(184, 157, 106, 0.3);
  padding-bottom: 4px;
  margin: 8px 0 -2px;
}

/* ============================================================
   New Character — topnav button + form helpers
   ============================================================ */

.topnav-new-char {
  font-family: var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  cursor: pointer;
}

.topnav-new-char:hover {
  color: var(--gold-bright);
  border-color: var(--gold-bright);
}

.lvlup-label-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lvlup-btn-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .lvlup-form > .lvlup-field[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   Source badges (RACE / CLASS labels in level-up + new-char forms)
   ============================================================ */

.src-race,
.src-class {
  display: inline-block;
  font-style: normal;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 2px;
  margin-left: 4px;
  vertical-align: middle;
  opacity: 0.95;
}

.src-race {
  background: rgba(120, 170, 220, 0.18);
  color: #a9c7e8;
  border: 1px solid rgba(120, 170, 220, 0.4);
}

.src-class {
  background: rgba(184, 157, 106, 0.18);
  color: var(--gold);
  border: 1px solid rgba(184, 157, 106, 0.45);
}

/* Locked-class checkbox (Kindred race forces Kindred class) */
.lvlup-radio-locked {
  background: rgba(184, 157, 106, 0.12);
  border-color: rgba(184, 157, 106, 0.55);
  opacity: 0.95;
  cursor: not-allowed;
}

.lvlup-radio-locked em {
  font-style: normal;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
  margin-left: 4px;
}

/* ============================================================
   Bio card — character details on the portal
   ============================================================ */

.bio-card {
  max-width: 920px;
  margin: 18px auto 22px;
  padding: 18px 22px;
  background: var(--ink-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 2px;
}

.bio-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(184, 157, 106, 0.25);
}

.bio-card-title {
  font-family: var(--serif);
  color: var(--gold);
  font-size: 1.25rem;
  margin: 0;
  letter-spacing: 0.04em;
}

.bio-amend-btn {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold);
  border-radius: 2px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}

.bio-amend-btn:hover {
  background: var(--gold);
  color: var(--ink);
}

.bio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px 14px;
  margin-bottom: 14px;
}

.bio-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 0;
}

.bio-key {
  font-family: var(--sans);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

.bio-val {
  font-family: var(--serif);
  font-size: 0.98rem;
  color: var(--paper);
}

.bio-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(184, 157, 106, 0.15);
}

.bio-block:first-of-type {
  border-top: none;
  margin-top: 8px;
  padding-top: 0;
}

.bio-block-title {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}

.bio-block-body {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--paper);
  white-space: pre-wrap;
  line-height: 1.45;
}

.bio-block-html {
  white-space: normal;
}

.bio-block-html p { margin: 0 0 8px; }
.bio-block-html p:last-child { margin-bottom: 0; }
.bio-block-html ul,
.bio-block-html ol { margin: 4px 0 8px 22px; }
.bio-block-html strong { color: var(--gold-bright); }
.bio-block-html em { color: var(--paper); }
.bio-block-html a { color: var(--gold); }

/* ============================================================
   New Character form — bio entry grid
   ============================================================ */

.bio-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 14px;
}

.bio-form-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bio-form-key {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.9;
}

.bio-empty {
  font-style: italic;
  font-size: 0.9rem;
  opacity: 0.65;
  margin: 4px 0 0;
}

@media (max-width: 600px) {
  .bio-card { padding: 14px 16px; }
  .bio-card-header { flex-wrap: wrap; }
}

/* ============================================================
   Inner tabs (per-character: Overview / Skills / Tools & Weapons / Features / Theluri)
   ============================================================ */

.inner-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 20px auto 22px;
  padding: 6px;
  background: rgba(14, 12, 10, 0.55);
  border: 1px solid var(--border);
  border-radius: 999px;
  max-width: 720px;
}

.inner-tab {
  flex: 0 1 auto;
  padding: 7px 16px;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--paper-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: color 180ms, background 180ms, border-color 180ms;
}

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

.inner-tab.active {
  color: var(--ink);
  background: var(--gold);
  border-color: var(--gold);
}

.inner-tab-pane[hidden] { display: none; }

.pane-empty {
  text-align: center;
  font-style: italic;
  color: var(--paper-dim);
  padding: 40px 20px;
  opacity: 0.7;
}

/* ============================================================
   Class image row (Overview pane)
   ============================================================ */

.class-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.class-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--gold);
  background: var(--ink-soft);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.class-icon-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 0.9rem;
  color: var(--gold);
  border-style: dashed;
}

/* ============================================================
   Skills & Tools tab — two-column layout, grid of rows in each
   ============================================================ */

.skills-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 4px;
  align-items: start;
}

.skills-col-title {
  margin: 0 0 6px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #b8a877;
  border-bottom: 1px solid #3a3228;
  padding-bottom: 4px;
}

/* On narrow screens stack into a single column so the rows stay readable. */
@media (max-width: 720px) {
  .skills-two-col {
    grid-template-columns: 1fr;
  }
}

.skill-grid {
  display: grid;
  /* Inside each column we just want a single column of rows; the outer
     two-col grid handles the visual side-by-side. */
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 4px 0;
}

.skill-row {
  display: grid;
  grid-template-columns: 48px 1fr auto 16px;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(14, 12, 10, 0.4);
  border: 1px solid var(--border);
  border-radius: 2px;
}

.ability-badge {
  display: inline-block;
  text-align: center;
  font-family: var(--sans);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  font-weight: 600;
  padding: 3px 0;
  border-radius: 2px;
  border: 1px solid rgba(184, 157, 106, 0.4);
  color: var(--paper);
}

.ability-badge.ability-str { background: rgba(180, 80, 70, 0.25); border-color: rgba(180, 80, 70, 0.55); color: #e8b6ae; }
.ability-badge.ability-dex { background: rgba(120, 165, 100, 0.22); border-color: rgba(120, 165, 100, 0.5); color: #c3e0a4; }
.ability-badge.ability-con { background: rgba(200, 140, 70, 0.22); border-color: rgba(200, 140, 70, 0.55); color: #ecc89a; }
.ability-badge.ability-int { background: rgba(110, 145, 195, 0.22); border-color: rgba(110, 145, 195, 0.5); color: #b9d0ec; }
.ability-badge.ability-wis { background: rgba(160, 130, 195, 0.22); border-color: rgba(160, 130, 195, 0.5); color: #d4c2ec; }
.ability-badge.ability-cha { background: rgba(210, 140, 175, 0.22); border-color: rgba(210, 140, 175, 0.5); color: #ecc1d4; }
.ability-badge.ability-none { background: rgba(120, 120, 120, 0.18); color: var(--paper-dim); }

.skill-name {
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--paper);
}

.skill-mod {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.92rem;
  color: var(--gold);
}

.prof-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--paper-dim);
  background: transparent;
}

.prof-dot.prof-0 { border-color: rgba(150, 140, 130, 0.4); }
.prof-dot.prof-0_5 { background: rgba(200, 154, 77, 0.5); border-color: #c89a4d; }
.prof-dot.prof-1 { background: var(--gold); border-color: var(--gold); }
.prof-dot.prof-2 {
  background: var(--gold);
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(184, 157, 106, 0.35);
}

/* ============================================================
   Tools & Weapons tab
   ============================================================ */

.tw-section {
  margin-bottom: 24px;
}

.tw-section-title {
  font-family: var(--serif);
  color: var(--gold);
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  margin: 0 0 12px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(184, 157, 106, 0.25);
}

.tw-prof-block {
  margin: -8px 0 24px;
  padding: 12px 14px;
  background: rgba(14, 12, 10, 0.4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 2px;
}

.tw-prof-title {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 8px;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.icon-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 12px 8px;
  background: var(--ink-soft);
  border: 1px solid var(--border);
  border-radius: 2px;
  transition: border-color 180ms;
}

.icon-card:hover { border-color: var(--gold); }

.icon-card-img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--ink);
}

.icon-card-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  color: var(--paper-dim);
  font-size: 1.1rem;
}

.icon-card-name {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--paper);
  line-height: 1.25;
}

/* ============================================================
   Item cards (Features + Theluri)
   ============================================================ */

.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: var(--ink-soft);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px 14px;
  transition: border-color 180ms;
}

.item-card[data-expanded="true"] {
  border-color: var(--gold);
}

.item-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-icon {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--ink);
  flex: 0 0 auto;
}

.item-icon-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  color: var(--paper-dim);
  font-size: 0.85rem;
}

.item-card-title {
  flex: 1;
  font-family: var(--serif);
  color: var(--paper);
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: 0.02em;
}

.item-toggle {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold);
  border-radius: 2px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 180ms, color 180ms;
  flex: 0 0 auto;
}

.item-toggle:hover {
  background: var(--gold);
  color: var(--ink);
}

.item-desc {
  margin-top: 12px;
  padding-left: 52px;
  font-family: var(--serif);
  font-size: 0.98rem;
  color: var(--paper);
  line-height: 1.55;
  max-height: 60vh;
  overflow-y: auto;
  /* Foundry's TinyMCE output uses heavily nested <ul> for spec sheets; force
     left alignment on every descendant so we don't inherit centring from the
     character header or get the default "centre on narrowing column" look. */
  text-align: left;
}

.item-desc * { text-align: left; }

.item-desc p { margin: 0 0 8px; }
.item-desc p:last-child { margin-bottom: 0; }

/* Lists — flatten the cumulative-indent that browser defaults give nested
   ULs/OLs. Each level adds a sane fixed indent (20px) instead of stacking. */
.item-desc ul,
.item-desc ol {
  margin: 4px 0 8px;
  padding-left: 20px;
  list-style-position: outside;
}
.item-desc ul { list-style-type: disc; }
.item-desc ul ul { list-style-type: circle; }
.item-desc ul ul ul { list-style-type: square; }
.item-desc ul ul ul ul { list-style-type: disc; }

.item-desc li {
  margin: 2px 0;
  padding-left: 4px;
}
/* Tight nested lists — drop the top margin so a sub-bullet sits flush under
   its parent line instead of starting a new visual block. */
.item-desc li > ul,
.item-desc li > ol {
  margin-top: 2px;
  margin-bottom: 4px;
}

.item-desc strong { color: var(--gold-bright); }
.item-desc em { color: var(--paper); font-style: italic; }
.item-desc h1, .item-desc h2, .item-desc h3,
.item-desc h4, .item-desc h5, .item-desc h6 {
  font-family: var(--serif);
  color: var(--gold);
  font-size: 1rem;
  margin: 10px 0 4px;
  letter-spacing: 0.03em;
}
.item-desc table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 0.9rem;
}
.item-desc th, .item-desc td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
}
.item-desc th {
  background: rgba(184, 157, 106, 0.12);
  color: var(--gold);
  font-weight: 600;
}
.item-desc blockquote {
  margin: 6px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--gold);
  background: rgba(184, 157, 106, 0.05);
}
.item-desc code {
  background: var(--ink);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
}

/* ============================================================
   Theluri groups (per spell level)
   ============================================================ */

.theluri-group {
  margin-bottom: 22px;
}

.theluri-group-title {
  font-family: var(--serif);
  color: var(--gold);
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  margin: 0 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(184, 157, 106, 0.25);
}

/* ============================================================
   Inventory tab — slot figure + belt + containers + held grid
   ============================================================ */

.inv-pane {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.inv-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inv-section-title {
  font-family: var(--serif);
  color: var(--gold);
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  margin: 0;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(184, 157, 106, 0.25);
}

/* Slot figure — anatomical grid layout.
   Columns:  cloak | rh  | core | lh  | rwrist
                head/neck/chest/torso/waist/legs/feet centred in core
                hands span the side columns, rings flank the wrists row */
.inv-layout {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr 1fr 1fr;
  grid-template-areas:
    ".      .      head   .      ."
    ".      .      neck   .      ."
    "cloak  .      chest  .      ."
    "cloak  .      torso  .      ."
    "rhand  rhand  waist  lhand  lhand"
    ".      .      legs   .      ."
    ".      .      feet   .      ."
    "lring  lwrist .      rwrist rring";
  gap: 10px;
  padding: 14px;
  background: var(--ink-soft);
  border: 1px solid var(--border);
  border-radius: 2px;
}

/* Two-handed grip: rhand spans all 4 hand cells (centred). */
.inv-layout[data-two-handed="1"] {
  grid-template-areas:
    ".      .      head   .      ."
    ".      .      neck   .      ."
    "cloak  .      chest  .      ."
    "cloak  .      torso  .      ."
    "hand   hand   waist  hand   hand"
    ".      .      legs   .      ."
    ".      .      feet   .      ."
    "lring  lwrist .      rwrist rring";
}

.inv-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--ink);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-height: 90px;
  position: relative;
  transition: border-color 180ms;
}

.inv-slot[data-expanded="true"] { border-color: var(--gold); }

.inv-slot--empty {
  border-style: dashed;
  opacity: 0.55;
}

.inv-slot--filled:hover { border-color: var(--gold); }

.inv-slot--twoh { /* placeholder hook for future tweaks */ }

.inv-slot-label {
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-dim);
  text-align: center;
}

.inv-slot-empty-mark {
  font-family: var(--serif);
  color: var(--paper-dim);
  font-size: 1.4rem;
  margin: auto 0;
  opacity: 0.5;
}

.inv-slot-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  color: inherit;
  position: relative;
}

.inv-slot-btn:disabled { cursor: default; }

.inv-slot-img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--ink-soft);
}

.inv-slot-img-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  color: var(--paper-dim);
  font-size: 0.85rem;
}

.inv-slot-name {
  font-family: var(--serif);
  color: var(--paper);
  font-size: 0.78rem;
  line-height: 1.15;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.inv-slot-qty {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--ink);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-size: 0.65rem;
  font-family: var(--sans);
  padding: 1px 5px;
  border-radius: 8px;
  pointer-events: none;
}

.inv-sheath-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--ink);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-size: 0.7rem;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

.inv-slot-desc {
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--ink-soft);
  border: 1px solid var(--border);
  border-radius: 2px;
  text-align: left;
}

/* Belt row */
.inv-belt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inv-belt-slot {
  min-width: 110px;
  flex: 0 0 auto;
}

.inv-belt-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inv-belt-sheathed {
  border-style: dotted;
}

/* Sheathed + held grids */
.inv-held-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.inv-held-tile { min-height: 110px; }

.inv-sheath-tile { /* same dimensions as held tile, label provides distinction */ }

/* Containers */
.inv-container {
  background: var(--ink-soft);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inv-container-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inv-container-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.inv-container-name {
  font-family: var(--serif);
  color: var(--gold);
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: 0.03em;
}

.inv-container-count {
  font-family: var(--sans);
  color: var(--paper-dim);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.inv-container-contents {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inv-container-empty {
  color: var(--paper-dim);
  font-style: italic;
  margin: 0;
  font-size: 0.9rem;
}

.inv-row .item-card-title { font-size: 0.95rem; }

.inv-row-qty {
  color: var(--gold);
  font-family: var(--sans);
  font-size: 0.85rem;
  margin-left: 6px;
}

/* Mobile — stack the figure vertically */
@media (max-width: 540px) {
  .inner-tabs { gap: 4px; padding: 4px; }
  .inner-tab { padding: 6px 10px; font-size: 0.7rem; letter-spacing: 0.08em; }
  .item-card-header { flex-wrap: wrap; }
  .item-desc { padding-left: 0; }
  .icon-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }

  /* Collapse the anatomical grid into a single column. Each slot becomes a
     full-width row stacked top to bottom. */
  .inv-layout,
  .inv-layout[data-two-handed="1"] {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "neck"
      "cloak"
      "chest"
      "torso"
      "rhand"
      "hand"
      "lhand"
      "waist"
      "legs"
      "feet"
      "lring"
      "rring"
      "lwrist"
      "rwrist";
    gap: 8px;
    padding: 10px;
  }

  .inv-slot { min-height: 70px; }
  .inv-held-grid { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); }
  .inv-belt-slot { min-width: 95px; }
}
