.section .form-group {
  padding-left: 0;
  padding-right: 0;
}
/* Select input styling to match number inputs */
.select-input {
  width: 100%;
  padding: 6px 10px;
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  transition: all 0.2s ease;
  height: 32px;
  box-sizing: border-box;
  cursor: pointer;
  /* Flatten native bevel/arrow to match .form-control selects */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Minimal custom caret */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23cbd5e1' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
  padding-right: 28px; /* space for caret */
}

/* ===== Panel Headings & Labels (consistent all-caps style) ===== */
.section label,
.form-group > label,
.range-group > label {
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 12px; /* maintain readability while providing clean lines */
  font-weight: 600;
  color: var(--text-secondary);
}

.select-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgb(99 102 241 / 20%);
}

.select-input:hover {
  border-color: var(--primary);
}

/* Force Inter font on option elements within select - Safari workaround */
.select-input option {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  font-weight: 400 !important;
  color: var(--text-primary);
  background: var(--dark-surface);
}

/* Additional Safari-specific fixes */
select.select-input,
select.select-input * {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* Hide number input spinners for cleaner appearance */
.ability-score-input::-webkit-inner-spin-button,
.ability-score-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.ability-score-input[type=number] {
  -moz-appearance: textfield;
}
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap');

/* ===== CORE VARIABLES ===== */
:root {

  /* ─── Fonts ──────────────────────────────────────────── */
  --font-ui:      'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: 'EB Garamond', Georgia, serif;
  --font-mono:    ui-monospace, 'SFMono-Regular', Consolas, monospace;

  /* ─── Type Scale ─────────────────────────────────────── */
  --text-xs:   11px;
  --text-sm:   12px;
  --text-base: 14px;
  --text-md:   16px;
  --text-lg:   18px;
  --text-xl:   22px;
  --text-2xl:  28px;

  /* ─── Spacing Scale ──────────────────────────────────── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  /* ─── Border Radius ──────────────────────────────────── */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* ─── Base Colors (blue-leaning deep purple) ─────────── */
  --dark:         #0d0e1f;
  --dark-lighter: #141729;
  --dark-panel:   #181b38;
  --dark-surface: #1f2240;

  /* ─── Brand ──────────────────────────────────────────── */
  --brand:       #7c3aed;
  --brand-hover: #6d28d9;
  --brand-ghost: rgb(124 58 237 / 15%);
  --gold:        #c9a84c;
  --gold-dim:    #a8883a;
  --crimson:     #9b2335;

  /* --primary aliased to --brand for backward compatibility */
  --primary:       #7c3aed;
  --primary-hover: #6d28d9;

  /* ─── Semantic UI ────────────────────────────────────── */
  --success: #10b981;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --info:    #3b82f6;

  /* ─── Game Semantics ─────────────────────────────────── */
  --hp-high:      #10b981;  /* HP full / healthy  */
  --hp-mid:       #f59e0b;  /* HP half / caution  */
  --hp-low:       #ef4444;  /* HP critical / dying */
  --color-ac:     #60a5fa;  /* Armor Class        */
  --color-spell:  #a78bfa;  /* Spell slots / magic */
  --color-action: #fb923c;  /* Actions / reactions */
  --color-xp:     #c9a84c;  /* XP / gold          */

  /* ─── Glass / Surface ────────────────────────────────── */
  --glass-bg:     rgb(31 34 64 / 95%);
  --glass-border: rgb(140 130 200 / 20%);

  /* ─── Text ───────────────────────────────────────────── */
  --text-primary:   #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted:     #64748b;

  /* ─── Shadows ────────────────────────────────────────── */
  --shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 20%);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 30%);
  --shadow-lg: 0 25px 50px -12px rgb(0 0 0 / 50%);

  /* ─── Transitions ────────────────────────────────────── */
  --transition-base:   0.2s ease;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);

  /* ─── Layout ─────────────────────────────────────────── */
  --toolbar-width: 60px;
  --panel-width:   320px;

  /* ─── Legacy aliases ─────────────────────────────────── */
  --lore-primary:   #7c3aed;
  --lore-secondary: #06b6d4;
}

/* ===== RESET & BASE STYLES ===== */
*, 
*::before, 
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
}

body {
  min-height: 100%;
  font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark-lighter) 100%);
  overflow: hidden;
}

/* ===== LAYOUT ===== */
#stageContent {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, var(--dark-lighter) 0%, var(--dark) 100%);
}

/* Canvas elements */
#stageContent canvas:not(.token-preview-canvas) {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  background: transparent !important;
  pointer-events: none;
}

#stageContent canvas:not([data-engine="babylon"]):not(.token-preview-canvas) {
  pointer-events: auto;
}

/* Token preview canvas in character sheet - must NOT inherit stage canvas styles */
.token-preview-canvas {
  position: relative !important;
  width: 100px !important;
  height: 100px !important;
  max-width: 100px !important;
  max-height: 100px !important;
  top: auto !important;
  left: auto !important;
  pointer-events: auto !important;
}

#stageContent canvas[data-engine="babylon"] {
  z-index: 700; /* DICE layer */
}

/* Game board */
#gameBoard {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: 50% 50%;
  cursor: grab;
  /* Remove transform transition to keep grid and map perfectly in sync while panning */
  transition: none;
  pointer-events: auto;
  z-index: 1; /* MAP_BACKGROUND */
}

#gameBoard:active {
  cursor: grabbing;
}

#gameBoard * {
  z-index: 1 !important; /* MAP_BACKGROUND */
}

/* Override for grid canvas to appear above map */
#gridCanvas {
  z-index: 10 !important; /* GRID - above map */
}

#mapLayer,
#gridCanvas {
  position: absolute;
  top: 0;
  left: 0;
}

#mapLayer {
  z-index: 1; /* MAP_BACKGROUND */
  pointer-events: auto;
}

/* ===== PANEL ===== */
#panelContent {
  position: absolute;
  top: 0;
  left: var(--toolbar-width);
  width: var(--panel-width);
  height: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  color: var(--text-primary);
  z-index: 650; /* PANELS layer from LayerManager */
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}

#panelContent.active {
  transform: translateX(0);
  pointer-events: auto;
}

#panelContent.active {
  transform: translateX(0);
}

#panelContent::-webkit-scrollbar {
  width: 6px;
}

#panelContent::-webkit-scrollbar-track {
  background: transparent;
}

#panelContent::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 3px;
}

/* Panel header */
.panel-header {
  position: sticky;
  top: 0;
  background: var(--dark-surface);
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  z-index: 10;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title i {
  color: var(--primary);
}

/* Panel content */
.panel-body {
  /* tighter side padding for wider-looking sections */
  padding: 12px 8px;
}

/* ===== ZOOM CONTROLS ===== */
/* ===== RIGHT-EDGE TOOLBAR ===== */
.mini-toolbar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  background: var(--glass-bg);
  border-left: 1px solid var(--glass-border);
  border-radius: 0;
  padding: 8px 4px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  z-index: 1000; /* MINI_TOOLBAR layer */
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: scroll;
  overflow-x: hidden;
}

/* Hide scrollbar while keeping scroll functionality */
.mini-toolbar::-webkit-scrollbar {
  display: none;
}

.mini-toolbar {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

/* Toolbar sections */
.toolbar-section {
  margin-bottom: 4px;
}

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

/* Section headers (icon-only with offset background) */
.section-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  cursor: pointer;
  border-radius: 4px;
  background: #334155;
  transition: all var(--transition-base);
  user-select: none;
  margin-bottom: 8px;
  position: relative;
}

.section-header:hover {
  background: #3b4557;
}

.section-header.expanded {
  background: #3b4557;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: center;
}

.section-title i {
  font-size: 16px;
  color: var(--text-secondary);
}

/* Color-coded section icons */
.section-header.dice-section .section-title i {
  color: var(--warning);
}

.section-header.view-section .section-title i {
  color: var(--info);
}

.section-header.draw-section .section-title i {
  color: var(--success);
}

.section-header.measure-section .section-title i {
  color: var(--warning);
}

.section-header.walls-section .section-title i {
  color: var(--danger);
}

.section-header.options-section .section-title i {
  color: var(--lore-primary);
}

/* Section toggle chevron */
.section-toggle {
  position: absolute;
  right: 8px;
  font-size: 8px;
  color: var(--text-muted);
  transition: transform var(--transition-base);
}

.section-header.expanded .section-toggle {
  transform: rotate(90deg);
}

/* Section content (collapsible) */
.section-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  overflow: hidden;
  transition: all var(--transition-smooth);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--glass-border);
}

.toolbar-section:last-child .section-content {
  border-bottom: none;
}

.section-content.collapsed {
  max-height: 0;
  padding-bottom: 0;
  border-bottom: none;
  opacity: 0;
}

.section-content.expanded {
  max-height: 800px;
  opacity: 1;
}

/* Toolbar buttons */
.toolbar-btn {
  width: 100%;
  height: 32px;
  border: none;
  background: var(--dark-surface);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  position: relative;
}

.toolbar-btn:hover {
  background: var(--dark-lighter);
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.05);
}

.toolbar-btn:active {
  transform: scale(0.98);
}

.toolbar-btn.active {
  background: var(--primary);
  color: var(--text-primary);
  border-color: var(--primary-hover);
}

.toolbar-btn i {
  font-size: 14px;
}

/* Dice buttons (in mini-toolbar) */
.mini-toolbar .dice-btn {
  width: 100%;
  height: 32px;
  background: var(--dark-surface);
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mini-toolbar .dice-btn:hover {
  background: #334155;
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.05);
}

.mini-toolbar .dice-btn:active {
  transform: scale(0.98);
}

/* GM-only buttons */
.toolbar-btn.gm-only {
  /* Visibility controlled by JS based on role */
}

/* Wall Type Selector */
.toolbar-select {
  width: 100%;
  height: 32px;
  background: var(--dark-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 8px;
  transition: all var(--transition-base);
}

.toolbar-select:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.toolbar-select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--dark-lighter);
}

/* Toolbar Button Group (for mode toggles) */
.toolbar-btn-group {
  width: 100%;
  display: flex;
  gap: 4px;
  background: var(--dark-surface);
  padding: 2px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* Small Toolbar Buttons (for grouped buttons) */
.toolbar-btn-small {
  flex: 1;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.toolbar-btn-small:hover {
  background: var(--dark-lighter);
  color: var(--primary);
}

.toolbar-btn-small.active {
  background: var(--primary);
  color: var(--text-primary);
}

.toolbar-btn-small i {
  font-size: 12px;
}

/* Flip icon horizontally */
.flip-horizontal {
  transform: scaleX(-1);
}

/* Color Picker Palette */
.color-picker-palette {
  position: fixed; /* Use fixed to escape overflow:hidden */
  right: 48px; /* Position to the left of the toolbar */
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px;
  backdrop-filter: blur(20px);
  display: none; /* Hidden by default */
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  z-index: 1100; /* Higher than modals (1001) and mini-toolbar (1000) */
}

.color-picker-palette.open {
  display: grid; /* Show when open class is added */
}

.color-swatch {
  width: 28px;
  height: 28px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.color-swatch:hover {
  transform: scale(1.1);
  border-color: var(--primary);
}

.color-swatch.active {
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

.custom-color-picker {
  grid-column: 1 / -1; /* Span both columns */
  padding: 6px;
  border: 2px dashed var(--glass-border);
  border-radius: 4px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-size: 11px;
  text-align: center;
  transition: all 0.2s ease;
}

.custom-color-picker:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

.custom-color-picker input[type="color"] {
  width: 100%;
  height: 24px;
  border: none;
  cursor: pointer;
  background: transparent;
}

/* ===== TOOLBAR ===== */
#toolbar {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--toolbar-width);
  height: 100%;
  padding: 12px 0;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  z-index: 700; /* TOOLBAR - higher than panels */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: visible;
}

.toolbar-brand {
  width: 44px;
  height: 44px;
  margin-bottom: 16px;
  background: var(--dark);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-base);
  flex-shrink: 0;
  position: relative;
}

.toolbar-brand:hover {
  transform: scale(1.05);
  border-color: var(--brand);
  box-shadow: 0 0 12px var(--brand-ghost);
}

/* Divider line separating brand mark from tool buttons */
.toolbar-brand::after {
  content: '';
  display: block;
  position: absolute;
  width: 28px;
  height: 1px;
  background: var(--glass-border);
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
}

/* The RL mark — colored via mask so we get direct CSS color control */
.toolbar-brand-mark {
  display: block;
  width: 26px;
  height: 26px;
  background-color: var(--brand);
  -webkit-mask: url('/public/assets/brand/rl-mark.svg') center / contain no-repeat;
  mask: url('/public/assets/brand/rl-mark.svg') center / contain no-repeat;
  transition: background-color var(--transition-base);
}

.toolbar-brand:hover .toolbar-brand-mark {
  background-color: #a78bfa;
}

/* Tool buttons */
.tool-button {
  --button-size: 44px;
  
  position: relative;
  width: var(--button-size);
  height: var(--button-size);
  margin: 4px 0;
  padding: 0;
  background: var(--dark-surface);
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-width: var(--button-size);
  min-height: var(--button-size);
}

/* Ensure Font Awesome icons are visible */
.tool-button i {
  font-size: 16px;
  color: inherit;
  display: inline-block;
  width: auto;
  height: auto;
  position: relative;
  z-index: 1;
}

/* Debug styles - make buttons more visible */
.tool-button {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.tool-button:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.tool-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  opacity: 0;
  transition: opacity var(--transition-base);
  border-radius: inherit;
  z-index: -1;
}

.tool-button:hover {
  transform: scale(1.05);
  color: var(--text-primary);
  border-color: var(--primary);
}

.tool-button:hover::before {
  opacity: 0.15;
}

.tool-button.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: white;
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
  border-color: transparent;
}

/* Tooltips */
.tool-button::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  background: var(--dark-surface);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-base);
  border: 1px solid var(--glass-border);
  z-index: 900; /* TOOLTIPS */
}

