/* MED 0.30 interface. This layer keeps the existing functional components while
   giving every route the same compact, task-first product language. */

:root {
  --med-content: 920px;
  --med-row: #101017;
  --med-row-hover: #15151e;
}

body { background: var(--bg-base); }
button, input, select, textarea { font: inherit; }
main { max-width: var(--med-content); padding-top: 36px; }
.topbar { background: var(--bg-base); border-bottom-color: var(--border-subtle); }
.gm-caption { color: var(--text-secondary); font-family: var(--mono); font-size: 8px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.gm-lockup { align-items: flex-start; flex-direction: column; gap: 1px; }
.gm-mark { font-size: 15px; line-height: 16px; }
.nav-item { border: 0; background: transparent; cursor: pointer; font-family: var(--sans); }
.page-title { font-size: 32px; line-height: 36px; font-weight: 650; letter-spacing: -.035em; }
.page-lead { color: var(--text-secondary); font-size: 13px; line-height: 19px; }
.section { margin-top: 30px; }
.compact-section { margin-top: 32px; }
.section-title { font-size: 13px; line-height: 18px; font-weight: 600; }
.section-head { margin-bottom: 10px; }
.card { border-color: var(--border-subtle); border-radius: 5px; background: var(--bg-surface); }
.btn { border-radius: 3px; min-height: 44px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.input { border-radius: 3px; background: var(--bg-surface); }

.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.view-head > div { min-width: 0; }
.view-date { color: var(--text-tertiary); font-family: var(--mono); font-size: 10px; letter-spacing: .04em; white-space: nowrap; }
.filter-strip { display: flex; gap: 0; overflow-x: auto; border-bottom: 1px solid var(--border-subtle); scrollbar-width: none; }
.filter-strip::-webkit-scrollbar { display: none; }
.filter-chip { flex: none; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-bottom: 2px solid transparent; color: var(--text-secondary); font-size: 12px; }
.filter-chip.is-active { border-bottom-color: var(--accent); color: var(--text-primary); }

.action-list { border: 1px solid var(--border-subtle); border-radius: 5px; overflow: hidden; background: var(--bg-surface); }
.action-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 66px; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); background: var(--med-row); transition: background 140ms ease, border-color 140ms ease; }
.action-row:last-child { border-bottom: 0; }
.action-row:hover { background: var(--med-row-hover); }
.action-row > span:nth-child(2), .action-copy { display: flex; flex-direction: column; min-width: 0; }
.action-row strong { overflow: hidden; color: var(--text-primary); font-size: 13px; font-weight: 550; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
.action-row small { overflow: hidden; color: var(--text-tertiary); font-family: var(--mono); font-size: 9px; line-height: 15px; text-overflow: ellipsis; white-space: nowrap; }
.action-row > .icon:last-child { width: 15px; height: 15px; color: var(--text-tertiary); }
.action-trailing { display: inline-flex; align-items: center; justify-content: flex-end; justify-self: end; gap: 10px; min-width: 15px; }
.action-trailing > .icon { flex: none; width: 15px; height: 15px; color: var(--text-tertiary); }
.action-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid var(--border-subtle); border-radius: 3px; color: var(--text-secondary); background: var(--bg-base); }
.action-icon .icon { width: 16px; height: 16px; }
.attention-row.tone-danger .action-icon { border-color: color-mix(in srgb, var(--danger) 35%, var(--border-subtle)); color: var(--danger); }
.attention-row.tone-warning .action-icon { border-color: color-mix(in srgb, var(--warning) 30%, var(--border-subtle)); color: var(--warning); }
.row-action { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 0 11px; border: 1px solid var(--border-default); border-radius: 3px; color: var(--text-secondary); font-size: 10px; font-weight: 600; }
.attention-row:first-child .row-action { border-color: var(--accent); background: var(--accent); color: #fff; }

.calm-state { display: flex; align-items: flex-start; flex-direction: column; gap: 10px; padding: 24px; }
.calm-state h2 { font-family: Georgia, serif; font-size: 24px; font-style: italic; font-weight: 400; line-height: 30px; }
.calm-state p { max-width: 560px; color: var(--text-secondary); }
.calm-state .btn { margin-top: 4px; }

.today-people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.today-person { padding: 0; overflow: hidden; }
.today-person-head { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 11px; min-height: 68px; padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); }
.today-person-head > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.today-person-head strong { font-size: 14px; }
.today-person-head small { color: var(--text-tertiary); font-family: var(--mono); font-size: 9px; }
.today-person-head > .icon { color: var(--text-tertiary); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: none; border: 1px solid #63204a; border-radius: 50%; background: #301124; color: #f0bad8; font-size: 14px; font-weight: 600; }
.avatar-1 { border-color: #634b20; background: #2e230f; color: #e8d19f; }
.avatar-2 { border-color: #285847; background: #10281f; color: #a8dbc9; }
.avatar-3 { border-color: #365176; background: #142238; color: #b6cbea; }
.avatar-large { width: 50px; height: 50px; font-size: 18px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.quick-grid a { display: flex; align-items: center; flex-direction: column; justify-content: center; min-height: 62px; border-right: 1px solid var(--border-subtle); }
.quick-grid a:last-child { border-right: 0; }
.quick-grid strong { font-family: var(--mono); font-size: 13px; font-weight: 500; }
.quick-grid span { color: var(--text-tertiary); font-size: 9px; }

.family-stack { display: flex; flex-direction: column; gap: 10px; }
.family-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 15px 16px; }
.family-row.has-attention { border-left: 2px solid var(--accent); }
.family-row-copy { display: flex; flex-direction: column; min-width: 0; }
.family-row-copy > strong { font-size: 15px; line-height: 20px; }
.family-row-copy > small { color: var(--text-secondary); font-size: 11px; line-height: 17px; }
.family-facts { display: flex; gap: 12px; margin-top: 5px; color: var(--text-tertiary); font-family: var(--mono); font-size: 9px; }
.family-medications { overflow: hidden; margin-top: 3px; color: var(--text-secondary); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.family-row > .icon { color: var(--text-tertiary); }
.inline-create { margin-top: 16px; padding: 0; }
.inline-create > summary { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 0 16px; cursor: pointer; font-weight: 550; list-style: none; }
.inline-create > summary::-webkit-details-marker { display: none; }
.inline-create > .stack-form { padding: 0 16px 16px; border-top: 1px solid var(--border-subtle); }

.person-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; margin: 12px 0 22px; }
.person-hero .page-title { font-size: 26px; line-height: 30px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--border-subtle); border-radius: 50%; color: var(--text-secondary); }
.person-entry-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.entry-card { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 7px 10px; padding: 14px; }
.entry-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--border-default); border-radius: 3px; color: var(--text-secondary); }
.entry-card > strong { font-size: 13px; }
.entry-count { justify-self: end; font-family: var(--mono); font-size: 18px; }
.entry-card > small { grid-column: 2 / 4; color: var(--text-tertiary); font-size: 10px; }
.entry-status-danger { width: max-content; padding: 2px 6px; border: 1px solid color-mix(in srgb, var(--danger) 24%, var(--border-subtle)); border-radius: 2px; background: var(--danger-bg); color: var(--danger) !important; font-family: var(--mono); font-weight: 600; line-height: 16px; white-space: nowrap; }
.page-actions { display: flex; gap: 8px; margin-top: 28px; }
.compact-prescriptions { margin-top: 16px; }
.compact-prescriptions .prescriptions-card { padding: 0; }
.compact-prescriptions .prescriptions-card > summary { min-height: 54px; padding: 0 16px; }
.compact-prescriptions .prescriptions-card-body { padding: 0 16px 16px; }

/* Accepted desktop person card: chronology first, expandable context second. */
body.med-person-page main { max-width: 1440px; padding-right: 48px; padding-left: 48px; }
body.med-person-page .page-footer { max-width: 1440px; padding-right: 48px; padding-left: 48px; }
.person-overview { width: 100%; }
.person-overview > .back { margin-bottom: 6px; }
.person-overview .person-hero { max-width: 1030px; }
.person-hero-actions { display: flex; align-items: center; gap: 10px; }
.person-ai-cta { white-space: nowrap; }
.person-overview .person-subnav { margin-top: 14px; }
.person-subnav-mobile { display: none; }
.person-workspace { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(300px, .95fr); gap: 52px; align-items: start; margin-top: 30px; }
.person-main-column { min-width: 0; }
.person-main-column > .section:first-child { margin-top: 0; }
.person-kpi-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--border-subtle); border-radius: 5px; background: var(--border-subtle); }
.person-kpi { display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 12px; min-height: 88px; padding: 14px 18px; background: var(--bg-surface); transition: background 150ms var(--ease-out); }
.person-kpi:hover { background: var(--med-row-hover); }
.person-kpi-icon, .context-icon { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: 1px solid var(--border-default); border-radius: 4px; color: var(--text-secondary); background: var(--bg-base); }
.person-kpi > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.person-kpi strong { font-family: var(--mono); font-size: 22px; font-weight: 500; line-height: 25px; font-variant-numeric: tabular-nums; }
.person-kpi small { color: var(--text-secondary); font-size: 11px; line-height: 17px; }
.person-kpi-alert:not(.is-zero) .person-kpi-icon { border-color: color-mix(in srgb, var(--danger) 32%, var(--border-subtle)); color: var(--danger); background: var(--danger-bg); }
.person-kpi-alert:not(.is-zero) strong, .person-kpi-alert:not(.is-zero) small { color: var(--danger); }
.person-status-mobile { display: none; }
.person-attention .action-list { border-color: color-mix(in srgb, var(--danger) 22%, var(--border-subtle)); }
.person-attention .action-row { background: color-mix(in srgb, var(--danger-bg) 48%, var(--med-row)); }
.medical-timeline { position: relative; overflow: visible; margin-left: 27px; }
.medical-timeline::before { position: absolute; top: 25px; bottom: 25px; left: -18px; width: 1px; background: var(--border-default); content: ""; }
.medical-timeline .action-row { position: relative; min-height: 72px; }
.medical-timeline .action-row::before { position: absolute; top: 50%; left: -22px; width: 8px; height: 8px; border: 2px solid var(--bg-base); border-radius: 50%; background: var(--text-tertiary); content: ""; transform: translateY(-50%); }
.medical-timeline .action-row:hover::before { background: var(--accent); }
.person-primary-actions { margin-top: 18px; }

