/* -------------------------------------------------------------
 * Gogglez D&D - Modern Arcane Design System
 * ------------------------------------------------------------- */

/* Custom Variables */
:root {
  --primary-crimson: #8c1616;      /* High-contrast Crimson */
  --primary-crimson-hover: #b31c1c;
  --accent-gold: #b38b00;          /* Occult Gold */
  --accent-gold-light: #fbeba8;
  --bg-color: #fff8f7;             /* Off-white paper background */
  --surface-color: #ffffff;        /* Pure white card surface */
  --header-bg: rgba(255, 255, 255, 0.95);
  --text-dark: #271815;            /* High-contrast charcoal */
  --text-muted: #5b403c;           /* Warm brownish-gray for labels */
  --border-light: rgba(143, 112, 107, 0.15); /* Hairline borders */
  --border-focus: #8f706b;
  --max-width: 1440px;
  
  /* Fonts */
  --font-serif: 'EB Garamond', Georgia, serif;
  --font-sans: 'Manrope', system-ui, -apple-system, sans-serif;
}

body.dark-theme {
  --primary-crimson: #e53935;
  --primary-crimson-hover: #ff5252;
  --accent-gold: #e5b73b;
  --bg-color: #120907;
  --surface-color: #1f1412;
  --header-bg: rgba(31, 20, 18, 0.95);
  --text-dark: #f5e9e6;
  --text-muted: #bcaaa7;
  --border-light: rgba(228, 190, 184, 0.12);
  --border-focus: #e4beb8;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Typography Defaults */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--primary-crimson);
}

/* -------------------------------------------------------------
 * Layout Components
 * ------------------------------------------------------------- */

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--header-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(140, 22, 22, 0.08);
  height: 80px;
  display: flex;
  align-items: center;
}

.header-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 32px !important;
  color: var(--primary-crimson);
  font-variation-settings: 'FILL' 1;
}

.logo-text {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 800;
  color: var(--primary-crimson);
  text-transform: uppercase;
  letter-spacing: -0.5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 40px;
}

.nav-link {
  text-decoration: none;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(91, 64, 60, 0.5);
  transition: color 0.2s ease;
  padding-bottom: 4px;
}

.nav-link.active {
  color: var(--primary-crimson);
  border-bottom: 2px solid var(--primary-crimson);
}

.nav-link.disabled {
  cursor: not-allowed;
}

.nav-link:hover:not(.active):not(.disabled) {
  color: var(--primary-crimson);
}

.theme-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 8px;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  color: var(--primary-crimson);
}

/* Main Container */
.main-content {
  flex-grow: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 64px;
}

/* -------------------------------------------------------------
 * Section 1: Hero
 * ------------------------------------------------------------- */
.hero-section {
  text-align: center;
  margin-bottom: 32px;
}

.hero-title {
  font-size: 72px;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-bottom: 16px;
  font-weight: 800;
}

.hero-subtitle {
  font-family: var(--font-sans);
  font-size: 18px;
  color: rgba(91, 64, 60, 0.7);
  font-weight: 500;
  max-width: 600px;
  margin: 0 auto;
}

/* -------------------------------------------------------------
 * Section 2: Controls (Search & Filters)
 * ------------------------------------------------------------- */
.controls-section {
  display: flex;
  gap: 24px;
  max-width: 1024px;
  margin: 0 auto 32px auto;
  align-items: stretch;
}

.search-wrapper {
  position: relative;
  flex-grow: 1;
  background-color: var(--surface-color);
  border: 2px solid rgba(140, 22, 22, 0.1);
  transition: border-color 0.2s ease;
}

.search-wrapper:hover,
.search-wrapper:focus-within {
  border-color: rgba(140, 22, 22, 0.3);
}

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(140, 22, 22, 0.4);
  font-size: 28px !important;
}

.search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 20px 24px 20px 72px;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--text-dark);
  font-weight: 500;
}

.search-input::placeholder {
  color: rgba(91, 64, 60, 0.35);
}

.filter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background-color: var(--surface-color);
  border: 2px solid rgba(140, 22, 22, 0.1);
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-dark);
  padding: 0 40px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  border-color: rgba(140, 22, 22, 0.5);
  color: var(--primary-crimson);
}

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

/* Collapsible Filter Drawer */
.filter-drawer {
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  max-width: 1024px;
  margin: -16px auto 32px auto;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.filter-drawer.active {
  max-height: 200px;
  opacity: 1;
  border-color: rgba(140, 22, 22, 0.15);
  padding: 24px;
}

.filter-drawer-inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  gap: 16px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.filter-select {
  width: 100%;
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  outline: none;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  border-radius: 0px;
  transition: border-color 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='%238c1616' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 32px;
}

.filter-select:focus {
  border-color: var(--primary-crimson);
}

.btn-clear-filters {
  background-color: transparent;
  border: 1px solid var(--primary-crimson);
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary-crimson);
  padding: 0 20px;
  cursor: pointer;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border-radius: 0px;
}

.btn-clear-filters:hover {
  background-color: var(--primary-crimson);
  color: #ffffff;
}

/* Adjust layout on smaller screens */
@media (max-width: 900px) {
  .filter-drawer.active {
    max-height: 400px;
  }
  .filter-drawer-inner {
    grid-template-columns: repeat(2, 1fr);
  }
  .btn-clear-filters {
    grid-column: 1 / -1;
    width: 100%;
  }
}
@media (max-width: 600px) {
  .filter-drawer-inner {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------------
 * Section 3: Character Grid & Cards
 * ------------------------------------------------------------- */
.character-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
}

/* Custom Landscape/Responsive grid rules (Surface Optimization) */
@media (max-width: 1200px) {
  .character-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 900px) {
  .character-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .character-grid {
    grid-template-columns: 1fr;
  }
  .controls-section {
    flex-direction: column;
    padding: 0 16px;
  }
  .header-container, .main-content {
    padding: 24px 24px;
  }
}

/* L-Shaped Corner Brackets */
.corner-bracket {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--accent-gold);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 5;
}

.bracket-tl {
  top: -1px;
  left: -1px;
  border-right: none;
  border-bottom: none;
}

.bracket-tr {
  top: -1px;
  right: -1px;
  border-left: none;
  border-bottom: none;
}

.bracket-bl {
  bottom: -1px;
  left: -1px;
  border-right: none;
  border-top: none;
}

.bracket-br {
  bottom: -1px;
  right: -1px;
  border-left: none;
  border-top: none;
}

/* Base Heroic Card */
.heroic-card {
  position: relative;
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 480px;
  height: 100%;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.heroic-card:hover {
  border-color: rgba(140, 22, 22, 0.2);
  transform: translateY(-4px);
}

/* Hover brackets expand slightly outward */
.heroic-card:hover .bracket-tl { top: -4px; left: -4px; }
.heroic-card:hover .bracket-tr { top: -4px; right: -4px; }
.heroic-card:hover .bracket-bl { bottom: -4px; left: -4px; }
.heroic-card:hover .bracket-br { bottom: -4px; right: -4px; }

/* Portrait Image container */
.portrait-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid rgba(140, 22, 22, 0.08);
}

.portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.heroic-card:hover .portrait-img {
  transform: scale(1.04);
}

/* Info Section */
.card-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 8px;
}

.name-details {
  flex-grow: 1;
}

.character-name {
  font-size: 28px;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.1;
  margin-bottom: 4px;
}

.character-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  flex-wrap: wrap; /* Allows text wrapping rather than stretching card width */
}

.character-author {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.75;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent-gold);
  border-radius: 50%;
}

/* Actions Section */
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 60px; /* Fits exactly 2 buttons per row, wrapping 4 buttons into a compact 2x2 grid */
}

.action-icon-btn {
  background: none;
  border: none;
  color: rgba(91, 64, 60, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: color 0.2s ease;
}

.action-icon-btn:hover {
  color: var(--primary-crimson);
}

.action-icon-btn .material-symbols-outlined {
  font-size: 22px !important;
}

/* Card Button at Bottom */
.card-btn-container {
  margin-top: auto;
  padding: 0 4px 4px 4px;
}

.btn-heroic {
  display: block;
  width: 100%;
  background-color: transparent;
  border: 1px solid var(--primary-crimson);
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--primary-crimson);
  padding: 16px 0;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.btn-heroic:hover {
  background-color: var(--primary-crimson);
  color: #ffffff;
}

/* Trigger Card style */
.forge-trigger-card {
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px dashed rgba(140, 22, 22, 0.2);
  background-color: rgba(140, 22, 22, 0.02);
}

.forge-trigger-card:hover {
  border-style: solid;
  border-color: rgba(140, 22, 22, 0.3);
  background-color: rgba(140, 22, 22, 0.04);
}

.forge-circle-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 1px solid rgba(140, 22, 22, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  background-color: rgba(255, 255, 255, 0.8);
  color: var(--primary-crimson);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.forge-trigger-card:hover .forge-circle-icon {
  background-color: var(--primary-crimson);
  border-color: var(--primary-crimson);
  color: #ffffff;
  transform: scale(1.08);
}

.forge-circle-icon .material-symbols-outlined {
  font-size: 38px !important;
}

.forge-text {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary-crimson);
  letter-spacing: 0.05em;
  text-align: center;
  line-height: 1.2;
}

/* -------------------------------------------------------------
 * Modals & Forms
 * ------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(39, 24, 21, 0.4);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  position: relative;
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  width: 100%;
  max-width: 500px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

/* Modal Brackets expand custom behavior */
.modal-content:hover .bracket-tl { top: -4px; left: -4px; }
.modal-content:hover .bracket-tr { top: -4px; right: -4px; }
.modal-content:hover .bracket-bl { bottom: -4px; left: -4px; }
.modal-content:hover .bracket-br { bottom: -4px; right: -4px; }

.modal-title {
  font-size: 36px;
  text-transform: uppercase;
  font-weight: 800;
  margin-bottom: 24px;
  text-align: center;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  background-color: #ffffff;
  border: 1px solid var(--border-light);
  outline: none;
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-dark);
  font-weight: 500;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  border-color: var(--primary-crimson);
}

/* Image Upload Area */
.upload-zone {
  position: relative;
  width: 100%;
  height: 140px;
  border: 1px dashed rgba(140, 22, 22, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background-color: rgba(140, 22, 22, 0.01);
  overflow: hidden;
  transition: all 0.2s ease;
}

.upload-zone:hover {
  border-color: var(--primary-crimson);
  background-color: rgba(140, 22, 22, 0.03);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
  padding: 16px;
}

.upload-icon {
  font-size: 32px !important;
  color: rgba(140, 22, 22, 0.5);
  margin-bottom: 8px;
}

.upload-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-crimson);
  margin-bottom: 2px;
}

.upload-hint {
  font-size: 10px;
  color: var(--text-muted);
}

.upload-preview-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #ffffff;
  z-index: 10;
}