.tool-button:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* Notification Badge */
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--dark-surface);
  z-index: 10;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(239 68 68 / 70%); }
  70% { box-shadow: 0 0 0 6px rgb(239 68 68 / 0%); }
  100% { box-shadow: 0 0 0 0 rgb(239 68 68 / 0%); }
}

/* ===== COMPONENTS ===== */
.section {
  margin-bottom: 24px;
  padding: 16px;
  background: rgb(255 255 255 / 2%);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  position: relative;
  overflow: visible; /* allow inner content/shadows; children handle their own sizing */
  min-width: 0; /* allow children to shrink within flex containers */
}

.section h4 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* Grid presets */
.grid-presets {
  margin-top: 16px;
}

.grid-presets label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preset-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
}

.preset-btn {
  padding: 8px 12px;
  background: var(--dark-surface);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  transition: all var(--transition-base);
  text-align: center;
}

.preset-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.preset-btn.active {
  background: var(--success);
  color: white;
  border-color: var(--success);
  transform: scale(1.05);
}

/* ===== NOTIFICATIONS & MESSAGES ===== */
.notification {
  --notification-padding: 14px 20px;
  --notification-max-width: 350px;
  --notification-min-width: 200px;
  
  position: fixed;
  top: 20px;
  right: 20px;
  padding: var(--notification-padding);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 850; /* NOTIFICATIONS */
  opacity: 0;
  transform: translateX(100%);
  transition: all var(--transition-smooth);
  box-shadow: var(--shadow-lg);
  max-width: var(--notification-max-width);
  min-width: var(--notification-min-width);
  display: flex;
  align-items: center;
  gap: 10px;
}

.notification.show {
  opacity: 1;
  transform: translateX(0);
}

.notification.success { background: var(--success); color: white; }
.notification.error { background: var(--danger); color: white; }
.notification.warning { background: var(--warning); color: white; }
.notification.info { background: var(--info); color: white; }

/* Chat messages */
.chat-message {
  display: flex;
  flex-direction: column; /* stack meta above content */
  align-items: stretch;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
}

/* Meta row (timestamp + sender + indicators) */
.chat-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.chat-message.system {
  background: rgb(99 102 241 / 10%);
  border-left: 3px solid var(--primary);
}

.chat-message.public {
  background: rgb(255 255 255 / 5%);
}

.chat-message.whisper {
  background: rgb(245 158 11 / 10%);
  border-left: 3px solid var(--warning);
}

.chat-message.dice {
  background: rgb(16 185 129 / 10%);
  border-left: 3px solid var(--success);
}

.chat-timestamp {
  color: var(--text-muted);
  margin-right: 8px;
  font-size: 11px;
  min-width: 35px;
  font-family: monospace;
}

.chat-sender {
  color: var(--primary);
  font-weight: 600;
  margin-right: 8px;
}

.chat-content {
  color: var(--text-primary);
  flex: 1;
}

.chat-whisper-indicator {
  color: var(--warning);
  font-style: italic;
  margin-right: 4px;
}

.chat-dice-result {
  background: rgb(16 185 129 / 20%);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  margin-left: 4px;
}

/* === CHAT PANEL (rl-chat) === */
.rl-chat {
  padding: 0;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 260px;
}

.rl-chat__header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 12px 16px;
  background: var(--dark-surface);
  border-bottom: 1px solid var(--glass-border);
  gap: 8px;
}

.rl-chat__title {
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rl-chat__title:empty { display: none; }

.rl-chat__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.rl-chat__search {
  flex: 1;
  min-width: 0;
}

.rl-chat__messages {
  /* Stable height window (scroll when exceeded) */
  max-height: 320px;
  min-height: 160px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rl-chat__input {
  border-top: 1px solid var(--glass-border);
  background: var(--dark-surface);
  padding: 8px;
}

.rl-chat__input-row {
  display: flex;
  gap: 6px;
}

/* Footer controls under the input */
.rl-chat__footer-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px; /* breathing room below the input */
}

.rl-chat__footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rl-chat__footer-right {
  display: flex;
  gap: 8px;
}

@media (width <= 360px) {
  .rl-chat__footer-controls {
    flex-wrap: wrap;
  }
  .rl-chat__footer-right {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Hover toolbar (from prototype-1) */
.rl-toolbar {
  position: relative;
  display: none;
  gap: 6px;
  background: rgba(20, 20, 30, 0.9);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 14px;
  margin-top: 6px;
  width: max-content;
}

.rl-tool {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
}

.rl-tool:hover { color: #fff; }

/* Show toolbar on message hover */
.chat-message:hover .rl-toolbar { display: flex; }

/* Reaction chips */
.rl-chat__reactions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.rl-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  font-size: 12px;
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
}

/* Input validation */
.rl-input--invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgb(239 68 68 / 20%);
}

.rl-chat__validation {
  color: var(--warning);
  font-size: 12px;
  margin-top: 6px;
}

/* Compact mode reduces paddings and gaps */
.rl-chat.rl-chat--compact .rl-chat__messages { padding: 8px; gap: 4px; }
.rl-chat.rl-chat--compact .chat-message { padding: 6px; margin-bottom: 4px; }
.rl-chat.rl-chat--compact .rl-chat__input { padding: 6px; }
.rl-chat.rl-chat--compact .rl-chat__header { padding: 8px 12px; }

/* GM color control */
.rl-chat__gm-color {
  width: 32px;
  height: 32px;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: var(--dark-surface);
  padding: 0;
}

/* ===== MAP PLACEHOLDER ===== */
.map-placeholder {
  --placeholder-width: 300px;
  --placeholder-height: 200px;
  
  position: fixed;
  top: 50%;
  left: calc(var(--toolbar-width) + 50%);
  transform: translate(-50%, -50%);
  width: var(--placeholder-width);
  height: var(--placeholder-height);
  background: linear-gradient(135deg, rgb(30 41 59 / 80%), rgb(51 65 85 / 80%));
  backdrop-filter: blur(10px);
  border: 2px dashed var(--glass-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  transition: all var(--transition-base);
  cursor: pointer;
  z-index: 502; /* MAP_PLACEHOLDER */
}

.map-placeholder:hover {
  background: linear-gradient(135deg, rgb(30 41 59 / 90%), rgb(51 65 85 / 90%));
  border-color: var(--primary);
  transform: translate(-50%, -50%) scale(1.02);
}

.map-placeholder i {
  font-size: 32px;
  margin-bottom: 8px;
  color: var(--lore-primary);
}

/* ===== CHARACTER TABS ===== */
.character-tab-horizontal {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-base);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
}

.character-tab-horizontal:hover {
  background: var(--dark-surface);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.character-tab-horizontal.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.character-tab-horizontal.active::after {
  content: '';
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}

.character-tab-horizontal i {
  font-size: 12px;
}

.character-tab-square {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-base);
  font-size: 14px;
  position: relative;
  border: 1px solid var(--glass-border);
}

.character-tab-square:hover {
  background: var(--dark-surface);
  color: var(--text-primary);
  transform: translateY(-1px);
  border-color: var(--primary);
}

.character-tab-square.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
  border-color: var(--primary);
}

/* ===== MODAL SYSTEM ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 70%);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001; /* MODALS */
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-smooth);
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  --modal-min-width: 320px;
  --modal-max-width: 500px;
  --modal-padding: 24px;
  
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: var(--modal-padding);
  min-width: var(--modal-min-width);
  max-width: var(--modal-max-width);
  box-shadow: var(--shadow-lg);
  transform: scale(0.9) translateY(-20px);
  transition: all var(--transition-smooth);
}

.modal-overlay.show .modal-dialog {
  transform: scale(1) translateY(0);
}

.modal-header {
  margin-bottom: 16px;
  text-align: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-body {
  margin-bottom: 20px;
}

.modal-body p {
  color: var(--text-secondary);
  margin: 0 0 12px;
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-input {
  width: 100%;
  padding: 12px;
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 16px;
  transition: all var(--transition-base);
}

.modal-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgb(99 102 241 / 20%);
}

/* ===== FORM ELEMENTS ===== */
.form-control {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--dark-surface);
  background-clip: padding-box;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  transition: border-color var(--transition-base), 
              box-shadow var(--transition-base);
}

.form-control:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 2px rgb(99 102 241 / 25%);
}

/* Flatten select dropdowns using form-control (remove native bevel/arrow) */
select.form-control {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: var(--dark-surface);
  /* Minimal custom caret */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23cbd5e1' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
  padding-right: 32px; /* space for caret */
  box-shadow: none; /* flatten look */
}

/* Ensure consistent height with other controls */
select.form-control {
  height: 36px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Force Inter font on option elements within form-control selects - Safari fix */
select.form-control option {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-weight: 400;
}

.form-control:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 2px rgb(99 102 241 / 25%);
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== BUTTONS ===== */
/* Consolidated in the canonical .btn block below (around Components section). */

.btn-primary {
  color: white;
  background-color: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-outline {
  color: var(--text-primary);
  background-color: transparent;
  border-color: var(--glass-border);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--dark-surface);
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* ===== RESPONSIVE ===== */
@media (width <= 768px) {
  :root {
    --toolbar-width: 50px;
    --panel-width: 280px;
  }
  
  .tool-button {
    width: 38px;
    height: 38px;
    font-size: 14px;
  }
  
  .toolbar-brand {
    width: 36px;
    height: 36px;
  }
  .toolbar-brand-mark {
    width: 22px;
    height: 22px;
  }
}

/* === NOTIFICATIONS === */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 850; /* NOTIFICATIONS layer from LayerManager */
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  max-width: 350px;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.notification.show {
  opacity: 1;
  transform: translateX(0);
}

.notification.success {
  background: var(--success);
  color: white;
}

.notification.error {
  background: var(--danger);
  color: white;
}

.notification.warning {
  background: var(--warning);
  color: white;
}

.notification.info {
  background: var(--info);
  color: white;
}

/* === CHAT MESSAGES === */
.chat-message {
  display: flex;
  align-items: flex-start;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
}

.chat-message.system {
  background: rgb(99 102 241 / 10%);
  border-left: 3px solid var(--primary);
}

.chat-message.public {
  background: rgb(255 255 255 / 5%);
}

.chat-message.whisper {
  background: rgb(245 158 11 / 10%);
  border-left: 3px solid var(--warning);
}

.chat-message.dice {
  background: rgb(16 185 129 / 10%);
  border-left: 3px solid var(--success);
}

.chat-timestamp {
  color: var(--text-muted);
  margin-right: 8px;
  font-size: 11px;
  min-width: 35px;
  font-family: monospace;
}

.chat-sender {
  color: var(--primary);
  font-weight: 600;
  margin-right: 8px;
}

.chat-content {
  color: var(--text-primary);
  flex: 1;
}

.chat-whisper-indicator {
  color: var(--warning);
  font-style: italic;
  margin-right: 4px;
}

.chat-dice-result {
  background: rgb(16 185 129 / 20%);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  margin-left: 4px;
}

/* === MAP PLACEHOLDER === */
.map-placeholder {
  position: fixed;
  top: 50%;
  left: calc(var(--toolbar-width) + 50%);
  transform: translate(-50%, -50%);
  width: 300px;
  height: 200px;
  background: linear-gradient(135deg, rgb(30 41 59 / 80%), rgb(51 65 85 / 80%));
  backdrop-filter: blur(10px);
  border: 2px dashed var(--glass-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  transition: all 0.3s ease;
  cursor: pointer;
  z-index: 502; /* MAP_PLACEHOLDER layer from LayerManager */
  text-align: center;
}

.map-placeholder:hover {
  background: linear-gradient(135deg, rgb(30 41 59 / 90%), rgb(51 65 85 / 90%));
  border-color: var(--primary);
  transform: translate(-50%, -50%) scale(1.02);
}

.map-placeholder i {
  font-size: 32px;
  margin-bottom: 8px;
  color: var(--lore-primary);
  display: block;
}

/* === RESPONSIVE === */
@media (width <= 768px) {
  :root {
    --toolbar-width: 50px;
    --panel-width: 280px;
  }
  
.tool-button {
    width: 38px;
    height: 38px;
    font-size: 14px;
}
      
.toolbar-brand {
    width: 36px;
    height: 36px;
}
    }

/* === CHARACTER TABS === */
.character-tab-horizontal {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
}
    
.character-tab-horizontal:hover {
  background: var(--dark-surface);
  color: var(--text-primary);
  transform: translateY(-1px);
}
    
.character-tab-horizontal.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}
    
.character-tab-horizontal.active::after {
  content: '';
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}
    
.character-tab-horizontal i {
  font-size: 12px;
}
    
/* === CHARACTER SQUARE TABS === */
.character-tab-square {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  position: relative;
  border: 1px solid var(--glass-border);
    }
    
.character-tab-square:hover {
  background: var(--dark-surface);
  color: var(--text-primary);
  transform: translateY(-1px);
  border-color: var(--primary);
}
    
.character-tab-square.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
  border-color: var(--primary);
}

/* === CUSTOM MODAL SYSTEM === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgb(0 0 0 / 70%);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001; /* MODALS layer from LayerManager */
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}
    