.medical-section-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.medical-section-card { display: grid; grid-template-columns: 38px minmax(0, 1fr) 16px; align-items: center; gap: 11px; min-height: 70px; padding: 11px 12px; border: 1px solid var(--border-subtle); border-radius: 5px; background: var(--bg-surface); transition: border-color 150ms var(--ease-out), background 150ms var(--ease-out); }
.medical-section-card:hover { border-color: var(--border-default); background: var(--med-row-hover); }
.medical-section-icon, .person-section-heading-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--border-default); border-radius: 4px; color: var(--text-secondary); background: var(--bg-base); }
.medical-section-card > .icon { width: 15px; height: 15px; color: var(--text-tertiary); }
.medical-section-copy { display: flex; flex-direction: column; min-width: 0; }
.medical-section-copy strong { overflow: hidden; font-size: 12px; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
.medical-section-copy small { overflow: hidden; color: var(--text-tertiary); font-size: 9px; line-height: 15px; text-overflow: ellipsis; white-space: nowrap; }

.person-section-page { max-width: 980px; margin: 0 auto; }
.person-section-head { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 14px; }
.person-section-heading-icon { width: 48px; height: 48px; }
.person-section-heading-icon .icon { width: 22px; height: 22px; }
.person-section-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 24px; overflow: hidden; border: 1px solid var(--border-subtle); border-radius: 5px; background: var(--border-subtle); }
.person-section-stats > span { display: flex; align-items: center; flex-direction: column; justify-content: center; min-height: 76px; padding: 10px; background: var(--bg-surface); text-align: center; }
.person-section-stats strong { font-family: var(--mono); font-size: 18px; font-weight: 500; }
.person-section-stats small { color: var(--text-tertiary); font-size: 9px; line-height: 15px; }
.section-result-list { overflow: hidden; border: 1px solid var(--border-subtle); border-radius: 5px; background: var(--bg-surface); }
.section-result-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(100px, auto) 16px; align-items: center; gap: 14px; min-height: 62px; padding: 9px 12px; border-bottom: 1px solid var(--border-subtle); }
.section-result-row:last-child { border-bottom: 0; }
.section-result-row:hover { background: var(--med-row-hover); }
.section-result-row > span:first-child, .section-result-value { display: flex; flex-direction: column; min-width: 0; }
.section-result-row strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.section-result-row small { overflow: hidden; color: var(--text-tertiary); font-size: 9px; line-height: 15px; text-overflow: ellipsis; white-space: nowrap; }
.section-result-value { align-items: flex-end; font-family: var(--mono); font-size: 12px; text-align: right; }
.section-result-row.is-alert .section-result-value { color: var(--danger); }
.section-result-row > .icon { width: 15px; height: 15px; color: var(--text-tertiary); }
.section-note { display: flex; flex-direction: column; gap: 4px; margin-top: 24px; padding: 15px; }
.section-note p { margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 18px; }
.review-head-actions { display: flex; align-items: flex-end; flex-direction: column; gap: 8px; }
.review-head-actions form { margin: 0; }