.upload-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-preview-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: rgba(39, 24, 21, 0.8);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  transition: background-color 0.2s ease;
}

.remove-preview-btn:hover {
  background-color: var(--primary-crimson);
}

.remove-preview-btn .material-symbols-outlined {
  font-size: 18px !important;
}

.hidden {
  display: none !important;
}

/* Modal Buttons */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 12px;
}

.btn-secondary {
  background: none;
  border: 1px solid var(--border-light);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  color: var(--text-dark);
}

.btn-primary {
  background-color: var(--primary-crimson);
  border: 1px solid var(--primary-crimson);
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #ffffff;
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* No Results Message styling */
.no-results-message {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background-color: rgba(140, 22, 22, 0.01);
  border: 1px dashed var(--border-light);
  margin-top: 24px;
}

.no-results-message .material-symbols-outlined {
  font-size: 40px !important;
  color: rgba(140, 22, 22, 0.3);
}

.no-results-message p {
  font-size: 16px;
  font-weight: 500;
}

/* Custom Confirmation Modal Specific Styling */
.confirm-modal-content {
  max-width: 420px;
  padding: 32px;
  text-align: center;
}

.confirm-title {
  font-size: 28px;
  text-transform: uppercase;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--primary-crimson);
}

.confirm-message {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.confirm-actions {
  justify-content: center !important;
}

/* -------------------------------------------------------------
 * Gogglez D&D - Character Sheet Specific Styles
 * ------------------------------------------------------------- */

.sheet-body {
  overflow: hidden;
}

@keyframes rotateIndicator {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.indicator-icon {
  font-size: 18px !important;
  color: #2e7d32; /* green success */
}

/* Sheet Layout - Side navigation and panel */
.sheet-layout {
  display: flex;
  flex-grow: 1;
  height: 100vh;
  overflow: hidden;
}

.sheet-sidebar {
  width: 60px;
  height: 100%;
  background-color: var(--surface-color);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
  z-index: 10;
  flex-shrink: 0;
}

.sidebar-top, .sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.sidebar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sidebar-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  transition: all 0.2s ease;
  text-decoration: none;
  outline: none;
}

.sidebar-action-btn:hover {
  color: var(--primary-crimson);
}

.sidebar-action-btn .material-symbols-outlined {
  font-size: 24px !important;
}

.sidebar-save-indicator {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  color: var(--text-muted);
  cursor: help;
}

.sidebar-save-indicator.saving {
  color: var(--accent-gold);
}

.sidebar-save-indicator.saving .indicator-icon {
  animation: rotateIndicator 1.5s linear infinite;
  color: var(--accent-gold);
}

.save-tooltip {
  position: absolute;
  left: 70px;
  background-color: var(--text-dark);
  color: var(--surface-color);
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.sidebar-save-indicator:hover .save-tooltip {
  opacity: 1;
}

.sidebar-tab {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: center;
  text-transform: uppercase;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.2em;
  padding: 24px 12px;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  white-space: nowrap;
}

.sidebar-tab:hover {
  color: var(--primary-crimson);
}

.sidebar-tab.active {
  color: var(--primary-crimson);
  border-left-color: var(--primary-crimson);
  background-color: var(--bg-color);
}

/* Side panels content area */
.sheet-content-wrapper {
  flex-grow: 1;
  background-color: var(--bg-color);
  padding: 32px 48px;
  overflow-y: auto;
  height: 100vh;
}

.sheet-panel {
  display: none;
  width: 100%;
}

.sheet-panel.active {
  display: block;
}

.panel-header {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 12px;
}

.panel-title {
  font-size: 32px;
  text-transform: uppercase;
}

/* Panel: Notes */
.notes-container {
  width: 100%;
  height: calc(100vh - 220px);
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  padding: 24px;
}

.notes-textarea {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-dark);
  line-height: 1.6;
}

/* Panel: Character Background */
.background-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 32px;
  align-items: stretch;
}

.bg-textarea {
  width: 100%;
  height: calc(100vh - 240px);
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  padding: 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dark);
  outline: none;
  resize: none;
}

.bg-trait-textarea {
  width: 100%;
  height: 80px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 900;
  color: var(--text-dark);
}

/* Panel: Character Stats - Header Box (Full Widescreen Width Layout) */
.stats-header-box {
  width: 100%;
  margin: 0 0 28px 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.stats-header-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: stretch; /* Stretch all boxes to match height */
  gap: 16px;
  width: 100%;
}

.char-stats-subwrapper {
  display: flex;
  flex: 7.5;
  align-items: center;
  gap: 16px;
  position: relative;
}

.spell-stats-subwrapper {
  display: flex;
  flex: 3.5;
  align-items: stretch;
  gap: 16px;
  position: relative;
}

/* Common SVG background styling */
.header-details-box,
.header-circle-box,
.header-shield-box,
.header-right-box,
.header-spell-ability-box,
.header-spell-slots-box {
  position: relative;
  background-color: transparent;
  z-index: 1;
}

.header-box-frame,
.header-circle-frame,
.header-shield-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.header-box-frame path,
.header-circle-frame circle,
.header-circle-frame line,
.header-shield-frame path {
  stroke: var(--border-light);
  transition: stroke 0.3s ease;
}

/* Dark theme vector colors */
body.dark-theme .header-box-frame path,
body.dark-theme .header-circle-frame circle,
body.dark-theme .header-circle-frame line,
body.dark-theme .header-shield-frame path {
  stroke: var(--primary-crimson);
}

/* 0. Leftmost Portrait Box */
.header-portrait-box {
  width: 150px;
  height: 150px;
  position: relative;
  border: 1px solid var(--border-light);
  background-color: var(--surface-color);
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s ease;
  z-index: 10;
}

body.dark-theme .header-portrait-box {
  border-color: var(--primary-crimson);
}

.header-portrait-box:hover {
  border-color: var(--primary-crimson);
  box-shadow: 0 0 10px rgba(140, 22, 22, 0.15);
}

body.dark-theme .header-portrait-box:hover {
  box-shadow: 0 0 15px rgba(229, 57, 53, 0.25);
}

.header-portrait-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.header-portrait-box:hover img {
  transform: scale(1.06);
}

/* 1. Left Details Box */
.header-details-box {
  flex: 3;
  padding: 16px 20px 16px 42px;
  min-height: 150px;
  display: flex;
  align-items: center;
}

.details-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.details-row {
  display: flex;
  gap: 12px;
}

.details-row.full-width {
  width: 100%;
}

.details-row.two-cols .details-cell,
.details-row.three-cols .details-cell {
  flex: 1;
}

.details-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.details-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.details-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid transparent;
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--primary-crimson);
  padding: 2px 0;
  outline: none;
  transition: border-bottom-color 0.2s ease;
}

body.edit-mode .details-input {
  border-bottom-color: var(--border-light);
}

body.edit-mode .details-input:focus {
  border-bottom-color: var(--primary-crimson) !important;
}

.details-input.font-bold {
  font-size: 22px;
  font-weight: 900;
}

/* 2. Circle Box (Level & XP) */
.header-circle-box {
  width: 150px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  margin-left: -32px; /* Overlaps details box */
  margin-right: -4px;
  z-index: 10;
}

.circle-content {
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.circle-top, .circle-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 50%;
}

.circle-top {
  justify-content: flex-end;
  padding-bottom: 2px;
}

.circle-bottom {
  justify-content: flex-start;
  padding-top: 4px;
}

.circle-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.circle-input {
  width: 50px;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 900;
  color: var(--text-dark);
}

.circle-input-small {
  width: 65px;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

/* 3. Shield Box (AC & Shield) */
.header-shield-box {
  width: 120px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.shield-content {
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

.shield-ac-wrap, .shield-sh-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.shield-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dark);
  text-align: center;
}

.shield-label-small {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.shield-input {
  width: 100%;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 900;
  color: var(--primary-crimson);
}

.shield-input-small {
  width: 100%;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
}

/* 4. Right Box (HP, Hit Dice, Death Saves) */
.header-right-box {
  flex: 5; /* More prominence */
  padding: 16px 24px 16px 16px; /* Optimized padding for space */
  min-height: 150px;
  display: flex;
  align-items: center;
}

.right-box-content {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: stretch; /* Stretch columns to same height */
  gap: 16px;
}

.right-sub-section {
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* Align headers to the top */
}

.sub-section-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  text-align: center;
}

.vertical-divider {
  width: 1.5px;
  height: 100px;
  background-color: var(--border-light);
  opacity: 0.6;
}

/* HP Section layout */
.hp-section {
  flex: 2;
}

.hp-layout {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  gap: 8px;
}

.hp-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  text-align: center;
}

.hp-cell-label {
  font-size: 7px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
  text-align: center;
  width: 100%;
}

.hp-input-large {
  width: 100%;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-serif);
  font-size: 42px; /* Prominent HP size */
  font-weight: 900;
  color: var(--primary-crimson);
  line-height: 1.1;
}

.hp-input-medium {
  width: 100%;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-serif);
  font-size: 28px; /* Readable Max/Temp HP */
  font-weight: 700;
  color: var(--text-dark);
}

.hp-calculator-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.hp-calc-input {
  width: 75px;
  height: 34px; /* Touch friendly */
  background: rgba(143, 112, 107, 0.05);
  border: 1px solid var(--border-light);
  color: var(--text-dark);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  outline: none;
  transition: all 0.2s ease;
}

body.dark-theme .hp-calc-input {
  background: rgba(255, 255, 255, 0.04);
}

.hp-calc-input:focus {
  border-color: var(--primary-crimson);
}

.hp-calc-btn {
  height: 34px; /* Touch friendly */
  padding: 0 16px;
  background-color: var(--primary-crimson);
  border: 1px solid var(--primary-crimson);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

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

.hp-calc-btn:active {
  transform: scale(0.95);
}

/* Make sure calculator controls remain fully visible and interactive in View Mode */
body.view-mode .hp-calc-input,
body.view-mode .hp-calc-btn {
  opacity: 1;
  pointer-events: auto;
}

/* Underlines for view-mode editable HP inputs */
body.view-mode #char-hp-current,
body.view-mode #char-hp-temp {
  border-bottom: 1.2px dashed rgba(140, 22, 22, 0.25) !important;
}

body.view-mode #char-hp-current:focus,
body.view-mode #char-hp-temp:focus {
  border-bottom: 1.2px solid var(--primary-crimson) !important;
}

/* Hit Dice Section Layout */
.dice-section {
  flex: 1;
}

.dice-layout {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}

.dice-spent-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

.hd-adjust-btn {
  background: rgba(140, 22, 22, 0.06);
  border: 1px solid var(--border-light);
  color: var(--text-dark);
  font-size: 15px;
  font-weight: 900;
  width: 30px; /* Touch friendly width */
  height: 30px; /* Touch friendly height */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  user-select: none;
  outline: none;
  z-index: 10;
}

