/* --------------------------------------------------------------------------
 * Case cards (October 2025 alternating accent refresh)
 * JavaScript assigns variant-* classes so the accent palette swaps per row
 * while the structural layout stays identical between API and fallback data.
 * -------------------------------------------------------------------------- */
.p-cases .case-card {
  --case-border-color: rgb(59 130 246);
  --case-title-color: rgb(249 115 22);
  --case-divider-color: var(--case-border-color);
  --case-badge-primary: rgb(249 115 22);
  --case-badge-secondary: rgb(234 88 12);
  --case-badge-text: #fff;

  /* Scroll contract keeps tab panels within a predictable viewport and colours
   * the scrollbar thumb to match the card title accent. Marketing hero cards
   * override these values only when a unique layout is needed. */
  --case-content-overflow: auto;
  --case-content-max-block: clamp(260px, 34vh, 320px);
  --case-content-scroll-padding: 6px;
  --case-scrollbar-thumb: var(--case-title-color);
  --case-scrollbar-width: 9px;
  --case-scrollbar-track: rgb(15 23 42 / 35%);

  border: 0;
  border-radius: 28px;
  padding: 0;
  position: relative;
  background: transparent;
  box-shadow: 0 24px 48px rgb(15 23 42 / 28%);
  transition: transform .2s ease, box-shadow .2s ease;
}

.p-cases .case-card.variant-blue {
  --case-border-color: rgb(59 130 246);
  --case-title-color: rgb(249 115 22);
}

.p-cases .case-card.variant-orange {
  --case-border-color: rgb(249 115 22);
  --case-title-color: rgb(59 130 246);
  --case-badge-primary: rgb(59 130 246);
  --case-badge-secondary: rgb(29 78 216);
}

.p-cases .case-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 32px 56px rgb(15 23 42 / 32%);
}

body.light-mode.p-cases .case-card {
  box-shadow: 0 16px 32px rgb(15 23 42 / 14%);
}

.p-cases .case-card .card-surface {
  position: relative;
  border-radius: 26px;
  padding: 30px 32px 34px;
  background: linear-gradient(180deg, rgb(16 23 42 / 94%), rgb(10 17 34 / 92%));
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  border: 3px solid var(--case-border-color);
}

.p-cases .case-card .card-surface::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  background-size: 60px 60px;
  background-repeat: repeat;
  opacity: 0.14;
  pointer-events: none;
}

body.light-mode.p-cases .case-card .card-surface {
  background: #fff;
  color: #0f172a;
  border: 2px solid var(--case-border-color);
  box-shadow: 0 18px 34px rgb(148 163 184 / 18%), 0 0 0 1px rgb(255 255 255 / 92%) inset;
}

body.light-mode.p-cases .case-card .card-surface::before {
  opacity: 0.04;
}

.p-cases .case-card-header {
  /* Three columns keep the support button, title, and case number aligned on one row. */
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.p-cases .case-card .case-header-titles {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-self: center;
  text-align: center;
}

.p-cases .case-card .case-title {
  margin: 0;

  /* Slightly reduced per design feedback */
  font-size: 1.2rem;
  line-height: 1.3;
  max-width: 64ch;
  color: var(--case-title-color);
  font-weight: 800;
  word-break: break-word;
  overflow-wrap: break-word;
}

/*
 * Float verification badge to the top-right of the card.
 * Revert verification badge to footer placement; header uses the right column for the case number badge.
 * `.verification-indicator` stays inside `.case-footer-status` so the shared badge module remains consistent.
 */
.p-cases .case-card-header .case-number-badge { justify-self: end; }
/* Header meta stack holds ID badge and last-updated chip on the right */
.p-cases .case-card-header .case-header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-self: end;
  gap: 6px;
}

