/* ============================================================================
   Character Sheet Tool — CS-prefixed styles
   Depends on shared-components.css (.mns-* classes)
   ============================================================================ */

/* ── Hide ToC and footer on character sheet page ─────────────────────── */
main.container:has(#character-sheet-root) .book-toc {
  visibility: hidden;
}

@media screen and (min-width: 56rem) {
  main.container:has(#character-sheet-root) {
    position: relative;
  }
  main.container:has(#character-sheet-root) > .book-page:has(#character-sheet-root) {
    position: absolute;
    left: 16rem;
    right: 16rem;
    top: 0;
    padding: 1rem;
  }
}

.book-page:has(#character-sheet-root) .book-footer {
  display: none;
}

/* ── Roster ─────────────────────────────────────────────────────────────── */
.cs-roster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.cs-roster-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.cs-roster-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cs-roster-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cs-roster-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--mns-text-muted);
  font-style: italic;
}

.cs-roster-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--mns-border);
  border-radius: 8px;
  background: var(--mns-card-bg);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cs-roster-card:hover {
  border-color: var(--mns-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.cs-roster-card-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cs-roster-card-name {
  font-weight: 600;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-roster-card-stats {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.cs-roster-card-stat {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.85rem;
  color: var(--mns-text-muted);
}

.cs-roster-card-stat svg {
  width: 14px;
  height: 14px;
}

.cs-roster-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.cs-roster-card-actions .mns-btn {
  padding: 4px 8px;
  font-size: 0.8rem;
}

/* ── Level Badge ────────────────────────────────────────────────────────── */
.cs-level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1.5px solid var(--mns-border);
  background: transparent;
  color: var(--mns-text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

/* ── Creation progress bar ───────────────────────────────────────────────── */
.cs-creation-progress {
  display: flex;
  border: 1px solid var(--mns-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

.cs-creation-dot {
  flex: 1;
  padding: 8px 12px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--mns-card-bg);
  color: var(--mns-text-muted);
  border-right: 1px solid var(--mns-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-creation-dot:last-child { border-right: none; }
.cs-creation-dot--active { background: var(--mns-primary); color: #fff; }
.cs-creation-dot--completed { background: #dcfce7; color: #166534; }
.cs-creation-dot--completed::before { content: '\2713 '; }
.cs-creation-dot--locked { opacity: 0.5; }

/* ── Sheet-native creation sections ─────────────────────────────────────── */
.cs-creation-sheet-section {
  border-radius: 8px;
  transition: box-shadow 0.2s;
}

.cs-creation-sheet-section--active {
  outline: 2px solid var(--mns-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.10);
}

.cs-creation-sheet-section--locked {
  opacity: 0.38;
  pointer-events: none;
}

/* Inline editor panel inside active sheet section */
.cs-creation-inline-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--mns-border);
  border-radius: 6px;
  background: var(--mns-card-bg);
}

/* SSF column states during creation */
.cs-creation-ssf-col--active {
  border-bottom: 2px solid var(--mns-primary);
  padding-bottom: 4px;
}

.cs-creation-ssf-col--locked {
  opacity: 0.4;
}

.cs-ssf-col:not(.cs-creation-ssf-col--locked):hover {
  background: var(--mns-hover-bg);
  border-radius: 4px;
  transition: background 0.12s;
}

.cs-creation-sheet-section--active:hover,
.cs-creation-sheet-section--completed:hover {
  box-shadow: 0 0 0 6px rgba(59,130,246,0.12);
}

/* Picker modal (creation steps 4 & 5) — flex column so shop list fills the panel */
.cs-picker-modal {
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

.cs-picker-modal .cs-creation-modal-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;       /* required for flex overflow to work */
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Let the shop list grow to fill available space instead of capping at 350px */
.cs-picker-modal .cs-shop-list {
  max-height: none;
  overflow-y: visible;
  flex: 1;
}

.cs-picker-modal .cs-creation-nav {
  flex-shrink: 0;
  border-top: none;
  padding: 12px 0 0;
  margin-top: 0;
}

.cs-creation-locked-ph { font-size: 0.8rem; color: var(--mns-text-muted); font-style: italic; }

.cs-creation-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--mns-border);
  background: var(--mns-card-bg);
}

.cs-creation-error {
  flex: 1;
  padding: 0 8px;
}

/* Confirm button always sits at the right */
.cs-creation-nav .mns-btn-primary { margin-left: auto; }

/* ── Pick-list (skills / styles two-tier selection) ──────────────────── */
.cs-pick-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.cs-pick-section {
  margin-bottom: 16px;
}

.cs-pick-label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--mns-text-muted);
}

.cs-pick-grid {
  display: flex;
  flex-direction: column;
  width: fit-content;
  gap: 8px;
}

.cs-pick-chip {
  padding: 8px 16px;
  border: 2px solid var(--mns-border);
  border-radius: 8px;
  background: var(--mns-card-bg);
  color: var(--mns-text);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.cs-pick-chip:hover:not(:disabled):not(.active) {
  border-color: var(--mns-primary);
}

.cs-pick-chip.active {
  border-color: var(--mns-primary);
  background: var(--mns-pill-bg);
  color: var(--mns-pill-text);
  font-weight: 600;
}

.cs-pick-chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Allocation Controls (skills, styles, focuses point-buy) ──────────── */
.cs-alloc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.cs-alloc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--mns-border);
  border-radius: 6px;
  background: var(--mns-card-bg);
}

.cs-alloc-label {
  font-weight: 500;
  font-size: 0.95rem;
}

.cs-alloc-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cs-alloc-value {
  min-width: 24px;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
}

.cs-alloc-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--mns-border);
  border-radius: 4px;
  background: var(--mns-card-bg);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: var(--mns-text);
  transition: background 0.12s;
}

.cs-alloc-btn:hover:not(:disabled) {
  background: var(--mns-hover-bg);
}

.cs-alloc-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.cs-alloc-base {
  font-size: 0.8rem;
  color: var(--mns-text-muted);
}

.cs-points-remaining {
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.cs-points-remaining.over-budget {
  color: var(--mns-danger, #dc2626);
}

/* ── Shopping Cart (equipment, talents, powers) ───────────────────────── */
.cs-shop {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Sticky budget header — stays visible while scrolling the item list */
.cs-budget-sticky {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--mns-panel-bg, #fff);
  padding-bottom: 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--mns-border);
}

.mns-ui.color-toggle-dark .cs-budget-sticky,
[data-mode="dark"] .cs-budget-sticky {
  background: var(--mns-panel-bg, #1c1917);
}

.cs-shop-budget {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.cs-shop-budget.over-budget {
  color: var(--mns-danger, #dc2626);
}

.cs-xp-bonus-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
  color: var(--mns-text-muted);
  font-size: 0.875rem;
  margin-top: -2px;
  padding-left: 2px;
}

.cs-shop-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--mns-border);
  border-radius: 6px;
  background: var(--mns-card-bg);
  color: var(--mns-text);
  font-size: 0.9rem;
  outline: none;
}

.cs-shop-search:focus {
  border-color: var(--mns-primary);
}

.cs-shop-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--mns-border);
  border-radius: 6px;
  overflow: hidden;
}

.cs-shop-tab {
  flex: 1;
  padding: 6px 12px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--mns-card-bg);
  color: var(--mns-text-muted);
  border: none;
  border-right: 1px solid var(--mns-border);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.cs-shop-tab:last-child {
  border-right: none;
}

.cs-shop-tab.active {
  background: var(--mns-primary);
  color: #fff;
}

.cs-shop-filter-bar {
  display: flex;
  flex-direction: column;
  padding: 0;
}

/* Toggle button — hamburger icon */
.cs-shop-filter-toggle {
  background: transparent;
  border: none;
  padding: 0.4rem;
  margin: 0.15rem 0;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.cs-shop-filter-toggle:hover {
  background: var(--mns-border);
}

.cs-shop-filter-toggle:focus {
  outline: 2px solid var(--mns-primary);
  outline-offset: 2px;
}

.cs-shop-toggle-icon {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 18px;
}

.cs-shop-toggle-line {
  height: 2px;
  background: var(--mns-text-muted);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.cs-shop-toggle-line:nth-child(1) { width: 100%; }
.cs-shop-toggle-line:nth-child(2) { width: 80%; }
.cs-shop-toggle-line:nth-child(3) { width: 60%; }

.cs-shop-filter-toggle.expanded .cs-shop-toggle-line:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
  width: 100%;
}

.cs-shop-filter-toggle.expanded .cs-shop-toggle-line:nth-child(2) {
  opacity: 0;
}

.cs-shop-filter-toggle.expanded .cs-shop-toggle-line:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
  width: 100%;
}

/* Collapsible content */
.cs-shop-filter-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.cs-shop-filter-content.expanded {
  max-height: 500px;
  background: var(--mns-card-bg);
  border: 1px solid var(--mns-border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.cs-shop-filter-content:not(.expanded) {
  border: none;
  background: transparent;
}

.cs-shop-filter-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  line-height: 0;
}

.cs-shop-filter-btns + .cs-shop-filter-btns {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--mns-border);
}

.cs-shop-filter-btn {
  display: inline-block;
  background: var(--mns-card-bg);
  border: 1px solid var(--mns-border);
  padding: 3px 8px;
  margin: 0 5px 5px 0;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--mns-text-muted);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  line-height: 1.4;
  vertical-align: top;
  box-sizing: border-box;
}

.cs-shop-filter-btn:hover {
  border-color: var(--mns-primary);
  color: var(--mns-text);
}

.cs-shop-filter-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.cs-shop-filter-btn.active {
  background: var(--mns-primary);
  color: #fff;
  border-color: var(--mns-primary);
}

.cs-shop-filter-btn.active:hover {
  background: var(--mns-primary-hover);
  border-color: var(--mns-primary-hover);
}

.cs-shop-filter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cs-shop-filter-clear {
  background: transparent;
  color: var(--mns-primary);
  border: none;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: underline;
  white-space: nowrap;
}

.cs-shop-filter-clear:hover {
  color: var(--mns-primary-hover);
}

.cs-shop-filter-count {
  font-size: 0.75rem;
  color: var(--mns-text-muted);
  white-space: nowrap;
  text-align: right;
}

.cs-shop-list {
  display: flex;
  flex-direction: column;
  max-height: 350px;
  overflow-y: auto;
  border-top: 1px solid var(--mns-border);
}

.cs-shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 2px;
  border-bottom: 1px solid var(--mns-border);
  background: transparent;
  cursor: pointer;
  transition: background 0.12s;
  gap: 8px;
}