.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}
    
.modal-dialog {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 24px;
  min-width: 320px;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9) translateY(-20px);
  transition: all 0.3s ease;
}
    
.modal-overlay.show .modal-dialog {
  transform: scale(1) translateY(0);
}
    
.modal-header {
  margin-bottom: 16px;
  text-align: center;
}
    
.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
    
.modal-body {
  margin-bottom: 20px;
}
    
.modal-body p {
  color: var(--text-secondary);
  margin: 0 0 12px;
  line-height: 1.5;
}
    
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
    
.modal-input {
  width: 100%;
  padding: 12px;
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 16px;
  transition: all 0.2s ease;
}
    
.modal-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgb(99 102 241 / 20%);
}
    
/* Character form improvements */
.character-form-row {
  margin-bottom: 16px;
}
    
.character-form-row .form-control {
  width: 100%;
}

/* Custom Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--dark-surface);
  transition: all 0.3s ease;
  border-radius: 24px;
  border: 1px solid var(--glass-border);
}

.toggle-slider:hover {
  border-color: var(--primary);
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  top: 2px;
  background-color: white;
  transition: all 0.3s ease;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgb(0 0 0 / 30%);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(26px);
}

.number-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.number-input {
  width: 100%;
  padding: 6px 10px;
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
  text-align: center;
  font-weight: 500;
  height: 32px;
  box-sizing: border-box;
}

.number-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgb(99 102 241 / 20%);
}

.number-input:hover {
  border-color: var(--primary);
}

/* Enable native number spinners for manual fine control */
.number-input::-webkit-outer-spin-button,
.number-input::-webkit-inner-spin-button {
  appearance: auto;
  margin: 0;
}

.number-input[type="number"] {
  appearance: auto;
}

/* Tooltip for number inputs */
.number-group::after {
  content: "Use arrow keys for fine control (Shift for ±10)";
  position: absolute;
  bottom: -18px;
  left: 0;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
}

.number-group:focus-within::after {
  opacity: 1;
}

/* Range Input Styling */
input[type="range"] {
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--dark-surface);
  border-radius: 3px;
  outline: none;
  margin: 12px 0;
  border: 1px solid var(--glass-border);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
  transition: all 0.2s ease;
}

input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.1);
  background: var(--primary-hover, #7c3aed);
}

input[type="range"]:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(99 102 241 / 20%);
}

/* Fix margin bottom for buttons */
.mb-16 {
  margin-bottom: 16px;
}

/* ===== BUTTON STYLES ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 0.25rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  line-height: 1.5;
  text-align: center;
  white-space: nowrap;
  user-select: none;
  height: 32px; /* unify control height */
}

/* Button States */
.btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
}

.btn:active {
  transform: translateY(0);
  box-shadow: inset 0 2px 4px rgb(0 0 0 / 10%);
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Use toolbar highlight color on focus instead of default outline */
.btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(99 102 241 / 30%);
  border-color: var(--primary);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Button Sizes */
.btn.small {
  padding: 0 12px;
  font-size: 0.75rem;
  height: 32px; /* unified small height */
}

/* Button Variants */
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn.secondary {
  background: var(--dark-surface);
  border-color: var(--glass-border);
}

.btn.secondary:hover {
  background: var(--dark-panel);
  border-color: var(--primary);
}

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

.btn.danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

/* Button Icons */
.btn i {
  margin-right: 0.5rem;
  font-size: 0.875em;
  display: inline-flex;
  align-items: center;
}

.location-header i {
  color: var(--lore-secondary);
}

.btn.small i {
  margin-right: 0.25rem;
  font-size: 0.75em;
}

/* Fix: labels used as buttons should not inherit the generic label all-caps styling */
.section label.btn {
  text-transform: none;           /* keep normal casing, e.g., "Load" */
  letter-spacing: normal;         /* reset spacing from label style */
  font-size: 0.875rem;            /* match .btn base font-size */
  font-weight: 500;               /* match .btn base weight */
}

.section label.btn i {
  font-size: 0.875em;             /* match icon size used in .btn i */
}

/* Button Group */
.btn-group {
  display: inline-flex;
  border-radius: 0.25rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgb(0 0 0 / 10%);
}

/* Tab Buttons */
.tab-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.75rem;
}

.tab-nav .btn {
  font-weight: 500;
}

.btn-group .btn {
  border-radius: 0;
  border-right: 1px solid rgb(255 255 255 / 10%);
  margin: 0;
}

.btn-group .btn:first-child {
  border-top-left-radius: 0.25rem;
  border-bottom-left-radius: 0.25rem;
}

.btn-group .btn:last-child {
  border-top-right-radius: 0.25rem;
  border-bottom-right-radius: 0.25rem;
  border-right: none;
}

.tab-nav .btn.primary {
  position: relative;
  overflow: hidden;
}

.tab-nav .btn.primary::after {
  content: '';
  position: absolute;
  bottom: -0.75rem;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
  transition: all 0.2s ease;
}

/* Quick Reference Card */
.quick-ref-card {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 300px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 800;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95) translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quick-ref-card.show {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

/* ===== PANEL CONTENT STYLES ===== */

/* Section styling */
.section {
  margin-bottom: 24px;
}

.section h4 {
  margin: 0 0 12px 0;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
}

.section p {
  margin: 0 0 16px 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Button styling consolidated into the global .btn section above (around line ~1369). */

/* Flex utilities */
.flex {
  display: flex;
}

.gap-2 {
  gap: 8px;
}

.mb-4 {
  margin-bottom: 16px;
}

/* List styling */
.maps-list,
.characters-list,
.creatures-list,
.initiative-list,
.dice-history,
.lore-list,
.rules-list {
  margin-top: 16px;
}

.maps-list h5,
.characters-list h5,
.creatures-list h5,
.initiative-list h5,
.dice-history h5,
.lore-list h5,
.rules-list h5 {
  margin: 0 0 12px 0;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
}

.map-item,
.character-item,
.creature-item,
.initiative-item,
.dice-roll-item,
.lore-item,
.rule-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-base);
}

.map-item:hover,
.character-item:hover,
.creature-item:hover,
.initiative-item:hover,
.lore-item:hover,
.rule-item:hover {
  background: var(--surface-hover);
  border-color: var(--accent-color);
}

.map-item i,
.character-item i,
.creature-item i,
.lore-item i,
.rule-item i {
  color: var(--accent-color);
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.character-item .level,
.creature-item .cr {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.initiative-item {
  display: grid;
  grid-template-columns: 30px 1fr 60px;
  gap: 12px;
  align-items: center;
}

.initiative-item.active {
  background: var(--accent-color);
  color: var(--text-on-accent);
  border-color: var(--accent-color);
}

.initiative-number {
  font-weight: 600;
  text-align: center;
}

.initiative-roll {
  text-align: right;
  font-weight: 500;
}

.dice-roll-item {
  display: grid;
  grid-template-columns: 1fr 60px 80px;
  gap: 12px;
  align-items: center;
}

.dice-formula {
  font-family: monospace;
  font-weight: 500;
}

.dice-result {
  font-weight: 600;
  text-align: center;
}

.dice-time {
  color: var(--text-muted);
  font-size: 12px;
  text-align: right;
}

/* Chat styling */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 400px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  margin-bottom: 12px;
}

.chat-message {
  margin-bottom: 8px;
  padding: 8px;
  background: var(--surface-hover);
  border-radius: 6px;
}

.chat-timestamp {
  color: var(--text-muted);
  font-size: 12px;
  margin-right: 8px;
}

.chat-sender {
  font-weight: 600;
  color: var(--accent-color);
  margin-right: 8px;
}

.chat-content {
  color: var(--text-primary);
}

.chat-input {
  display: flex;
  gap: 8px;
}

.chat-input input {
  flex: 1;
  padding: 8px 12px;
  background: var(--dark-surface);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  font-size: 14px;
}

.chat-input input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.chat-input button {
  padding: 8px 16px;
  background: var(--accent-color);
  color: var(--text-on-accent);
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.chat-input button:hover {
  background: var(--accent-hover);
}

/* Text utilities */
.text-muted {
  color: var(--text-muted);
  font-style: italic;
}

.quick-ref-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--glass-border);
}

.quick-ref-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.quick-ref-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.quick-ref-close:hover {
  background: var(--danger);
  color: white;
}

.quick-ref-body {
  padding: 16px 20px 20px;
}

.quick-ref-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.quick-ref-stat {
  text-align: center;
  background: rgb(255 255 255 / 5%);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px;
}

.quick-ref-stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.quick-ref-stat-value {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.quick-ref-hp-edit {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.quick-ref-hp-input {
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text-primary);
  font-size: 14px;
  text-align: center;
  transition: all 0.2s ease;
}

.quick-ref-hp-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgb(99 102 241 / 20%);
}

.quick-ref-hp-separator {
  color: var(--text-muted);
  font-weight: 600;
}

.quick-ref-status {
  text-align: center;
  margin-top: 12px;
  font-size: 12px;
}

.quick-ref-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.quick-ref-btn {
  flex: 1;
  padding: 6px 10px;
  background: var(--dark-surface);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.quick-ref-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.quick-ref-btn.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
}

.quick-ref-btn.success:hover {
  background: var(--success);
  border-color: var(--success);
}

/* === UTILITY CLASSES === */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; }



/* Keep Map Management buttons on one line and allow horizontal scroll if needed */
.section .flex.gap-2 {
  flex-wrap: nowrap;
  overflow-x: auto;
  min-width: 0;
  white-space: nowrap;
  gap: 8px;
  padding-bottom: 2px; /* Optional: for visual comfort if scrollbar appears */
}

.section .flex.gap-2 .btn {
  flex: 1 1 0;
  min-width: 0;
  max-width: none; /* allow equal widths per row */
  white-space: nowrap;
}

/* === PANEL/UI UTILITIES (non-invasive, global-safe) === */
/* Spacing helpers */
.m-0 { margin: 0 !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.mb-2 { margin-bottom: 8px !important; }

/* Alignment helpers */
.align-center { align-items: center !important; }

/* Action column and grids for card button layouts (used by Maps/Campaigns/Characters) */
.action-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 188px;
}

.action-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 100%;
  max-width: 188px;
}