/* Top-left support action uses the same accent logic as the numeric badge. */
.p-cases .case-card .case-support-btn,
.p-collections .case-card .case-support-btn {
  appearance: none;
  border: none;
  padding: 0;
  margin: 0;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--case-badge-primary) 0%, var(--case-badge-secondary) 100%);
  color: var(--case-badge-text);
  box-shadow: 0 10px 18px rgb(15 23 42 / 28%);
  cursor: pointer;
}

.p-cases .case-card .case-support-btn:hover,
.p-collections .case-card .case-support-btn:hover {
  filter: brightness(1.05) saturate(1.05);
  box-shadow: 0 14px 22px rgb(15 23 42 / 34%);
}

.p-cases .case-card .case-support-btn:focus,
.p-collections .case-card .case-support-btn:focus {
  outline: 2px solid rgb(255 255 255 / 85%);
  outline-offset: 2px;
}

.p-cases .case-card .support-icon,
.p-collections .case-card .support-icon {
  width: 20px;
  height: 20px;
  display: block;
  fill: currentcolor;
}

/* Numeric case badge mirrors reference pill style for quick scanning. */
/* Both numeric badge (collections) and ID badge (cases) share styling */
.p-cases .case-card .case-number-badge,
.p-collections .case-card .case-number-badge,
.p-cases .case-card .case-id-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--case-badge-primary) 0%, var(--case-badge-secondary) 100%);
  color: var(--case-badge-text);
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  box-shadow: 0 12px 20px rgb(15 23 42 / 32%);
}

/* Updated chip pairs nicely with the badge without stealing focus */
.p-cases .case-card .case-updated-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgb(99 102 241 / 35%);
  background: linear-gradient(135deg, rgb(59 130 246 / 18%) 0%, rgb(14 165 233 / 14%) 100%);
  color: rgb(191 219 254);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

body.light-mode.p-cases .case-card .case-updated-chip {
  border-color: rgb(203 213 225);
  background: rgb(241 245 249);
  color: rgb(30 41 59);
}

/* Suggest modal + overlay (invoked from the support icon) */
.suggest-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 55%);
  /* stylelint-disable-next-line property-no-vendor-prefix */
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
}

.suggest-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(calc(100vw - 32px), 640px);
  border-radius: 16px;
  border: 1px solid rgb(108 123 178 / 35%);
  background: linear-gradient(180deg, rgb(16 23 42 / 98%), rgb(10 17 34 / 96%));
  color: #e2e8f0;
  box-shadow: 0 28px 64px rgb(7 14 35 / 52%), 0 0 0 1px rgb(99 120 188 / 22%);
  z-index: 1001;
  display: none;
}

.suggest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  border-bottom: 1px solid rgb(255 255 255 / 8%);
}

.suggest-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--qk-accent-orange);
}

.suggest-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--qk-accent-orange);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.suggest-body {
  padding: 16px 18px 18px;
}

.suggest-label {
  display: block;
  font-size: 0.9rem;
  margin: 0 0 8px;
  color: rgb(226 232 240);
}

#suggestText {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgb(148 163 184 / 45%);
  background: rgb(15 23 42 / 65%);
  color: #e2e8f0;
  padding: 12px 14px;
  resize: vertical;
}

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