/* Block layout for talents/powers items (uses power-component structure) */
.cs-shop-item.cs-shop-block {
  padding: 8px 4px;
}
.cs-shop-item.cs-shop-block > .mns-power-item {
  flex: 1;
  min-width: 0;
}

.cs-shop-item:hover {
  background: var(--mns-hover-bg);
}

.cs-shop-item.selected {
  background: var(--mns-selected-bg, rgba(59,130,246,0.10));
  border-left: 3px solid var(--mns-primary);
  padding-left: 5px;
  position: relative;
}

.cs-shop-item.cs-shop-block.selected::after {
  content: '\2713';
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--mns-primary);
  pointer-events: none;
}

.cs-shop-item.selected .cs-shop-item-name,
.cs-shop-item.selected .mns-power-name-row > strong {
  color: var(--mns-primary);
  font-weight: 600;
}

.cs-shop-item-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.cs-shop-item-detail {
  font-size: 0.8rem;
  color: var(--mns-text-muted);
  margin-top: 2px;
}

.cs-shop-item-desc {
  font-size: 0.8rem;
  color: var(--mns-text-muted);
  margin-top: 2px;
}

.cs-shop-item-info {
  min-width: 0;
  flex: 1;
}

/* ── Cost Pills (XP = gold, coin = silver) ───────────────────────────── */
.cs-cost-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