/* Helper to make a button fill available width while respecting box sizing */
.btn-full {
  width: 100%;
  box-sizing: border-box;
}
.align-start { align-items: flex-start !important; }

/* Generic grid helper */
.grid { display: grid; }

/* Labels for inline key/value blocks */
.label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Compact stats layout used in panels */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-card {
  background: rgb(255 255 255 / 5%);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.9;
}

/* === LORE PANEL === */

.tab-btn {
  padding: 8px 16px;
  background: var(--dark-surface);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Category Filter */
.category-btn {
  padding: 4px 12px;
  background: var(--dark-surface);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s ease;
}

.category-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.category-btn.active {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

/* Lore Tabs */
.lore-tab {
  transition: all 0.3s ease;
}

.lore-tab.active {
  display: block !important;
}

/* Note Items */
.note-item {
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-left: 3px solid #f59e0b; /* NPC amber accent */
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.note-item:hover {
  border-color: var(--primary);
  border-left-color: #f59e0b;
  box-shadow: var(--shadow-sm);
}

.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.note-header h5 {
  margin: 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}

.note-category {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
}

.note-preview {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 8px;

  /* Standard line clamping with -webkit fallback */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

.note-actions {
  display: flex;
  gap: 4px;
}

.btn-icon {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--primary);
  color: white;
}

/* Location Items */
.location-item {
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-left: 3px solid #10b981; /* Location emerald accent */
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.location-item:hover {
  border-color: var(--lore-secondary);
  border-left-color: #10b981;
  box-shadow: var(--shadow-sm);
}

.location-header h5 {
  margin: 0 0 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.location-preview {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.location-actions {
  display: flex;
  gap: 8px;
}

/* Handout Items (Quest cards) */
.handout-item {
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-left: 3px solid #8b5cf6; /* Quest purple accent */
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.handout-item:hover {
  border-color: var(--lore-primary);
  border-left-color: #8b5cf6;
  box-shadow: var(--shadow-sm);
}

.handout-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.handout-header h5 {
  margin: 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}

.handout-status {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
}

.handout-status.shared {
  background: var(--success);
  color: white;
}

.handout-status.draft {
  background: var(--warning);
  color: white;
}

.handout-preview {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.handout-actions {
  display: flex;
  gap: 8px;
}

.form-group {
  margin-bottom: 12px;
}

.calendar-day.has-events {
  background: rgb(16 185 129 / 10%);
  border-left: 3px solid var(--success);
}

.calendar-day.empty {
  background: rgb(0 0 0 / 10%);
  opacity: 0.3;
}

.calendar-day-number {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.current-day .calendar-day-number {
  color: var(--lore-primary);
  font-weight: 700;
}

.day-events-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calendar-event-mini {
  background: var(--success);
  color: white;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: all 0.2s ease;
}

.calendar-event-mini:hover {
  background: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
}

.has-events .calendar-event-mini:nth-child(odd) {
  background: var(--info);
}

.has-events .calendar-event-mini:nth-child(even) {
  background: var(--warning);
}

/* === REMOVE NUMBER INPUT SPINNERS === */

.no-spinners::-webkit-outer-spin-button,
.no-spinners::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.no-spinners[type="number"] {
  appearance: textfield;
}

/* === CONTEXT MENU === */

.context-menu {
  font-family: Inter, sans-serif;
  font-size: 14px;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  color: var(--text-primary);
}

.context-menu-item:hover {
  background: var(--primary);
  color: white;
}

.context-menu-item:hover i {
  opacity: 1;
}

.context-menu-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 4px 0;
}

.context-menu-submenu {
  position: relative;
}

.context-menu-submenu > .context-menu-item::after {
  content: '›';
  margin-left: auto;
  font-size: 16px;
  opacity: 0.7;
}

.context-menu-submenu:hover > .context-menu-item::after {
  opacity: 1;
}

.context-menu-submenu .context-menu {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  margin-left: 2px;
}

.context-menu-submenu:hover > .context-menu {
  display: block;
}

@keyframes context-menu-fade-in {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ql-toolbar button {
  width: 24px !important;
  height: 24px !important;
  padding: 2px !important;
}

.ql-toolbar .ql-picker {
  font-size: 12px !important;
}

.ql-toolbar .ql-picker-label {
  padding: 2px 4px !important;
  height: 24px !important;
  line-height: 20px !important;
  color: var(--text-secondary) !important;
}

.ql-toolbar .ql-stroke {
  fill: none !important;
  stroke: var(--text-secondary) !important;
}

.ql-toolbar .ql-fill {
  fill: var(--text-secondary) !important;
  stroke: none !important;
}

.ql-toolbar button:hover,
.ql-toolbar button.ql-active {
  color: var(--primary) !important;
}

.ql-toolbar button:hover .ql-stroke {
  stroke: var(--primary) !important;
}

.ql-toolbar button:hover .ql-fill {
  fill: var(--primary) !important;
}

.ql-container {
  background: var(--dark-surface) !important;
  border: 1px solid var(--glass-border) !important;
  border-top: none !important;
  color: var(--text-primary) !important;
  font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif !important;
  font-size: 15px !important;
  line-height: 1.7 !important;
  border-radius: 0 0 8px 8px !important;
}

.ql-editor {
  color: var(--text-primary) !important;
  background: var(--dark-surface) !important;
  line-height: 1.7 !important;
  padding: 20px !important;
  min-height: 400px !important;
}

.ql-editor.ql-blank::before {
  color: var(--text-muted) !important;
  font-style: italic !important;
}

.ql-editor h1, .ql-editor h2, .ql-editor h3 {
  color: var(--text-primary) !important;
  margin-top: 16px !important;
  margin-bottom: 8px !important;
}

.ql-editor strong {
  color: var(--text-primary) !important;
  font-weight: 600 !important;
}

.ql-editor em {
  color: var(--text-secondary) !important;
}

.ql-editor ul, .ql-editor ol {
  padding-left: 20px !important;
}

.ql-editor blockquote {
  border-left: 3px solid var(--primary) !important;
  background: rgb(99 102 241 / 10%) !important;
  margin: 16px 0 !important;
  padding: 12px 16px !important;
  border-radius: 0 6px 6px 0 !important;
}

.ql-picker-options {
  background: var(--dark-surface) !important;
  border-color: var(--glass-border) !important;
}

.ql-snow .ql-picker.ql-expanded .ql-picker-options {
  background: var(--dark-panel) !important;
  border: 1px solid var(--glass-border) !important;
  border-radius: 6px !important;
  box-shadow: var(--shadow-lg) !important;
}

.ql-picker-item {
  color: var(--text-secondary) !important;
}

.ql-picker-item:hover {
  color: var(--primary) !important;
}

.ql-snow .ql-picker-options .ql-picker-item:hover {
  background: var(--primary) !important;
  color: white !important;
}

/* === ELEGANT CHARACTER SHEET STYLING === */
.markdown-editor {
  font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-primary);
  tab-size: 4;
  max-width: none;
  padding: 0;
  margin: 0;
  background: transparent;
}

/* Hidden markdown markers (Bear approach) */
.markdown-editor .marker {
  opacity: 0;
  font-size: 0.75em;
  color: var(--text-muted);
  pointer-events: none;
  transition: opacity 0.2s ease;
  font-weight: 400;
}

/* Show markers on focus for editing context */
.markdown-editor:focus .marker {
  opacity: 0.25;
}

/* Elegant Headers */
.markdown-editor h1 {
  font-size: 1.75em;
  font-weight: 700;
  margin: 1.5em 0 0.75em;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  border-bottom: 2px solid var(--glass-border);
  padding-bottom: 0.5em;
}

.markdown-editor h2 {
  font-size: 1.35em;
  font-weight: 600;
  margin: 1.2em 0 0.6em;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  position: relative;
}

.markdown-editor h2::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 0.1em;
  width: 3px;
  height: 1.2em;
  background: var(--primary);
  border-radius: 2px;
}

.markdown-editor h3 {
  font-weight: 600;
  margin: 1em 0 0.4em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.95em;
  color: var(--text-secondary);
}

/* Refined Paragraph Styling */
.markdown-editor p {
  margin: 0.8em 0;
  line-height: 1.7;
}

.markdown-editor p:first-child {
  margin-top: 0;
}

.markdown-editor p:last-child {
  margin-bottom: 0;
}

.markdown-editor p.blank-line {
  margin: 0.8em 0;
  min-height: 1.2em;
  opacity: 0.3;
}

.markdown-editor p.blank-line::before {
  content: "⌐";
  opacity: 0.1;
  font-size: 0.8em;
}

/* Elegant Lists */
.markdown-editor ul {
  margin: 1em 0;
  padding-left: 0;
  list-style: none;
}

.markdown-editor li {
  margin: 0.5em 0;
  position: relative;
  padding-left: 1.5em;
  line-height: 1.6;
}

.markdown-editor li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: bold;
  font-size: 1.1em;
}

/* Beautiful Todo Checkboxes */
.markdown-editor .todo-checkbox {
  display: inline-flex;
  align-items: center;
  margin-right: 0.5em;
}

.markdown-editor .todo-checkbox input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  margin: 0 0.5em 0 0;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--dark-surface);
}

.markdown-editor .todo-checkbox input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.markdown-editor .todo-checkbox input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: -1px;
  left: 2px;
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.markdown-editor .todo-checkbox input[type="checkbox"]:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

/* Premium Dice Buttons */
.markdown-editor .dice-wrapper {
  display: inline-block;
  position: relative;
  margin: 0 2px;
}

.markdown-editor .dice-button {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%) !important;
  color: white !important;
  border: none !important;
  border-radius: 12px !important;
  padding: 8px 12px !important;
  margin: 0 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 
    0 4px 12px rgb(99 102 241 / 30%),
    0 2px 4px rgb(0 0 0 / 10%),
    inset 0 1px 0 rgb(255 255 255 / 20%) !important;
  transition: all 0.25s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  position: relative !important;
  overflow: hidden !important;
}

.markdown-editor .dice-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 20%), transparent);
  transition: left 0.5s ease;
}

.markdown-editor .dice-button:hover::before {
  left: 100%;
}

.markdown-editor .dice-button:hover {
  transform: translateY(-2px) scale(1.05) !important;
  box-shadow: 
    0 8px 20px rgb(99 102 241 / 40%),
    0 4px 8px rgb(0 0 0 / 15%),
    inset 0 1px 0 rgb(255 255 255 / 30%) !important;
}

.markdown-editor .dice-button:active {
  transform: translateY(0) scale(0.98) !important;
  box-shadow: 
    0 2px 8px rgb(99 102 241 / 30%),
    0 1px 2px rgb(0 0 0 / 10%) !important;
}

.markdown-editor .dice-button i {
  font-size: 11px !important;
  color: white !important;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 30%));
}

/* Refined Focus Styles */
.markdown-editor:focus {
  outline: none;
  background: rgb(255 255 255 / 1%);
}

/* Enhanced Bold and Italic */
.markdown-editor strong {
  font-weight: 700;
  color: var(--text-primary);
}

.markdown-editor em {
  font-style: italic;
  color: var(--text-secondary);
}

/* Content Container Styling */
.new-tab-content {
  background: transparent;
}


/* Custom dice and divider buttons */
.ql-dice-roll, .ql-divider {
  width: 28px !important;
  height: 28px !important;
}

.ql-dice-roll:hover, .ql-divider:hover {
  color: var(--primary) !important;
}



/* Divider line styling */
.divider-line {
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
  margin: 16px 0;
  border: none;
}

/* ===== Mapcase Card Layout ===== */
.mapcase-grid {
  display: grid;
  /* Stable columns: don't let cards shrink below a readable width */
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0; /* important when parent is flex */
  overflow: visible; /* let content render within section; section clips if needed */
  justify-items: stretch; /* ensure single column stretches full width */
  padding-left: 0; /* align with section title */
  padding-right: 0;
}

.mapcard {
  display: grid;
  gap: 10px;
  padding: 10px; /* uniform padding so left edge aligns with section title */
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: #0f1114;
  width: 100%;
  max-width: 100%;
  min-width: 0; /* avoid flex overflow */
  box-sizing: border-box;
  overflow: visible; /* avoid clipping inner controls on the right */
}

.mapcard * { box-sizing: border-box; }

.mapcard-title {
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
  white-space: normal;
  overflow-wrap: anywhere;
}

