/* Bio: iPhone-inspired navigation, pinned measurements and detail sheets.
   The four measurement colors continue to come from each metric's own token. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --sheet-surface: #152135;
  --group-surface: #1b2a40;
  --inset-separator: #304057;
}

body { -webkit-font-smoothing: antialiased; }
body:has(dialog[open]) { overflow: hidden; }
.diary-prompt { margin-bottom: 24px; }
.page-heading h1 { font-size: 36px; font-weight: 730; letter-spacing: -1.25px; }
.page-heading p { line-height: 1.55; }
.card-head h2, .section-heading h2 { font-weight: 680; letter-spacing: -.45px; }
.card-head > .badge { white-space: nowrap; }
.btn { min-height: 44px; border-radius: 12px; }
.icon-btn { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; }
.text-btn { min-height: 44px; }
.segmented { border-radius: 11px; }
.segmented button { border-radius: 8px; }

/* Favorites are a personal, glanceable summary, with editing at section level. */
.pinned-section { margin: 26px 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2 { font-size: 22px; }
.section-heading .text-btn { font-size: 13px; flex-shrink: 0; }
.pinned-section .metrics { margin-bottom: 0; }
.pinned-section .metric-card { border-radius: 20px; border-color: transparent; }
.pinned-section .metric-card:hover { border-color: color-mix(in srgb, var(--metric) 45%, transparent); }
.pinned-section .metric-head { color: var(--metric); font-weight: 650; }
.pinned-section .metric-value { font-weight: 650; font-variant-numeric: tabular-nums; }
.pinned-section .metric-foot { font-size: 11px; }
.pinned-section .empty { padding: 26px 18px; background: var(--panel); border-radius: 20px; }

/* Each checkpoint is one large, unambiguous navigation target. */
.checkpoint-path { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.checkpoint-stop { min-width: 0; min-height: 112px; display: flex; align-items: flex-start; gap: 12px; padding: 17px 14px; border: 1px solid var(--line); border-radius: 16px; background: #162338; text-align: left; transition: background .16s, border-color .16s; }
.checkpoint-stop:hover { background: #1b2d47; border-color: #5373a1; }
.checkpoint-stop:active { background: #233a59; }
.checkpoint-symbol { width: 34px; height: 34px; display: grid; place-items: center; flex-shrink: 0; border-radius: 50%; border: 1px solid #4c73a7; background: #233c60; color: #b9d7ff; font-size: 14px; font-weight: 700; }
.checkpoint-symbol .icon { width: 17px; height: 17px; }
.checkpoint-stop[data-id="current"] .checkpoint-symbol { background: #528fed; color: #fff; border-color: #75aaff; }
.checkpoint-stop[data-id="b"] .checkpoint-symbol { background: transparent; border-style: dashed; }
.checkpoint-copy { display: block; min-width: 0; flex: 1; }
.checkpoint-copy strong { display: block; font-size: 14px; line-height: 1.35; font-weight: 650; padding-top: 1px; }
.checkpoint-copy small { display: block; font-size: 12px; line-height: 1.5; color: var(--muted); margin-top: 6px; }
.checkpoint-stop > .icon { width: 15px; height: 15px; flex-shrink: 0; margin-top: 9px; color: #879fbe; }
button.goal-node { min-width: 0; min-height: 87px; text-align: left; background: transparent; padding: 7px 2px; border-radius: 9px; }
button.goal-node:hover { background: #20334d; }
button.goal-node:active { background: #294467; }
button.goal-node .small { display: inline-flex; align-items: center; gap: 3px; }
button.goal-node .small:after { content: '›'; font-size: 16px; line-height: 10px; color: #97bae8; }

/* Keep the three new navigation sheets isolated from diary form behavior. */
dialog:is(.checkpoint-sheet, .metric-sheet, .pin-sheet) {
  width: min(600px, calc(100% - 40px));
  max-height: min(860px, calc(100dvh - 60px));
  background: var(--sheet-surface);
  border: 1px solid #34475f;
  border-radius: 26px;
  overflow: hidden;
}
dialog:is(.checkpoint-sheet, .metric-sheet, .pin-sheet)[open] { display: flex; flex-direction: column; }
.sheet-grabber { display: none; }
:is(.checkpoint-sheet, .metric-sheet, .pin-sheet) > .modal-header { flex-shrink: 0; padding: 24px; align-items: center; background: var(--sheet-surface); border-bottom-color: var(--inset-separator); }
:is(.checkpoint-sheet, .metric-sheet, .pin-sheet) .modal-header h2 { font-size: 25px; font-weight: 700; letter-spacing: -.65px; }
:is(.checkpoint-sheet, .metric-sheet, .pin-sheet) .modal-header p { font-size: 13px; }
:is(.checkpoint-sheet, .metric-sheet, .pin-sheet) .modal-header .icon-btn { background: #2b3a50; color: #cad8eb; }
:is(.checkpoint-sheet, .metric-sheet, .pin-sheet) .modal-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 24px; background: var(--sheet-surface); }
:is(.checkpoint-sheet, .metric-sheet, .pin-sheet) .modal-footer { flex-shrink: 0; background: var(--sheet-surface); border-top-color: var(--inset-separator); padding: 17px 24px; }
.pin-sheet > #pin-form { display: flex; flex-direction: column; min-height: 0; }
:is(.checkpoint-sheet, .metric-sheet, .pin-sheet) .modal-footer > .btn { flex-shrink: 0; }
.sheet-back { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; padding: 0 0 5px; margin: -9px 0 8px; background: transparent; color: var(--link); font-size: 14px; }
.sheet-back .icon { width: 17px; height: 17px; }
.modal-header .sheet-back { margin: 0; padding: 0; flex-shrink: 0; }

.checkpoint-overview { margin-bottom: 20px; }
.checkpoint-tag { display: inline-flex; align-items: center; gap: 7px; color: #a7cbff; font-size: 13px; font-weight: 600; }
.checkpoint-tag .icon { width: 17px; height: 17px; }
.checkpoint-overview h3 { margin-top: 8px; color: var(--text); font-size: 25px; font-weight: 700; line-height: 1.2; letter-spacing: -.7px; }
.checkpoint-overview .checkpoint-date { display: block; margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.checkpoint-overview p { margin-top: 9px; color: var(--muted); font-size: 13px; line-height: 1.55; max-width: 48ch; }
.measurement-list { border-radius: 18px; overflow: hidden; background: var(--group-surface); margin-bottom: 20px; }
.measurement-row { display: flex; align-items: center; width: 100%; min-height: 78px; gap: 12px; padding: 15px 16px; background: transparent; text-align: left; position: relative; }
.measurement-row + .measurement-row:before { position: absolute; content: ''; top: 0; right: 0; left: 62px; height: 1px; background: var(--inset-separator); }
.measurement-row:hover, .measurement-row:active { background: #253752; }
.measurement-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; color: var(--metric, var(--accent)); background: color-mix(in srgb, var(--metric, var(--accent)) 13%, var(--group-surface)); }
.measurement-icon .icon { width: 20px; height: 20px; }
.measurement-copy { min-width: 0; flex: 1; }
.measurement-copy strong { display: block; font-size: 14px; font-weight: 600; line-height: 1.3; }
.measurement-copy small { display: block; font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.35; }
.measurement-value { text-align: right; color: var(--metric, var(--text)); font-size: 21px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.measurement-value small { color: #b0c0d6; font-size: 11px; font-weight: 400; }
.measurement-row > .icon { width: 14px; height: 14px; color: #829ab9; }
.detail-facts { margin: 22px 0 0; padding: 0; }
.detail-facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; padding: 12px 0; border-bottom: 1px solid var(--inset-separator); font-size: 12px; line-height: 1.5; }
.detail-facts > div:last-child { border-bottom: 0; }
.detail-facts dt { color: var(--muted); flex-shrink: 0; }
.detail-facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.metric-sheet .metric-detail-value { color: var(--metric, var(--accent)); font-weight: 700; line-height: 1.15; margin-bottom: 5px; }
.metric-pin-button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 46px; padding: 11px 15px; border: 1px solid #425e83; border-radius: 13px; background: #223a59; color: #b7d6ff; font-size: 13px; font-weight: 600; }
.metric-pin-button[aria-pressed="true"] { background: #26394c; border-color: #476178; color: #c4daee; }
.metric-pin-button .icon { width: 18px; height: 18px; }
.chart-record-button { margin-left: auto; font-size: 11px; white-space: nowrap; }
.chart-record-button .icon { width: 13px; height: 13px; }
.chart-readout { flex-wrap: wrap; }
.sheet-grabber { touch-action: none; }
.pin-list { border-radius: 18px; overflow: hidden; background: var(--group-surface); }
.pin-row { display: flex; align-items: center; gap: 12px; position: relative; min-height: 70px; padding: 14px 16px; cursor: pointer; }
.pin-row + .pin-row:before { content: ''; position: absolute; top: 0; right: 0; left: 62px; height: 1px; background: var(--inset-separator); }
.pin-row:hover { background: #253752; }
.pin-row > .icon { color: var(--metric, var(--accent)); width: 24px; height: 24px; }
.pin-row > span:not(.measurement-icon) { flex: 1; font-size: 15px; }
.pin-row strong { display: block; font-size: 14px; font-weight: 600; }
.pin-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.pin-row input[type="checkbox"] { width: 24px; height: 24px; accent-color: #649fff; flex-shrink: 0; margin: 0 0 0 auto; cursor: pointer; }

@media (max-width: 700px) {
  main { padding-bottom: calc(98px + env(safe-area-inset-bottom)); }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 34px; line-height: 1.1; font-weight: 740; letter-spacing: -1.05px; }
  .page-heading p { max-width: 260px; font-size: 13px; }
  .page-heading > .date-pill { margin-top: 5px; }
  .page-heading .btn { min-height: 44px; }
  .topbar { min-height: 76px; height: auto; padding: 10px 18px; }
  .top-actions > .icon-btn { width: 44px; }
  .role-switch button { min-height: 38px; }
  .sidebar { height: calc(70px + env(safe-area-inset-bottom)); background: #0c1727ed; border-top-color: #28394f; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .nav-link { font-size: 10px; border-radius: 12px; }
  .nav-link.active { background: #1b31524d; color: #90bcff; }
  .nav-link .icon { width: 23px; height: 23px; }
  .pinned-section { margin: 25px 0; }
  .diary-prompt { min-height: 0; padding: 22px; }
  .diary-prompt h2 { font-size: 24px; line-height: 1.2; max-width: 260px; }
  .diary-prompt .hero-art { display: none; }
  .diary-prompt .hero-actions { margin-top: 18px; gap: 12px; }
  .section-heading h2 { font-size: 22px; }
  .pinned-section .metrics { gap: 11px; }
  .pinned-section .metric-card { padding: 15px 13px; min-height: 151px; border-radius: 19px; }
  .pinned-section .metric-head { font-size: 11px; }
  .pinned-section .metric-value { font-size: 31px; }
  .pinned-section .metric-foot { font-size: 10px; }
  .card { border-radius: 20px; }
  .analytics-card .chart-period button, .analytics-card .chart-tabs button, .chart-style-control button, .chart-goal-control { min-height: 44px; }
  .analytics-card .chart-tabs { gap: 12px; }
  .analytics-card .chart-tabs button { padding-bottom: 10px; }
  .checkpoint-path { grid-template-columns: 1fr; gap: 0; background: #18283e; border-radius: 17px; overflow: hidden; margin-top: 22px; }
  .checkpoint-stop { position: relative; align-items: center; min-height: 84px; border: 0; border-radius: 0; background: transparent; padding: 15px 13px; gap: 12px; }
  .checkpoint-stop + .checkpoint-stop:before { content: ''; height: 1px; position: absolute; top: 0; right: 0; left: 60px; background: var(--inset-separator); }
  .checkpoint-symbol { width: 34px; height: 34px; }
  .checkpoint-copy strong { font-size: 14px; }
  .checkpoint-copy small { margin-top: 4px; font-size: 12px; }
  .checkpoint-stop > .icon { margin-top: 0; }
  dialog:is(.checkpoint-sheet, .metric-sheet, .pin-sheet) {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - max(24px, env(safe-area-inset-top)));
    margin: 0;
    border-radius: 26px 26px 0 0;
    border-width: 1px 0 0;
    padding-top: 0;
  }
  .sheet-grabber { display: grid; place-items: center; width: 100%; height: 44px; min-height: 44px; flex-shrink: 0; background: transparent; border-radius: 26px 26px 0 0; padding: 0; }
  .sheet-grabber:after { content: ''; width: 36px; height: 4px; border-radius: 3px; background: #627087; }
  .sheet-grabber:hover:after, .sheet-grabber:focus-visible:after { background: #b1c4df; }
  :is(.checkpoint-sheet, .metric-sheet, .pin-sheet) > .modal-header { padding: 0 20px 17px; }
  :is(.checkpoint-sheet, .metric-sheet, .pin-sheet) .modal-header h2 { font-size: 24px; }
  :is(.checkpoint-sheet, .metric-sheet, .pin-sheet) .modal-header p { font-size: 12px; line-height: 1.45; }
  :is(.checkpoint-sheet, .metric-sheet, .pin-sheet) .modal-body { padding: 21px 20px; }
  :is(.checkpoint-sheet, .metric-sheet, .pin-sheet) .modal-footer { padding: 14px 20px max(18px, env(safe-area-inset-bottom)); gap: 12px; flex-wrap: wrap; }
  :is(.checkpoint-sheet, .metric-sheet, .pin-sheet) .modal-footer > .small { flex: 1; min-width: 100px; font-size: 11px; }
  .checkpoint-overview h3 { font-size: 26px; }
  .checkpoint-overview p { font-size: 13px; }
  .measurement-row { gap: 10px; padding: 15px 12px; }
  .measurement-copy strong { font-size: 13px; }
  .measurement-copy small { font-size: 11px; }
  .measurement-value { font-size: 21px; }
  .measurement-row > .icon { width: 12px; height: 12px; }
  .metric-pin-button { width: 100%; }
  .metric-sheet .notice { font-size: 12px; line-height: 1.6; }
}

@media (max-width: 380px) {
  .topbar { padding-inline: 13px; }
  .top-actions { gap: 2px; }
  .role-switch button { font-size: 9px; padding-inline: 6px; }
  .pinned-section .metric-card { padding-inline: 11px; }
  .measurement-row { gap: 8px; }
  .measurement-icon { width: 30px; height: 30px; }
  .measurement-value { font-size: 20px; }
  .analytics-card .chart-tabs { gap: 9px; }
}

@keyframes bio-sheet-enter { from { transform: translateY(32px); opacity: .7; } to { transform: translateY(0); opacity: 1; } }
@media (max-width: 700px) and (prefers-reduced-motion: no-preference) {
  dialog:is(.checkpoint-sheet, .metric-sheet, .pin-sheet)[open] { animation: bio-sheet-enter 240ms cubic-bezier(.2,.75,.25,1); }
}
@media (prefers-reduced-motion: reduce) {
  .checkpoint-stop, button.goal-node, .measurement-row, .pin-row, .metric-pin-button { transition: none; }
  dialog:is(.checkpoint-sheet, .metric-sheet, .pin-sheet)[open] { animation: none; }
}