.suggest-cancel {
  appearance: none;
  border: 1px solid rgb(148 163 184 / 45%);
  background: transparent;
  color: #e2e8f0;
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.suggest-submit {
  appearance: none;
  border: none;
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;

  /* Use the same accent gradient as case badges for brand continuity */
  background: linear-gradient(135deg, var(--case-badge-primary, rgb(59 130 246)) 0%, var(--case-badge-secondary, rgb(29 78 216)) 100%);
  color: var(--case-badge-text, #fff);
  box-shadow: 0 14px 24px rgb(15 23 42 / 28%);
}

.suggest-hint {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: rgb(226 232 240 / 90%);
}

.suggest-status {
  margin: 8px 0 0;
  font-size: 0.92rem;
  color: rgb(244 114 182);
}

/* Light mode adjustments */
body.light-mode .suggest-modal {
  background: #fff;
  color: #0f172a;
  border-color: rgb(226 232 240);
  box-shadow: 0 18px 34px rgb(148 163 184 / 28%);
}

body.light-mode .suggest-label {
  color: #334155;
}

body.light-mode #suggestText {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

body.light-mode .suggest-cancel {
  color: #0f172a;
  border-color: #cbd5e1;
}

body.light-mode .suggest-close {
  color: var(--qk-accent-orange);
}

/* Badge row mirrors tab spacing so both cases and collections stay centered with the Summary/Solution/Context controls. */
.p-cases .case-badges {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  padding: 4px;
}

/* Keep badges on a single row while letting content size each pill. */
.p-cases .case-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgb(255 255 255 / 12%);
  background: rgb(15 23 42 / 55%);
  color: #e2e8f0;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: none;
  flex: 0 0 auto;
  min-width: max-content;
}

.p-cases .case-badge-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.56rem;
  opacity: 0.82;
  white-space: nowrap;
  flex: 0 0 auto;
}

.p-cases .case-badge-value {
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: visible;
  text-overflow: initial;
  max-width: 100%;
  flex: 1 1 auto;
  text-align: center;
  line-height: 1.08;
  font-size: 0.68rem;
  color: var(--qk-accent-orange);
}

.p-cases .case-badge-domain {
  border-color: rgb(59 130 246 / 45%);
  background: rgb(59 130 246 / 18%);
  color: rgb(219 234 254);
}

.p-cases .case-badge-impact {
  border-color: rgb(249 115 22 / 48%);
  background: rgb(249 115 22 / 18%);
  color: rgb(255 237 213);
}

.p-cases .case-badge-skill {
  border-color: rgb(139 92 246 / 45%);
  background: rgb(139 92 246 / 16%);
  color: rgb(233 213 255);
}

/* Light theme keeps contrast by reapplying tinted fills instead of the dark glass. */
body.light-mode.p-cases .case-badge {
  background: rgb(241 245 249 / 70%);
  border-color: rgb(203 213 225 / 70%);
  color: rgb(51 65 85);
}

body.light-mode.p-cases .case-badge-value {
  color: inherit;
}

body.light-mode.p-cases .case-badge-domain {
  background: rgb(59 130 246 / 18%);
  border-color: rgb(59 130 246 / 45%);
  color: rgb(37 99 235);
}

body.light-mode.p-cases .case-badge-impact {
  background: rgb(249 115 22 / 18%);
  border-color: rgb(249 115 22 / 45%);
  color: rgb(194 65 12);
}

body.light-mode.p-cases .case-badge-skill {
  background: rgb(139 92 246 / 18%);
  border-color: rgb(139 92 246 / 40%);
  color: rgb(109 40 217);
}

.p-cases .case-divider {
  height: 1.5px;
  border-radius: 1px;
  background: var(--case-divider-color);
  margin-bottom: 22px;
  opacity: 0.9;
}

.p-cases .case-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}

/* Case content area adopts a shared scroll contract so tab panels can cap
 * their height without growing the outer card. Pages opt-in by supplying the
 * sizing variables while keeping catalogue defaults untouched. */
.p-cases .case-card .case-content {
  flex: 1 1 auto;
  min-height: 0;
  max-height: var(--case-content-max-block, none);
  max-block-size: var(--case-content-max-block, none);
  overflow-y: var(--case-content-overflow, visible);
  overflow-x: hidden;
  padding-right: var(--case-content-scroll-padding, 0);
  word-break: break-word;
  overflow-wrap: break-word;
}

/* WebKit scrollbar styling mirrors the title accent so condensed cards feel
 * native to the QueryKey catalogue in both marketing and app contexts. */
.p-cases .case-card .case-content::-webkit-scrollbar {
  width: var(--case-scrollbar-width, 8px);
}