body.dark-theme .hd-adjust-btn {
  background-color: rgba(229, 57, 53, 0.15);
  border-color: rgba(229, 57, 53, 0.3);
  color: var(--text-dark);
}

.hd-adjust-btn:hover {
  background-color: var(--primary-crimson) !important;
  color: #ffffff !important;
  border-color: var(--primary-crimson) !important;
}

.hd-adjust-btn:active {
  transform: scale(0.9);
}

/* In view-mode, make sure they still look clickable and are not hidden */
body.view-mode .hd-adjust-btn {
  opacity: 1;
  pointer-events: auto;
}

.dice-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  text-align: center;
}

.dice-cell-label {
  font-size: 6.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  width: 100%;
}

.dice-input {
  width: 100%;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-serif);
  font-size: 24px; /* Prominent dice input size */
  font-weight: 900;
  color: var(--text-dark);
}

.dice-input-text {
  width: 100%;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 800;
  color: var(--text-muted);
}

/* Death Saves Layout */
.saves-section {
  flex: 1.5;
}

.saves-layout {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saves-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.saves-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.saves-checkboxes {
  display: flex;
  gap: 8px; /* Touch friendly gap */
}

.death-check {
  width: 18px; /* Touch friendly width */
  height: 18px; /* Touch friendly height */
  border: 2.2px solid var(--accent-gold);
  transform: rotate(45deg);
  cursor: pointer;
  appearance: none;
  outline: none;
  transition: all 0.2s ease;
  background-color: transparent;
  margin: 4px; /* Prevents rotated bounding boxes from overlapping click regions */
}

.death-check:checked {
  background-color: var(--primary-crimson);
  border-color: var(--primary-crimson);
}

/* 5. Spellcasting Ability Box */
.header-spell-ability-box {
  flex: 1.8;
  padding: 12px 16px 12px 24px;
  min-height: 150px;
  display: flex;
  align-items: center;
}

.spell-ability-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 3;
}

.spell-ability-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  text-align: center;
}

.spell-ability-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.spell-ability-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: right;
  flex: 1;
}

.spell-ability-select-box {
  width: 48px;
  background: rgba(143, 112, 107, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 0px;
  outline: none;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dark);
  text-align: center;
  padding: 2px;
  height: 22px;
  cursor: pointer;
}

.spell-ability-input {
  width: 48px;
  height: 22px;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 900;
  color: var(--text-dark);
}

.spell-ability-input-num {
  width: 48px;
  height: 22px;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 900;
  color: var(--primary-crimson);
}

.spell-input-with-adj {
  display: flex;
  align-items: center;
  gap: 4px;
}

.spell-adj-input {
  width: 25px;
  height: 20px;
  background-color: rgba(197, 160, 89, 0.08) !important;
  border: 1px dashed var(--accent-gold) !important;
  border-radius: 3px;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-gold);
  outline: none;
  padding: 0;
  appearance: textfield;
}

/* Hide adj input in View Mode */
body.view-mode .spell-adj-input {
  display: none !important;
}

/* Color codes for main inputs with active adjustments in View Mode */
.spell-ability-input.adj-bonus,
.spell-ability-input-num.adj-bonus {
  color: #2e7d32 !important;
  font-weight: 900;
  text-shadow: 0 0 4px rgba(46, 125, 50, 0.1);
}

.spell-ability-input.adj-malus,
.spell-ability-input-num.adj-malus {
  color: #c62828 !important;
  font-weight: 900;
  text-shadow: 0 0 4px rgba(198, 40, 40, 0.1);
}

/* 6. Spell Slots Box */
.header-spell-slots-box {
  flex: 3.5;
  padding: 12px 24px 12px 24px;
  min-height: 150px;
  display: flex;
  align-items: center;
}

.spell-slots-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 3;
}

.spell-slots-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  text-align: center;
}

.slots-columns-container {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.slots-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slots-col-header {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 2px;
  margin-bottom: 4px;
  gap: 8px;
}

.slots-col-label {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.slots-col-label.label-total {
  width: 24px;
  text-align: center;
}

.slots-col-row {
  display: flex;
  align-items: center;
  height: 28px; /* Touch friendly row height */
  gap: 8px;
}

.slot-level-name {
  width: 22px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.slot-total-val {
  width: 24px;
  height: 22px;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 900;
  color: var(--text-dark);
  flex-shrink: 0;
}

.slot-diamonds-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.slot-diamond-check {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent-gold);
  transform: rotate(45deg);
  cursor: pointer;
  appearance: none;
  outline: none;
  transition: all 0.2s ease;
  background-color: transparent;
  margin: 2px;
  z-index: 10;
}

.slot-diamond-check:checked {
  background-color: var(--primary-crimson);
  border-color: var(--primary-crimson);
}

/* Default toggles based on view/edit modes for Spell Slots */
body.view-mode .slot-total-val,
body.view-mode .slots-col-label.label-total {
  display: none !important;
}

body.view-mode .slot-diamonds-wrap,
body.view-mode .slots-col-label.label-expended {
  display: flex !important;
}

body.edit-mode .slot-total-val,
body.edit-mode .slots-col-label.label-total {
  display: block !important;
}

body.edit-mode .slot-diamonds-wrap,
body.edit-mode .slots-col-label.label-expended {
  display: none !important;
}

/* 3-Column Layout */
.sheet-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1.2fr;
  gap: 24px;
  align-items: stretch;
}

.grid-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100%;
}

/* Column 1 Subcolumns Layout */
.col1-subcolumns-layout {
  display: flex;
  gap: 16px;
  width: 100%;
}

.col1-subcolumn {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0; /* Prevents overflow */
}

/* 1. Premium Proficiency Bonus Box */
.prof-bonus-box-premium {
  background-color: var(--surface-color);
  border: 1.5px solid var(--border-light);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.bard-bonus-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.bard-check {
  width: 11px;
  height: 11px;
  border: 1.2px solid var(--accent-gold);
  border-radius: 2px;
  cursor: pointer;
  appearance: none;
  outline: none;
  background-color: var(--surface-color);
  transition: all 0.2s ease;
}

.bard-check:checked {
  background-color: var(--accent-gold) !important;
  border-color: var(--accent-gold) !important;
}

.bard-label {
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  letter-spacing: 0.03em;
}

.prof-bonus-title {
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.prof-bonus-graphics-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.prof-bonus-input-new {
  width: 60px;
  height: 24px;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 900;
  color: var(--primary-crimson);
}

/* 2. Premium Ability Cards */
.ability-card {
  background-color: var(--surface-color);
  border: 1.5px solid var(--border-light);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(39, 24, 21, 0.03);
}

.ability-card-header {
  text-align: center;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-dark);
  border-bottom: 1.2px solid var(--border-light);
  padding: 5px;
  letter-spacing: 0.05em;
  background-color: rgba(143, 112, 107, 0.02);
}

.ability-card-upper {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 12px 10px;
  position: relative;
}

.ability-modifier-circle-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ability-modifier-circle {
  width: 48px;
  height: 48px;
  border: 2px solid var(--accent-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 900;
  color: var(--primary-crimson);
  background-color: var(--surface-color);
  box-shadow: inset 0 0 4px rgba(197, 160, 89, 0.2);
}

.ability-sublabel-modifier {
  font-size: 7px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
}

.ability-score-box-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(143, 112, 107, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 4px 6px;
  width: 50px;
}

.ability-score-input-new {
  width: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 800;
  color: var(--text-dark);
  outline: none;
  padding: 0;
  height: 20px;
}

/* Hide spin buttons inside score inputs */
.ability-score-input-new::-webkit-inner-spin-button,
.ability-score-input-new::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number].ability-score-input-new {
  -moz-appearance: textfield;
}

body.edit-mode .ability-score-input-new {
  border-bottom: none !important;
  background-color: transparent !important;
}

.ability-sublabel-score {
  font-size: 7px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
  text-align: center;
}

.ability-card-lower {
  border-top: 1px solid var(--border-light);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background-color: rgba(143, 112, 107, 0.01);
}

.ability-skill-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.prof-check {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--border-light);
  cursor: pointer;
  appearance: none;
  outline: none;
  transition: all 0.2s ease;
  background-color: var(--surface-color);
  flex-shrink: 0;
}

.prof-check:checked {
  background-color: var(--primary-crimson);
  border-color: var(--primary-crimson);
}

.save-check {
  border-radius: 50% !important; /* round checkboxes for saves */
}

.ability-skill-modifier-val {
  width: 26px;
  border-bottom: 1.2px solid var(--border-light);
  text-align: center;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dark);
  padding-bottom: 1px;
  margin-right: 4px;
  flex-shrink: 0;
  height: 15px;
}

.ability-skill-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dark);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ability-skill-label.font-bold {
  font-weight: 700 !important;
}

/* 3. Premium Heroic Inspiration Box */
.inspiration-box-premium {
  background-color: var(--surface-color);
  border: 1.5px solid var(--border-light);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.inspiration-title-premium {
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dark);
  text-align: center;
}

.inspiration-circle-emblem {
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--accent-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(197, 160, 89, 0.05);
}

.inspiration-check-premium {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--accent-gold);
  border-radius: 3px;
  appearance: none;
  outline: none;
  cursor: pointer;
  background-color: var(--surface-color);
  transition: all 0.2s ease;
}

.inspiration-check-premium:checked {
  background-color: var(--primary-crimson);
  border-color: var(--primary-crimson);
}

@media (max-width: 768px) {
  .col1-subcolumns-layout {
    flex-direction: column;
  }
}

/* Generic sheet box */
.sheet-box {
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  padding: 16px;
}

.box-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed var(--border-light);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.box-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary-crimson);
}

.btn-box-add, .btn-pane-add {
  background: none;
  border: none;
  color: var(--primary-crimson);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  transition: transform 0.2s ease;
}

.btn-box-add:hover, .btn-pane-add:hover {
  transform: scale(1.1);
}

.btn-box-add .material-symbols-outlined,
.btn-pane-add .material-symbols-outlined {
  font-size: 20px !important;
}

.margin-top-sm {
  margin-top: 12px;
}

/* Combat Metrics Grid */
.combat-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.metric-small-box {
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.metric-small-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 800;
  color: var(--primary-crimson);
}

.metric-small-input-text {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
}

/* Weapons table styles */
.table-container {
  overflow-x: auto;
  width: 100%;
}

.weapons-table {
  width: 100%;
  border-collapse: collapse;
}

.weapons-table th {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1.5px solid var(--border-light);
}

.weapons-table td {
  padding: 6px;
  border-bottom: 1px solid rgba(143, 112, 107, 0.08);
}

.table-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-dark);
  font-weight: 600;
  outline: none;
  padding: 2px 0;
}

.table-input:focus {
  border-bottom-color: var(--primary-crimson);
}