.mapcard-usage {
  font-size: 12px;
  margin-top: 2px;
  color: var(--text-muted, #9aa4b2);
}

/* Main two-column area inside a card: 30% thumb | 70% actions */
.mapcard-main {
  display: grid;
  grid-template-columns: 24% 76%; /* explicit split that sums to 100% */
  gap: 6px; /* modest gap inside the 100% total */
  align-items: start;
}

.mapcard-thumb {
  height: 72px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  overflow: hidden;
  background: #1b1f24;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mapcard-thumb img {
  width: 100%;
  height: 72px;
  object-fit: cover;
  display: block;
}

.mapcard-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-self: stretch;
  width: 100%;
  padding-right: 6px; /* create a safe inset inside the 76% column */
}

/* Fill the actions column to avoid any right-edge clipping */
.mapcard-load {
  width: 100%; /* fill only the actions column (76% of card) */
  height: 26px;
}

/* Ensure buttons inside actions can shrink within the column */
.mapcard-actions .btn {
  min-width: 0;
  padding-left: 4px;
  padding-right: 4px; /* compact spacing */
  font-size: 0.8rem; /* compact but readable */
}

.mapcard-row {
  display: flex;
  gap: 4px;
  width: 100%; /* fill the actions column */
}

.mapcard-row .btn {
  height: 26px;
  flex: 1 1 0; /* split the row equally */
  min-width: 0;
}

/* === RUNEBINDER REFERENCE STYLES === */
.rb-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px 10px 8px;
}

.rb-toolbar-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--dark-surface);
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all var(--transition-base);
}

.rb-toolbar-btn:hover { 
  background: rgba(255,255,255,0.04); 
  color: var(--text-primary); 
  border-color: var(--primary);
  transform: translateY(-1px);
}

.rb-toolbar-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.rb-toolbar-spacer {
  flex: 1 1 auto;
}

.rb-search {
  margin: 6px 8px 10px 8px;
}

.rb-content {
  display: block;
  padding: 0 8px 8px 8px;
}

.rb-system-name {
  margin: 4px 8px 6px 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.rb-section {
  padding: 0;
  margin-bottom: 10px;
  background: rgb(255 255 255 / 2%);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  overflow: hidden;
}

.rb-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--dark-surface);
  cursor: pointer;
  user-select: none;
}

.rb-icon-btn {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 4px 6px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rb-icon-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

.rb-section-header .rb-section-collapse-all,
.rb-section-header .rb-section-expand-all {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  padding: 0 6px;
  cursor: pointer;
}

.rb-section-header .rb-section-collapse-all:hover,
.rb-section-header .rb-section-expand-all:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.rb-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.rb-section-chevron {
  font-size: 12px;
  color: var(--text-secondary);
}

.rb-section-content {
  padding: 10px;
  border-top: 1px solid var(--glass-border);
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.rb-section-intro {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 2px 2px 8px 2px;
}

.rb-section.collapsed .rb-section-content {
  display: none;
}

.rb-card {
  background: rgb(255 255 255 / 4%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.rb-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.rb-card-chevron {
  font-size: 12px;
  color: var(--text-secondary);
}

.rb-card-body {
  margin-top: 8px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.rb-card.collapsed .rb-card-body {
  display: none;
}

.rb-card:hover {
  border-color: var(--primary);
}

.rb-card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px 0;
}

.rb-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  vertical-align: middle;
}

.rb-badge.secondary {
  background: rgba(255,255,255,0.16);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.rb-card-summary {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.rb-card-details {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.45;
}

.rb-subheading {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 6px 0 4px 0;
  text-transform: none;
}

.rb-list {
  margin: 4px 0 6px 18px;
  padding: 0;
}

.rb-list li {
  margin: 2px 0;
}

.rb-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 4px 0 6px 0;
}

.rb-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
}

/* ===== Spell Card Styles ===== */
.spell-quick-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.spell-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 11px;
  background: rgba(122, 148, 255, 0.12);
  border: 1px solid rgba(122, 148, 255, 0.2);
  border-radius: 6px;
  color: var(--text-secondary);
}

.spell-meta-chip i {
  opacity: 0.8;
  font-size: 10px;
}

.spell-meta-chip-warning {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  font-weight: 600;
}

.spell-meta-chip-warning i {
  color: #fbbf24;
  opacity: 1;
}

.spell-components,
.spell-duration {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.spell-components strong,
.spell-duration strong {
  color: var(--text-primary);
  font-weight: 600;
}

.spell-description {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.5;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.spell-description em {
  color: var(--text-muted);
  font-style: italic;
  font-size: 11px;
}

.spell-card-header {
  transition: background-color 0.2s ease;
  cursor: pointer;
  user-select: none;
}

.spell-card-header:hover {
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
}

.spell-level-header {
  background: rgba(122, 148, 255, 0.08);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  transition: background-color 0.2s ease;
  cursor: pointer;
  user-select: none;
}

.spell-level-header:hover {
  background: rgba(122, 148, 255, 0.12);
}

.spell-level-header .rb-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== CHARACTER PORTRAIT SECTION ===== */
.character-portrait-section {
  position: relative;
  width: 100%;
  height: 300px;
  overflow: hidden;
  margin: 0 0 0 0; /* No margins - contained within panel */
  background: linear-gradient(135deg, rgba(30, 30, 40, 0.9) 0%, rgba(20, 20, 30, 0.9) 100%);
  border-radius: 0; /* Sharp corners at top to match panel */
}

.character-portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.character-portrait-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  color: rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, rgba(50, 50, 70, 0.3) 0%, rgba(30, 30, 50, 0.3) 100%);
}

.character-name-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 16px 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 50%, transparent 100%);
}

.character-name-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 4px 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  line-height: 1.2;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.character-name-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  font-weight: 500;
}

/* ===== CHARACTER INFO BAR ===== */
.character-info-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.character-info-item {
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
}

.character-info-item-value {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 2px;
}

/* ===== HP BAR SECTION ===== */
.hp-bar-section {
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hp-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.hp-bar-value {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.hp-progress-bar {
  position: relative;
  width: 100%;
  height: 24px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 8px;
}

.hp-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.hp-progress-fill.low {
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.hp-progress-fill.critical {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.rest-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rest-btn {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.2s ease;
}

.rest-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.rest-btn i {
  margin-right: 4px;
}

/* ===== CHARACTER TAB TOOLTIPS ===== */
.character-tab-square {
  position: relative;
}

.character-tab-square::after {
  content: attr(title);
  position: absolute;
  bottom: -32px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}

.character-tab-square::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-bottom-color: rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1001;
}

.character-tab-square:hover::after,
.character-tab-square:hover::before {
  opacity: 1;
}

/* ===== ACTION ROLL BUTTONS ===== */
.action-roll-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
  width: 100%;
  max-width: 100%;
}

.action-roll-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-radius: 6px;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.03);
  min-width: 0;
  box-sizing: border-box;
}

.action-roll-btn.attack {
  border-color: rgba(59, 130, 246, 0.5);
  color: #3b82f6;
}

.action-roll-btn.attack:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: #3b82f6;
  transform: translateY(-1px);
}

.action-roll-btn.damage {
  border-color: rgba(239, 68, 68, 0.5);
  color: #ef4444;
}

.action-roll-btn.damage:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  transform: translateY(-1px);
}

.action-roll-btn i {
  font-size: 13px;
}

/* Weapon card styling */
.weapon-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.weapon-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.weapon-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.weapon-card-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.weapon-card-type {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.weapon-card-details {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.4;
}

.weapon-card-properties {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

/* ===== CLICKABLE ABILITY SCORES & SAVES ===== */
.ability-modifier-clickable {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  user-select: none;
}

.ability-modifier-clickable:hover {
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
  transform: scale(1.05);
}

.ability-modifier-clickable:active {
  transform: scale(0.95);
}

.save-throw-clickable {
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.2s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.save-throw-clickable:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: #6366f1;
  color: #6366f1;
  transform: translateY(-1px);
}

.save-throw-clickable:active {
  transform: translateY(0);
}

.save-throw-clickable.proficient {
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.08);
}

/* ===== CLICKABLE SKILLS ===== */
.skill-row-clickable {
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid transparent;
}

.skill-row-clickable:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateX(2px);
}

.skill-row-clickable:active {
  transform: translateX(0);
}

.skill-row-clickable.proficient {
  background: rgba(99, 102, 241, 0.05);
  border-color: rgba(99, 102, 241, 0.2);
}

.skill-row-clickable.proficient:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
}

/* Conditions & Effects Styling */
.condition-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.condition-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.condition-card.expanded {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(220, 38, 38, 0.3);
}

.condition-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.condition-name {
  font-weight: 600;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  gap: 6px;
}

.condition-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(220, 38, 38, 0.15);
  color: #fca5a5;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.condition-details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.condition-summary {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 8px;
  line-height: 1.4;
}

.condition-effects {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.condition-effect-item {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  padding-left: 12px;
  position: relative;
  line-height: 1.4;
}

.condition-effect-item::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #fca5a5;
}

.condition-remove-btn {
  padding: 4px 8px;
  font-size: 11px;
  background: rgba(220, 38, 38, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.condition-remove-btn:hover {
  background: rgba(220, 38, 38, 0.25);
  border-color: rgba(220, 38, 38, 0.5);
}

.add-condition-btn {
  width: 100%;
  padding: 10px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px dashed rgba(99, 102, 241, 0.3);
  border-radius: 6px;
  color: #a5b4fc;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.add-condition-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.5);
  color: #c7d2fe;
}

.conditions-empty-state {
  text-align: center;
  padding: 20px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-style: italic;
}

/* Condition Selection Dropdown */
.condition-select-dropdown-wrapper {
  position: relative;
}

.condition-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--dark-surface);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.condition-select-item {
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.condition-select-item:last-child {
  border-bottom: none;
}

.condition-select-item:hover {
  background: rgba(99, 102, 241, 0.15);
}

.condition-select-item-name {
  font-weight: 600;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  gap: 8px;
}

.condition-select-item-summary {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.3;
}

.condition-select-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.condition-select-item.disabled:hover {
  background: transparent;
}

/* Conditions Badge Bar (in character header) */
.conditions-badge-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  align-items: center;
  min-height: 36px;
}

.condition-badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: help;
  transition: all 0.2s ease;
  border: 1px solid;
  position: relative;
}

.condition-badge-icon:hover {
  transform: scale(1.05);
  filter: brightness(1.2);
}

.condition-badge-icon i {
  font-size: 12px;
}

.condition-badge-advantage-indicator {
  font-size: 9px;
  margin-left: 2px;
  opacity: 0.9;
}

/* ========================================
   RESOURCES
   ======================================== */

.resource-item {
  transition: all 0.2s ease;
}

.resource-item:hover {
  background: rgba(255, 255, 255, 0.04) !important;
}

.resource-dot {
  transition: all 0.2s ease;
}

.resource-dot:hover {
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

.resource-dot.available {
  box-shadow: 0 0 4px rgba(99, 102, 241, 0.3);
}

.resource-dot.used {
  opacity: 0.4;
}

.resource-dot.used:hover {
  opacity: 0.7;
}

/* ========================================
   SPELL SLOTS
   ======================================== */

.spell-slot-dot {
  transition: all 0.2s ease;
}

.spell-slot-dot:hover {
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

.spell-slot-dot.available {
  box-shadow: 0 0 4px rgba(99, 102, 241, 0.3);
}

.spell-slot-dot.used {
  opacity: 0.4;
}

.spell-slot-dot.used:hover {
  opacity: 0.7;
}
/* ================================
   GAME INFO WIDGET (Initiative & Dice)
   ================================ */

.game-info-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 320px;
  background: rgba(26, 27, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  z-index: 900;
  display: flex;
  flex-direction: column;
  max-height: 500px;
  transition: all 0.3s ease;
}

.game-info-widget.minimized {
  max-height: 48px;
}

.game-info-widget.minimized .widget-body {
  display: none;
}

/* Widget Header */
.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: move;
  user-select: none;
}

.widget-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.widget-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.widget-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.9);
}

.widget-tab.active {
  background: rgba(99, 102, 241, 0.2);
  color: #fff;
}

.widget-tab i {
  font-size: 14px;
}

.widget-controls {
  display: flex;
  gap: 4px;
}

.widget-control-btn {
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.2s ease;
}

.widget-control-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Widget Body */
.widget-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.widget-tab-content {
  display: none;
  flex-direction: column;
  height: 100%;
  padding: 12px;
  overflow-y: auto;
}