.p-cases .case-card .case-content::-webkit-scrollbar-track {
  background: rgb(15 23 42 / 35%);
  background: var(--case-scrollbar-track, rgb(15 23 42 / 35%));
  border-radius: 999px;
}

.p-cases .case-card .case-content::-webkit-scrollbar-thumb {
  background: var(--case-scrollbar-thumb, var(--case-title-color));
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.p-cases .case-card .case-content::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--case-scrollbar-thumb, var(--case-title-color)) 85%, #fff 15%);
}

@supports (scrollbar-width: thin) {
  .p-cases .case-card .case-content {
    scrollbar-width: thin;
  }
}

@supports (scrollbar-color: #000 #fff) {
  .p-cases .case-card .case-content {
    scrollbar-color: var(--case-scrollbar-thumb, var(--case-title-color)) var(--case-scrollbar-track, rgb(15 23 42 / 35%));
  }
}

body.light-mode.p-cases .case-card .case-identifiers,
body.light-mode.p-cases .case-card .case-meta-inline {
  color: rgb(100 116 139);
}

/* Light-mode readability: force core body copy to pure black on white/soft surfaces */
body.light-mode.p-cases .case-card .case-content p,
body.light-mode.p-cases .case-card .case-content li,
body.light-mode.p-cases .case-card .case-content .muted {
  color: #000 !important;
}

/* Collections page uses the same case-card; enforce black for body copy as well */
body.light-mode.p-collections .case-card .case-content p,
body.light-mode.p-collections .case-card .case-content li,
body.light-mode.p-collections .case-card .case-content .muted {
  color: #000 !important;
}

/* Expandable sections styling moved below base metric selectors to satisfy no-descending-specificity */

/* Summary section now renders as a dedicated insight panel with accent rail */
.p-cases .case-card .case-summary {
  margin: 20px 0;
  padding: 20px 22px 20px 38px;
  position: relative;
  border-radius: 16px;
  background: linear-gradient(135deg, rgb(30 41 59 / 58%) 0%, rgb(15 23 42 / 46%) 100%);
  border: 1px solid rgb(148 163 184 / 28%);
  box-shadow: 0 18px 32px rgb(15 23 42 / 24%);
  color: rgb(226 232 240);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.p-cases .case-card .case-summary::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 18px;
  width: 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgb(59 130 246 / 95%) 0%, rgb(14 165 233 / 90%) 100%);
}

.p-cases .case-card .case-summary p {
  margin: 0;
  line-height: 1.7;
  color: inherit;
}

.p-cases .case-card .case-summary p + p {
  margin-top: 10px;
}

.p-cases .case-card .case-summary .derived-from-link {
  margin-top: 8px;
}

body.light-mode.p-cases .case-card .case-summary {
  background: linear-gradient(180deg, rgb(255 255 255 / 98%), rgb(241 245 249 / 94%));
  border: 1px solid rgb(148 163 184 / 34%);
  box-shadow: 0 16px 30px rgb(15 23 42 / 10%), inset 0 1px 0 rgb(255 255 255 / 94%);
  color: rgb(30 41 59);
}

body.light-mode.p-cases .case-card .case-summary::before {
  background: linear-gradient(180deg, rgb(37 99 235 / 92%) 0%, rgb(14 165 233 / 92%) 100%);
}

body.light-mode.p-cases .case-card .case-impact,
body.light-mode.p-cases .case-card .context-info {
  color: rgb(71 85 105);
}

body.light-mode.p-cases .case-card .case-impact p,
body.light-mode.p-cases .case-card .context-info p {
  color: inherit;
}

.p-cases .case-card .case-impact {
  margin: 20px 0;
  padding: 16px 0;
  border-top: 1px solid rgb(255 255 255 / 10%);
}

body.light-mode.p-cases .case-card .case-impact {
  border-top: 1px solid rgb(226 232 240);
}

.p-cases .case-card .case-impact p {
  margin-bottom: 12px;
}

