/* CASTLE v227 UI fixes: modal positioning, compact builder controls, phase navigation. */

/* Fix 1: Restore fixed positioning on Round Table modals after broad body child positioning rules. */
html.castle-v219-ui .sim-modal,
html.castle-v223-ui .sim-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 100 !important;
}

/* Fix 2: Round Table list/tile titles match Archive reference size. */
html.castle-v223-ui body.castle-v223-page-sims .tile-title {
  font-size: 16px !important;
  font-weight: 400 !important;
}

/* Fix 3: Keep list/tile titles match Archive reference size. */
html.castle-v223-ui body.castle-v223-page-admin .admin-tile-title {
  font-size: 16px !important;
  font-weight: 400 !important;
}

/* Fix 4: Right-panel admin action buttons stay compact. */
html.castle-v223-ui body.castle-v223-page-admin #editor-actions .btn {
  font-size: 13px !important;
  min-height: 38px !important;
  line-height: 1.25 !important;
  font-weight: 600 !important;
  border-radius: 9px !important;
  padding: 8px 13px !important;
}

/* Fix 5: Inline inject/phase action buttons stay compact. */
html.castle-v223-ui body.castle-v223-page-admin .inline-actions .btn,
html.castle-v223-ui body.castle-v223-page-admin .phase-actions .btn,
html.castle-v223-ui body.castle-v223-page-admin .inject-actions .btn {
  font-size: 13px !important;
  min-height: 34px !important;
  line-height: 1.25 !important;
  padding: 6px 14px !important;
  font-weight: 600 !important;
}

/* Fix 6: Performance indicator score/default rows shrink inside the editor column. */
html.castle-v223-ui body.castle-v223-page-admin .indicator-row-expanded {
  grid-template-columns: minmax(0,2fr) minmax(0,1fr) minmax(0,.8fr) auto !important;
  min-width: 0 !important;
  overflow: visible !important;
}
html.castle-v223-ui body.castle-v223-page-admin .indicator-defaults-grid,
html.castle-v223-ui body.castle-v223-page-admin .indicator-score-row {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0,1fr)) !important;
  gap: 8px !important;
  min-width: 0 !important;
  overflow: visible !important;
}
html.castle-v223-ui body.castle-v223-page-admin .indicator-row-expanded .mini-field,
html.castle-v223-ui body.castle-v223-page-admin .indicator-defaults-grid .mini-field,
html.castle-v223-ui body.castle-v223-page-admin .indicator-score-row .mini-field {
  min-width: 0 !important;
}
html.castle-v223-ui body.castle-v223-page-admin .indicator-row-expanded input,
html.castle-v223-ui body.castle-v223-page-admin .indicator-defaults-grid input,
html.castle-v223-ui body.castle-v223-page-admin .indicator-score-row input {
  width: 100% !important;
  min-width: 0 !important;
}

/* Fix 8: Revert broad admin .btn override back to normal button scale. */
html.castle-v223-ui body.castle-v223-page-admin .btn {
  font-size: 13px !important;
}

/* Fix 9: Briefing appears as the first navigation tile in the phase rail. */
html.castle-v223-ui body.castle-v223-page-admin .brief-nav-tile {
  position: relative;
  border-color: var(--cyanbd, rgba(0,155,170,.28)) !important;
  background: linear-gradient(90deg, rgba(0,155,170,.08), rgba(255,255,255,.92)) !important;
  box-shadow: inset 4px 0 0 var(--cyan, #009BAA);
}
html.castle-v223-ui body.castle-v223-page-admin .brief-nav-tile .phase-kicker {
  color: var(--cyan, #009BAA) !important;
}
html.castle-v223-ui body.castle-v223-page-admin .brief-focus-pulse {
  box-shadow: 0 0 0 4px rgba(0,155,170,.14), 0 10px 28px rgba(0,0,0,.08) !important;
}

/* Fix 10: Compact destructive phase action without dominating the card. */
html.castle-v223-ui body.castle-v223-page-admin .phase-card {
  position: relative;
}
html.castle-v223-ui body.castle-v223-page-admin .phase-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
html.castle-v223-ui body.castle-v223-page-admin .phase-delete-btn {
  appearance: none;
  border: 1px solid rgba(192,57,43,.22);
  background: rgba(192,57,43,.06);
  color: var(--live, #C0392B);
  border-radius: 7px;
  padding: 4px 8px;
  font-family: var(--fm, monospace);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: .62;
}
html.castle-v223-ui body.castle-v223-page-admin .phase-card:hover .phase-delete-btn,
html.castle-v223-ui body.castle-v223-page-admin .phase-delete-btn:focus {
  opacity: 1;
}

@media (max-width: 900px) {
  html.castle-v223-ui body.castle-v223-page-admin .indicator-row-expanded,
  html.castle-v223-ui body.castle-v223-page-admin .indicator-defaults-grid,
  html.castle-v223-ui body.castle-v223-page-admin .indicator-score-row {
    grid-template-columns: 1fr !important;
  }
}

/* Fix 11: Restore fixed positioning on User Management / admin modal overlays after broad body child positioning rules (same root cause as Fix 1). */
html.castle-v219-ui .modal-overlay,
html.castle-v223-ui .modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 100 !important;
}