.widget-tab-content.active {
  display: flex;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-state p {
  margin: 8px 0 4px 0;
  font-size: 14px;
  font-weight: 500;
}

.empty-state small {
  font-size: 12px;
  opacity: 0.7;
}

/* Initiative Tab */
.initiative-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.initiative-list {
  flex: 1;
  overflow-y: auto;
}

.initiative-item {
  display: flex;
  align-items: center;
  padding: 10px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.initiative-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.initiative-item.current-turn {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
}

.initiative-item-value {
  min-width: 40px;
  padding: 4px 8px;
  background: rgba(99, 102, 241, 0.2);
  border-radius: 4px;
  font-weight: bold;
  text-align: center;
  margin-right: 10px;
}

.initiative-item-name {
  flex: 1;
  font-size: 14px;
}

.initiative-item-actions {
  display: flex;
  gap: 4px;
}

.initiative-item-btn {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.initiative-item-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}

/* Dice Tab */
.dice-quick-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.dice-btn {
  padding: 10px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 4px;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dice-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
  transform: translateY(-2px);
}

.dice-btn:active {
  transform: translateY(0);
}

.dice-custom {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.dice-custom input {
  flex: 1;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
}

.dice-custom input:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(255, 255, 255, 0.08);
}

.dice-results {
  flex: 1;
  overflow-y: auto;
  max-height: 250px;
}

.dice-result-item {
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid rgba(99, 102, 241, 0.5);
  border-radius: 4px;
}

.dice-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.dice-result-expression {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

.dice-result-total {
  font-size: 20px;
  font-weight: bold;
  color: #fff;
}

.dice-result-rolls {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.dice-result-roller {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 4px;
}

/* Small Button Styles */
.btn-sm {
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-sm:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.btn-sm.primary {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

.btn-sm.primary:hover {
  background: rgba(99, 102, 241, 0.3);
  border-color: rgba(99, 102, 241, 0.6);
}

.btn-sm i {
  font-size: 11px;
}

/* ===== Wall Control Panel ===== */
.wall-control-panel {
  position: absolute;
  z-index: 1000;
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px;
  display: flex;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
}

.wall-control-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-subtle);
  background: var(--dark-surface);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all var(--transition-base);
}

.wall-control-btn:hover {
  background: var(--glass-subtle);
  border-color: var(--primary);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.wall-control-btn:active {
  transform: translateY(0);
}

.wall-control-btn i {
  pointer-events: none;
}

/* Delete button special styling */
#wallDelete:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
  color: var(--danger);
}

/* NPC Portrait hover effects */
.npc-portrait:hover .portrait-overlay {
  opacity: 1 !important;
}

.npc-portrait-placeholder:hover {
  background: rgba(99, 102, 241, 0.2) !important;
}

.npc-portrait-placeholder:hover i {
  color: rgba(255, 255, 255, 0.7) !important;
}

.portrait-action-btn:hover {
  background: rgba(255, 255, 255, 0.4) !important;
}

/* ===== Entity Mentions (from TipTap editor @mentions) ===== */
.entity-mention {
  color: var(--primary, #6366f1);
  background: rgba(99, 102, 241, 0.15);
  padding: 1px 4px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.entity-mention:hover {
  background: rgba(99, 102, 241, 0.3);
  text-decoration: underline;
}

.journal-content .entity-mention,
.backstory-content .entity-mention {
  cursor: pointer;
}

/* ===== Creature Quick Popover ===== */
.creature-popover {
  position: fixed;
  z-index: 10001;
  width: 290px;
  height: 400px;
  background: #1F1F28;
  border: 1px solid #4B4B52;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #fff;
  overflow: hidden;
}

/* Popover Header - Draggable */
.creature-popover__header {
  display: flex;
  align-items: flex-start;
  padding: 10px;
  gap: 10px;
  cursor: grab;
  user-select: none;
}

.creature-popover__header:active {
  cursor: grabbing;
}

.creature-popover__portrait {
  width: 35px;
  height: 35px;
  background: #442A2F;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.creature-popover__portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.creature-popover__portrait-icon {
  color: #E77975;
  font-size: 18px;
}

.creature-popover__info {
  flex: 1;
  min-width: 0;
}

.creature-popover__name {
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  /* Allow up to 2 lines for long names */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.creature-popover__type {
  font-weight: 300;
  font-size: 12px;
  color: #CDD5E0;
}

/* AC Shield */
.creature-popover__ac-shield {
  position: relative;
  width: 40px;
  height: 45px;
  flex-shrink: 0;
}

.creature-popover__ac-shield svg {
  width: 100%;
  height: 100%;
}

.creature-popover__ac-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 700;
  font-size: 22px;
  color: #fff;
  margin-top: -4px;
}

/* Header Buttons */
.creature-popover__header-buttons {
  display: flex;
  gap: 4px;
  margin: -5px -5px 0 0;
}

.creature-popover__btn {
  background: transparent;
  border: none;
  color: #7A7A80;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.creature-popover__btn--delete {
  font-size: 14px;
}

.creature-popover__btn--delete:hover {
  color: #E77975;
}

.creature-popover__btn--close {
  font-size: 18px;
}

.creature-popover__btn--close:hover {
  color: #fff;
}

/* Tab Bar */
.creature-popover__tabs {
  display: flex;
  gap: 5px;
  padding: 0 10px;
  margin-bottom: 5px;
}

.creature-popover__tab {
  flex: 1;
  height: 25px;
  border-radius: 6px;
  border: none;
  background: #2A3344;
  color: #CDD5E0;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.01em;
  text-align: center;
  transition: all 0.15s;
}

.creature-popover__tab:hover {
  background: #3A4354;
}

.creature-popover__tab--active {
  background: #6466E8;
  color: #fff;
}

/* Tab Content */
.creature-popover__content {
  height: 280px;
  overflow: hidden;
}

.creature-popover__scroll {
  padding: 0 10px 35px 10px;
  height: 100%;
  overflow-y: auto;
}

.creature-popover__scroll--flex {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Footer */
.creature-popover__footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  text-align: center;
  border-top: 1px solid #4B4B52;
  background: #1F1F28;
}

.creature-popover__footer-text {
  font-size: 9px;
  color: #7A7A80;
  font-weight: 300;
}

/* HP Section */
.creature-popover__hp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
}

.creature-popover__hp-btn {
  width: 25px;
  height: 35px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 2px;
  border: 1px solid;
}

.creature-popover__hp-btn--damage {
  background: #442A2F;
  border-color: #82393A;
}

.creature-popover__hp-btn--damage i,
.creature-popover__hp-btn--damage span {
  color: #E77975;
}

.creature-popover__hp-btn--heal {
  background: #2C4035;
  border-color: #40744A;
}

.creature-popover__hp-btn--heal i,
.creature-popover__hp-btn--heal span {
  color: #5EC269;
}

.creature-popover__hp-btn i {
  font-size: 10px;
}

.creature-popover__hp-btn span {
  font-size: 14px;
  line-height: 1;
}

.creature-popover__hp-btn:hover {
  filter: brightness(1.2);
}

.creature-popover__hp-label {
  font-weight: 700;
  font-size: 12px;
}

.creature-popover__hp-bar {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  overflow: hidden;
}

.creature-popover__hp-fill {
  height: 100%;
  background: #5EC269;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.creature-popover__hp-value {
  font-weight: 700;
  font-size: 12px;
  min-width: 50px;
  text-align: right;
}

/* Legendary Resistance */
.creature-popover__leg-resist {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #4B4B52;
}

.creature-popover__leg-resist-label {
  font-size: 12px;
  color: #70A3F3;
  font-weight: 500;
}

.creature-popover__leg-resist-pips {
  display: flex;
  gap: 5px;
}

.creature-popover__leg-resist-pip {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #2A3344;
  border: 2px solid #70A3F3;
  cursor: pointer;
  transition: background 0.15s;
}

.creature-popover__leg-resist-pip--used {
  background: #286AE6;
}

.creature-popover__leg-resist-pip:hover {
  border-color: #90B3F3;
}

/* Legendary Actions (in Actions tab) */
.creature-popover__leg-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 8px 0;
  margin-bottom: 4px;
}

.creature-popover__leg-actions-label {
  font-size: 12px;
  color: #C084FC;
  font-weight: 500;
}

.creature-popover__leg-actions-pips {
  display: flex;
  gap: 5px;
}

.creature-popover__leg-actions-pip {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #9333EA;
  border: 2px solid #C084FC;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.creature-popover__leg-actions-pip--used {
  background: #2A2344;
  opacity: 0.5;
}

.creature-popover__leg-actions-pip:hover {
  border-color: #D8B4FE;
}

/* Defenses */
.creature-popover__defenses {
  padding: 8px 0;
  font-size: 12px;
}

.creature-popover__defense-row {
  margin-bottom: 2px;
}

.creature-popover__defense-label--resist {
  color: #FB923C;
}

.creature-popover__defense-label--immune {
  color: #DD524C;
}

/* Section Headers */
.creature-popover__section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.creature-popover__section-header--spaced {
  margin-top: 4px;
}

.creature-popover__section-line {
  flex: 1;
  height: 1px;
  background: #4B4B52;
}

.creature-popover__section-title {
  font-weight: 700;
  font-size: 12px;
  color: #CDD5E0;
}

/* Abilities & Saves Grid */
.creature-popover__abilities-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
}

.creature-popover__ability-cell {
  background: #2A3344;
  border: 1px solid #4F5664;
  border-radius: 6px;
  padding: 4px 2px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.creature-popover__ability-label {
  font-size: 9px;
  font-weight: 600;
  color: #7A7A80;
  margin-bottom: 1px;
}

.creature-popover__ability-check {
  cursor: pointer;
  padding: 2px 0;
  border-radius: 4px;
  transition: background 0.15s;
}

.creature-popover__ability-check:hover {
  background: #3A4354;
}

.creature-popover__ability-score {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}

.creature-popover__ability-mod {
  font-size: 10px;
  font-weight: 500;
  color: #8C7CD2;
}

.creature-popover__ability-save-btn {
  font-size: 10px;
  font-weight: 600;
  color: #7A7A80;
  border-top: 1px solid #4B4B52;
  padding: 3px 0 1px 0;
  margin-top: 2px;
  cursor: pointer;
  border-radius: 0 0 4px 4px;
  transition: background 0.15s, color 0.15s;
}

.creature-popover__ability-save-btn:hover {
  background: #3A4354;
  color: #A0A0A8;
}

.creature-popover__ability-save-btn--proficient {
  color: #F2C14B;
}

.creature-popover__ability-save-btn--proficient:hover {
  color: #FFD84B;
}

/* Legacy Saves Grid (keep for backwards compatibility) */
.creature-popover__saves-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
}

.creature-popover__save-chip {
  background: #2A3344;
  border: 1px solid #4F5664;
  border-radius: 6px;
  padding: 4px 2px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.creature-popover__save-chip:hover {
  background: #3A4354;
  border-color: #6F7684;
}

.creature-popover__save-label {
  font-size: 11px;
  font-weight: 300;
  color: #CDD5E0;
}

.creature-popover__save-value {
  font-size: 12px;
  font-weight: 700;
  color: #8C7CD2;
}

.creature-popover__save-value--proficient {
  color: #F2C14B;
}

/* Conditions Grid */
.creature-popover__conditions-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
}

.creature-popover__condition {
  padding: 2px 3px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  background: #2A3344;
  border: 1px solid transparent;
  color: #4F5664;
  transition: all 0.15s;
}

.creature-popover__condition:hover {
  background: #3A4354;
  color: #6F7684;
}

.creature-popover__condition--active {
  background: #453C2B;
  border-color: #836C32;
  color: #E1B53E;
}

/* Exhaustion has levels 1-5, style more prominently when active */
.creature-popover__condition--exhaustion.creature-popover__condition--active {
  background: linear-gradient(135deg, #4A2F2F 0%, #3A2222 100%);
  border-color: #8B4444;
  color: #FF8888;
  font-weight: 600;
}

/* Mini section header for extra conditions */
.creature-popover__section-header--mini {
  margin-top: 8px;
  margin-bottom: 6px;
}

.creature-popover__section-title--mini {
  font-size: 9px;
  color: #5A5A60;
}

/* Extra conditions have slightly different styling */
.creature-popover__condition--extra {
  border-style: dashed;
  font-size: 10px;
}

.creature-popover__condition--extra.creature-popover__condition--active {
  background: #2B3A45;
  border-color: #4A7A8C;
  border-style: solid;
  color: #7AC4D8;
}

/* Speed Row */
.creature-popover__speed-row {
  display: flex;
  padding: 8px 10px;
  border-bottom: 1px solid #4B4B52;
  flex-shrink: 0;
}

.creature-popover__speed-item {
  flex: 1;
  text-align: center;
}

.creature-popover__speed-label {
  font-size: 12px;
  font-weight: 300;
  color: #CDD5E0;
}

.creature-popover__speed-value {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.creature-popover__speed-divider {
  width: 1px;
  background: #4B4B52;
  margin: 0 2px;
}

/* Actions List */
.creature-popover__actions-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 35px 10px;
  min-height: 0;
}

.creature-popover__action {
  padding: 8px 0;
  border-bottom: 1px solid #2A3344;
}

.creature-popover__action:last-child {
  border-bottom: none;
}

.creature-popover__action-header {
  font-size: 13px;
}

.creature-popover__action-header--spaced {
  margin-bottom: 6px;
}

.creature-popover__action--no-border {
  border-bottom: none;
}

.creature-popover__section {
  padding: 8px 0;
}

.creature-popover__action-name {
  font-weight: 500;
  color: #E9A23B;
}

.creature-popover__action-cost {
  color: #E9A23B;
}

.creature-popover__action-reach {
  font-weight: 300;
  color: #fff;
}

.creature-popover__action-desc {
  font-weight: 300;
  color: #fff;
}

.creature-popover__action-dice {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.creature-popover__dice-chip {
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 300;
  transition: filter 0.15s;
}

.creature-popover__dice-chip:hover {
  filter: brightness(1.3);
}

.creature-popover__dice-chip--attack {
  background: #283731;
  color: #5CBE68;
}

.creature-popover__dice-chip--damage {
  background: #3B262D;
  color: #E47774;
}

/* Recharge & Legendary Action Tracking */
.creature-popover__action--unavailable {
  opacity: 0.5;
}

.creature-popover__action--unavailable .creature-popover__action-name {
  color: #7A7A80;
}

.creature-popover__recharge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 4px;
}

.creature-popover__recharge--ready {
  background: rgba(92, 190, 104, 0.2);
  color: #5CBE68;
}

.creature-popover__recharge--used {
  background: rgba(122, 122, 128, 0.2);
  color: #7A7A80;
}

.creature-popover__action-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: all 0.15s;
}

.creature-popover__action-btn--use {
  background: rgba(92, 190, 104, 0.2);
  color: #5CBE68;
}

.creature-popover__action-btn--use:hover {
  background: rgba(92, 190, 104, 0.4);
}

.creature-popover__action-btn--recharge {
  background: rgba(100, 102, 232, 0.2);
  color: #6466E8;
}

.creature-popover__action-btn--recharge:hover {
  background: rgba(100, 102, 232, 0.4);
}

/* Spellcasting section in popover */
.creature-popover__spell-meta {
  font-size: 11px;
  color: #8C7CD2;
  font-weight: 500;
  padding: 4px 12px 2px;
  letter-spacing: 0.3px;
}

.creature-popover__spell-row {
  font-size: 12px;
  line-height: 1.5;
  padding: 2px 12px;
}

.creature-popover__spell-level {
  font-weight: 600;
  color: #A78BFA;
  font-size: 11px;
}

.creature-popover__spell-names {
  color: #CDD5E0;
  font-weight: 300;
}

/* Spell slot pips */
.creature-popover__spell-slot-pips {
  display: inline-flex;
  gap: 3px;
  margin: 0 6px 0 2px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.creature-popover__spell-slot-pip {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid #A78BFA;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.creature-popover__spell-slot-pip--used {
  background: #A78BFA;
  box-shadow: 0 0 4px rgba(167, 139, 250, 0.4);
}

.creature-popover__spell-slot-pip:hover {
  border-color: #C4B5FD;
  box-shadow: 0 0 6px rgba(196, 181, 253, 0.5);
}

.creature-popover__spell-link {
  color: #60A5FA;
  cursor: pointer;
  border-bottom: 1px dotted rgba(96, 165, 250, 0.4);
  transition: color 0.2s, border-color 0.2s;
}

.creature-popover__spell-link:hover {
  color: #93C5FD;
  border-bottom-color: rgba(147, 197, 253, 0.6);
}

/* Spell tooltip from popover */
.creature-popover__spell-tooltip {
  position: fixed;
  z-index: 10002;
  max-width: 280px;
  background: #1e1e2e;
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  color: #e0e0e0;
  font-size: 12px;
  line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.creature-popover__spell-tooltip-name {
  font-weight: 700;
  font-size: 13px;
  color: #60A5FA;
  margin-bottom: 2px;
}

.creature-popover__spell-tooltip-meta {
  font-size: 10px;
  opacity: 0.7;
  margin-bottom: 4px;
  font-style: italic;
}

.creature-popover__spell-tooltip-detail {
  font-size: 11px;
  color: #9ca3af;
  line-height: 1.4;
}

.creature-popover__spell-tooltip-detail strong {
  color: #d1d5db;
}

.creature-popover__spell-tooltip-desc {
  font-size: 12px;
  line-height: 1.4;
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 6px;
}

.creature-popover__spell-tooltip-expand {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 10px;
  background: rgba(96, 165, 250, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 6px;
  color: #60a5fa;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.creature-popover__spell-tooltip-expand:hover {
  background: rgba(96, 165, 250, 0.25);
  color: #93c5fd;
}

/* Legendary Actions Header with Counter */
.creature-popover__legendary-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 8px;
}

.creature-popover__legendary-counter {
  font-size: 12px;
  font-weight: 700;
  color: #a855f7;
  background: rgba(168, 85, 247, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.creature-popover__legendary-reset {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: none;
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: all 0.15s;
}

.creature-popover__legendary-reset:hover {
  background: rgba(168, 85, 247, 0.3);
}

/* Stats Tab - Key Stats Row */
.creature-popover__stats-row {
  display: flex;
  gap: 5px;
  padding: 10px 0;
}

.creature-popover__stat-box {
  flex: 1;
  background: #2A3344;
  border-radius: 6px;
  padding: 8px 4px;
  text-align: center;
}

.creature-popover__stat-box--cr {
  background: linear-gradient(135deg, #C93A31, #8D2822);
}

.creature-popover__stat-box--cr .creature-popover__stat-label,
.creature-popover__stat-box--cr .creature-popover__stat-value {
  color: #fff;
}

.creature-popover__stat-label {
  font-size: 11px;
  font-weight: 300;
  color: #CDD5E0;
  line-height: 1.2;
}

.creature-popover__stat-value {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-top: 4px;
}

/* Stats Sections */
.creature-popover__stats-section {
  padding: 8px 0;
  border-bottom: 1px solid #4B4B52;
}

.creature-popover__stats-section:last-child {
  border-bottom: none;
}

.creature-popover__stats-text {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
  text-align: center;
}

/* Skills */
.creature-popover__skills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

.creature-popover__skill-chip {
  background: #2A3344;
  border: 1px solid #4F5664;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  transition: all 0.15s;
}

.creature-popover__skill-chip:hover {
  background: #3A4354;
  border-color: #6F7684;
}

/* Token Settings */
.creature-popover__token-settings {
  padding: 8px 0;
}

.creature-popover__token-toggles {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 10px;
}

.creature-popover__token-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  color: #CDD5E0;
}

.creature-popover__token-toggle input {
  width: 14px;
  height: 14px;
  accent-color: #6466E8;
  cursor: pointer;
}

.creature-popover__token-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.creature-popover__token-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.creature-popover__token-control-label {
  font-size: 11px;
  color: #CDD5E0;
}

.creature-popover__token-input {
  width: 50px;
  background: #2A3344;
  border: 1px solid #4F5664;
  border-radius: 4px;
  color: #fff;
  padding: 4px 6px;
  font-size: 12px;
  text-align: center;
  font-family: 'Inter', system-ui, sans-serif;
}

.creature-popover__token-input:focus {
  outline: none;
  border-color: #6466E8;
}

.creature-popover__token-input--rotation {
  width: 55px;
}

.creature-popover__token-unit {
  font-size: 11px;
  color: #7A7A80;
}

/* ═══════════════════════════════════════════════════════════════
   Map Context Menu — right-click on empty map (GM only)
   ═══════════════════════════════════════════════════════════════ */

.map-context-menu {
  position: fixed;
  z-index: 10001;
  width: 320px;
  background: #1F1F28;
  border: 1px solid #4B4B52;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #fff;
  overflow: hidden;
}

/* Title bar — draggable row with title + close button */
.mcm-titlebar {
  display: flex;
  align-items: center;
  padding: 8px 10px 6px;
  cursor: grab;
  user-select: none;
  background: #26262F;
  border-radius: 10px 10px 0 0;
}
.mcm-titlebar:active {
  cursor: grabbing;
}

.mcm-title {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  color: #CDD5E0;
  flex: 1;
}
.mcm-title i {
  color: #8b5cf6;
  margin-right: 5px;
}

/* Close button */
.mcm-close-btn {
  background: transparent;
  border: none;
  color: #7A7A80;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.mcm-close-btn:hover {
  color: #fff;
  background: rgba(255, 80, 80, 0.25);
}

/* Tab bar — row below title */
.mcm-tabbar {
  display: flex;
  gap: 4px;
  padding: 0 10px 8px;
  background: #26262F;
  border-bottom: 1px solid #333;
}

.mcm-tab {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #7A7A80;
  font-size: 11px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-align: center;
}
.mcm-tab:hover {
  color: #CDD5E0;
  background: rgba(255,255,255,0.05);
}
.mcm-tab.active {
  color: #fff;
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.4);
}
.mcm-tab i {
  margin-right: 4px;
  font-size: 10px;
}

/* Body (tab content) */
.mcm-body {
  padding: 10px;
  max-height: 420px;
  overflow-y: auto;
}

/* Section spacing */
.mcm-section {
  margin-bottom: 10px;
}
.mcm-section:last-child {
  margin-bottom: 0;
}

/* Labels */
.mcm-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #CDD5E0;
  margin-bottom: 5px;
}
.mcm-sublabel {
  display: block;
  font-size: 10px;
  color: #7A7A80;
  margin-bottom: 3px;
}

/* Hint text */
.mcm-hint {
  font-size: 11px;
  color: #7A7A80;
  margin-top: 5px;
}

/* Divider between scene sections */
.mcm-divider {
  height: 1px;
  background: #333;
  margin: 12px 0;
}

/* Icon inside labels */
.mcm-label-icon {
  margin-right: 4px;
  opacity: 0.6;
}

/* Slider + number row */
.mcm-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mcm-slider {
  flex: 1.6;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #3A3A44;
  border-radius: 2px;
  outline: none;
}
.mcm-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #8b5cf6;
  cursor: pointer;
  border: 2px solid #fff;
}
.mcm-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #8b5cf6;
  cursor: pointer;
  border: 2px solid #fff;
}

/* Number input */
.mcm-number {
  width: 64px;
  background: #2A2A34;
  border: 1px solid #4B4B52;
  border-radius: 5px;
  color: #fff;
  font-size: 12px;
  padding: 4px 6px;
  text-align: center;
  outline: none;
}
.mcm-number:focus {
  border-color: #8b5cf6;
}
.mcm-number-full {
  width: 100%;
}

/* Select input */
.mcm-select {
  width: 100%;
  background: #2A2A34;
  border: 1px solid #4B4B52;
  border-radius: 5px;
  color: #fff;
  font-size: 12px;
  padding: 4px 6px;
  outline: none;
  cursor: pointer;
}
.mcm-select:focus {
  border-color: #8b5cf6;
}

/* Button rows */
.mcm-row-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* Buttons */
.mcm-btn {
  background: #2A2A34;
  border: 1px solid #4B4B52;
  border-radius: 5px;
  color: #CDD5E0;
  font-size: 11px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.mcm-btn:hover {
  background: #333340;
  border-color: #666;
}
.mcm-btn-active {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #10b981;
}
.mcm-btn-sm {
  padding: 4px 8px;
  font-size: 10px;
}

/* Color swatch + hidden picker */
.mcm-color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid #999;
  border-radius: 3px;
}
.mcm-color-picker {
  display: none;
}
.mcm-btn-color {
  font-family: monospace;
  font-size: 11px;
}

/* Units row */
.mcm-units-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.mcm-units-row .mcm-field {
  flex: 1;
}

/* Offset row */
.mcm-offset-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.mcm-offset-row .mcm-field {
  flex: 1;
}

/* Field wrapper */
.mcm-field {
  display: flex;
  flex-direction: column;
}

/* Scrollbar styling for body */
.mcm-body::-webkit-scrollbar {
  width: 6px;
}
.mcm-body::-webkit-scrollbar-track {
  background: transparent;
}
.mcm-body::-webkit-scrollbar-thumb {
  background: #4B4B52;
  border-radius: 3px;
}
.mcm-body::-webkit-scrollbar-thumb:hover {
  background: #666;
}

/* ─── Stage Initiative Bar Overlay ──────────────────────────────────────────
   Horizontal strip inside #stageContent — sits at top or bottom of the Stage,
   showing all combatants with an animated active-turn ring.                  */

.initiative-bar-overlay {
  position: absolute;
  bottom: 0;
  left: var(--toolbar-width);   /* 60px — clears the left toolbar */
  right: 0;
  height: 72px;
  background: var(--glass-bg);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 900;
  transition: transform var(--transition-smooth), opacity var(--transition-smooth);
  scrollbar-width: none;
}

.initiative-bar-overlay::-webkit-scrollbar { display: none; }

.initiative-bar-overlay.position-top {
  top: 0;
  bottom: auto;
  border-top: none;
  border-bottom: 1px solid var(--glass-border);
}

.initiative-bar-overlay.ibar-hidden {
  transform: translateY(110%);
  opacity: 0;
  pointer-events: none;
}

.initiative-bar-overlay.position-top.ibar-hidden {
  transform: translateY(-110%);
}

/* ─── Individual combatant slot ─── */

.ibar-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 6px 4px;
  border-radius: 8px;
  cursor: pointer;
  min-width: 52px;
  max-width: 64px;
  flex-shrink: 0;
  position: relative;
  transition: background var(--transition-base);
  user-select: none;
}

.ibar-slot:hover { background: rgba(255, 255, 255, 0.07); }

.ibar-slot.ibar-active { background: rgba(99, 102, 241, 0.12); }

.ibar-slot.ibar-hidden-combatant { opacity: 0.45; }

/* ─── Token avatar ─── */

.ibar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: var(--dark-surface);
  flex-shrink: 0;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.ibar-slot.ibar-active .ibar-avatar {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35), 0 0 12px rgba(99, 102, 241, 0.25);
  animation: ibar-ring-pulse 2s ease-in-out infinite;
}

/* ─── Name label ─── */

.ibar-name {
  font-size: 9px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52px;
  text-align: center;
  line-height: 1.2;
}

.ibar-slot.ibar-active .ibar-name { color: var(--text-primary); }

/* ─── Initiative number badge (top-right corner of slot) ─── */

.ibar-init-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--dark-surface);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 1px 3px;
  min-width: 16px;
  text-align: center;
  line-height: 1.4;
}