/* Ensure generic context paragraphs precede more specific last-child in impact */
.p-cases .case-card .context-info p {
  margin-bottom: 8px;
  line-height: 1.5;
}

.p-cases .case-card .context-info p:last-child {
  margin-bottom: 0;
}

.p-cases .case-card .case-impact p:last-child {
  margin-bottom: 0;
}

/* Enhanced error signature in summary with better spacing */

.p-cases .case-card .error-label {
  font-size: 0.68rem;
  color: rgb(249 115 22);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin: 0;
}

.p-cases .case-card .error-signature code {
  background: none;
  padding: 0;
}

body.light-mode.p-cases .case-card .error-signature code {
  background: none;
  border: none;
  color: inherit;
  padding: 0;
}

body.light-mode.p-cases .case-card .error-signature {
  border-color: rgb(59 130 246 / 28%);
  border-left-color: rgb(249 115 22 / 90%);
  background: linear-gradient(135deg, rgb(255 247 237 / 92%) 0%, rgb(248 250 252 / 98%) 100%);
  box-shadow: 0 10px 22px rgb(148 163 184 / 16%), inset 0 1px 0 rgb(255 255 255 / 92%);
}

/* Simplified lineage styling (placed after error-signature code for ordering) */
.p-cases .case-card .expandable-section .lineage-content code {
  background: linear-gradient(135deg, rgb(255 255 255 / 8%) 0%, rgb(255 255 255 / 4%) 100%);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.75rem;
  color: #60a5fa;
  border: 1px solid rgb(255 255 255 / 15%);
}

/* Light-mode lineage code readability */

/* Light-mode: readable code text inside error/signature */

/* Keep base error-signature code before lineage content code and keep light-mode variant before lineage for ordering */
body.light-mode.p-cases .case-card .error-signature code {
  color: #0f172a;
}

body.light-mode.p-cases .case-card .expandable-section .lineage-content code {
  background: #f0f5ff;
  color: #0b3b8a;
  border-color: rgb(20 40 70 / 20%);
}

/* Expandable sections styling */
.p-cases .case-card .expandable-section {
  margin: 16px 0;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 8px;
  background: linear-gradient(135deg, rgb(255 255 255 / 3%) 0%, rgb(255 255 255 / 1%) 100%);
}

body.light-mode.p-cases .case-card .expandable-section {
  border: 1px solid rgb(226 232 240);
  background: rgb(248 250 252);
}

.p-cases .case-card .expandable-section summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--light-text);
  border-radius: 8px;
  transition: background-color 0.2s ease;
  /* stylelint-disable-next-line property-no-vendor-prefix */
  -webkit-user-select: none;
  user-select: none;
}

body.light-mode.p-cases .case-card .expandable-section summary {
  color: rgb(30 41 59);
}

.p-cases .case-card .expandable-section summary:hover {
  background: linear-gradient(135deg, rgb(255 255 255 / 8%) 0%, rgb(255 255 255 / 4%) 100%);
}

body.light-mode.p-cases .case-card .expandable-section summary:hover {
  background: rgb(226 232 240);
}

.p-cases .case-card .expandable-section[open] summary {
  border-bottom: 1px solid rgb(255 255 255 / 10%);
  border-radius: 8px 8px 0 0;
}

body.light-mode.p-cases .case-card .expandable-section[open] summary {
  border-bottom: 1px solid rgb(203 213 225);
}

.p-cases .case-card .expandable-section .metric-grid,
.p-cases .case-card .expandable-section .validation-content,
.p-cases .case-card .expandable-section .sources-list,
.p-cases .case-card .expandable-section .lineage-content {
  padding: 16px;
}