.btn-row-del {
  background: none;
  border: none;
  color: rgba(91, 64, 60, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  transition: color 0.2s ease;
}

.btn-row-del:hover {
  color: var(--primary-crimson);
}

.btn-row-del .material-symbols-outlined {
  font-size: 18px !important;
}

/* Equipment List Box */
.equipment-box {
  display: flex;
  flex-direction: column;
  flex-grow: 1; /* Stretch to fill available vertical space */
}

.attunement-counter-wrap {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent-gold);
}

.equipment-list-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
  flex-grow: 1;
  height: 0;
  overflow-y: auto;
}

.equipment-row-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border-light);
}

.equipment-row-item .attune-check {
  width: 12px;
  height: 12px;
  border: 1px solid var(--border-light);
  transform: rotate(45deg); /* Diamond shape! */
  appearance: none;
  outline: none;
  cursor: pointer;
  background-color: var(--surface-color);
  margin-left: 6px;
  margin-right: 6px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.equipment-row-item .attune-check:checked {
  background-color: var(--accent-gold) !important;
  border-color: var(--accent-gold) !important;
}

/* In View Mode, disabled checked attune check stays gold */
body.view-mode .equipment-row-item .attune-check:disabled:checked {
  background-color: var(--accent-gold) !important;
  border-color: var(--accent-gold) !important;
  opacity: 1;
}

.equipment-item-name {
  flex-grow: 1;
  border: none !important;
  background: transparent !important;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dark);
  outline: none !important;
  padding: 2px 0;
  resize: none;
  overflow: hidden;
  min-height: 18px;
  height: auto;
  line-height: 1.5;
}