.cs-cost-pill-xp {
  background: #d97706;
  color: #fff;
}

.cs-cost-pill-coin {
  background: #6b7280;
  color: #fff;
}

.mns-ui.color-toggle-dark .cs-cost-pill-xp,
[data-mode="dark"] .cs-cost-pill-xp {
  background: #fbbf24;
  color: #1c1917;
}

.mns-ui.color-toggle-dark .cs-cost-pill-coin,
[data-mode="dark"] .cs-cost-pill-coin {
  background: #9ca3af;
  color: #1c1917;
}

/* Stack count badge (×N for stackable talents) */
.cs-stack-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  background: #7c3aed;
  color: #fff;
}
.mns-ui.color-toggle-dark .cs-stack-badge,
[data-mode="dark"] .cs-stack-badge {
  background: #a78bfa;
  color: #1c1917;
}

/* ── Use pips (consumables & once-per items) ─────────────────────────── */
.cs-use-pips {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.4rem;
  flex-shrink: 0;
  font-size: 0.8rem;
  opacity: 0.7;
}
.cs-use-pips-label {
  margin-right: 0.1rem;
}
.mns-ref-item > .cs-use-pips {
  padding-left: calc(14px + 0.3rem);
  margin-left: 0;
}
.cs-use-pip {
  width: 1rem;
  height: 1rem;
  border-radius: 2px;
  border: 1.5px solid currentColor;
  padding: 0;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
  font-size: 0.75rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.1s, background-color 0.1s;
}
.cs-use-pip.used::after {
  content: '\2713';
}
.cs-use-pips:hover {
  opacity: 1;
}

