/* Bio2Twin Personal Model + AGP shared visual bridge, 2026-11-05.
   DESIGN.md section 26-31; member graphite v5 is the authoritative palette.
   Scope: only pages opting into .b2t-pm-agp-v3. No clinical data or chart rewrites. */

body.bt-member-graphite.b2t-pm-agp-v3 {
  --b2t-pm-bg: var(--ds-canvas, #0b0c0c);
  --b2t-pm-card: var(--ds-elevated, #171919);
  --b2t-pm-inset: var(--ds-soft, #101111);
  --b2t-pm-line: rgba(255, 255, 255, .10);
  --b2t-pm-text: var(--ds-ink, #f2f3f1);
  --b2t-pm-muted: var(--ds-body, #b8bdb9);
  --b2t-pm-focus: var(--ds-accent, #e2e5e3);
  background: var(--b2t-pm-bg) !important;
  background-image: none !important;
  color: var(--b2t-pm-text);
  font-family: var(--bt-font-sans, "Inter", "Noto Sans TC", "Noto Sans JP", "PingFang TC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  -webkit-font-smoothing: antialiased;
}

/* The site's shared navigation stays owned by b2t-newsite-topbar.css. */
body.b2t-pm-agp-v3 :is(a, button, select, input, [role="tab"]):focus-visible {
  outline: 2px solid var(--b2t-pm-focus);
  outline-offset: 3px;
}

/* Overview: design.md strictly monochrome, with no alteration to measured plots. */
body.b2t-pm-agp-v3[data-page="overview"] .pmhome3-card {
  background: var(--b2t-pm-card) !important;
  background-image: none !important;
  border: 1px solid var(--b2t-pm-line) !important;
  box-shadow: none !important;
  border-radius: 14px;
}
body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"] .pmhome3-metric {
  background: var(--b2t-pm-inset) !important;
  background-image: none !important;
  border: 1px solid var(--b2t-pm-line) !important;
  box-shadow: none !important;
  border-radius: 10px;
}
body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"] .pmhome3-dot {
  background: #c0c6c3 !important;
  box-shadow: 0 0 0 3px rgba(192,198,195,.1) !important;
}
body.b2t-pm-agp-v3[data-page="overview"] .pmhome3-trend-grid {
  background: transparent !important;
  gap: 10px;
}
body.b2t-pm-agp-v3[data-page="overview"] .pmhome3-trend-item {
  background: var(--b2t-pm-inset) !important;
  border: 1px solid var(--b2t-pm-line) !important;
  border-radius: 10px;
}
body.b2t-pm-agp-v3[data-page="overview"] :is(.pmhome3-meta, .pmhome3-data-note, .pmhome3-delta, .pmhome3-metric-name) {
  color: var(--b2t-pm-muted);
}
body.b2t-pm-agp-v3[data-page="overview"] .pmhome3-title { color: var(--b2t-pm-text); }

/* AGP: map the page-local visual variables to the SAME member tokens.
   Intentionally do NOT override --blue, --purple, --amber, plot strokes,
   clinical bands, inline SVGs, or provenance / evidence labels. */
body.b2t-agp-v3.b2t-pm-agp-v3 {
  --bg: var(--b2t-pm-bg);
  --surface: var(--b2t-pm-card);
  --s2: var(--b2t-pm-inset);
  --border: #303333;
  --ink: var(--b2t-pm-text);
  --muted: var(--b2t-pm-muted);
  line-height: 1.55;
}
body.b2t-agp-v3 .wrap {
  max-width: 1400px;
  padding: clamp(14px, 2.2vw, 26px);
  box-sizing: border-box;
}
body.b2t-agp-v3 .wrap > h1 {
  color: var(--b2t-pm-text);
  font-weight: 500;
  letter-spacing: -.022em;
  line-height: 1.22;
}
body.b2t-agp-v3 :is(.panel, .metric) {
  background: var(--b2t-pm-card);
  border: 1px solid var(--b2t-pm-line);
  border-radius: 14px;
  box-shadow: none;
}
body.b2t-agp-v3 .panel > header {
  background: var(--b2t-pm-inset);
  border-bottom: 1px solid var(--b2t-pm-line);
  border-radius: 13px 13px 0 0;
}
body.b2t-agp-v3 .panel > header h2 { color: var(--b2t-pm-text); }
body.b2t-agp-v3 .metric .tiny { color: var(--b2t-pm-muted); }
body.b2t-agp-v3 .metric .value { color: var(--b2t-pm-text); font-variant-numeric: tabular-nums; }
body.b2t-agp-v3 .badge {
  color: var(--b2t-pm-muted);
  background: var(--b2t-pm-inset);
  border: 1px solid var(--b2t-pm-line);
  border-radius: 999px;
}
body.b2t-agp-v3 .controls :is(button, select, a),
body.b2t-agp-v3 .tabs button,
body.b2t-agp-v3 #agpModeObserved,
body.b2t-agp-v3 #agpModePersonal,
body.b2t-agp-v3 #agpModeModel {
  min-height: 38px;
  box-sizing: border-box;
  background: var(--b2t-pm-inset);
  color: var(--b2t-pm-text);
  border: 1px solid var(--b2t-pm-line);
  border-radius: 9px;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
}
body.b2t-agp-v3 .controls a { display: inline-flex; align-items: center; text-decoration: none; }
/* Legacy link has inline blue chrome; normalize it with the shared controls. */
body.b2t-agp-v3 .controls a[href^="/personal-model/"] {
  color: var(--b2t-pm-text) !important;
  border: 1px solid var(--b2t-pm-line) !important;
  border-radius: 9px !important;
}
body.b2t-agp-v3 .controls :is(button, select, a):hover,
body.b2t-agp-v3 .tabs button:hover { border-color: rgba(226,229,227,.38); }
body.b2t-agp-v3 .tabs button[aria-selected="true"],
body.b2t-agp-v3 :is(#agpModeObserved, #agpModePersonal, #agpModeModel)[aria-pressed="true"] {
  color: #f2f3f1;
  background: #202323;
  border-color: rgba(226,229,227,.55);
}
/* Retain explicit textual distinction among the 3 scientific source types. */
body.b2t-agp-v3 #agpModeObserved { border-left: 3px solid #c0c6c3; }
body.b2t-agp-v3 #agpModePersonal { border-left: 3px solid #76b6f5; }
body.b2t-agp-v3 #agpModeModel { border-left: 3px solid #d4a95f; }
body.b2t-agp-v3 .warn {
  background: #1e1c19;
  border: 1px solid rgba(212,169,95,.32);
  border-radius: 10px;
  color: #d4c9b9;
}
body.b2t-agp-v3 .b2t-data-rule span {
  background: var(--b2t-pm-inset);
  border: 1px solid var(--b2t-pm-line);
  border-radius: 10px;
  color: var(--b2t-pm-muted);
}
body.b2t-agp-v3 .b2t-data-rule span:nth-child(1) { border-left: 3px solid #c0c6c3; }
body.b2t-agp-v3 .b2t-data-rule span:nth-child(2) { border-left: 3px solid #76b6f5; }
body.b2t-agp-v3 .b2t-data-rule span:nth-child(3) { border-left: 3px solid #d4a95f; }
body.b2t-agp-v3 .b2t-data-rule b { color: var(--b2t-pm-text); }
body.b2t-agp-v3 .agp-model90-wrap {
  background: var(--b2t-pm-card);
  border-color: var(--b2t-pm-line);
  border-radius: 12px;
}
body.b2t-agp-v3 .agp-model90-info { color: var(--b2t-pm-muted); }
body.b2t-agp-v3 .agp-model90-info a { color: #9ecbff; }

@media (max-width: 700px) {
  body.b2t-agp-v3 .wrap { padding: 14px 12px 28px; max-width: 100%; }
  body.b2t-agp-v3 :is(.controls button, .controls select, .controls a, .tabs button, #agpModeObserved, #agpModePersonal, #agpModeModel) {
    min-height: 44px;
  }
  body.b2t-agp-v3 .panel { border-radius: 12px; }
  body.b2t-agp-v3 .wrap > h1 { font-size: clamp(22px, 6vw, 30px); }
}

/* 2026-11-07: Restore breathing room to the Personal Model overview.
   Specifically fix the solid #303333 plate exposed by the incomplete
   final row of the Reality metric grid; do not touch its numeric data. */
body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
  .pmhome3-card:not(.pm-biomni-flow) {
  padding: 24px 26px !important;
}
body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
  .pmhome3-card:not(.pm-biomni-flow) > .pmhome3-head {
  padding-bottom: 16px;
  margin-bottom: 18px;
}
body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
  .pmhome3-card > .pmhome3-data-note {
  margin: 0 0 20px;
  line-height: 1.7;
}
body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
  #pmhome3Metrics.pmhome3-metrics {
  background: transparent !important;
  background-image: none !important;
  gap: 18px !important;
  padding: 0 !important;
  margin-top: 18px;
}
body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
  #pmhome3Metrics .pmhome3-metric {
  padding: 20px 22px !important;
  min-height: 132px;
  box-sizing: border-box;
  border-radius: 12px;
}
body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
  .pm-today-actions {
  gap: 12px 22px;
  margin-top: 24px;
}
body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
  .pm-today-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}

@media (max-width: 700px) {
  body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
    .pmhome3-card:not(.pm-biomni-flow) {
    padding: 18px 16px !important;
  }
  body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
    #pmhome3Metrics.pmhome3-metrics {
    gap: 12px !important;
    margin-top: 16px;
  }
  body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
    #pmhome3Metrics .pmhome3-metric {
    padding: 18px 15px !important;
    min-height: 126px;
  }
  body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
    .pm-today-actions a { min-height: 44px; }
}

/* 2026-11-07 responsive audit: the legacy sidebar switched at 900px
   while the shared public topbar switches at 1100px. The 901–1100px
   interval squeezed the model to the right; keep one tablet breakpoint. */
@media (max-width: 1100px) {
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2 .pmv2-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    height: calc(100dvh - 64px);
    min-height: 0;
    max-height: calc(100dvh - 64px);
    width: 240px;
    transform: translateX(-100%);
    visibility: hidden;
    z-index: 100;
  }
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2.is-drawer-open .pmv2-sidebar {
    transform: translateX(0);
    visibility: visible;
  }
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2.is-drawer-open .pmv2-backdrop {
    display: block;
  }
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2 .pmv2-main-col {
    width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
    min-width: 0;
  }
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2 .pmv2-unified-topbar .pmv2-menu {
    display: block;
    flex-shrink: 0;
    border-radius: 8px;
  }
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2 .pmv2-content {
    width: 100%;
    max-width: 1140px;
    min-width: 0;
    box-sizing: border-box;
  }
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2 .pmv2-workspace {
    min-width: 0;
    box-sizing: border-box;
  }
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2 .pmhome3-card,
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2 .pmhome3-section {
    min-width: 0;
    box-sizing: border-box;
  }
}

/* Small screens: keep the navigation operable and each action visibly
   tappable. Never hide scientific values or replace missing records. */
@media (max-width: 700px) {
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2 .pmv2-unified-topbar {
    min-width: 0;
    max-width: 100%;
    padding-inline: 12px;
    gap: 10px;
  }
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2 .b2t-member-nav {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  body.bt-member-graphite.b2t-pm-agp-v3.pmv2 .b2t-member-nav::-webkit-scrollbar {
    display: none;
  }
  body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"] .pm-today-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 20px;
  }
  body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"] .pm-today-actions :is(a, button) {
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    min-height: 44px;
    padding: 10px 7px;
    border: 1px solid var(--b2t-pm-line);
    border-radius: 9px;
    background: var(--b2t-pm-inset);
    color: var(--b2t-pm-text);
    text-align: center;
    text-decoration: none;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
    box-sizing: border-box;
  }
  body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
    #pmhome3Metrics .pmhome3-metric {
    min-width: 0;
  }
  body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
    #pmhome3Metrics .pmhome3-metric-value {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0 4px;
    overflow-wrap: anywhere;
    line-height: 1.25;
  }
  body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
    #pmhome3Metrics :is(.pmhome3-metric-name, .pmhome3-metric-note) {
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 360px) {
  body.bt-member-graphite.b2t-pm-agp-v3[data-page="overview"]
    #pmhome3Metrics .pmhome3-metric {
    padding: 15px 12px !important;
  }
}