.btn-item-del {
  background: none;
  border: none;
  color: rgba(91, 64, 60, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.btn-item-del:hover {
  color: var(--primary-crimson);
}

.btn-item-del .material-symbols-outlined {
  font-size: 16px !important;
}

.btn-item-toggle-avail {
  background: none;
  border: none;
  color: rgba(91, 64, 60, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.btn-item-toggle-avail:hover {
  color: var(--accent-gold);
}

.btn-item-toggle-avail .material-symbols-outlined {
  font-size: 16px !important;
}

.equipment-row-item.item-unavailable {
  opacity: 0.45;
}

.equipment-row-item.item-unavailable .equipment-item-name {
  text-decoration: line-through;
  font-style: italic;
}

/* Premium Coins Section */
.premium-coins-section {
  margin-top: 8px;
  border-top: 1.5px solid var(--border-light);
  padding-top: 6px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.coins-header-row {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.coins-header-title {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.premium-coins-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
}

.premium-coin-cell {
  background-color: var(--surface-color);
  border: 1.5px solid var(--border-light);
  border-radius: 6px;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.premium-coin-cell:focus-within {
  box-shadow: 0 0 8px rgba(197, 160, 89, 0.15) !important;
}

.premium-coin-cell.cell-cp { border-color: rgba(161, 136, 127, 0.4); }
.premium-coin-cell.cell-sp { border-color: rgba(144, 164, 174, 0.4); }
.premium-coin-cell.cell-ep { border-color: rgba(128, 222, 234, 0.4); }
.premium-coin-cell.cell-gp { border-color: rgba(197, 160, 89, 0.5); }
.premium-coin-cell.cell-pp { border-color: rgba(176, 190, 197, 0.4); }

.premium-coin-cell.cell-cp:focus-within { border-color: #a1887f !important; }
.premium-coin-cell.cell-sp:focus-within { border-color: #78909c !important; }
.premium-coin-cell.cell-ep:focus-within { border-color: #00acc1 !important; }
.premium-coin-cell.cell-gp:focus-within { border-color: var(--accent-gold) !important; }
.premium-coin-cell.cell-pp:focus-within { border-color: #b0bec5 !important; }

.premium-coin-label {
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.premium-coin-label.cp { color: #a1887f; }
.premium-coin-label.sp { color: #78909c; }
.premium-coin-label.ep { color: #00acc1; }
.premium-coin-label.gp { color: var(--accent-gold); }
.premium-coin-label.pp { color: #b0bec5; }

.premium-coin-input-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.coin-input-new {
  width: 100%;
  text-align: center;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 13px;
  color: var(--text-dark);
  padding: 0;
  margin: 0;
}

/* Hide EP Toggles & Dynamic Grid Columns */
body.view-mode #hide-ep-control-wrap {
  display: none !important;
}

body.edit-mode #hide-ep-control-wrap {
  display: flex !important;
}

.hide-ep-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto; /* Push to the right of the title */
  user-select: none;
}

.hide-ep-check {
  width: 10px;
  height: 10px;
  border: 1px solid var(--border-light);
  border-radius: 2px;
  appearance: none;
  outline: none;
  cursor: pointer;
  background-color: var(--surface-color);
  transition: all 0.2s ease;
}

.hide-ep-check:checked {
  background-color: var(--primary-crimson);
  border-color: var(--primary-crimson);
}

.premium-coins-grid.hide-ep-active {
  grid-template-columns: repeat(4, 1fr) !important;
}

.premium-coins-grid.hide-ep-active .cell-ep {
  display: none !important;
}

/* Spellcasting stats styling */
.spellcasting-stats-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr;
  gap: 10px;
}

.spell-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spell-select {
  width: 100%;
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  padding: 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dark);
  outline: none;
  border-radius: 0px;
}

.spell-select:focus {
  border-color: var(--primary-crimson);
}

.spell-stat-input {
  width: 100%;
  background: var(--surface-color);
  border: 1px solid var(--border-light);
  text-align: center;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
  outline: none;
  padding: 5px 0;
  border-radius: 0px;
}

.spell-stat-input:focus {
  border-color: var(--primary-crimson);
}

.spell-stat-input-num {
  width: 100%;
  background: var(--surface-color);
  border: 1px solid var(--border-light);
  text-align: center;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 800;
  color: var(--primary-crimson);
  outline: none;
  padding: 4px 0;
  border-radius: 0px;
}

.spell-stat-input-num:focus {
  border-color: var(--primary-crimson);
}

.spell-slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.slot-row {
  background-color: rgba(143, 112, 107, 0.03);
  border: 1px solid var(--border-light);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.slot-lvl {
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 800;
  color: var(--primary-crimson);
}

.slot-total-input {
  width: 32px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-light);
  text-align: center;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
  outline: none;
  padding-bottom: 2px;
}

.slot-total-input:focus {
  border-bottom-color: var(--primary-crimson);
}

.slot-expended-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 2px;
}

.slot-sublabel {
  font-size: 7px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  scale: 0.9;
}

.slot-expended-input {
  width: 28px;
  background: transparent;
  border: none;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-crimson);
  outline: none;
}

/* Defenses & Conditions Box */
.defenses-conditions-box {
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  height: 140px;
  box-sizing: border-box;
}

.defenses-col-wrap, .conditions-col-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.def-col-title {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.defenses-textarea {
  flex-grow: 1;
  width: 100%;
  height: 100%;
  resize: none;
  background: rgba(143, 112, 107, 0.02);
  border: 1px solid var(--border-light);
  padding: 6px 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  outline: none;
  border-radius: 0px;
  box-sizing: border-box;
}

.defenses-textarea:focus {
  border-color: var(--primary-crimson);
}

.defenses-view-div {
  flex-grow: 1;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
}

.defenses-list-view {
  margin: 0;
  padding-left: 14px;
  list-style-type: disc;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.5;
}

.defenses-list-view li {
  margin-bottom: 4px;
}

/* Toggle visibility between modes */
body.view-mode .defenses-textarea {
  display: none !important;
}
body.view-mode .defenses-view-div {
  display: block !important;
}

body.edit-mode .defenses-textarea {
  display: block !important;
}
body.edit-mode .defenses-view-div {
  display: none !important;
}

/* Hide Ruleset toggle in View Mode */
body.view-mode #ruleset-select {
  display: none !important;
}

/* Conditions Column Header */
.conditions-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.ruleset-select-box {
  background: rgba(197, 160, 89, 0.08);
  border: 1px solid var(--accent-gold);
  border-radius: 2px;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 800;
  color: var(--accent-gold);
  padding: 1px 4px;
  outline: none;
  cursor: pointer;
}

/* Exhaustion Editor */
.exhaustion-edit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(143, 112, 107, 0.04);
  border: 1px solid var(--border-light);
  padding: 3px 6px;
  margin-bottom: 6px;
}

.exhaustion-edit-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dark);
}

.exhaustion-adjust-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-exhaustion-adjust {
  background: var(--primary-crimson);
  border: none;
  color: #fff;
  font-weight: 800;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  font-size: 10px;
}

.btn-exhaustion-adjust:hover {
  background-color: var(--primary-crimson-hover);
}

.exhaustion-edit-val {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-crimson);
  width: 10px;
  text-align: center;
}

/* Add Condition Button Trigger style */
.add-condition-wrap {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 4px;
}

.btn-add-condition-trigger {
  width: auto;
  background: rgba(143, 112, 107, 0.02);
  border: 1px dashed var(--border-light);
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 3px 8px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
}

.btn-add-condition-trigger:hover {
  border-color: var(--primary-crimson);
  color: var(--primary-crimson);
  background-color: rgba(140, 22, 22, 0.02);
}

/* Conditions Popup Modal details */
.conditions-modal-content {
  max-width: 440px !important;
}

.conditions-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px solid var(--border-light);
  padding-bottom: 8px;
  margin-bottom: 4px;
}

.btn-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.btn-modal-close:hover {
  color: var(--primary-crimson);
}

.modal-subtext {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-muted);
  margin: 4px 0 12px 0;
}

.conditions-grid-select {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.btn-select-condition {
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 8px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-select-condition:hover {
  background-color: rgba(140, 22, 22, 0.04);
  border-color: var(--primary-crimson);
  color: var(--primary-crimson);
}

.btn-select-condition.active {
  background-color: rgba(140, 22, 22, 0.1);
  border-color: var(--primary-crimson);
  color: var(--primary-crimson);
}

/* Exhaustion button in popup active styling */
.btn-select-condition.exhaustion-active {
  background-color: rgba(197, 160, 89, 0.12);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.btn-select-condition.exhaustion-active:hover {
  background-color: rgba(197, 160, 89, 0.18);
}

/* Active Conditions Chip List */
.active-conditions-list {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: flex-start;
  padding-right: 2px;
}

.condition-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: rgba(140, 22, 22, 0.06);
  border: 1px solid rgba(140, 22, 22, 0.15);
  border-radius: 4px;
  padding: 3px 8px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-crimson);
  cursor: help;
  user-select: none;
}

.condition-icon {
  font-size: 13px !important;
  color: var(--primary-crimson);
  display: inline-block;
  vertical-align: middle;
}

/* Exhaustion Chip View Mode style */
.condition-chip.exhaustion-chip {
  background-color: rgba(197, 160, 89, 0.08);
  border-color: rgba(197, 160, 89, 0.25);
  color: var(--accent-gold);
}

.condition-chip.exhaustion-chip .condition-icon {
  color: var(--accent-gold);
}

.btn-condition-remove {
  background: none;
  border: none;
  color: rgba(140, 22, 22, 0.4);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
}

.btn-condition-remove:hover {
  color: var(--primary-crimson);
}

/* Lower Right Tabs box */
.sheet-tabs-container {
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  height: 0;
}

.tab-triggers {
  display: flex;
  border-bottom: 1.5px solid var(--border-light);
  background-color: rgba(143, 112, 107, 0.03);
}

.tab-trigger {
  flex-grow: 1;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 14px 0;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.tab-trigger.active {
  color: var(--primary-crimson);
  background-color: var(--surface-color);
  border-bottom: 2.5px solid var(--primary-crimson);
  margin-bottom: -1px;
}

.tab-contents {
  flex-grow: 1;
  padding: 16px;
  overflow-y: auto;
}

.tab-content-pane {
  display: none;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

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

.tab-pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed var(--border-light);
  padding-bottom: 6px;
}

.text-accent {
  color: var(--primary-crimson);
}

/* Actions list & Features list */
.action-rows-list, .features-rows-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex-grow: 1;
}

.action-row-item, .feature-row-item {
  border: 1px solid var(--border-light);
  background-color: rgba(143, 112, 107, 0.01);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.row-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.row-item-title {
  width: 60%;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 800;
  color: var(--primary-crimson);
}

.row-item-meta {
  width: 30%;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent-gold);
  text-align: right;
}

.row-item-desc {
  width: 100%;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  outline: none;
  resize: none;
  height: 48px;
}

/* Spells Cards Grid (As in reference 2) */
.spells-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  overflow-y: auto;
  flex-grow: 1;
}

.spell-card-item {
  border: 1px solid var(--border-light);
  background-color: rgba(143, 112, 107, 0.01);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.spell-card-name {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 800;
  color: var(--primary-crimson);
  border: none;
  background: transparent;
  outline: none;
  width: 80%;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}

.spell-card-name:focus {
  border-bottom-color: var(--primary-crimson);
}

.spell-card-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  border-top: 1px dashed var(--border-light);
  padding-top: 4px;
  margin-bottom: 4px;
}

.spell-card-cell {
  display: flex;
  flex-direction: column;
}

.spell-card-label {
  font-size: 7px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
}

.spell-card-input {
  width: 100%;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-dark);
  font-weight: 600;
  outline: none;
}

.spell-card-desc {
  width: 100%;
  height: 38px;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
  outline: none;
  resize: none;
}

.btn-card-del {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: rgba(91, 64, 60, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
}

.btn-card-del:hover {
  color: var(--primary-crimson);
}

.btn-card-del .material-symbols-outlined {
  font-size: 16px !important;
}

/* Custom Scrollbar */
.tab-contents::-webkit-scrollbar,
.action-rows-list::-webkit-scrollbar,
.spells-cards-grid::-webkit-scrollbar,
.features-rows-list::-webkit-scrollbar,
.sheet-content-wrapper::-webkit-scrollbar {
  width: 6px;
}

.tab-contents::-webkit-scrollbar-thumb,
.action-rows-list::-webkit-scrollbar-thumb,
.spells-cards-grid::-webkit-scrollbar-thumb,
.features-rows-list::-webkit-scrollbar-thumb,
.sheet-content-wrapper::-webkit-scrollbar-thumb {
  background-color: var(--border-light);
}

.tab-contents::-webkit-scrollbar-thumb:hover,
.action-rows-list::-webkit-scrollbar-thumb:hover,
.spells-cards-grid::-webkit-scrollbar-thumb:hover,
.features-rows-list::-webkit-scrollbar-thumb:hover,
.sheet-content-wrapper::-webkit-scrollbar-thumb:hover {
  background-color: var(--primary-crimson);
}

/* -------------------------------------------------------------
 * Gogglez D&D - View & Edit Modes Aesthetics
 * ------------------------------------------------------------- */

/* View Mode Styling for Disabled Inputs */
body.view-mode input:disabled:not([type="checkbox"]):not([type="radio"]), 
body.view-mode textarea:disabled,
body.view-mode select:disabled {
  color: var(--text-dark);
  cursor: default;
  border-color: transparent !important;
  background: transparent !important;
  opacity: 0.95;
  box-shadow: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Ensure contents overlay SVG background layers */
.details-content,
.right-box-content {
  position: relative;
  z-index: 3;
}

/* Hide number input spinners for perfect horizontal centering */
.circle-input::-webkit-inner-spin-button,
.circle-input::-webkit-outer-spin-button,
.circle-input-small::-webkit-inner-spin-button,
.circle-input-small::-webkit-outer-spin-button,
.shield-input::-webkit-inner-spin-button,
.shield-input::-webkit-outer-spin-button,
.shield-input-small::-webkit-inner-spin-button,
.shield-input-small::-webkit-outer-spin-button,
.hp-input-large::-webkit-inner-spin-button,
.hp-input-large::-webkit-outer-spin-button,
.hp-input-medium::-webkit-inner-spin-button,
.hp-input-medium::-webkit-outer-spin-button,
.dice-input::-webkit-inner-spin-button,
.dice-input::-webkit-outer-spin-button,
.spell-ability-input-num::-webkit-inner-spin-button,
.spell-ability-input-num::-webkit-outer-spin-button,
.slot-total-val::-webkit-inner-spin-button,
.slot-total-val::-webkit-outer-spin-button,
.prof-bonus-input-new::-webkit-inner-spin-button,
.prof-bonus-input-new::-webkit-outer-spin-button,
.companion-stat-val::-webkit-inner-spin-button,
.companion-stat-val::-webkit-outer-spin-button,
.companion-attr-val::-webkit-inner-spin-button,
.companion-attr-val::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number].circle-input,
input[type=number].circle-input-small,
input[type=number].shield-input,
input[type=number].shield-input-small,
input[type=number].hp-input-large,
input[type=number].hp-input-medium,
input[type=number].dice-input,
input[type=number].spell-ability-input-num,
input[type=number].slot-total-val,
input[type=number].prof-bonus-input-new,
input[type=number].companion-stat-val,
input[type=number].companion-attr-val {
  -moz-appearance: textfield;
}

body.view-mode select:disabled {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

/* Keep empty checkboxes visible in view-mode but not interactive */
body.view-mode .prof-check:disabled:not(:checked) {
  opacity: 0.8; /* Keep empty outlines fully visible in View Mode */
}

body.view-mode .attune-check:disabled:not(:checked) {
  opacity: 0.08;
}

/* Keep checked boxes clearly visible */
body.view-mode .prof-check:disabled:checked,
body.view-mode .attune-check:disabled:checked,
body.view-mode .inspiration-check:disabled:checked {
  opacity: 1;
}

/* Disabled checkboxes in view-mode should not show pointer cursor */
body.view-mode .prof-check:disabled,
body.view-mode .bard-check:disabled,
body.view-mode .attune-check:disabled {
  cursor: default !important;
}

/* Styling the 3 states of prof checks in both modes */
.prof-check[data-state="1"] {
  background-color: var(--primary-crimson) !important;
  border-color: var(--primary-crimson) !important;
}

.prof-check[data-state="2"] {
  background-color: var(--accent-gold) !important;
  border-color: var(--accent-gold) !important;
}

body.view-mode .inspiration-check:disabled:checked {
  background-color: var(--accent-gold);
  border-color: var(--accent-gold);
}

/* Custom styled inputs in edit-mode get light borders to indicate editability */
body.edit-mode input:not([type="checkbox"]):not([type="radio"]), 
body.edit-mode textarea,
body.edit-mode select {
  border-bottom: 1px solid var(--border-light);
  background-color: rgba(143, 112, 107, 0.02);
}

body.edit-mode input:not([type="checkbox"]):not([type="radio"]):focus, 
body.edit-mode textarea:focus,
body.edit-mode select:focus {
  border-color: var(--primary-crimson) !important;
  background-color: rgba(143, 112, 107, 0.04);
}

/* Override borders/backgrounds for visual graphics (Level Circle & Armor Class Shield) */
body.edit-mode .circle-input,
body.edit-mode .circle-input-small,
body.edit-mode .shield-input,
body.edit-mode .shield-input-small,
body.edit-mode .prof-bonus-input-new {
  border-bottom: none !important;
  background-color: transparent !important;
}

/* Portrait Modal Overlay and Content */
.portrait-modal-content {
  max-width: 420px;
  padding: 35px;
  text-align: center;
}

.portrait-large-preview-container {
  width: 100%;
  aspect-ratio: 4 / 5;
  background-color: rgba(39, 24, 21, 0.03);
  border: 1px solid var(--border-light);
  margin-bottom: 24px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-large-preview-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait-modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.portrait-modal-actions button {
  flex: 1;
}

@media (max-width: 400px) {
  .portrait-modal-actions {
    flex-direction: column;
  }
}

/* Subtle separator line between pages */
.sheet-page-divider {
  position: relative;
  border-top: 1.5px solid var(--border-light);
  opacity: 0.8;
  margin: 40px 0;
  width: 100%;
}

.sheet-page-divider::after {
  content: '◆';
  position: absolute;
  color: var(--accent-gold);
  background-color: var(--surface-color);
  padding: 0 16px;
  font-size: 14px;
  line-height: 1;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
}

/* Page 2 Layout Styles */
.page2-grid {
  grid-template-columns: 1fr 2fr 2fr !important;
  margin-top: 16px;
}

.col-20 {
  flex: 1;
  min-width: 0;
}

.col-40 {
  flex: 2;
  min-width: 0;
}

/* Equipment Training & Proficiencies Box styles */
.proficiencies-box {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background-color: var(--surface-color);
  border: 1.5px solid var(--border-light);
  box-sizing: border-box;
}

.box-title.centered {
  width: 100%;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dark);
  margin-bottom: 12px;
  border-bottom: 1.5px solid var(--border-light);
  padding-bottom: 8px;
}

.armor-training-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.armor-training-label {
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  line-height: 1.1;
  flex-shrink: 0;
}

.armor-training-checkboxes {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-grow: 1;
  justify-content: space-between;
}

.armor-checkbox-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.armor-checkbox-item .slot-diamond-check {
  width: 11px;
  height: 11px;
  margin: 0;
}

.armor-label-text {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dark);
}

body.view-mode .armor-label-text,
body.view-mode .armor-checkbox-item .slot-diamond-check {
  cursor: default !important;
}

body.edit-mode .armor-label-text,
body.edit-mode .armor-checkbox-item .slot-diamond-check {
  cursor: pointer !important;
}

.prof-divider {
  border-top: 1px solid var(--border-light);
  margin: 8px 0;
  width: 100%;
}

.prof-text-section {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 80px;
}

.prof-section-title {
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.prof-textarea {
  flex-grow: 1;
  width: 100%;
  height: 60px;
  resize: none;
  background: rgba(143, 112, 107, 0.01);
  border: 1px solid transparent;
  padding: 4px 6px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-dark);
  outline: none;
  box-sizing: border-box;
}

.prof-textarea:focus {
  border-color: var(--primary-crimson);
  background: rgba(143, 112, 107, 0.03);
}

.prof-view-div {
  flex-grow: 1;
  width: 100%;
  overflow-y: auto;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-dark);
  box-sizing: border-box;
}

.prof-list-view {
  margin: 0;
  padding-left: 14px;
  list-style-type: disc;
  font-weight: 600;
  line-height: 1.4;
}

.prof-list-view li {
  margin-bottom: 2px;
}

/* View vs Edit modes styles */
body.view-mode .prof-textarea {
  display: none !important;
}
body.view-mode .prof-view-div {
  display: block !important;
}

body.edit-mode .prof-textarea {
  display: block !important;
}
body.edit-mode .prof-view-div {
  display: none !important;
}

/* Features & Traits List */
.features-traits-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

/* Feature Trait Card */
.feature-trait-item {
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.feature-trait-item:hover {
  border-color: var(--primary-crimson);
}

/* Drag Handle styling */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: move;
  padding: 4px;
  user-select: none;
}

.drag-handle:hover {
  color: var(--primary-crimson);
}

/* Edit Mode Card Header */
.edit-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(143, 112, 107, 0.02);
  border-bottom: 1px solid var(--border-light);
  padding: 6px 12px;
}

.edit-card-title {
  flex-grow: 1;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-dark);
}