/* ── Consumable stepper (shop) ───────────────────────────────────────── */
.cs-shop-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: 0.5rem;
  flex-shrink: 0;
}
.cs-shop-stepper-btn {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0.6;
}
.cs-shop-stepper-btn:hover:not(:disabled) { opacity: 1; }
.cs-shop-stepper-btn:disabled { opacity: 0.25; cursor: default; }
.cs-shop-stepper-qty {
  min-width: 1.1rem;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
}

/* Selected items (cart) — sticky at bottom of scrollable panel */
.cs-cart {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--mns-panel-bg, #fff);
  padding: 8px 0 12px;
  margin-top: 4px;
  box-shadow: 0 -8px 8px var(--mns-panel-bg, #fff);
}

.mns-ui.color-toggle-dark .cs-cart,
[data-mode="dark"] .cs-cart {
  background: var(--mns-panel-bg, #1c1917);
  box-shadow: 0 -8px 8px var(--mns-panel-bg, #1c1917);
}

.cs-cart h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.cs-cart-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cs-cart-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--mns-border);
  border-radius: 999px;
  background: var(--mns-card-bg);
  font-size: 0.82rem;
}

.cs-cart-chip-remove {
  cursor: pointer;
  font-weight: 700;
  color: var(--mns-text-muted);
  margin-left: 2px;
}

.cs-cart-chip-remove:hover {
  color: var(--mns-danger, #dc2626);
}

.cs-cart-chip-locked {
  opacity: 0.6;
}

/* ── Locked shop items (MA/RD without gating talent) ─────────────────── */
.cs-shop-item.locked {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.cs-shop-item-lock-note {
  font-size: 0.75rem;
  color: var(--mns-text-muted);
  font-style: italic;
  margin-top: 3px;
}

/* Lowercase filter tags in talent/power shop */
.mns-ui .filter-btn {
  text-transform: lowercase;
}

/* ── Bioware dual cost badge buttons ─────────────────────────────────── */

.cs-cost-btn {
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  background: transparent;
  color: var(--mns-text-muted);
  border: 1px solid var(--mns-border);
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: opacity 0.12s;
}

.cs-cost-btn:hover {
  opacity: 0.75;
}

.cs-cost-btn-xp.active {
  background: #d97706;
  color: #fff;
  border-color: #d97706;
}

.cs-cost-btn-coin.active {
  background: #6b7280;
  color: #fff;
  border-color: #6b7280;
}

.mns-ui.color-toggle-dark .cs-cost-btn-xp.active,
[data-mode="dark"] .cs-cost-btn-xp.active {
  background: #fbbf24;
  color: #1c1917;
  border-color: #fbbf24;
}

.mns-ui.color-toggle-dark .cs-cost-btn-coin.active,
[data-mode="dark"] .cs-cost-btn-coin.active {
  background: #9ca3af;
  color: #1c1917;
  border-color: #9ca3af;
}

/* ── Focus undo icon button ───────────────────────────────────────────── */
.cs-focus-undo-btn {
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 8px;
}

/* ── Focus Pick Grid ─────────────────────────────────────────────────── */
.cs-focus-pick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

/* ── Focus Allocation List ───────────────────────────────────────────── */
.cs-focus-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cs-focus-list .mns-stat-label {
  min-width: 10em;
}

.cs-focus-remove {
  margin-left: 12px;
  color: var(--mns-text-muted);
  font-size: 1rem;
}

.cs-focus-remove:hover {
  color: var(--mns-danger, #dc2626);
}

/* ── Focus Picker ─────────────────────────────────────────────────────── */
.cs-focus-add {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.cs-focus-add select,
.cs-focus-add input {
  padding: 6px 10px;
  border: 1px solid var(--mns-border);
  border-radius: 6px;
  background: var(--mns-card-bg);
  color: var(--mns-text);
  font-size: 0.9rem;
}

.cs-focus-add select {
  flex: 1;
}

.cs-focus-add input {
  width: 140px;
}

/* ── Identity Step ────────────────────────────────────────────────────── */
.cs-identity-field {
  margin-bottom: 16px;
}

.cs-identity-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.cs-identity-field input,
.cs-identity-field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--mns-border);
  border-radius: 6px;
  background: var(--mns-card-bg);
  color: var(--mns-text);
  font-size: 0.9rem;
  box-sizing: border-box;
}

.cs-identity-field textarea {
  resize: vertical;
  min-height: 60px;
}

.cs-identity-field .cs-hint {
  font-size: 0.8rem;
  color: var(--mns-text-muted);
  margin-top: 4px;
}

/* Required field state (identity step 0) */
.cs-identity-field--required input,
.cs-identity-field--required textarea {
  border: 1.5px dashed #94a3b8;
  background: #f8fafc;
}

.cs-required-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #fee2e2;
  color: #dc2626;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

.cs-name-required {
  border-bottom-style: dashed !important;
  border-bottom-color: #94a3b8 !important;
}

/* Continue button for identity step */
.cs-identity-continue {
  display: block;
  width: 100%;
  margin-top: 8px;
  margin-bottom: 4px;
  padding: 0.4rem 0;
  font-size: 0.9rem;
  text-align: center;
}

/* ── Sheet View ─────────────────────────────────────────────────────────── */
.cs-sheet {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cs-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.cs-sheet-name {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cs-sheet-name-input {
  font-size: 1.4rem;
  font-weight: 700;
  border: none;
  border-bottom: 2px solid var(--mns-primary);
  background: transparent;
  color: var(--mns-text);
  outline: none;
  padding: 0;
  width: auto;
  min-width: 120px;
}

.cs-sheet-header-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cs-sheet-traits-row {
  margin: 8px 0;
}

.cs-sheet-traits-text {
  font-style: italic;
  font-size: 0.82rem;
  color: var(--mns-text-muted);
}

.cs-trait-input {
  width: 14rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  font-style: italic;
  font-size: 0.82rem;
  color: var(--mns-text-muted);
  outline: none;
  padding: 2px 0;
  font-family: inherit;
  transition: border-bottom-color 0.15s, color 0.15s;
}
.cs-trait-input:focus {
  border-bottom-color: var(--mns-primary);
  color: var(--mns-text);
}
.cs-trait-input::placeholder {
  font-style: italic;
  color: var(--mns-text-muted);
  opacity: 0.6;
}

.cs-trait-sep-dot {
  font-style: normal;
  opacity: 0.5;
  color: var(--mns-text-muted);
  margin: 0 0.6rem;
  user-select: none;
}

.cs-trait-input--required {
  border-bottom: 1.5px dashed #94a3b8;
}


.cs-sheet-stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.cs-sheet-stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--mns-border);
  background: var(--mns-card-bg);
}

.cs-sheet-stat-badge svg {
  width: 16px;
  height: 16px;
}

/* ── Skills + Styles + Focuses Columns ────────────────────────────────── */
.cs-ssf-grid {
  display: flex;
  gap: 32px;
  margin-bottom: 16px;
}

.cs-ssf-col {
  flex: 1;
  display: grid;
  grid-template-columns: max-content 1.5em;
  column-gap: 1.25em;
  row-gap: 2px;
  align-content: start;
  min-width: 0;
}

.cs-ssf-title {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--mns-text-muted);
  margin-bottom: 4px;
  font-weight: 400;
}

.cs-ssf-row {
  display: contents;
}

.cs-ssf-label {
  font-weight: 600;
  white-space: nowrap;
}

.cs-ssf-value {
  font-weight: 400;
  text-align: right;
}

/* ── Suppress shared-component top-border inside the sheet (cs-divider handles it) ── */
#character-sheet-root .mns-ref-section {
  border-top: none;
  padding-top: 0;
}

/* ── Match powers/actions section title to cs-section-title ──────────── */
#character-sheet-root .mns-ref-section > .mns-ref-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--mns-text);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 8px;
}