.ibar-slot.ibar-active .ibar-init-badge {
  background: var(--primary);
  border-color: var(--primary);
}

/* ─── Active-turn ring pulse animation ─── */

@keyframes ibar-ring-pulse {
  0%,  100% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35), 0 0 12px rgba(99, 102, 241, 0.25); }
  50%        { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.12), 0 0 20px rgba(99, 102, 241, 0.35); }
}

/* ─── Turn timer ring in Combat Panel header ─── */

.turn-timer-ring {
  transform: rotate(-90deg);
  flex-shrink: 0;
}

.turn-timer-wrap {
  position: relative;
  width: 36px;
  height: 36px;
}

.turn-timer-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: var(--text-secondary);
  pointer-events: none;
}

/* ─── Concentration icon on combatant cards ─── */

.conc-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition-base);
  flex-shrink: 0;
  color: var(--text-muted);
}

.conc-icon.concentrating {
  border-color: #06b6d4;
  color: #06b6d4;
  background: rgba(6, 182, 212, 0.12);
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.3);
}

/* ─── Campaigns Panel — Tab Bar & Jukebox Strip ──────────────────────────────── */

.camps-tab-bar {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  height: 40px;
}

.camps-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.38);
  cursor: pointer;
  font-size: 14px;
  transition: color var(--transition-base), background var(--transition-base), border-color var(--transition-base);
  user-select: none;
}