/* Edit Form Fields Grid */
.edit-fields-container {
  display: none;
  padding: 12px;
  flex-direction: column;
  gap: 10px;
  background-color: var(--surface-color);
}

.feature-trait-item.expanded .edit-fields-container {
  display: flex;
}

.edit-form-row {
  display: flex;
  gap: 12px;
}

.edit-form-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-grow: 1;
  flex-basis: 0;
}

.edit-form-group.full-width {
  flex-basis: 100%;
}

.edit-form-group.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
}

.edit-form-label {
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.edit-form-input, .edit-form-select {
  background: rgba(143, 112, 107, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  padding: 4px 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-dark);
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.edit-form-input:focus, .edit-form-select:focus {
  border-color: var(--primary-crimson);
  background-color: var(--surface-color);
}

.edit-form-textarea {
  background: rgba(143, 112, 107, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  padding: 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-dark);
  outline: none;
  height: 60px;
  resize: none;
  width: 100%;
  box-sizing: border-box;
}

.edit-form-textarea:focus {
  border-color: var(--primary-crimson);
  background-color: var(--surface-color);
}

/* View Mode Card */
.view-card {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
}

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

.feat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-grow: 1;
}

.feat-title {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 800;
  color: var(--text-dark);
}

.feat-source {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Action Badges styling */
.action-badge {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.action-badge.action {
  background-color: rgba(140, 22, 22, 0.06);
  border-color: rgba(140, 22, 22, 0.2);
  color: var(--primary-crimson);
}

.action-badge.bonus-action {
  background-color: rgba(46, 125, 50, 0.06);
  border-color: rgba(46, 125, 50, 0.2);
  color: #2e7d32;
}

.action-badge.reaction {
  background-color: rgba(21, 101, 192, 0.06);
  border-color: rgba(21, 101, 192, 0.2);
  color: #1565c0;
}

.action-badge.passive {
  background-color: rgba(120, 120, 120, 0.06);
  border-color: rgba(120, 120, 120, 0.2);
  color: #666666;
}

.action-badge.free-action {
  background-color: rgba(106, 27, 154, 0.06);
  border-color: rgba(106, 27, 154, 0.2);
  color: #6a1b9a;
}

/* View Mode details */
.feat-short-text {
  font-family: var(--font-sans);
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 3px;
  padding-left: 2px;
}

.feat-desc-container {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-out, margin-top 0.25s ease-out;
}

.feat-desc-container.expanded {
  max-height: 500px;
  margin-top: 8px;
  border-top: 1px dashed var(--border-light);
  padding-top: 8px;
}

.feat-rules-text {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-dark);
  white-space: pre-line;
}

/* Resource Tracker styling */
.feat-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.resource-tracker {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tracker-bubble {
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent-gold);
  border-radius: 50%;
  appearance: none;
  outline: none;
  cursor: pointer;
  background-color: transparent;
  transition: all 0.2s ease;
  margin: 0;
}

.tracker-bubble:checked {
  background-color: var(--accent-gold);
}

body.view-mode .tracker-bubble {
  cursor: pointer !important;
  pointer-events: auto !important;
}

/* Drag Over Dropzone indicator */
.feature-trait-item.drag-over {
  border-color: var(--accent-gold) !important;
  box-shadow: 0 0 8px rgba(179, 139, 0, 0.25);
}

.feature-trait-item.dragging {
  opacity: 0.4;
}

/* Page 2 Spells List & Card Styling */
.spells-page2-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.spell-page2-item {
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.spell-page2-item:hover {
  border-color: var(--primary-crimson);
}

.spell-page2-item.expanded .edit-fields-container {
  display: flex;
}

.spell-page2-item.drag-over {
  border-color: var(--accent-gold) !important;
  box-shadow: 0 0 8px rgba(179, 139, 0, 0.25);
}

.spell-page2-item.dragging {
  opacity: 0.4;
}

.spell-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.spell-meta-row span {
  display: inline-flex;
  align-items: center;
}

.concentration-badge {
  background-color: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.35);
  color: #bfa11b;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

/* Page 2 Magic Items Styling */
.magic-items-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.magic-item-card {
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.magic-item-card:hover {
  border-color: var(--primary-crimson);
}

.magic-item-card.expanded .edit-fields-container {
  display: flex;
}

.magic-item-card.drag-over {
  border-color: var(--accent-gold) !important;
  box-shadow: 0 0 8px rgba(179, 139, 0, 0.25);
}

.magic-item-card.dragging {
  opacity: 0.4;
}

/* Rarity Badges */
.rarity-badge {
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.rarity-badge.common {
  background-color: rgba(120, 120, 120, 0.06);
  border-color: rgba(120, 120, 120, 0.2);
  color: #666666;
}

.rarity-badge.uncommon {
  background-color: rgba(46, 125, 50, 0.06);
  border-color: rgba(46, 125, 50, 0.2);
  color: #2e7d32;
}

.rarity-badge.rare {
  background-color: rgba(21, 101, 192, 0.06);
  border-color: rgba(21, 101, 192, 0.2);
  color: #1565c0;
}

.rarity-badge.very-rare {
  background-color: rgba(106, 27, 154, 0.06);
  border-color: rgba(106, 27, 154, 0.2);
  color: #6a1b9a;
}

.rarity-badge.legendary {
  background-color: rgba(230, 81, 0, 0.06);
  border-color: rgba(230, 81, 0, 0.2);
  color: #e65100;
}

.rarity-badge.artifact {
  background-color: rgba(183, 28, 28, 0.06);
  border-color: rgba(183, 28, 28, 0.2);
  color: #b71c1c;
}

/* Attunement text */
.attunement-text {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Nested Magic Item Effects sublist */
.item-effects-sublist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  border-top: 1px solid var(--border-light);
  padding-top: 10px;
}

.item-effect-edit-card {
  background: rgba(143, 112, 107, 0.01);
  border: 1px dashed var(--border-light);
  border-radius: 4px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.item-effect-edit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.item-effect-edit-title {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
}

.item-effect-view-item {
  border-bottom: 1px dashed rgba(143, 112, 107, 0.15);
  padding-bottom: 8px;
  margin-bottom: 4px;
}

.item-effect-view-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.effect-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Quickbar styling */
.quickbar-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  flex-grow: 1;
}

/* Category header in actions tab */
.quickbar-category-title {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary-crimson);
  border-bottom: 1.5px solid rgba(143, 112, 107, 0.15);
  padding-bottom: 3px;
  margin-top: 8px;
  margin-bottom: 4px;
}

.quickbar-category-title:first-child {
  margin-top: 2px;
}

/* Filter buttons in actions quickbar */
.btn-filter {
  background-color: transparent;
  border: 1px solid var(--border-light);
  border-radius: 3px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-filter:hover {
  color: var(--text-dark);
  border-color: var(--text-muted);
}

.btn-filter.active {
  background-color: var(--primary-crimson);
  border-color: var(--primary-crimson);
  color: #ffffff;
}

/* Quickbar item cards */
.quickbar-card {
  border: 1px solid var(--border-light);
  background-color: rgba(143, 112, 107, 0.01);
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quickbar-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
}

.quickbar-card-title {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-crimson);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact overrides for elements inside quickbar cards */
.quickbar-card .action-badge {
  font-size: 8px !important;
  padding: 0px 4px !important;
  line-height: 1.2 !important;
}

.quickbar-card .feat-frequency {
  font-size: 9px !important;
}

.quickbar-card .tracker-bubble {
  width: 13px !important;
  height: 13px !important;
  border-width: 1.5px !important;
}

.quickbar-card .resource-tracker {
  gap: 3px !important;
}

.quickbar-card .spell-meta-row {
  margin-top: 0px !important;
  font-size: 9px !important;
  line-height: 1.2 !important;
}

.quickbar-card .feat-short-text {
  font-size: 10.5px !important;
  line-height: 1.25 !important;
  margin-top: 0px !important;
  color: var(--text-muted) !important;
  padding-left: 0px !important;
}

.quickbar-card .feat-rules-text {
  font-size: 10.5px !important;
  line-height: 1.3 !important;
}

.quickbar-card .feat-desc-container.expanded {
  margin-top: 3px !important;
  padding-top: 3px !important;
}

/* Custom Skill & Saving Throw Adjustments */
.trait-adj-input {
  width: 32px;
  height: 18px;
  padding: 0 2px;
  border: 1px dashed var(--border-light);
  border-radius: 3px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  background-color: rgba(143, 112, 107, 0.05);
  color: var(--text-dark);
  margin-left: 2px;
  margin-right: 2px;
  display: none;
  -moz-appearance: textfield;
}

.trait-adj-input::-webkit-outer-spin-button,
.trait-adj-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

body.edit-mode .trait-adj-input {
  display: inline-block;
}

.val-adjusted-bonus {
  color: #2e7d32 !important;
  font-weight: 800 !important;
  background-color: rgba(46, 125, 50, 0.12) !important;
  border-radius: 3px;
  padding: 0 4px;
}

.val-adjusted-malus {
  color: var(--primary-crimson) !important;
  font-weight: 800 !important;
  background-color: rgba(140, 22, 22, 0.1) !important;
  border-radius: 3px;
  padding: 0 4px;
}
/* Split Notes Layout */
#panel-notes,
#panel-background {
  display: none;
  height: 950px;
  flex-direction: column;
  box-sizing: border-box;
}

#panel-notes.active,
#panel-background.active {
  display: flex;
}

.notes-split-container {
  display: flex;
  gap: 20px;
  width: 100%;
  flex-grow: 1;
  height: 0;
  align-items: stretch;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .notes-split-container {
    flex-direction: column;
    height: auto;
  }
  .notes-left-column, .notes-right-column {
    width: 100% !important;
  }
}

.notes-left-column {
  width: 60%;
  display: flex;
  flex-direction: column;
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 14px;
  box-sizing: border-box;
  height: 100%;
}

.notes-right-column {
  width: 40%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.notes-right-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 14px;
  box-sizing: border-box;
  height: calc(50% - 8px);
}

.notes-block-header {
  border-bottom: 1.5px solid var(--primary-crimson);
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.notes-block-title {
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary-crimson);
  letter-spacing: 0.05em;
  margin: 0;
}

.notes-list-header {
  display: flex;
  gap: 8px;
  padding: 2px 8px;
  margin-bottom: 4px;
}

.notes-col-header {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.notes-rows-container {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

/* Notes Row Item */
.notes-row-item {
  display: flex;
  gap: 8px;
  align-items: stretch;
  background-color: rgba(143, 112, 107, 0.01);
  padding: 4px 8px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  transition: border-color 0.15s ease;
}

.notes-row-item:hover {
  border-color: var(--primary-crimson);
}

.notes-cell-textarea {
  flex-grow: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark);
  padding: 4px 0;
  box-sizing: border-box;
  line-height: 1.4;
  height: 30px; /* Single line default height */
}

.notes-cell-textarea.npc-cell-textarea {
  font-size: 13px;
  font-weight: 550;
  height: 26px;
}

/* New Collapsible Quest Log Styles */
.quest-quick-add-wrap {
  margin-bottom: 8px;
  width: 100%;
  box-sizing: border-box;
}

.quest-quick-input {
  width: 100%;
  background-color: rgba(143, 112, 107, 0.02);
  border: 1px dashed var(--primary-crimson);
  border-radius: 4px;
  color: var(--text-dark);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  padding: 4px 8px;
  outline: none;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.quest-quick-input:focus {
  background-color: var(--surface-color);
  border-style: solid;
  border-color: var(--primary-crimson);
  box-shadow: 0 0 4px rgba(140, 22, 22, 0.15);
}

.quest-row-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background-color: rgba(143, 112, 107, 0.01);
  padding: 4px 8px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  position: relative;
  transition: border-color 0.15s ease;
  margin-bottom: 4px;
}

.quest-row-item:hover {
  border-color: var(--primary-crimson);
}

.quest-checkbox-container {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0;
}

.quest-inputs-column {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 24px; /* leave space for delete button */
}

.quest-title-input {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 0;
  margin: 0;
  min-height: 20px;
  height: auto;
  box-sizing: border-box;
  overflow: hidden;
}

.quest-desc-input {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 550;
  color: var(--text-muted);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 0;
  margin: 0;
  min-height: 16px;
  height: auto;
  line-height: 1.4;
  box-sizing: border-box;
  overflow: hidden;
}

.quest-del-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: rgba(91, 64, 60, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  transition: color 0.15s ease;
  width: 20px;
  height: 20px;
  outline: none;
}

.quest-del-btn:hover {
  color: var(--primary-crimson);
}

.quest-completed-divider {
  border-top: 1px dashed var(--border-light);
  margin: 12px 0 10px 0;
}

.quest-completed-header {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  user-select: none;
}

.quest-completed-header:hover {
  color: var(--primary-crimson);
}

.quest-completed-header .dropdown-arrow {
  font-size: 16px;
  transition: transform 0.2s ease;
  line-height: 1;
}

.quest-completed-header.collapsed .dropdown-arrow {
  transform: rotate(-90deg);
}

.quest-row-item.quest-done-row {
  opacity: 0.6;
}

.quest-row-item.quest-done-row .quest-title-input {
  text-decoration: line-through;
  color: var(--text-muted);
}

.btn-notes-add-row {
  align-self: flex-start;
  background: rgba(140, 22, 22, 0.04);
  border: 1px dashed var(--primary-crimson);
  color: var(--primary-crimson);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  flex-shrink: 0;
}

.btn-notes-add-row:hover {
  background: var(--primary-crimson);
  color: #ffffff;
}

.notes-row-del-btn {
  background: none;
  border: none;
  color: rgba(91, 64, 60, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  transition: color 0.15s ease;
  width: 24px;
  flex-shrink: 0;
  align-self: center;
}

.notes-row-del-btn:hover {
  color: var(--primary-crimson);
}

/* Notes Toolbar & Rich Editor Styles */
.notes-dropdown-nav {
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-dark);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
  max-width: 200px;
}

.notes-dropdown-nav:hover {
  border-color: var(--primary-crimson);
}

.notes-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: rgba(143, 112, 107, 0.04);
  border: 1px solid var(--border-light);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  flex-wrap: wrap;
  min-height: 44px;
  box-sizing: border-box;
}

.tb-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 4px;
  transition: all 0.15s ease;
  width: 32px;
  height: 32px;
  outline: none;
  box-sizing: border-box;
}

.tb-btn:hover {
  background-color: rgba(143, 112, 107, 0.1);
  border-color: var(--border-light);
  color: var(--text-dark);
}

.tb-btn span {
  font-size: 18px;
  line-height: 1;
}

.tb-divider {
  width: 1px;
  height: 20px;
  background-color: var(--border-light);
  margin: 0 4px;
  flex-shrink: 0;
}

.tb-preset-btn {
  background: rgba(143, 112, 107, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-dark);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 800;
  height: 32px;
  padding: 0 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.tb-preset-btn:hover {
  background-color: var(--primary-crimson);
  border-color: var(--primary-crimson);
  color: #ffffff;
}

.tb-preset-btn[data-preset="header"] {
  background-color: rgba(197, 160, 89, 0.08);
  border-color: rgba(197, 160, 89, 0.3);
  color: var(--accent-gold);
}

.tb-preset-btn[data-preset="header"]:hover {
  background-color: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--surface-color);
}

.tb-preset-btn[data-preset="highlight"] {
  background-color: rgba(140, 22, 22, 0.08);
  border-color: rgba(140, 22, 22, 0.3);
  color: var(--primary-crimson);
}

.tb-preset-btn[data-preset="highlight"]:hover {
  background-color: var(--primary-crimson);
  border-color: var(--primary-crimson);
  color: #ffffff;
}

.tb-color-picker-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.tb-color-picker-wrap:hover {
  background-color: rgba(143, 112, 107, 0.1);
  border-color: var(--border-light);
}

.tb-color-picker-wrap .tb-btn {
  border: none;
}

.tb-color-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.notes-editor-container {
  flex-grow: 1;
  height: 0; /* Forces editor to stay inside flex boundaries */
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 0 0 6px 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notes-rich-editor {
  flex-grow: 1;
  height: 100%;
  padding: 16px;
  overflow-y: auto;
  outline: none;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-dark);
  box-sizing: border-box;
}

.notes-rich-editor[placeholder]:empty:before {
  content: attr(placeholder);
  color: var(--text-muted);
}

/* Custom styling inside the rich editor */
.notes-rich-editor h2 {
  font-family: var(--font-serif);
  color: var(--primary-crimson);
  font-size: 22px;
  font-weight: 800;
  margin-top: 18px;
  margin-bottom: 8px;
  border-bottom: 1px dashed var(--border-light);
  padding-bottom: 4px;
}

.notes-rich-editor p {
  margin-top: 0;
  margin-bottom: 12px;
}

.notes-rich-editor ul, .notes-rich-editor ol {
  margin-top: 0;
  margin-bottom: 12px;
  padding-left: 20px;
}

/* Quest drag and drop styling */
.quest-row-item.drag-over {
  border: 1px dashed var(--accent-gold) !important;
  background-color: rgba(197, 160, 89, 0.05) !important;
}
.quest-row-item.dragging {
  opacity: 0.4;
}

/* Notes Search Bar Styles */
.notes-search-bar-wrap {
  position: relative;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  width: 100%;
  flex-shrink: 0;
}

.notes-search-input {
  width: 100%;
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-dark);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  padding: 8px 36px 8px 38px;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.notes-search-input:focus {
  border-color: var(--primary-crimson);
  box-shadow: 0 0 6px rgba(140, 22, 22, 0.15);
}

.notes-search-bar-wrap .search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
  font-size: 18px;
  line-height: 1;
}

.notes-search-clear {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  outline: none;
}

.notes-search-clear:hover {
  color: var(--primary-crimson);
}

.notes-search-clear span {
  font-size: 16px;
}

/* Notes Search Results Overlay Panel */
.notes-search-results-panel {
  flex-grow: 1;
  height: 0;
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 16px 20px;
  overflow-y: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.notes-search-result-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notes-search-result-title {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  color: var(--primary-crimson);
  letter-spacing: 0.05em;
  border-bottom: 1.5px solid var(--primary-crimson);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.notes-search-result-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background-color: rgba(143, 112, 107, 0.01);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.notes-search-result-item:hover {
  border-color: var(--primary-crimson);
  background-color: rgba(143, 112, 107, 0.03);
}

.notes-search-result-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.notes-search-result-item-title {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 800;
  color: var(--text-dark);
}

.notes-search-result-badge {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.notes-search-result-badge.badge-active {
  background-color: rgba(197, 160, 89, 0.08);
  color: var(--accent-gold);
  border: 1px solid rgba(197, 160, 89, 0.3);
}

.notes-search-result-badge.badge-completed {
  background-color: rgba(76, 175, 80, 0.08);
  color: #4caf50;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.notes-search-result-badge.badge-npc {
  background-color: rgba(140, 22, 22, 0.08);
  color: var(--primary-crimson);
  border: 1px solid rgba(140, 22, 22, 0.3);
}

.notes-search-result-item-text {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 550;
  color: var(--text-muted);
  line-height: 1.4;
}

.search-highlight {
  background-color: rgba(197, 160, 89, 0.25);
  color: var(--text-dark);
  font-weight: 800;
  border-radius: 2px;
  padding: 0 2px;
}

/* Flash effect on navigate jump */
@keyframes flash-highlight {
  0% {
    background-color: rgba(197, 160, 89, 0.4);
    box-shadow: 0 0 10px rgba(197, 160, 89, 0.4);
  }
  100% {
    background-color: transparent;
    box-shadow: none;
  }
}

.flash-highlight-target {
  animation: flash-highlight 1.5s ease-out;
}

.bg-synced-portrait {
  cursor: default !important;
}

.bg-traits-panel {
  position: relative;
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 10px 16px;
  box-sizing: border-box;
}

.bg-traits-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 12px;
}

.bg-trait-cell {
  display: flex;
  flex-direction: column-reverse;
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 4px 6px;
  box-sizing: border-box;
}

.bg-trait-input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
  text-align: center;
  padding: 2px 0;
}

.bg-trait-label {
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 850;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  margin-top: 2px;
  letter-spacing: 0.05em;
}

/* 4-column layout */
.bg-content-columns {
  display: flex;
  gap: 16px;
  height: 750px;
  width: 100%;
  box-sizing: border-box;
}

.bg-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.col-22 {
  width: 22%;
}

.col-26 {
  width: 26%;
}

.bg-box {
  background-color: var(--surface-color);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  box-sizing: border-box;
  gap: 6px;
  flex: 1;
}

.bg-box-large {
  flex: 2;
}

.bg-box-xlarge {
  flex: 1; /* single element column stretching fully */
}

.bg-box-header {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  color: var(--primary-crimson);
  letter-spacing: 0.05em;
  border-bottom: 1.5px solid var(--primary-crimson);
  padding-bottom: 4px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.bg-box-textarea {
  width: 100%;
  flex-grow: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 550;
  color: var(--text-dark);
  line-height: 1.45;
  padding: 0;
  box-sizing: border-box;
}

/* Portrait display on background tab */
.bg-appearance-box {
  flex: 0 0 220px;
}

.bg-appearance-portrait-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 4px;
  background-color: rgba(143, 112, 107, 0.02);
  border: 1px solid var(--border-light);
}

.bg-appearance-portrait-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Companion Card Box */
.companion-box {
  flex: 1;
}

.companion-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  box-sizing: border-box;
}

.companion-row {
  display: flex;
  flex-direction: column;
}

.companion-name-input {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--border-light);
  background: transparent;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 850;
  color: var(--primary-crimson);
  padding: 2px 0;
  outline: none;
  text-align: center;
}