/* ── Section Divider ──────────────────────────────────────────────────── */
.cs-divider {
  border: none;
  border-top: 1px solid var(--mns-border);
  margin: 12px 0;
}

/* ── Sheet Sections ───────────────────────────────────────────────────── */
.cs-section {
  margin-bottom: 16px;
}

.cs-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.cs-section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cs-section-title-row .cs-section-title {
  margin-bottom: 0;
}

.cs-talent-item {
  padding: 2px 0;
}

.cs-talent-name {
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cs-talent-desc {
  font-size: 0.78rem;
  color: var(--mns-text-muted);
  margin-top: 1px;
}

/* ── Resistance badge (armor items) ──────────────────────────────────── */
.cs-res-tag {
  background: var(--mns-hover-bg);
  color: var(--mns-text-muted);
}

/* ── Equipment Section ────────────────────────────────────────────────── */
.cs-equip-item {
  padding: 6px 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cs-equip-name {
  font-weight: 600;
}

.cs-equip-remove {
  margin-left: auto;
  background: transparent;
  border-color: transparent;
  cursor: pointer;
  color: var(--gray-400, #9ca3af);
  font-size: 1rem;
  padding: 0 4px;
  line-height: 1;
}

.cs-equip-remove:hover {
  color: var(--mns-danger, #dc2626);
  background: var(--gray-100, #f3f4f6);
  border-color: var(--gray-300, #dee2e6);
}

.cs-equip-order-btns {
  display: flex;
  gap: 2px;
  margin-top: 4px;
}

.cs-equip-order-btn {
  background: transparent;
  border-color: transparent;
  color: var(--gray-400, #9ca3af);
  font-size: 0.8rem;
  padding: 0 4px;
  cursor: pointer;
  line-height: 1;
}

.cs-equip-order-btn:hover:not(:disabled) {
  color: var(--mns-text);
  background: var(--gray-100, #f3f4f6);
  border-color: var(--gray-300, #dee2e6);
}

.cs-equip-order-btn:disabled {
  opacity: 0.2;
  cursor: default;
}

.cs-equip-add-search {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 10px;
  font-size: 0.82rem;
  padding: 3px 7px;
  border: 1px solid var(--gray-300, #dee2e6);
  border-radius: 4px;
  background: var(--mns-bg);
  color: var(--mns-text);
}

.cs-equip-add-results {
  margin-top: 4px;
  border: 1px solid var(--gray-300, #dee2e6);
  border-radius: 4px;
  overflow: hidden;
}

.cs-equip-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 8px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--gray-200, #e9ecef);
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  color: var(--mns-text);
}

.cs-equip-add-row:last-child {
  border-bottom: none;
}

.cs-equip-add-row:hover {
  background: var(--mns-hover-bg);
}

.cs-equip-add-row-name {
  flex: 1;
}

.cs-equipment-coins {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.cs-equipment-coins-label {
  font-size: 0.85rem;
  color: var(--mns-text-muted);
}

.cs-equipment-coins-btn {
  cursor: pointer;
  border: none;
}

.cs-equip-detail {
  font-size: 0.85rem;
  color: var(--mns-text-muted);
}


/* ── Runtime / Play Mode ──────────────────────────────────────────────── */
.cs-runtime-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

/* ── Level Up Overlay ─────────────────────────────────────────────────── */
.cs-levelup-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: transparent;
}

.cs-levelup-modal {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100vw);
  background: var(--mns-card-bg);
  padding: 24px;
  overflow-y: auto;
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
  animation: cs-slide-in-right 0.22s ease-out;
}

@keyframes cs-slide-in-right {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* ── Focus Picker Panel (stacked slide-in) ───────────────────────────── */
.cs-focus-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: transparent;
}

.cs-focus-picker-modal {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 100vw);
  background: var(--mns-card-bg);
  padding: 24px;
  overflow-y: auto;
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
  animation: cs-slide-in-right 0.22s ease-out;
}

.cs-fp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cs-fp-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.cs-fp-close {
  font-size: 1.2rem;
  line-height: 1;
  padding: 4px 10px;
}

/* ── Level-up focus selection summary ────────────────────────────────── */
.cs-levelup-focus-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  padding: 4px 8px;
  color: var(--mns-text-muted);
}

.cs-levelup-modal h3 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

.cs-levelup-step {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--mns-border);
  border-radius: 8px;
}

.cs-levelup-step h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.cs-levelup-step.completed {
  border-color: var(--mns-success-text, #166534);
  background: var(--mns-success-bg, #dcfce7);
}

.cs-levelup-choice {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cs-levelup-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--mns-border);
  border-radius: 6px;
  cursor: pointer;
  background: var(--mns-card-bg);
}

.cs-levelup-option:hover {
  background: var(--mns-hover-bg);
}

.cs-levelup-option.selected {
  border-color: var(--mns-primary);
  background: var(--mns-selected-bg, rgba(59,130,246,0.06));
}

.cs-levelup-nav {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ── Import/Export ─────────────────────────────────────────────────────── */
.cs-import-drop {
  border: 2px dashed var(--mns-border);
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  color: var(--mns-text-muted);
  cursor: pointer;
  transition: border-color 0.15s;
}

.cs-import-drop:hover {
  border-color: var(--mns-primary);
}

.cs-import-drop.drag-over {
  border-color: var(--mns-primary);
  background: var(--mns-selected-bg, rgba(59,130,246,0.06));
}

/* ── Notes Textarea ───────────────────────────────────────────────────── */
.mns-notes-area {
  width: 100%;
  box-sizing: border-box;
  resize: none;
  overflow-y: hidden;
  padding: 8px 12px;
  border: 1px solid var(--mns-border);
  border-radius: 6px;
  background: var(--mns-card-bg);
  color: var(--mns-text);
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.5;
}

.mns-notes-area:focus {
  outline: none;
  border-color: var(--mns-primary);
}

/* ── Background (expandable) ──────────────────────────────────────────── */
.cs-background {
  padding: 8px 0;
}

.cs-background-toggle {
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
}

.cs-background-content {
  margin-top: 8px;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ── Validation Errors ────────────────────────────────────────────────── */
.cs-validation-error {
  color: var(--mns-danger, #dc2626);
  font-size: 0.85rem;
  margin-top: 4px;
}

.cs-validation-summary {
  padding: 12px;
  border: 1px solid var(--mns-danger, #dc2626);
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.05);
  margin-bottom: 16px;
}

.cs-validation-summary ul {
  margin: 4px 0 0;
  padding-left: 20px;
}

/* ── Dark Mode Overrides ──────────────────────────────────────────────── */
[data-mode="dark"] .cs-creation-dot--completed { background: #166534; color: #dcfce7; }

.mns-ui.color-toggle-dark .cs-levelup-step.completed,
[data-mode="dark"] .cs-levelup-step.completed {
  background: rgba(22, 101, 52, 0.2);
  border-color: #166534;
}

/* ── Level Down Preview ──────────────────────────────────────────────── */
.cs-leveldown-section {
  margin-bottom: 14px;
}

.cs-leveldown-section h4 {
  margin: 0 0 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mns-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cs-leveldown-item {
  padding: 3px 0;
  font-size: 0.95rem;
}

.cs-leveldown-empty {
  color: var(--mns-text-muted);
  font-style: italic;
  margin: 0 0 16px;
}

/* ── Mobile Responsive ────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .cs-creation-dot { padding: 6px 4px; font-size: 0.65rem; }

  .cs-alloc-grid {
    grid-template-columns: 1fr;
  }

  .cs-ssf-grid {
    gap: 12px;
    font-size: 0.85rem;
  }

  .cs-ssf-col {
    grid-template-columns: min-content 1.5em;
    align-items: start;
    row-gap: 6px;
  }

  .cs-ssf-label {
    white-space: normal;
  }

  .cs-ssf-value {
    padding-top: 1px;
  }

  .cs-roster-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .cs-roster-card-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .cs-sheet-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .cs-runtime-stats {
    gap: 8px;
  }

  .cs-shop-tabs {
    flex-wrap: wrap;
  }

  .cs-shop-filter-btn {
    font-size: 0.6875rem;
    padding: 2px 6px;
  }

  .cs-levelup-modal {
    padding: 16px;
    width: 100vw;
  }
}


/* ── Talent list wrapper ──────────────────────────────────────────────── */
.cs-talent-list {
  display: flex;
  flex-direction: column;
}

/* ── Empty placeholder for talents / powers in edit mode ─────────────── */
.cs-talent-none {
  font-size: 0.85rem;
  color: var(--mns-text-muted);
  font-style: italic;
  padding: 4px 0;
}

/* ── Category label in power search results ──────────────────────────── */
.cs-power-add-cat {
  font-size: 0.72rem;
  color: var(--mns-text-muted);
  font-style: italic;
  margin-left: auto;
  padding-right: 4px;
  flex-shrink: 0;
}

/* ── Print layout ────────────────────────────────────────────────────── */
.cs-print-stats { display: none; }

@media print {
  /* Zero top/bottom @page margin suppresses browser UA headers/footers in ALL browsers
     (Chrome, Firefox, Safari) — they require margin space to render. Side margins stay.
     Top/bottom spacing per page is provided by box-decoration-break: clone below. */
  @page { margin: 0 2cm; }

  /* Hide Hugo chrome */
  .book-menu,
  .book-header,
  .book-toc,
  .book-footer,
  .book-menu-toggle { display: none !important; }

  /* Hide interactive sheet controls, coins, notes, equipment edit controls */
  .cs-sheet-header-actions,
  .cs-runtime-stats,
  .mns-traits-row,
  .cs-equipment-coins,
  .cs-notes-section,
  .cs-equip-remove,
  .cs-equip-order-btns,
  .cs-section-edit-btn { display: none !important; }

  /* Full-width layout */
  body         { padding: 0 !important; }
  .book-page    { padding: 0 !important; }
  /* box-decoration-break: clone repeats padding at the top of every page fragment,
     giving a consistent 2cm top/bottom margin on all pages including page 2+. */
  .book-article {
    padding: 2cm 0 !important;
    max-width: none !important;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .cs-sheet     { max-width: none !important; padding: 0; }

  /* Prevent entries from being sliced across page breaks */
  .cs-talent-item,
  .cs-equip-item,
  .mns-ref-item,
  .mns-ref-section { break-inside: avoid; }

  /* Dividers: explicit color since var(--mns-border) may resolve to invisible in print */
  .cs-divider { border-top: 1px solid #777 !important; }

  /* Name: no underline */
  .cs-sheet-name-input { border-bottom: none !important; }

  /* Level badge: pull to top-right corner of the header */
  .cs-sheet-header { position: relative; }
  .cs-level-badge { position: absolute; top: 0; right: 0; }

  /* Print bubble tracks */
  .cs-print-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-bottom: 12px;
  }

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

  .cs-print-stat-label {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #555;
  }

  .cs-print-stat-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
  }

  .cs-print-stat-bubbles {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    max-width: 180px;
  }

  .cs-print-bubble {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 1.5px solid #333;
    display: inline-block;
  }
}

/* ── Share icon button ─────────────────────────────────────────────────── */
.cs-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
}
.cs-share-btn svg {
  display: block;
}