.camps-tab-btn:hover {
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.04);
}

.camps-tab-btn.active {
  color: #6366f1;
  border-bottom-color: #6366f1;
}

.camps-tab-divider {
  width: 1px;
  margin: 8px 0;
  background: rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.camps-popout-btn {
  flex: 0 0 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  font-size: 13px;
  transition: color var(--transition-base), background var(--transition-base), border-color var(--transition-base);
}
.camps-popout-btn:hover {
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.08);
}
.camps-popout-btn.active {
  color: #6366f1;
  border-bottom-color: #6366f1;
}

.camps-tab-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 52px;
}

.camps-jukebox-strip {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--dark-bg, #0e1117);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 10;
  flex-shrink: 0;
}

/* ============================================================
   INITIATIVE BAR — Stage Overlay
   ============================================================ */

initiative-bar {
  display: block;
  position: absolute;
  right: 40px;  /* clear the 40px mini-toolbar */
  top: 0;
  bottom: 0;
  width: 72px;
  z-index: 50;
  pointer-events: auto;
}

.initiative-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(10, 11, 20, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 4px;
  gap: 4px;
  height: 100%;
  overflow: hidden;
  border-left: 1px solid rgba(255,255,255,0.08);
}

.init-bar-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  padding: 2px 4px;
  width: 100%;
}

.init-bar-track::-webkit-scrollbar { display: none; }

/* ---- Individual combatant slot ---- */
.init-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
  flex-shrink: 0;
}

.init-slot:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.init-slot--active {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.45);
}

.init-slot--hidden {
  opacity: 0.45;
}

/* Turn-order badge */
.init-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Avatar wrapper (positions the initiative overlay) */
.init-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

/* Avatar */
.init-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.init-avatar--active {
  border-color: var(--primary, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35), 0 0 12px rgba(99, 102, 241, 0.25);
  animation: init-pulse 2s ease-in-out infinite;
}

@keyframes init-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(99,102,241,0.35), 0 0 12px rgba(99,102,241,0.2); }
  50%       { box-shadow: 0 0 0 5px rgba(99,102,241,0.5), 0 0 20px rgba(99,102,241,0.35); }
}

.init-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.init-avatar-letter {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

/* Concentration — dashed teal ring via ::before (overflow:visible lets it escape the avatar bounds) */
.init-avatar--conc {
  overflow: visible;
}
.init-avatar--conc::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px dashed #06b6d4;
  pointer-events: none;
}

/* Active + concentrating — indigo pulse handles active, dashed ring handles conc; no override needed */



/* Name label */
.init-name {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 64px;
  letter-spacing: 0.3px;
}

/* HP strip under avatar */
.init-hp-strip {
  width: 40px;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.init-hp-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* Initiative number — overlaid at the bottom of the token circle */
.init-number-overlay {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 11, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  color: var(--warning, #f59e0b);
  padding: 1px 4px;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
}

.init-slot--active .init-number-overlay {
  border-color: var(--primary, #6366f1);
  color: #fff;
  background: var(--primary, #6366f1);
}

/* Condition dots row */
.init-conditions {
  display: flex;
  gap: 2px;
  align-items: center;
}

.init-cond-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ef4444;
}

.init-cond-more {
  font-size: 8px;
  color: rgba(255,255,255,0.5);
}

/* Round counter pill on the right */
.init-bar-round {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  min-width: 42px;
  flex-shrink: 0;
}

.init-bar-round-label {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.6;
}

.init-bar-round-num {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary, #6366f1);
  line-height: 1;
}

/* ============================================================
   TURN TIMER — SVG Ring in combat-panel header
   ============================================================ */

.turn-timer-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.turn-timer-ring {
  display: block;
  transform: rotate(-90deg);  /* start progress from top */
}

.turn-timer-label {
  position: absolute;
  font-size: 8px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.5px;
  text-align: center;
  pointer-events: none;
}

/* ============================================================
   CONCENTRATION ICON in combat-panel combatant rows
   ============================================================ */

.conc-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  color: rgba(255,255,255,0.35);
  transition: all 0.15s;
}

.conc-icon:hover {
  border-color: #f59e0b;
  color: #f59e0b;
}

.conc-icon.concentrating {
  border-color: #f59e0b;
  background: rgba(245,158,11,0.15);
  color: #f59e0b;
}

/* ============================================================
   SHARED COMPONENT SYSTEM
   Reusable classes for panels, pop-outs, and overlays.
   Panels should use these classes and reserve inline <style>
   blocks only for panel-specific layout and unique overrides.
   ============================================================ */

/* ── Display heading (EB Garamond) ── */
.rl-heading {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

/* ── Section label (all-caps small label above content) ── */
.rl-label {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

/* ── Card (standard surface container) ── */
.rl-card {
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}
.rl-card + .rl-card {
  margin-top: var(--space-2);
}
.rl-card--active {
  border-color: var(--brand);
  background: var(--brand-ghost);
}

/* ── Divider ── */
.rl-divider {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: var(--space-3) 0;
}

/* ── Buttons ── */
.rl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 6px 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--dark-surface);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}
.rl-btn:hover {
  border-color: var(--brand);
  color: var(--text-primary);
  background: var(--brand-ghost);
}
.rl-btn:active {
  transform: scale(0.97);
}
.rl-btn--primary {
  background: var(--brand);
  border-color: var(--brand-hover);
  color: #fff;
}
.rl-btn--primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: #fff;
}
.rl-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.rl-btn--ghost:hover {
  background: var(--brand-ghost);
  border-color: var(--glass-border);
  color: var(--text-primary);
}
.rl-btn--danger {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.rl-btn--danger:hover {
  background: rgb(239 68 68 / 15%);
  border-color: var(--danger);
  color: var(--danger);
}
.rl-btn--gold {
  background: rgb(201 168 76 / 15%);
  border-color: var(--gold-dim);
  color: var(--gold);
}
.rl-btn--gold:hover {
  background: rgb(201 168 76 / 25%);
  border-color: var(--gold);
  color: var(--gold);
}
.rl-btn--sm {
  padding: 3px 10px;
  font-size: var(--text-xs);
}
.rl-btn--icon {
  padding: 0;
  width: 30px;
  height: 30px;
}

/* ── Badges ── */
.rl-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--dark-surface);
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  white-space: nowrap;
}
.rl-badge--brand {
  background: var(--brand-ghost);
  color: var(--brand);
  border-color: var(--brand);
}
.rl-badge--gold {
  background: rgb(201 168 76 / 15%);
  color: var(--gold);
  border-color: var(--gold-dim);
}
.rl-badge--success {
  background: rgb(16 185 129 / 15%);
  color: var(--success);
  border-color: var(--success);
}
.rl-badge--danger {
  background: rgb(239 68 68 / 15%);
  color: var(--danger);
  border-color: var(--danger);
}
.rl-badge--warning {
  background: rgb(245 158 11 / 15%);
  color: var(--warning);
  border-color: var(--warning);
}

/* ── Tab bar ── */
.rl-tabs {
  display: flex;
  border-bottom: 1px solid var(--glass-border);
  background: var(--dark-panel);
  flex-shrink: 0;
}
.rl-tab {
  flex: 1;
  padding: var(--space-2) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  text-align: center;
  user-select: none;
  white-space: nowrap;
}
.rl-tab:hover {
  color: var(--text-secondary);
}
.rl-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* ── Empty state ── */
.rl-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
  text-align: center;
}
.rl-empty i {
  font-size: 28px;
  opacity: 0.4;
}
.rl-empty p {
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* ── Scroll body (flex child that fills & scrolls) ── */
.rl-scroll-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.rl-scroll-body::-webkit-scrollbar { width: 4px; }
.rl-scroll-body::-webkit-scrollbar-track { background: transparent; }
.rl-scroll-body::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 2px;
}

/* ── Pinned footer strip ── */
.rl-footer-strip {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--glass-border);
  background: var(--dark-panel);
}

/* ── Form input ── */
.rl-input {
  width: 100%;
  padding: 6px 10px;
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  transition: border-color var(--transition-base);
  box-sizing: border-box;
}
.rl-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-ghost);
}
.rl-input::placeholder {
  color: var(--text-muted);
}

/* ── Textarea ── */
.rl-textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  resize: vertical;
  transition: border-color var(--transition-base);
  box-sizing: border-box;
  line-height: 1.5;
}
.rl-textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-ghost);
}
.rl-textarea::placeholder {
  color: var(--text-muted);
}