.companion-stats-row {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.companion-stat-cell {
  flex: 1;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 3px;
  background-color: var(--surface-color);
}

.companion-stat-lbl {
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 850;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 1px;
}

.companion-stat-val {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 800;
  color: var(--text-dark);
  text-align: center;
  padding: 0;
}

.companion-hp-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.companion-hp-wrap .companion-stat-val {
  width: 40%;
}

.companion-hp-wrap .slash {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 1px;
}

.companion-attr-row {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.companion-attr-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 4px 2px;
  background-color: rgba(143, 112, 107, 0.01);
}

.companion-attr-lbl {
  font-family: var(--font-sans);
  font-size: 7px;
  font-weight: 850;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.companion-attr-val {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 800;
  color: var(--text-dark);
  text-align: center;
  padding: 0;
}

.companion-sensory-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.companion-sensory-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px dashed var(--border-light);
  padding-bottom: 2px;
}

.companion-sensory-lbl {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 850;
  text-transform: uppercase;
  color: var(--primary-crimson);
  flex-shrink: 0;
  width: 38px;
}

.companion-sensory-val {
  flex-grow: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 550;
  color: var(--text-dark);
  padding: 0;
}

.companion-attacks-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.companion-section-title {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 850;
  text-transform: uppercase;
  color: var(--primary-crimson);
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--primary-crimson);
  padding-bottom: 2px;
}

