/* Shared information hierarchy. Theme tokens keep all eight palettes intact. */
@layer mv-readability {
  :root { --mv-section-gap: clamp(16px, 1.8vw, 26px); }
  /* Managed pages stamp an old body-level theme; inherit the selected pack. */
  :root[data-mv-pack] body {
    color-scheme: inherit !important;
    --mv-bg: inherit !important;
    --mv-panel: var(--mv-surface) !important;
    --mv-panel-2: var(--mv-surface-2) !important;
    --mv-text: inherit !important;
    --mv-muted: inherit !important;
  }
  /* Legal documents use the same readable surfaces without changing their text. */
  .mv-legal { --legal-muted: var(--mv-muted) !important; }
  .mv-legal strong { color: var(--mv-text) !important; }
  .mv-legal__toolbar-copy span { color: var(--mv-muted) !important; }
  .mv-legal__meta span, .mv-legal__switcher, .mv-legal__toolbar-hint {
    background: var(--mv-surface-2) !important;
    border-color: var(--mv-border) !important;
    color: var(--mv-muted) !important;
    box-shadow: none !important;
  }
  .mv-legal__switcher a { color: var(--mv-primary) !important; }
  .mv-legal__switcher a[aria-current=page] {
    background: var(--mv-action-bg) !important;
    color: var(--mv-action-text) !important;
    box-shadow: none !important;
  }
  .mv-legal__section > summary h2::before {
    background: var(--mv-surface-2) !important;
    color: var(--mv-primary) !important;
    border-color: var(--mv-border) !important;
    box-shadow: none !important;
  }
  .mv-legal__section[open] > summary h2::before {
    background: var(--mv-action-bg) !important;
    color: var(--mv-action-text) !important;
  }
  .mv-legal__section > summary h2::after {
    background: linear-gradient(var(--mv-text),var(--mv-text)) center/12px 2px no-repeat,
      linear-gradient(var(--mv-text),var(--mv-text)) center/2px 12px no-repeat, var(--mv-surface-2) !important;
    border-color: var(--mv-border) !important;
  }
  .mv-legal__section[open] > summary h2::after {
    background: linear-gradient(var(--mv-text),var(--mv-text)) center/12px 2px no-repeat, var(--mv-surface-2) !important;
  }
  .mv-legal-notice { background: var(--mv-warning-bg) !important; border-color: var(--mv-amber) !important; color: var(--mv-amber) !important; }
  .mv-legal-notice :is(strong,p) { color: var(--mv-amber) !important; }
  .mv-legal-notice::before { background: var(--mv-warning-bg) !important; color: var(--mv-amber) !important; }
  :where(.mv-content, .mv-pro-content) { padding: clamp(16px, 2vw, 32px) !important; min-width: 0; }
  :where(.mv-pro-grid, .mv312-grid, .mv246-grid, .mv-prefs-grid, .mv-pro-stack) { gap: var(--mv-section-gap) !important; align-items: start !important; }
  :where(.mv-content, .mv-pro-content) > :is(section, article) + :is(section, article) { margin-top: var(--mv-section-gap) !important; }
  :where(.mv-panel, .mv-pro-panel, .mv312-card, .mv246-card, .mv-prefs-panel) { padding: clamp(16px, 1.8vw, 24px) !important; min-width: 0; border-radius: 12px !important; }
  :where(.mv-pro-hero, .mv312-hero, .mv246-hero, .mv-prefs-hero) { padding: clamp(20px, 2vw, 30px) !important; gap: 20px !important; align-items: start !important; border-radius: 12px !important; }
  :where(.mv-pro-hero, .mv312-hero, .mv246-hero, .mv-prefs-hero) :is(h1,h2) { margin: 0 0 10px !important; }
  :where(.mv-pro-hero, .mv312-hero, .mv246-hero, .mv-prefs-hero) p { max-width: 75ch; line-height: 1.6 !important; }
  :where(.mv-panel-head, .mv312-panel-head, .mv246-panel-head) { gap: 16px !important; margin-bottom: 20px !important; align-items: start !important; }
  :where(.mv-panel-head, .mv312-panel-head, .mv246-panel-head) :is(h2,h3,p) { margin-top: 0; }
  :where(.mv-pro-actions, .mv312-actions, .mv246-actions) { flex-wrap: wrap; gap: 10px !important; }
  :where(.mv312-form-grid, .mv-form-grid) { gap: 16px !important; align-items: start !important; }
  :where(.mv312-form-grid, .mv-form-grid) > label { min-width: 0; gap: 6px; }
  :where(.mv312-form-grid, .mv-form-grid) label > span { color: var(--mv-muted) !important; font-size: .875rem !important; font-weight: 500 !important; text-transform: none !important; letter-spacing: 0 !important; }
  .mv312-table th, .mv-table th { color: var(--mv-muted) !important; font-weight: 600 !important; text-transform: none !important; letter-spacing: 0 !important; }
  .mv312-table .mv396-sort-head { color: var(--mv-primary) !important; text-transform: none !important; letter-spacing: 0 !important; }
  .mv317-user-cell small, .mv317-updated small, .mv317-user-contact small { text-transform: none !important; letter-spacing: 0 !important; line-height: 1.5 !important; }
  .mv-form-section { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
  .mv-form-section > legend { width: 100%; padding: 0 0 10px; margin-bottom: 14px; border-bottom: 1px solid var(--mv-border); color: var(--mv-text) !important; font-size: 1rem !important; font-weight: 650 !important; text-transform: none !important; letter-spacing: 0 !important; }
  .mv-form-section > .mv459-admin-password-tools { margin-top: 12px; }
  .mv-form-section .mv312-form-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .mv-admin-profile-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
  .mv-admin-controls-disclosure { margin-top: 22px; border-top: 1px solid var(--mv-border); padding-top: 16px; }
  .mv-admin-controls-disclosure > summary { color: var(--mv-text) !important; cursor: pointer; font-weight: 650 !important; padding: 8px 0; }
  .mv-admin-controls-disclosure > summary span { display: block; font-size: .8125rem !important; font-weight: 400 !important; color: var(--mv-muted) !important; margin: 4px 0 12px; }
  .mv-admin-controls-disclosure .mv361-admin-controls { margin: 0 !important; }

  /* A small, optional index for longer content pages; native anchors and details. */
  .mv-page-index { grid-column: 1 / -1; margin: 16px 0 var(--mv-section-gap); border: 1px solid var(--mv-border); border-radius: 10px; background: var(--mv-surface) !important; color: var(--mv-text) !important; padding: 0 16px; }
  .mv-page-index[hidden] { display: none !important; }
  .mv-page-index > summary { cursor: pointer; padding: 13px 0; color: var(--mv-text) !important; font-size: .875rem !important; font-weight: 600 !important; }
  .mv-page-index > summary span { margin-left: 10px; color: var(--mv-muted) !important; font-size: .8125rem !important; font-weight: 400 !important; }
  .mv-page-index nav { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 16px; }
  .mv-page-index nav a { display: block; padding: 8px 12px; border: 1px solid var(--mv-border); border-radius: 6px; background: var(--mv-surface-2) !important; color: var(--mv-primary) !important; text-decoration: none; font-size: .875rem !important; line-height: 1.4 !important; }
  .mv-page-index nav a:hover { border-color: var(--mv-primary); text-decoration: underline; }
  [data-mv-section-anchor] { scroll-margin-top: 100px; }

  /* Read-only profile: independently stacked columns, no duplicated overview data. */
  .mv480-user-profile-view { padding: 0 !important; border: 0 !important; background: transparent !important; gap: 16px !important; }
  .mv480-profile-grid { display: block !important; }
  .mv-profile { container-type: inline-size; display: grid; gap: 20px; min-width: 0; color: var(--mv-text) !important; }
  .mv-profile, .mv-profile * { box-sizing: border-box; text-transform: none !important; letter-spacing: normal !important; }
  .mv-profile-summary, .mv-profile-card { background: var(--mv-surface) !important; border: 1px solid var(--mv-border) !important; border-radius: 12px !important; padding: 22px !important; min-width: 0; }
  .mv-profile-summary { display: flex !important; align-items: center !important; gap: 20px !important; flex-wrap: wrap; }
  .mv-profile-avatar { display: grid; place-items: center; flex: 0 0 72px; width: 72px; height: 72px; border-radius: 50%; overflow: hidden; background: var(--mv-info-bg) !important; color: var(--mv-blue) !important; font-size: 1.625rem !important; font-weight: 650 !important; }
  .mv-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
  .mv-profile-identity { flex: 1 1 220px; min-width: 0; }
  .mv-profile-identity h2 { margin: 0 0 6px !important; font-size: clamp(1.5rem, 2.5cqi, 2rem) !important; overflow-wrap: anywhere; }
  .mv-profile-identity p { margin: 0 0 12px !important; color: var(--mv-muted) !important; font-size: .9375rem !important; overflow-wrap: anywhere; }
  .mv-profile-summary-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; align-self: start; }
  .mv-profile-badges { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
  .mv-profile-badge { display: inline-flex; align-items: center; padding: 4px 9px; border: 1px solid var(--mv-border); border-radius: 6px; background: var(--mv-surface-2) !important; color: var(--mv-text) !important; font-size: .8125rem !important; line-height: 1.5 !important; font-weight: 600 !important; }
  .mv-profile-badge.is-good { background: var(--mv-positive-bg) !important; color: var(--mv-green) !important; border-color: var(--mv-green); }
  .mv-profile-badge.is-warn { background: var(--mv-warning-bg) !important; color: var(--mv-amber) !important; border-color: var(--mv-amber); }
  .mv-profile-columns { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,1fr); gap: 20px; align-items: start; }
  .mv-profile-stack { display: grid; gap: 20px; min-width: 0; align-content: start; }
  .mv-profile-card h3 { margin: 0 0 18px !important; font-size: 1.1875rem !important; color: var(--mv-text) !important; }
  .mv-profile-facts { margin: 0; display: grid; }
  .mv-profile-row { display: grid; grid-template-columns: minmax(130px,.85fr) minmax(0,1.15fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--mv-border); align-items: start; }
  .mv-profile-row:last-child { border-bottom: 0; }
  .mv-profile-row dt, .mv-profile-row dd { margin: 0 !important; font-size: .9375rem !important; font-weight: 400 !important; line-height: 1.55 !important; min-width: 0; overflow-wrap: anywhere; }
  .mv-profile-row dt { color: var(--mv-muted) !important; }
  .mv-profile-row dd { color: var(--mv-text) !important; font-variant-numeric: tabular-nums; }
  .mv-profile-card > .mv-profile-badges { margin: 0 0 8px; }
  .mv-profile-notes { margin: 0 !important; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--mv-text) !important; font-size: .9375rem !important; line-height: 1.6 !important; }
  .mv-profile-timeline { list-style: none; padding: 0 0 0 8px; margin: 0; }
  .mv-profile-timeline li { position: relative; display: grid; gap: 5px; padding: 0 0 22px 22px; margin: 0; border-left: 1px solid var(--mv-border-strong); }
  .mv-profile-timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
  .mv-profile-timeline li::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--mv-primary); position: absolute; left: -5px; top: 6px; }
  .mv-profile-timeline strong { color: var(--mv-text) !important; font-size: .9375rem !important; }
  .mv-profile-timeline span { color: var(--mv-muted) !important; font-size: .875rem !important; line-height: 1.5 !important; }
  .mv-profile-details { border: 1px solid var(--mv-border); border-radius: 8px; margin-top: 10px; overflow: hidden; background: var(--mv-surface-2) !important; }
  .mv-profile-details > summary { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) 12px; align-items: center; gap: 14px; cursor: pointer; list-style: none; padding: 14px; color: var(--mv-text) !important; }
  .mv-profile-details > summary::-webkit-details-marker { display: none; }
  .mv-profile-details > summary::after { content: '›'; justify-self: end; font-size: 1.375rem; line-height: 1; }
  .mv-profile-details[open] > summary::after { transform: rotate(90deg); }
  .mv-profile-details > summary strong { color: var(--mv-text) !important; font-size: .875rem !important; }
  .mv-profile-details > summary span { color: var(--mv-muted) !important; font-size: .8125rem !important; line-height: 1.45 !important; }
  .mv-profile-details-body { padding: 0 16px 10px; border-top: 1px solid var(--mv-border); }
  .mv-profile-details-body .mv-profile-row { grid-template-columns: minmax(140px,.6fr) minmax(0,1.4fr); }
  @container (max-width: 800px) {
    .mv-profile-columns { grid-template-columns: minmax(0,1fr); }
    .mv-profile-summary, .mv-profile-card { padding: 18px !important; }
  }
  @container (max-width: 430px) {
    .mv-profile-summary { gap: 14px !important; }
    .mv-profile-avatar { width: 52px; height: 52px; flex-basis: 52px; font-size: 1.25rem !important; }
    .mv-profile-summary-actions { width: 100%; }
    .mv-profile-row, .mv-profile-details-body .mv-profile-row { grid-template-columns: minmax(0,1fr); gap: 3px; padding: 10px 0; }
    .mv-profile-row dt { font-size: .8125rem !important; }
    .mv-profile-details > summary { grid-template-columns: minmax(0,1fr) 12px; gap: 4px 10px; }
    .mv-profile-details > summary span { grid-column: 1; }
    .mv-profile-details > summary::after { grid-column: 2; grid-row: 1 / 3; }
  }
  @media (max-width: 600px) {
    .mv-form-section .mv312-form-grid { grid-template-columns: minmax(0,1fr) !important; }
    .mv-panel-head, .mv312-panel-head { flex-wrap: wrap; }
  }
  @media print {
    .mv-page-index { display: none !important; }
    .mv-profile-columns { grid-template-columns: 1fr; }
    .mv-profile-card { break-inside: avoid; }
  }
}