/* Simplified metric grid for expandable sections */
.p-cases .case-card .expandable-section .metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.p-cases .case-card .expandable-section .metric-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.p-cases .case-card .expandable-section .metric-label {
  font-size: 0.7rem;
  color: var(--muted-text);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.p-cases .case-card .expandable-section .metric-value {
  font-size: 0.85rem;
  color: var(--light-text);
  font-weight: 600;
}

body.light-mode.p-cases .case-card .expandable-section .metric-label {
  color: rgb(100 116 139);
}

body.light-mode.p-cases .case-card .expandable-section .metric-value {
  color: rgb(30 41 59);
}

/* Difficulty level badge */

/* Solution, validation, and rollback sections render as unified insight panels. */
.p-cases .case-card .remedy-steps,
.p-cases .case-card .validation-section,
.p-cases .case-card .rollback-section {
  margin: 18px 0;
  padding: 20px 24px 22px 36px;
  position: relative;
  border-radius: 18px;
  background: linear-gradient(135deg, rgb(30 41 59 / 60%) 0%, rgb(15 23 42 / 48%) 100%);
  border: 1px solid rgb(148 163 184 / 28%);
  box-shadow: 0 16px 30px rgb(15 23 42 / 22%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: rgb(226 232 240);
}

.p-cases .case-card .remedy-steps::before,
.p-cases .case-card .validation-section::before,
.p-cases .case-card .rollback-section::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 18px;
  width: 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgb(59 130 246 / 95%) 0%, rgb(14 165 233 / 90%) 100%);
}

.p-cases .case-card .remedy-steps h4,
.p-cases .case-card .validation-section h4,
.p-cases .case-card .rollback-section h4 {
  margin: 0;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgb(148 197 255);
  font-weight: 700;
}

.p-cases .case-card .validation-section p,
.p-cases .case-card .rollback-section p {
  margin: 0;
  line-height: 1.6;
  color: rgb(224 231 255);
}

.p-cases .case-card .remedy-steps ol {
  counter-reset: remedy-step;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.p-cases .case-card .remedy-steps li {
  counter-increment: remedy-step;
  position: relative;
  padding-left: 42px;
  line-height: 1.65;
  color: rgb(224 231 255);
}

.p-cases .case-card .remedy-steps li::before {
  content: counter(remedy-step);
  position: absolute;
  left: 0;
  top: 0.1rem;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgb(59 130 246 / 90%) 0%, rgb(14 165 233 / 85%) 100%);
  color: rgb(8 13 23);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  box-shadow: 0 6px 18px rgb(14 165 233 / 45%);
}

body.light-mode.p-cases .case-card .remedy-steps,
body.light-mode.p-cases .case-card .validation-section,
body.light-mode.p-cases .case-card .rollback-section {
  background: rgb(248 250 252);
  border: 1px solid rgb(226 232 240);
  box-shadow: 0 14px 28px rgb(148 163 184 / 18%);
  color: rgb(45 55 72);
}

body.light-mode.p-cases .case-card .remedy-steps::before,
body.light-mode.p-cases .case-card .validation-section::before,
body.light-mode.p-cases .case-card .rollback-section::before {
  background: linear-gradient(180deg, rgb(37 99 235 / 95%) 0%, rgb(56 189 248 / 90%) 100%);
}

body.light-mode.p-cases .case-card .remedy-steps h4,
body.light-mode.p-cases .case-card .validation-section h4,
body.light-mode.p-cases .case-card .rollback-section h4 {
  color: rgb(37 99 235);
}

body.light-mode.p-cases .case-card .validation-section p,
body.light-mode.p-cases .case-card .rollback-section p {
  color: rgb(55 65 81);
}

body.light-mode.p-cases .case-card .remedy-steps li {
  color: rgb(55 65 81);
}

body.light-mode.p-cases .case-card .remedy-steps li::before {
  background: linear-gradient(135deg, rgb(59 130 246) 0%, rgb(129 230 217) 100%);
  color: rgb(17 24 39);
  box-shadow: 0 6px 18px rgb(59 130 246 / 25%);
}

/* Context tab simplified styling */
.p-cases .case-card .context-info {
  margin-bottom: 16px;
}