.companion-atk-row {
  display: flex;
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 2px;
}

.companion-atk-name, .companion-atk-bonus, .companion-atk-damage {
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dark);
  padding: 0;
}

.companion-atk-name {
  font-weight: 750;
}

.companion-atk-bonus {
  text-align: center;
  color: var(--primary-crimson);
}

.companion-features-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  flex-grow: 1;
}

.companion-features-text {
  width: 100%;
  flex-grow: 1;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dark);
  line-height: 1.4;
  outline: none;
  resize: none;
  box-sizing: border-box;
}

/* Import/Export Modal Styling */
.import-file-info-card {
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background-color: rgba(143, 112, 107, 0.03);
  margin-bottom: 16px;
}

#import-overwrite-warning {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--primary-crimson);
  border-radius: 6px;
  background-color: rgba(140, 22, 22, 0.08);
  font-size: 13px;
  color: var(--primary-crimson);
  line-height: 1.4;
}

.checkbox-group label {
  transition: color 0.2s ease;
}

.checkbox-group label:hover {
  color: var(--primary-crimson);
}

/* Media query for Surface tablets / Laptop screens (max-width: 1450px) */
@media (max-width: 1450px) {
  /* 1. Reduce main content padding to save horizontal & vertical space */
  .sheet-content-wrapper {
    padding: 16px 24px;
  }
  
  /* 2. Keep header wrapper as row, but reduce gaps */
  .stats-header-wrapper {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
  }
  
  .char-stats-subwrapper {
    display: flex;
    flex-direction: row;
    flex: 7.2;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  
  .spell-stats-subwrapper {
    display: flex;
    flex-direction: row;
    flex: 3.8;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
  }

  /* 3. Reduce header height from 150px to 125px to save vertical space */
  .header-portrait-box,
  .header-details-box,
  .header-circle-box,
  .header-shield-box,
  .header-right-box,
  .header-spell-ability-box,
  .header-spell-slots-box {
    min-height: 125px;
    height: 125px;
    min-width: 0;
  }

  /* Scale down widths of fixed boxes */
  .header-portrait-box {
    width: 100px;
    height: 125px;
    flex-shrink: 0;
  }

  .header-circle-box {
    margin-left: -16px;
    margin-right: 0;
    width: 110px;
    height: 125px;
    flex-shrink: 0;
  }

  .header-shield-box {
    width: 90px;
    height: 125px;
    flex-shrink: 0;
  }

  /* Reduce paddings in flex boxes */
  .header-details-box {
    padding: 8px 12px 8px 24px; /* Reduced curved bracket padding */
    flex: 2.5;
  }

  .header-right-box {
    padding: 8px 12px 8px 8px;
    flex: 4;
  }

  .header-spell-ability-box {
    padding: 8px 8px 8px 16px;
    flex: 1.5;
  }

  .header-spell-slots-box {
    padding: 8px 12px;
    flex: 3;
  }

  /* Details box font sizes */
  .details-input {
    font-size: 11px;
    padding: 1px 0;
  }
  .details-input.font-bold {
    font-size: 15px;
  }
  .details-label {
    font-size: 8px;
  }
  .details-content {
    gap: 2px;
  }

  /* Circle box font sizes */
  .circle-input {
    font-size: 18px;
    width: 35px;
  }
  .circle-input-small {
    font-size: 9px;
    width: 45px;
  }
  .circle-label {
    font-size: 8px;
  }

  /* Shield box font sizes */
  .shield-input {
    font-size: 20px;
  }
  .shield-input-small {
    font-size: 13px;
  }
  .shield-label {
    font-size: 8px;
  }
  .shield-label-small {
    font-size: 8px;
  }
  .shield-ac-wrap, .shield-sh-wrap {
    gap: 0;
  }

  /* Right box (HP, Hit Dice, Death Saves) elements */
  .sub-section-title {
    font-size: 8px;
    margin-bottom: 4px;
  }
  .hp-input-large {
    font-size: 18px;
  }
  .hp-input-medium {
    font-size: 12px;
  }
  .hp-cell-label {
    font-size: 7px;
  }
  .hp-layout {
    gap: 4px;
  }
  .hp-calculator-row {
    margin-top: 4px;
    gap: 4px;
  }
  .hp-calc-input {
    height: 18px;
    font-size: 10px;
    width: 40px;
    padding: 2px 4px;
  }
  .hp-calc-btn {
    height: 20px;
    font-size: 9px;
    padding: 0 4px;
  }
  .hd-adjust-btn {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }
  .dice-input, .dice-input-text {
    font-size: 11px;
    height: 18px;
    width: 35px;
  }
  .dice-cell-label {
    font-size: 7px;
  }
  .saves-label {
    font-size: 8px;
  }
  .death-check {
    width: 9px;
    height: 9px;
    margin: 1px;
  }
  .saves-checkboxes {
    gap: 2px;
  }
  .saves-row {
    gap: 4px;
  }
  .vertical-divider {
    height: 75px;
  }
  .right-box-content {
    gap: 6px;
  }

  /* Spell casting elements */
  .spell-ability-title {
    font-size: 9px;
    margin-bottom: 4px;
  }
  .spell-ability-label {
    font-size: 8px;
  }
  .spell-ability-select-box {
    font-size: 9px;
    padding: 2px;
    width: 49px; /* Align with input + adjustment fields */
    box-sizing: border-box;
    margin-right: 0;
  }
  .spell-ability-input, .spell-ability-input-num {
    font-size: 11px;
    width: 25px;
  }
  .spell-adj-input {
    font-size: 9px;
    width: 20px;
  }
  .spell-ability-content {
    gap: 2px;
  }

  /* Spell slots elements */
  .spell-slots-title {
    font-size: 9px;
    margin-bottom: 4px;
  }
  .slots-col-label {
    font-size: 7px;
  }
  .slots-col-row {
    gap: 4px;
    margin-bottom: 2px;
    height: 18px; /* Touch friendly row height scaled down to prevent cut-offs */
  }
  .slots-col-header {
    margin-bottom: 2px;
    padding-bottom: 1px;
  }
  .slot-level-name {
    font-size: 9px;
  }
  .slot-total-val {
    width: 20px;
    font-size: 10px;
    height: 16px;
  }
  .slot-diamond-check {
    width: 8px;
    height: 8px;
    margin: 1px;
    border-width: 1.2px;
  }
  .slots-columns-container {
    gap: 8px;
  }

  /* 4. Compact the Ability Cards (STR, DEX, etc.) to save vertical height */
  .ability-card-upper {
    padding: 6px 8px;
  }
  .ability-modifier-circle {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }
  .ability-score-box-wrap {
    padding: 2px 4px;
    width: 42px;
  }
  .ability-score-input-new {
    font-size: 12px;
    height: 16px;
  }
  .ability-card-lower {
    padding: 5px 8px;
    gap: 4px;
  }
  .ability-card-header {
    padding: 4px;
    font-size: 9px;
  }

  /* 5. Compact the combat metrics (Initiative, Speed, Size, Passive Perc.) */
  .metric-small-box {
    padding: 4px 8px;
    gap: 0px;
  }
  .metric-small-box .form-label {
    font-size: 8px;
  }
  .metric-small-input {
    font-size: 14px;
    height: 20px;
  }
  .metric-small-input-text {
    font-size: 10px;
    height: 20px;
  }

  /* 6. Push page 2 further down to prevent it showing at the bottom of Page 1 */
  .sheet-page-divider {
    margin-top: 150px;
  }

  /* 7. Reduce spacing gaps on the stats panel */
  .stats-header-box {
    margin: 0 0 16px 0;
  }
  .sheet-grid-3 {
    gap: 16px;
  }
}