.person-context { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.person-context > .section-title { margin-bottom: 2px; }
.context-panel { overflow: hidden; border: 1px solid var(--border-subtle); border-radius: 5px; background: var(--bg-surface); }
.context-panel > summary, .context-link { display: grid; grid-template-columns: 42px minmax(0, 1fr) 18px; align-items: center; gap: 12px; min-height: 68px; padding: 12px 14px; }
.context-panel > summary { cursor: pointer; }
.context-panel > summary strong, .context-link strong { font-size: 13px; font-weight: 600; }
.context-chevron, .context-link > .icon:last-child { color: var(--text-tertiary); transition: transform 150ms var(--ease-out), color 150ms var(--ease-out); }
.context-panel[open] > summary .context-chevron { transform: rotate(180deg); }
.context-panel > summary:hover .context-chevron, .context-link:hover > .icon:last-child { color: var(--text-primary); }
.context-panel-body { border-top: 1px solid var(--border-subtle); }
.context-panel-body > a { display: grid; grid-template-columns: minmax(0, 1fr) auto 16px; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px 0 66px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: 12px; }
.context-panel-body > a:last-child { border-bottom: 0; }
.context-panel-body > a:hover { background: var(--med-row-hover); color: var(--text-primary); }
.context-panel-body strong { color: var(--text-primary); font-family: var(--mono); font-size: 14px; font-weight: 500; }
.context-panel-body .context-alert:not(.is-zero) strong { color: var(--danger); }
.context-panel-body .icon { color: var(--text-tertiary); }
.context-link { transition: background 150ms var(--ease-out); }
.context-link:hover { background: var(--med-row-hover); }
.context-link > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.context-link small { overflow: hidden; color: var(--text-tertiary); font-size: 10px; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }
.context-details-body { padding: 14px; border-top: 1px solid var(--border-subtle); }
.context-details-body .side-title { min-height: 40px; margin: 8px 0 0; font-size: 12px; }
.context-inline-link { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-top: 10px; padding: 0 10px; border-top: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: 12px; }
.context-reminder { margin-top: 0; }

/* Native toast component based on the selected 21st pattern. */
.toast-region { position: fixed; top: 84px; right: 24px; z-index: 400; width: min(390px, calc(100vw - 32px)); pointer-events: none; }
.med-toast { display: grid; grid-template-columns: 22px minmax(0, 1fr) 36px; align-items: start; gap: 11px; padding: 14px 10px 14px 14px; border: 1px solid var(--border-default); border-radius: 8px; background: var(--bg-surface); box-shadow: 0 12px 32px rgba(0, 0, 0, .42); pointer-events: auto; animation: med-toast-in 220ms var(--ease-out) both; }
.toast-status-icon { display: inline-flex; margin-top: 1px; }
.toast-status-icon .icon { width: 19px; height: 19px; }
.med-toast[data-toast-variant="success"] .toast-status-icon { color: var(--success); }
.med-toast[data-toast-variant="info"] .toast-status-icon { color: var(--text-primary); }
.med-toast[data-toast-variant="warning"] .toast-status-icon { color: var(--warning); }
.med-toast[data-toast-variant="error"] .toast-status-icon { color: var(--danger); }
.toast-copy { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.toast-copy strong { font-size: 13px; font-weight: 600; line-height: 19px; }
.toast-copy > span { color: var(--text-secondary); font-size: 11px; line-height: 17px; }
.toast-dismiss { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin: -8px -4px 0 0; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--text-secondary); cursor: pointer; }
.toast-dismiss:hover { background: var(--bg-elevated); color: var(--text-primary); }
.toast-dismiss:focus-visible { outline: 2px solid var(--accent-glow); outline-offset: 1px; }
.toast-dismiss .icon { width: 15px; height: 15px; }
.med-toast.is-leaving { opacity: 0; transform: translateY(-8px); transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out); }
@keyframes med-toast-in { from { opacity: 0; transform: translateY(-10px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }

.menu-group { margin-top: 28px; }
.menu-group > h2 { margin-bottom: 9px; font-size: 12px; font-weight: 600; }

.add-panel { position: fixed; inset: 0; z-index: 800; }
.add-panel .explain-backdrop { opacity: 0; transition: opacity 180ms ease; }
.add-sheet { position: absolute; right: 50%; bottom: 50%; width: min(430px, calc(100vw - 32px)); padding: 18px; border: 1px solid var(--border-default); border-radius: 6px; background: var(--bg-elevated); opacity: 0; transform: translate(50%, 54%); transition: opacity 180ms ease, transform 220ms var(--ease-out); }
.add-panel.is-open .explain-backdrop { opacity: 1; }
.add-panel.is-open .add-sheet { opacity: 1; transform: translate(50%, 50%); }
.add-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.add-sheet-head h2 { font-size: 20px; line-height: 26px; }
.add-sheet-head p { color: var(--text-tertiary); font-size: 11px; }
.add-sheet-head .btn { width: 44px; min-width: 44px; padding: 0; }
.add-sheet-list { border: 1px solid var(--border-default); border-radius: 4px; overflow: hidden; }

.reminder-create { margin-bottom: 18px; }
.reminder-list { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }
.reminder-card { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 14px; padding: 14px; }
.reminder-date { display: flex; align-items: center; flex-direction: column; justify-content: center; min-height: 52px; border-right: 1px solid var(--border-subtle); font-family: var(--mono); }
.reminder-date strong { font-size: 20px; font-weight: 500; line-height: 23px; }
.reminder-date span { color: var(--text-tertiary); font-size: 9px; text-transform: uppercase; }
.reminder-copy { display: flex; flex-direction: column; min-width: 0; }
.reminder-copy > strong { font-size: 13px; }
.reminder-copy > small { color: var(--text-tertiary); font-family: var(--mono); font-size: 9px; }
.reminder-copy .mini-actions { margin-top: 8px; }

.indicator-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 14px 0 18px; overflow: hidden; border: 1px solid var(--border-subtle); border-radius: 4px; background: var(--border-subtle); }
.indicator-summary > span { display: flex; align-items: center; flex-direction: column; justify-content: center; min-height: 66px; background: var(--bg-surface); color: var(--text-tertiary); font-size: 9px; }
.indicator-summary strong { color: var(--text-primary); font-family: var(--mono); font-size: 18px; font-weight: 500; }
.indicator-summary .tone-danger strong { color: var(--danger); }
.indicator-summary .tone-success strong { color: var(--success); }
.indicator-groups { display: flex; flex-direction: column; gap: 28px; margin-top: 20px; }
.indicator-groups .tiles { display: flex; flex-direction: column; gap: 7px; }
.indicator-groups .tile { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 2px 14px; min-height: 76px; padding: 12px; }
.indicator-groups .tile-head { grid-column: 1; grid-row: 1; }
.indicator-groups .tile-value { grid-column: 2; grid-row: 1; align-self: start; }
.indicator-groups .tile-num { font-size: 18px; line-height: 22px; }
.indicator-groups .tile-meta { grid-column: 1 / 3; grid-row: 2; margin: 0; }
.indicator-groups .tile-spark, .indicator-groups .tile-foot { display: none; }

/* Existing screens in the new language. */
.document-filters, .settings-grid, .health-overview, .med-form, .record-grid { gap: 10px; }
.doc, .pending, .chat-row, .source-card, .health-section-card, .med-product { border-radius: 4px; }
.record .page-head, .med-page .page-head { max-width: 680px; }
.record-grid { margin-top: 20px; }
.record-grid .card, .settings-grid .card, .health-section-card { border-color: var(--border-subtle); }
.tabs, .seg { border-radius: 3px; }
.tab, .seg-link, .dchip { min-height: 40px; }
.med-page { max-width: 820px; margin: 0 auto; }
.med-product { background: var(--bg-surface); }
.chat-list, .mail-list { border-color: var(--border-subtle); }
.chat-bubble { border-radius: 5px; }
.chat-bubble.is-user { background: var(--accent-muted); }
.settings-grid { grid-template-columns: 1fr; max-width: 760px; }
.page-footer { max-width: var(--med-content); width: 100%; margin-right: auto; margin-left: auto; }

@media (max-width: 820px) {
  main { padding-top: 22px; }
  .topbar { min-height: 62px; }
  .nav { background: #0d0d13; }
  .nav-item { min-height: 54px; }
  .nav-add .icon { width: 21px; height: 21px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 50%; }
  body.med-person-page main { padding-right: 24px; padding-left: 24px; }
  .person-workspace { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 22px; }
  .person-context { display: none; }
}

@media (max-width: 640px) {
  body { font-size: 13px; }
  main { width: 100%; padding: 17px 20px 28px; }
  .topbar { padding: max(12px, env(safe-area-inset-top)) 20px 10px; background: var(--bg-base); }
  .topbar .gm-lockup { min-width: 0; }
  .topbar .topbar-spacer { display: block; }
  .page-title { font-size: 28px; line-height: 32px; }
  .page-lead { font-size: 11px; line-height: 17px; }
  .view-head { margin-bottom: 18px; }
  .view-date { margin-top: 4px; font-size: 8px; }
  .section, .compact-section { margin-top: 26px; }
  .section-title { font-size: 12px; }
  .filter-strip { margin-right: -20px; margin-left: -20px; padding-left: 20px; }
  .filter-chip { padding: 0 15px; font-size: 11px; }
  .action-row { min-height: 63px; padding: 9px 11px; gap: 10px; }
  .action-row strong { font-size: 12px; }
  .action-row small { font-size: 8px; }
  .row-action { padding: 0 9px; font-size: 9px; }
  .today-people { grid-template-columns: minmax(0, 1fr); }
  .family-row { grid-template-columns: 42px minmax(0, 1fr) auto auto; gap: 11px; padding: 13px 12px; }
  .family-row .avatar { width: 42px; height: 42px; }
  .family-facts { gap: 8px; font-size: 8px; }
  body.med-person-page main { padding: 14px 16px 24px; }
  body.med-person-page .page-footer { padding-right: 16px; padding-left: 16px; }
  .person-overview > .back { min-height: 28px; margin-bottom: 2px; font-size: 11px; }
  .person-overview .person-hero { gap: 11px; margin: 6px 0 14px; }
  .person-overview .avatar-large { width: 42px; height: 42px; font-size: 15px; }
  .person-overview .person-hero .page-title { font-size: 22px; line-height: 27px; }
  .person-overview .person-hero .page-lead { font-size: 10px; line-height: 15px; }
  .person-overview .icon-button { width: 40px; height: 40px; }
  .person-hero-actions { gap: 0; }
  .person-ai-cta { display: none; }
  .person-subnav-desktop { display: none; }
  .person-subnav-mobile { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border: 1px solid var(--border-subtle); border-radius: 5px; background: var(--bg-surface); }
  .person-mobile-nav-item, .person-mobile-more > summary { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 5px; border-bottom: 2px solid transparent; color: var(--text-secondary); font-size: 10.5px; font-weight: 550; }
  .person-mobile-nav-item.is-active, .person-mobile-more.has-active > summary { border-bottom-color: var(--accent); color: var(--text-primary); }
  .person-mobile-more > summary { gap: 4px; cursor: pointer; }
  .person-mobile-more > summary .icon { width: 13px; height: 13px; transition: transform 150ms var(--ease-out); }
  .person-mobile-more[open] > summary .icon { transform: rotate(180deg); }
  .person-mobile-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 80; display: grid; width: min(230px, calc(100vw - 32px)); overflow: hidden; border: 1px solid var(--border-default); border-radius: 6px; background: var(--bg-elevated); box-shadow: 0 12px 32px rgba(0, 0, 0, .45); }
  .person-mobile-menu a { display: flex; align-items: center; justify-content: space-between; min-height: 46px; padding: 0 14px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: 12px; }
  .person-mobile-menu a:last-child { border-bottom: 0; }
  .person-mobile-menu a.is-active { color: var(--text-primary); background: var(--accent-muted); }
  .person-mobile-menu a span { font-family: var(--mono); font-size: 9px; }
  .person-mobile-menu a .is-alert { color: var(--warning); }
  .person-workspace { margin-top: 20px; }
  .person-state .section-head { display: none; }
  .person-kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .person-kpi { grid-template-columns: 32px minmax(0, 1fr); min-height: 62px; gap: 9px; padding: 8px 10px; }
  .person-kpi:nth-child(2) { border-right: 0; }
  .person-kpi:nth-child(-n+2) { border-bottom: 1px solid var(--border-subtle); }
  .person-kpi-icon { width: 32px; height: 32px; }
  .person-kpi-icon .icon { width: 15px; height: 15px; }
  .person-kpi strong { font-size: 16px; line-height: 20px; }
  .person-kpi small { font-size: 9px; line-height: 13px; }
  .medical-section-grid { gap: 6px; }
  .medical-section-card { grid-template-columns: 30px minmax(0, 1fr); min-height: 62px; gap: 8px; padding: 8px 9px; }
  .medical-section-icon { width: 30px; height: 30px; }
  .medical-section-icon .icon { width: 15px; height: 15px; }
  .medical-section-card > .icon { display: none; }
  .medical-section-copy strong { font-size: 10.5px; line-height: 16px; }
  .medical-section-copy small { font-size: 8px; line-height: 13px; white-space: normal; }
  .person-status-mobile { display: none; }
  .medical-timeline { margin-left: 12px; }
  .medical-timeline::before { left: -8px; }
  .medical-timeline .action-row::before { left: -12px; width: 7px; height: 7px; }
  .medical-timeline .action-row:nth-child(n+4) { display: none; }
  .medical-timeline .action-row { grid-template-columns: minmax(0, 1fr) auto; min-height: 64px; padding-left: 13px; }
  .medical-timeline .action-icon { display: none; }
  .medical-timeline .action-row strong { overflow: visible; display: -webkit-box; text-overflow: clip; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .person-oura { display: none; }
  .person-entry-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .entry-card { display: flex; align-items: flex-start; flex-direction: column; gap: 4px; padding: 11px; }
  .entry-card > strong { font-size: 10px; }
  .entry-count { font-size: 16px; }
  .entry-card > small { display: none; }
  .entry-card > .entry-status-danger { display: inline-flex; padding: 1px 4px; font-size: 9px; line-height: 14px; }
  .page-actions { align-items: stretch; flex-direction: column; }
  .menu-group { margin-top: 24px; }
  .add-sheet { right: 0; bottom: 0; width: 100%; padding: 22px 16px calc(18px + env(safe-area-inset-bottom)); border-right: 0; border-bottom: 0; border-left: 0; border-radius: 8px 8px 0 0; transform: translateY(100%); }
  .add-panel.is-open .add-sheet { transform: translateY(0); }
  .add-sheet .sheet-handle { display: block; }
  .reminder-card { grid-template-columns: 45px minmax(0, 1fr); padding: 11px; }
  .reminder-copy .mini-actions { display: flex; flex-wrap: wrap; }
  .reminder-copy .btn-mini { min-height: 36px; }
  .indicator-summary > span { min-height: 59px; }
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .document-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .document-filters > label:first-child { grid-column: 1 / -1; }
  .document-filters > label { gap: 4px; font-size: 10px; }
  .document-filters .input { min-height: 42px; }
  .document-filters .btn, .document-filters .link { min-height: 42px; }
  .record-grid, .med-product-sections { grid-template-columns: minmax(0, 1fr); }
  .page-footer { padding-right: 20px; padding-left: 20px; }
  .person-primary-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 20px; }
  .person-section-page .person-subnav { margin-top: 14px; }
  .person-section-head { grid-template-columns: 40px minmax(0, 1fr); gap: 11px; margin-bottom: 14px; }
  .person-section-heading-icon { width: 40px; height: 40px; }
  .person-section-heading-icon .icon { width: 18px; height: 18px; }
  .person-section-stats { margin-top: 18px; }
  .person-section-stats > span { min-height: 62px; padding: 7px 4px; }
  .person-section-stats strong { font-size: 14px; }
  .person-section-stats small { font-size: 8px; line-height: 12px; }
  .section-result-row { grid-template-columns: minmax(0, 1fr) minmax(78px, auto); min-height: 58px; gap: 8px; padding: 8px 10px; }
  .section-result-row > .icon { display: none; }
  .section-result-value { font-size: 10px; }
  .review-head-actions { align-items: stretch; width: 100%; }
  .review-head-actions .btn { width: 100%; }
  .toast-region { position: static; width: auto; margin-top: 12px; }
  .med-toast { grid-template-columns: 22px minmax(0, 1fr) 44px; padding: 13px 6px 13px 13px; }
  .toast-dismiss { width: 44px; height: 44px; margin-top: -10px; }
}

@media (max-width: 390px) {
  main { padding-right: 18px; padding-left: 18px; }
  .filter-strip { margin-right: -18px; margin-left: -18px; padding-left: 18px; }
  body.med-person-page main { padding-right: 14px; padding-left: 14px; }
  .person-mobile-menu { width: min(220px, calc(100vw - 28px)); }
  .family-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .family-row .status-dot { display: none; }
  .action-row { grid-template-columns: 32px minmax(0, 1fr) auto; }
  .action-icon { width: 32px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .add-panel .explain-backdrop, .add-sheet, .med-toast { animation: none; transition: none; }
}