/* Simplified sources styling for expandable sections */
.p-cases .case-card .expandable-section .sources-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.p-cases .case-card .expandable-section .source-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  background: linear-gradient(135deg, rgb(255 255 255 / 5%) 0%, rgb(255 255 255 / 2%) 100%);
  border-radius: 4px;
  border: 1px solid rgb(255 255 255 / 10%);
}

/* Move link styles after pagination to satisfy ordering rules */

.p-cases .case-card .expandable-section .source-date {
  font-size: 0.7rem;
  color: var(--muted-text);
  font-weight: 400;
}

/* Sources metadata remains part of card internals for both catalog and collections. */
.p-cases .case-card .sources-info {
  margin-top: 8px;
  padding: 8px;
  background: linear-gradient(135deg, rgb(255 255 255 / 5%) 0%, rgb(255 255 255 / 2%) 100%);
  border-radius: 6px;
  font-size: 0.8rem;
  border: 1px solid rgb(255 255 255 / 10%);
}

.p-cases .case-card .sources-info a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
}

.p-cases .case-card .expandable-section .source-item a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
}

.p-cases .case-card .expandable-section .source-item a:hover {
  color: #93c5fd;
  text-decoration: underline;
}

@media (width <= 640px) {
  .p-cases .case-card .card-surface {
    padding: 20px 18px 24px;
  }

  .p-cases .case-card {
    border-radius: 20px;
  }

  .p-cases .case-card .card-surface {
    border-radius: 18px;
  }

  .p-cases .case-card .case-title {
    font-size: 1.05rem;
  }

  .p-cases .case-card pre,
  .p-cases .case-card code {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
  }
}

/* Skinny screens: stack header, wrap badges, reduce padding */
@media (width <= 400px) {
  .p-cases .case-card .card-surface {
    padding: 16px 14px 20px;
  }

  .p-cases .case-card {
    border-radius: 16px;
  }

  .p-cases .case-card .card-surface {
    border-radius: 14px;
  }

  .p-cases .case-card-header {
    grid-template-columns: auto auto;
    grid-template-areas: "title title" "btn meta";
    justify-content: center;
    gap: 8px 10px;
    margin-bottom: 12px;
  }

  .p-cases .case-card .case-header-titles {
    grid-area: title;
    justify-self: center;
    text-align: center;
    width: 100%;
  }

  .p-cases .case-card .case-title {
    font-size: 0.98rem;
    max-width: 100%;
  }

  .p-cases .case-card .case-support-btn {
    grid-area: btn;
    justify-self: end;
    align-self: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
  }

  .p-cases .case-card .case-support-btn .support-icon {
    width: 16px;
    height: 16px;
  }

  .p-cases .case-card-header .case-header-meta {
    grid-area: meta;
    flex-direction: row;
    align-items: center;
    justify-self: start;
    gap: 6px;
  }

  .p-cases .case-card-header .case-number-badge,
  .p-cases .case-card-header .case-id-badge {
    padding: 4px 10px;
    font-size: 0.8rem;
    min-width: auto;
  }

  .p-cases .case-badges {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
  }

  .p-cases .case-badge {
    padding: 4px 8px;
    font-size: 0.62rem;
  }

  .p-cases .case-badge-label {
    font-size: 0.52rem;
  }

  .p-cases .case-badge-value {
    font-size: 0.64rem;
  }

  .p-cases .case-divider {
    margin-bottom: 16px;
  }

  .p-cases .case-card .case-summary {
    margin: 14px 0;
    padding: 16px 16px 16px 30px;
  }

  .p-cases .case-card .case-summary::before {
    top: 14px;
    bottom: 14px;
    left: 14px;
  }

  .p-cases .case-card .case-content {
    padding-right: 4px;
  }

  .p-cases .case-card .case-updated-chip {
    font-size: 0.7rem;
    padding: 3px 9px;
  }
}
