:root {
  color-scheme: light;
  --bg: #f4f8fb;
  --surface: #ffffff;
  --ink: #173247;
  --muted: #6f8291;
  --line: #d9e5ec;
  --teal: #10a99b;
  --teal-soft: #e7f7f4;
  --blue: #3478d4;
  --blue-soft: #eaf2fc;
  --amber: #d88416;
  --amber-soft: #fff4df;
  --red: #d94f4f;
  --red-soft: #fff0ef;
  --green: #168a5b;
  --shadow: 0 16px 45px rgba(30, 65, 88, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.is-hidden { display: none !important; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid rgba(16,169,155,.35); outline-offset: 2px; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    linear-gradient(115deg, rgba(16,169,155,.08), rgba(52,120,212,.04)),
    var(--bg);
}

.login-panel {
  width: min(430px, calc(100vw - 24px));
  padding: 42px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup > div:last-child { display: grid; gap: 2px; }
.brand-lockup strong { color: var(--ink); font-size: var(--text-21, 21px); line-height: 1.15; }
.brand-lockup span:not(.brand-mark span) { color: var(--muted); font-size: var(--text-12, 12px); }
.brand-mark {
  width: 54px;
  height: 54px;
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
}
.brand-mark.small { width: 42px; height: 42px; }
.mobile-brand { display: none; }
.login-brand { margin-bottom: 12px; }
.eyebrow { margin: 18px 0 4px; color: var(--teal); font-size: var(--text-13, 13px); font-weight: 700; }
.login-panel h1 { margin: 0; font-size: var(--text-30, 30px); }
.login-copy { margin: 10px 0 26px; color: var(--muted); }
.form-stack { display: grid; gap: 16px; }
label span { display: block; margin-bottom: 7px; color: var(--muted); font-size: var(--text-13, 13px); font-weight: 700; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
}

input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(16,169,155,.12); }

.primary-button, .secondary-button, .danger-button {
  min-height: 44px;
  border-radius: 6px;
  padding: 10px 18px;
  font-weight: 700;
}

.primary-button { border: 1px solid var(--teal); color: #fff; background: var(--teal); }
.primary-button:hover { background: #0b9185; }
.secondary-button { border: 1px solid #c7ddd9; color: #0d746b; background: #f8fdfc; }
.danger-button { border: 1px solid var(--red); color: var(--red); background: #fff; }
.danger-button:disabled { opacity: .45; cursor: not-allowed; }
.compact { min-height: 42px; align-self: end; white-space: nowrap; }
.demo-note { margin: 16px 0 0; color: var(--muted); font-size: var(--text-12, 12px); text-align: center; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  background: #fff;
  border-right: 1px solid var(--line);
  z-index: 20;
}

.brand-block { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; }
.brand-block strong, .brand-block span, .user-mini strong, .user-mini span { display: block; }
.brand-block span, .user-mini span { color: var(--muted); font-size: var(--text-12, 12px); }
.main-nav { display: grid; gap: 6px; margin-top: 12px; }
.nav-button {
  position: relative;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  border: 0;
  border-radius: 6px;
  color: #526879;
  background: transparent;
  text-align: left;
}
.nav-button:hover { background: #f2f7f9; }
.nav-button.is-active { color: #0d746b; background: var(--teal-soft); font-weight: 700; }
.nav-icon { width: 22px; font-size: var(--text-19, 19px); text-align: center; }
.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: var(--text-11, 11px); display: grid; place-items: center; }
.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.user-mini { display: flex; align-items: center; gap: 10px; min-width: 0; }
.account-actions { display: grid; gap: 6px; justify-items: stretch; }
.logout-button { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 7px 9px; border: 1px solid #d8e5ea; border-radius: 6px; color: var(--muted); background: #fff; font-size: var(--text-12, 12px); font-weight: 700; white-space: nowrap; }
.logout-button:hover { color: #a64545; border-color: #dfb7b7; background: #fff8f8; }
.account-button { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 5px 9px; border: 0; color: #24766e; background: transparent; font-size: var(--text-11, 11px); font-weight: 700; white-space: nowrap; }
.account-button:hover { color: #0d746b; text-decoration: underline; }
.delete-account-button { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 5px 9px; border: 0; color: #b05b5b; background: transparent; font-size: var(--text-11, 11px); font-weight: 700; white-space: nowrap; }
.delete-account-button:hover { color: #8d2f2f; text-decoration: underline; }
.delete-account-dialog .danger-button { background: #b05252; color: #fff; border-color: #b05252; }
.delete-account-dialog .danger-button:hover { background: #913d3d; border-color: #913d3d; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink); font-size: var(--text-20, 20px); }
.icon-button:hover { border-color: #b7cad5; background: #f8fbfc; }
.text-icon-button { width: 38px; padding: 0; color: var(--teal); font-size: var(--text-14, 14px); font-weight: 800; }
.text-icon-button.is-active { color: #fff; border-color: var(--teal); background: var(--teal); }

.main-content { min-height: 100vh; margin-left: 232px; padding: 22px clamp(24px, 4vw, 58px) 48px; }
.topbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px 20px; margin-bottom: 18px; }
.topbar .eyebrow { margin: 0 0 3px; }
.topbar h1 { margin: 0; font-size: var(--text-28, 28px); line-height: 1.4; }
.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.observer-pill { display: inline-flex; align-items: center; min-height: 30px; padding: 6px 10px; border-radius: 999px; color: #176e65; background: var(--teal-soft); font-size: var(--text-12, 12px); font-weight: 700; white-space: nowrap; }
.sync-status { color: var(--muted); font-size: var(--text-11, 11px); white-space: nowrap; }
.sync-status.is-error { color: var(--red); }
#refreshButton.is-loading { animation: refresh-spin .8s linear infinite; pointer-events: none; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }
.header-action.danger { color: var(--red); border-color: #ecd0d0; }
.header-action.danger:hover { background: var(--red-soft); border-color: #dda6a6; }
.header-action { min-height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid #d4e3ea; border-radius: 7px; color: #526879; background: #fff; font-weight: 700; }
.header-action:hover { color: var(--teal); border-color: #acd6d0; background: #f4fbfa; }
.simulate-launcher { min-height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border: 1px solid #c8e0dc; border-radius: 7px; color: #0d746b; background: #f0faf8; font-weight: 700; }
.simulate-launcher:hover { background: #e4f5f1; border-color: #9ccfc7; }
.status-pill, .metric-status { display: inline-flex; align-items: center; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.status-pill { min-height: 34px; padding: 7px 12px; font-size: var(--text-13, 13px); }
.status-pill.normal, .metric-status.normal { color: var(--green); background: #e8f6ef; }
.status-pill.warning, .metric-status.warning { color: #a55d00; background: var(--amber-soft); }
.status-pill.danger, .metric-status.danger { color: var(--red); background: var(--red-soft); }
.status-pill.neutral, .metric-status.neutral { color: var(--muted); background: #edf2f5; }

.view-section { display: none; }
.view-section.is-active { display: block; }
.dashboard-overview { display: grid; grid-template-columns: minmax(220px, .95fr) minmax(280px, 1.35fr) minmax(220px, .9fr); align-items: stretch; background: #eaf7f5; border-left: 4px solid var(--teal); }
.score-block, .overview-summary, .motto-block { padding: 20px 22px; }
.score-block { display: flex; align-items: center; gap: 15px; border-right: 1px solid #cfe7e2; }
.score-ring { --score: 0; position: relative; width: 78px; height: 78px; display: grid; place-content: center; flex: 0 0 auto; border-radius: 50%; background: conic-gradient(var(--score-color, var(--teal)) calc(var(--score) * 1%), #cfe7e2 0); }
.score-ring::after { position: absolute; inset: 7px; content: ""; border-radius: 50%; background: #eaf7f5; }
.score-ring strong, .score-ring span { position: relative; z-index: 1; text-align: center; }
.score-ring strong { font-size: var(--text-23, 23px); line-height: 1; }
.score-ring span { margin-top: 3px; color: var(--muted); font-size: var(--text-10, 10px); }
.score-block > div:last-child span, .overview-summary > span, .motto-block > span { color: #4f7773; font-size: var(--text-12, 12px); font-weight: 700; }
.score-block > div:last-child strong { display: block; margin-top: 3px; font-size: var(--text-18, 18px); }
.score-block p { margin: 3px 0 0; color: var(--muted); font-size: var(--text-11, 11px); }
.summary-band span, .section-heading span { display: block; color: var(--muted); font-size: var(--text-12, 12px); font-weight: 700; }
.summary-band strong, .overview-summary > strong { display: block; margin-top: 5px; font-size: var(--text-16, 16px); line-height: 1.5; }
.overview-summary { display: flex; flex-direction: column; justify-content: center; }
.overview-meta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; color: var(--muted); font-size: var(--text-12, 12px); }
.motto-block { display: flex; flex-direction: column; justify-content: center; border-left: 1px solid #cfe7e2; }
.motto-block p { margin: 7px 0 3px; color: #315d59; font-size: var(--text-16, 16px); font-weight: 700; }
.motto-block small { color: var(--muted); font-size: var(--text-11, 11px); }

.simulate-dialog {
  width: min(500px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 24px 70px rgba(30,65,88,.2);
}
.simulate-dialog::backdrop { background: rgba(23,43,56,.42); }
.simulate-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.simulate-dialog-header h2 { margin: 4px 0 0; font-size: var(--text-22, 22px); }
.simulate-dialog-copy { margin: 0; padding: 17px 24px; color: var(--muted); background: #f6fafb; line-height: 1.6; }
.simulate-options { display: grid; gap: 10px; padding: 18px 24px 24px; }
.simulate-option { display: grid; gap: 4px; padding: 15px 16px; border: 1px solid var(--line); border-radius: 8px; text-align: left; color: var(--ink); background: #fff; }
.simulate-option:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(30,65,88,.08); }
.simulate-option strong { font-size: var(--text-15, 15px); }
.simulate-option span { color: var(--muted); font-size: var(--text-12, 12px); }
.simulate-option.normal { border-left: 4px solid var(--green); }
.simulate-option.abnormal { border-left: 4px solid var(--red); }
.simulate-option.mixed { border-left: 4px solid var(--amber); }
.advice-panel { margin: 14px 0; padding: 17px 20px; border: 1px solid #d7e8e3; background: #f4fbf9; }
.advice-heading { margin-bottom: 8px; }
.advice-summary-inline { margin: 0 0 6px; color: #315d59; line-height: 1.55; font-weight: 700; }
.advice-sections-inline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.advice-section-inline { min-height: 104px; padding: 9px 14px; border: 0; border-left: 1px solid #d6e9e4; background: transparent; }
.advice-section-inline:first-child { border-left: 0; padding-left: 0; }
.advice-section-inline h3 { margin: 0 0 9px; font-size: var(--text-14, 14px); color: #176e65; }
.advice-section-inline ul { margin: 0; padding-left: 18px; color: #526879; font-size: var(--text-12, 12px); line-height: 1.55; }
.advice-section-inline li + li { margin-top: 5px; }
.advice-placeholder { grid-column: 1 / -1; padding: 18px; color: var(--muted); border: 1px dashed #bfded7; border-radius: 7px; background: rgba(255,255,255,.62); text-align: center; }
.advice-disclaimer-inline { margin: 5px 0 0; color: var(--muted); font-size: var(--text-11, 11px); line-height: 1.5; }
.advice-generated-at { margin: 8px 0 0; color: #6d8c88; font-size: var(--text-11, 11px); }
.advice-cloud-notice { margin: 12px 0; padding: 12px 16px; background: #edf6f2; border-left: 3px solid #268e77; font-size: var(--text-13, 13px); line-height: 1.7; }
.advice-cloud-notice p { margin: 0; overflow-wrap: anywhere; }
.advice-cloud-notice button { margin-top: 6px; }
.advice-panel .section-heading { align-items: center; }
.advice-panel .section-heading h2 { font-size: var(--text-19, 19px); }

.family-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 18px; padding: 24px 26px; border-left: 4px solid var(--blue); background: #eef7fb; }
.family-hero h2 { margin: 5px 0 6px; font-size: var(--text-26, 26px); line-height: 1.4; }
.family-hero p { max-width: 690px; margin: 0; color: var(--muted); line-height: 1.65; }
.family-hero-status { min-width: 170px; display: grid; gap: 5px; justify-items: end; text-align: right; }
.family-hero-status strong { font-size: var(--text-21, 21px); }
.family-hero-status small { color: var(--muted); font-size: var(--text-12, 12px); }
.family-grid { display: grid; grid-template-columns: minmax(280px, 1.1fr) minmax(260px, .9fr) minmax(280px, 1fr); gap: 18px; }
.family-grid .content-section { min-width: 0; }
.family-members, .family-timeline { display: grid; gap: 10px; }
.family-member { width: 100%; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 10px; border: 1px solid #e0ebf0; border-radius: 7px; color: var(--ink); background: #fff; text-align: left; }
.family-member:hover, .family-member.is-selected { border-color: #8fc9c6; background: #f1faf8; }
.family-avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; }
.family-avatar.elder { background: #4da99c; }
.family-avatar.daughter { background: #5f8fc5; }
.family-avatar.son { background: #9c83bd; }
.family-member-copy { min-width: 0; display: grid; gap: 3px; }
.family-member-copy strong { font-size: var(--text-14, 14px); }
.family-member-copy small, .family-member-state { color: var(--muted); font-size: var(--text-11, 11px); }
.family-member-state { white-space: nowrap; }
.family-member-state.online { color: var(--green); font-weight: 700; }
.family-note { margin: 14px 0 0; color: var(--muted); font-size: var(--text-11, 11px); line-height: 1.55; }
.share-setting { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #e7eef2; }
.share-setting-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; color: var(--teal); background: #e5f5f2; font-weight: 700; }
.share-setting div { display: grid; gap: 3px; }
.share-setting strong { font-size: var(--text-13, 13px); }
.share-setting small { color: var(--muted); font-size: var(--text-11, 11px); }
.setting-state { color: var(--muted); font-size: var(--text-11, 11px); white-space: nowrap; }
.setting-state.on { color: var(--green); font-weight: 700; }
.family-settings-button { margin-top: 14px; }
.family-timeline-item { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 11px; align-items: start; padding: 8px 0; }
.timeline-dot { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; }
.timeline-dot.green { background: var(--green); }
.timeline-dot.amber { background: var(--amber); }
.timeline-dot.blue { background: var(--blue); }
.family-timeline-item div { display: grid; gap: 4px; }
.family-timeline-item strong { font-size: var(--text-13, 13px); }
.family-timeline-item small { color: var(--muted); font-size: var(--text-11, 11px); }
.family-summary-section { margin-top: 18px; }
.family-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.family-summary-grid > div { display: grid; gap: 6px; padding: 14px; border: 1px solid #e0ebf0; background: #f8fbfc; }
.family-summary-grid strong { font-size: var(--text-15, 15px); }
.family-summary-grid span { color: var(--muted); font-size: var(--text-12, 12px); line-height: 1.55; }
.family-tools-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.family-task-list, .family-message-list { display: grid; gap: 9px; }
.family-task-item, .family-message-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid #e7eef2; }
.family-task-item:last-child, .family-message-item:last-child { border-bottom: 0; }
.family-task-item > div, .family-message-item { min-width: 0; }
.family-task-item strong, .family-message-item strong { display: block; font-size: var(--text-13, 13px); }
.family-task-copy { display: grid; gap: 4px; }
.family-task-title { display: flex; align-items: center; gap: 7px; min-width: 0; }
.family-task-title strong { overflow-wrap: anywhere; }
.family-task-item small, .family-message-item small { display: flex; flex-wrap: wrap; gap: 5px 12px; margin-top: 1px; color: var(--muted); font-size: var(--text-11, 11px); }
.family-task-item small span + span::before { content: "地点："; color: #8a9aa4; }
.family-task-copy em { color: #81929d; font-size: var(--text-10, 10px); font-style: normal; }
.task-category { flex: 0 0 auto; padding: 3px 6px; border-radius: 999px; color: #287c74; background: #e7f6f3; font-size: var(--text-10, 10px); font-weight: 700; }
.family-message-item { display: block; }
.family-message-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.family-message-heading strong { min-width: 0; overflow-wrap: anywhere; }
.message-delete-button { flex-shrink: 0; color: #a74343; }
.message-delete-button:hover { background: #fff0f0; }
.family-message-actions, .family-message-compose-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.family-message-actions .icon-button { flex-shrink: 0; }
.family-message-compose-actions { justify-content: flex-end; }
.message-play-button[aria-pressed="true"], #familyVoiceInputButton[aria-pressed="true"] { background: #ddf4ed; border-color: #087d77; }
.family-voice-preview, .family-voice-status { margin: 10px 0 0; font-size: var(--text-12, 12px); line-height: 1.6; overflow-wrap: anywhere; }
.family-voice-preview { padding: 8px 10px; background: #eef8f5; color: #175d51; border-left: 3px solid #269d8d; }
.family-voice-status { color: #526879; }
.family-message-item p { overflow-wrap: anywhere; }
.family-message-item p { margin: 5px 0 0; color: #526879; font-size: var(--text-12, 12px); line-height: 1.5; }
.family-message-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }
.family-message-form textarea { min-width: 0; width: 100%; min-height: 76px; line-height: 1.5; resize: vertical; overflow-wrap: anywhere; }
.task-state { color: var(--green); font-size: var(--text-11, 11px); font-weight: 700; white-space: nowrap; }
.task-read-button { white-space: nowrap; }
.task-read-button.is-read { color: var(--green); border-color: #9bcdb9; background: #f0faf5; }
.family-task-actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.task-delete-button { width: 28px; height: 28px; padding: 0; color: #8b6b6b; border-color: #eadede; background: #fffafa; }
.task-delete-button:hover { color: #a64545; border-color: #d8a9a9; background: #fff2f2; }
.observer-selection { margin: 16px 24px 0; padding: 16px; border: 1px solid #cce6e1; border-radius: 9px; background: #f5fcfa; }
.observer-selection-heading { display: grid; gap: 4px; }
.observer-selection-heading h2 { margin: 0; font-size: var(--text-20, 20px); }
.observer-selection-heading p { margin: 2px 0 0; color: var(--muted); font-size: var(--text-12, 12px); line-height: 1.5; }
.observer-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 16px 0 0; }
.observer-groups h3 { margin: 0 0 9px; }
.observer-kind { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: var(--text-12, 12px); }
.elder-kind { color: #0d746b; background: #e7f6f3; }
.family-kind { color: #416d9a; background: #eaf1fa; }
.observer-options { display: grid; gap: 8px; }
.observer-option-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.observer-option { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 9px; align-items: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; text-align: left; }
.observer-option:hover, .observer-option.is-selected { border-color: #8fc9c6; background: #f1faf8; }
.observer-option strong { font-size: var(--text-13, 13px); }
.observer-option small { grid-column: 1 / 2; color: var(--muted); font-size: var(--text-11, 11px); }
.observer-option span { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--teal); font-size: var(--text-11, 11px); font-weight: 700; white-space: nowrap; }
.observer-edit-button { align-self: stretch; padding: 0 9px; border: 1px solid #d4e3ea; border-radius: 6px; color: var(--muted); background: #fff; font-size: var(--text-11, 11px); }
.observer-edit-button:hover { color: var(--teal); border-color: #acd6d0; background: #f4fbfa; }
.family-dialog { width: min(720px, calc(100vw - 28px)); max-height: min(820px, calc(100vh - 28px)); overflow: auto; padding: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; box-shadow: 0 24px 70px rgba(30,65,88,.2); }
.family-dialog::backdrop { background: rgba(23,43,56,.42); }
.family-member-editor { margin: 14px 24px 24px; border-top: 1px solid var(--line); }
.family-member-editor summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0 2px; cursor: pointer; list-style: none; }
.family-member-editor summary::-webkit-details-marker { display: none; }
.family-member-editor summary > span { display: grid; gap: 3px; }
.family-member-editor summary small { color: var(--muted); font-size: var(--text-11, 11px); font-weight: 700; }
.family-member-editor summary strong { color: var(--ink); font-size: var(--text-15, 15px); }
.family-member-editor summary em { color: var(--muted); font-size: var(--text-11, 11px); font-style: normal; text-align: right; }
.family-member-editor summary::after { content: "+"; display: grid; flex: 0 0 auto; place-items: center; width: 24px; height: 24px; border: 1px solid #cbdde3; border-radius: 50%; color: var(--teal); font-size: var(--text-17, 17px); }
.family-member-editor[open] summary::after { content: "−"; }
.family-member-editor-body { padding-top: 14px; }
.family-member-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.family-member-form label { display: grid; gap: 5px; }
.family-member-form label > span { color: var(--muted); font-size: var(--text-12, 12px); font-weight: 700; }
.family-member-form-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 14px; padding-top: 4px; }
.family-editor-note { margin: 12px 0 0; color: var(--muted); font-size: var(--text-11, 11px); line-height: 1.5; }
.family-password-dialog, .register-family-dialog { width: min(520px, calc(100vw - 28px)); }
.change-password-dialog { width: min(520px, calc(100vw - 28px)); }
.password-strength-hint { grid-column: 1 / -1; margin: 0; }
.password-strength-hint.is-valid { color: var(--green); }
.password-strength-hint.is-invalid { color: var(--red); }
.delete-account-dialog { width: min(520px, calc(100vw - 28px)); }
.delete-account-dialog .simulate-dialog-header { padding-top: 30px; }
.delete-account-dialog .simulate-dialog-copy { padding-top: 20px; padding-bottom: 20px; }
.delete-account-dialog form { padding: 22px 26px 30px; }
.family-password-form, .register-family-form { display: grid; gap: 14px; padding: 18px 24px 24px; }
.family-password-form label, .register-family-form label { display: grid; gap: 6px; }
.family-password-form label > span, .register-family-form label > span { color: var(--muted); font-size: var(--text-12, 12px); font-weight: 700; }
.family-password-account { display: grid; gap: 4px; padding: 12px 14px; border: 1px solid #d7e8e3; background: #f4fbf9; }
.family-password-account span, .family-password-account small { color: var(--muted); font-size: var(--text-11, 11px); }
.family-password-account strong { color: #176e65; font-size: var(--text-17, 17px); }
.register-family-form .family-editor-note { grid-column: 1 / -1; margin: 0; }
.family-task-dialog { width: min(560px, calc(100vw - 28px)); }
.family-task-form { display: grid; gap: 14px; padding: 18px 24px 24px; }
.family-task-form label { display: grid; gap: 6px; }
.family-task-form label > span { color: var(--muted); font-size: var(--text-12, 12px); font-weight: 700; }
.family-task-form-grid { display: grid; grid-template-columns: minmax(130px, .8fr) minmax(0, 1.2fr); gap: 12px; }
.family-task-form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.device-source-note { margin: 12px 0 0; color: var(--muted); font-size: var(--text-12, 12px); line-height: 1.55; }
.login-demo-box { display: grid; gap: 4px; margin-top: 16px; padding: 12px 14px; border: 1px solid #d7e8e3; border-radius: 7px; color: #526879; background: #f4fbf9; font-size: var(--text-12, 12px); line-height: 1.45; }
.login-demo-box strong { color: #176e65; }
.login-demo-box small { color: var(--muted); }
.login-register-button { display: block; margin: 14px auto 0; }
.login-form-hint { margin: -2px 0 0; color: var(--muted); font-size: var(--text-11, 11px); line-height: 1.45; }
.advice-actions, .motto-actions { display: flex; align-items: center; gap: 8px; }
.advice-actions select { min-width: 130px; }
.advice-actions button { white-space: normal; overflow-wrap: anywhere; }
.manual-entry-dialog { width: min(620px, calc(100vw - 32px)); }
.manual-entry-form { display: grid; gap: 15px; padding: 18px 24px 24px; }
.manual-entry-form > label { display: grid; gap: 6px; }
.manual-input-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.manual-input-grid label { display: grid; gap: 6px; }
.manual-entry-hint { margin: 0; color: var(--muted); font-size: var(--text-12, 12px); line-height: 1.5; }
.manual-entry-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* The family page is organized around actions first: share/check in, then settings and history. */
#family.view-section { display: none; flex-direction: column; }
#family.view-section.is-active { display: flex; }
#family .family-hero { order: 1; }
#family .family-tools-grid { order: 2; }
#family .family-summary-section { order: 3; }
#family .family-grid { order: 4; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.metric-card { min-height: 132px; padding: 15px 16px; background: #fff; border: 1px solid var(--line); border-top-width: 3px; border-radius: 8px; box-shadow: 0 6px 22px rgba(30,65,88,.04); }
.metric-heart { border-top-color: var(--teal); }
.metric-pressure { border-top-color: var(--blue); }
.metric-oxygen { border-top-color: #28a8c9; }
.metric-temperature { border-top-color: var(--amber); }
.metric-heading { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: var(--text-14, 14px); }
.metric-status { padding: 4px 8px; font-size: var(--text-11, 11px); }
.metric-value { display: flex; align-items: baseline; gap: 7px; margin-top: 14px; }
.metric-value strong { font-size: var(--text-32, 32px); line-height: 1.2; letter-spacing: 0; }
.metric-value span, .metric-card p { color: var(--muted); font-size: var(--text-12, 12px); }
.metric-card p { margin: 13px 0 0; }

.dashboard-columns { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 20px; }
.content-section { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 22px; box-shadow: 0 8px 30px rgba(30,65,88,.035); }
.section-heading { min-height: 43px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { margin: 2px 0 0; font-size: var(--text-20, 20px); }
.text-button { border: 0; padding: 6px 0; color: var(--teal); background: transparent; font-size: var(--text-13, 13px); font-weight: 700; }
.chart-wrap { position: relative; width: 100%; min-height: 250px; }
.chart-wrap.large { min-height: 340px; }
canvas { display: block; width: 100%; height: 100%; }
.empty-overlay { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: rgba(255,255,255,.82); }
.empty-overlay.is-hidden { display: none; }

.compact-list, .alert-list { display: grid; gap: 10px; }
.compact-item, .alert-item { display: grid; gap: 5px; padding: 13px 0; border-bottom: 1px solid #e9f0f4; }
.compact-item:last-child, .alert-item:last-child { border-bottom: 0; }
.compact-item strong, .alert-title strong { font-size: var(--text-14, 14px); }
.compact-item span, .alert-meta { color: var(--muted); font-size: var(--text-12, 12px); }
.empty-state { min-height: 150px; display: grid; place-items: center; color: var(--muted); text-align: center; }

.monitor-toolbar, .filter-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.date-range { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.date-range input { width: 145px; padding: 9px 10px; }
.segmented { display: inline-flex; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.segment { min-height: 36px; padding: 7px 16px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; }
.segment.is-active { color: #fff; background: var(--teal); font-weight: 700; }
#periodSelect { width: 130px; }
.monitor-chart-section { margin-bottom: 20px; }
.latest-number { font-size: var(--text-28, 28px); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid #e7eef2; text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #f8fbfc; font-size: var(--text-12, 12px); }
td { font-size: var(--text-14, 14px); }

.device-layout { display: grid; grid-template-columns: minmax(280px,.8fr) minmax(340px,1.2fr); gap: 20px; margin-bottom: 20px; }
.device-visual { min-height: 420px; display: grid; place-items: center; }
.smart-ring-device { width: min(100%, 280px); display: grid; justify-items: center; gap: 8px; }
.smart-ring { display: block; width: 100%; height: auto; }
.smart-ring-caption { display: grid; gap: 6px; text-align: center; max-width: 100%; overflow-wrap: anywhere; }
.smart-ring-caption strong { font-size: var(--text-22, 22px); }
.smart-ring-caption span { color: var(--teal); font-size: var(--text-13, 13px); }
.definition-list { margin: 0 0 24px; }
.definition-list div { display: grid; grid-template-columns: 120px 1fr; gap: 18px; padding: 14px 0; border-bottom: 1px solid #e7eef2; }
.definition-list dt { color: var(--muted); }
.definition-list dd { margin: 0; font-weight: 700; }
.inline-form { display: grid; grid-template-columns: minmax(170px,.65fr) minmax(220px,1fr) minmax(170px,.65fr) auto; gap: 14px; align-items: end; }
.grow { min-width: 0; }

.alert-item { grid-template-columns: 1fr auto; gap: 16px; padding: 18px 4px; }
.alert-heading-actions { display: flex; align-items: center; gap: 12px; }
.alert-title { display: flex; align-items: center; gap: 10px; }
.level-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); }
.level-dot.level-3 { background: var(--red); }
.alert-action { align-self: center; }
.small-button { min-height: 34px; padding: 6px 12px; border: 1px solid var(--teal); border-radius: 5px; color: var(--teal); background: #fff; font-weight: 700; }
.small-button:disabled { opacity: .45; cursor: not-allowed; }
.alert-bulk-button { white-space: nowrap; }
.processed-label { color: var(--green); font-size: var(--text-13, 13px); font-weight: 700; }
.count-label { color: var(--muted); font-size: var(--text-13, 13px); }
.toast { position: fixed; top: 20px; right: 20px; z-index: 100; max-width: min(360px, calc(100vw - 40px)); padding: 12px 16px; border-radius: 6px; color: #fff; background: #263f52; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(-10px); transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.alert-guidance { margin-top: 5px; color: #8a5a1f; font-size: var(--text-12, 12px); line-height: 1.5; }
.mobile-nav { display: none; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-columns { grid-template-columns: 1fr; }
  .family-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .family-activity-section { grid-column: 1 / -1; }
  .inline-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form .primary-button { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .login-view { width: 100%; min-width: 0; overflow-x: hidden; padding: 20px 12px; }
  .login-panel { width: 100%; max-width: 430px; padding: 30px 22px; }
  .login-brand strong { font-size: var(--text-20, 20px); }
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px 16px 90px; }
  .topbar { align-items: flex-start; gap: 10px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
  .observer-pill { order: -2; }
  .sync-status { order: -1; width: 100%; text-align: right; }
  .topbar-actions .text-icon-button { display: inline-grid; place-items: center; }
  .topbar-actions .status-pill { display: none; }
  .header-action span:last-child, .simulate-launcher span:last-child { display: none; }
  .summary-band { align-items: flex-start; flex-direction: column; }
  .dashboard-overview { grid-template-columns: 112px 1fr; }
  .score-block { display: block; padding: 16px 12px; text-align: center; border-right: 1px solid #cfe7e2; }
  .score-ring { width: 70px; height: 70px; margin: 0 auto 7px; }
  .score-block p { display: none; }
  .score-block > div:last-child strong { font-size: var(--text-14, 14px); }
  .overview-summary { padding: 16px; }
  .overview-summary > strong { font-size: var(--text-14, 14px); }
  .motto-block { grid-column: 1 / -1; padding: 12px 16px; border-top: 1px solid #cfe7e2; border-left: 0; }
  .motto-block p { margin: 3px 0; font-size: var(--text-14, 14px); }
  .advice-sections-inline { display: flex; grid-template-columns: none; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; padding-bottom: 5px; }
  .advice-section-inline { flex: 0 0 78%; min-height: 126px; scroll-snap-align: start; padding: 13px 15px; border: 1px solid #d6e9e4; border-radius: 8px; background: rgba(255,255,255,.7); }
  .advice-section-inline:first-child { padding-left: 15px; border-left: 1px solid #d6e9e4; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 142px; padding: 13px; }
  .metric-value { margin-top: 14px; }
  .metric-value strong { font-size: var(--text-26, 26px); }
  .metric-card p { margin-top: 13px; }
  .device-layout { grid-template-columns: 1fr; }
  .family-hero { align-items: flex-start; flex-direction: column; padding: 20px; }
  .family-hero-status { justify-items: start; text-align: left; }
  .family-grid { grid-template-columns: 1fr; }
  .family-activity-section { grid-column: auto; }
  .family-summary-grid { grid-template-columns: 1fr; }
  .family-tools-grid { grid-template-columns: 1fr; }
  .observer-selection { margin: 14px 18px 0; padding: 14px; }
  .observer-groups { grid-template-columns: 1fr; padding: 14px 0 0; }
  .family-member-editor { margin: 14px 18px 20px; }
  .family-member-editor summary { align-items: flex-start; flex-wrap: wrap; }
  .family-member-editor summary em { flex: 1 1 100%; text-align: left; }
  .family-member-form { grid-template-columns: 1fr; }
  .delete-account-dialog .simulate-dialog-header { padding-top: 24px; }
  .delete-account-dialog form { padding: 20px 18px 24px; }
  .family-member-form-actions { grid-column: auto; }
  .advice-actions { align-items: stretch; flex-direction: column; }
  .advice-actions select { width: 100%; }
  .motto-actions { justify-content: space-between; }
  .device-visual { min-height: 360px; }
  .inline-form { grid-template-columns: 1fr; }
  .manual-input-grid { grid-template-columns: 1fr; }
  .manual-entry-form { padding: 16px 18px 20px; }
  .manual-entry-actions { justify-content: stretch; }
  .manual-entry-actions button { flex: 1; }
  .monitor-toolbar { align-items: stretch; flex-direction: column; }
  .segmented { width: 100%; overflow-x: auto; }
  .segment { flex: 1; min-width: max-content; }
  #periodSelect { width: 100%; }
  .date-range { width: 100%; margin-left: 0; }
  .date-range input { flex: 1; width: auto; }
  .mobile-nav { position: fixed; inset: auto 0 0; z-index: 30; height: 70px; display: grid; grid-template-columns: repeat(5,1fr); border-top: 1px solid var(--line); background: #fff; }
  .mobile-nav-button { border: 0; color: var(--muted); background: #fff; font-size: var(--text-11, 11px); }
  .mobile-nav-button span { display: block; font-size: var(--text-20, 20px); line-height: 1.1; }
  .mobile-nav-button.is-active { color: var(--teal); font-weight: 700; }
  .toast { top: auto; right: 12px; bottom: 82px; }
  .mobile-nav-button[data-view="family"] { color: #176e65; font-weight: 700; }
  .mobile-nav-button[data-view="family"] span { width: 34px; height: 34px; margin: -7px auto 2px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--teal); box-shadow: 0 5px 14px rgba(16,169,155,.25); }
  #family .family-tools-grid { order: 2; }
  #family .family-summary-section { order: 3; }
  #family .family-grid { order: 4; }
}

@media (max-width: 480px) {
  .login-panel { padding: 30px 22px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .topbar h1 { font-size: var(--text-22, 22px); }
  .content-section { padding: 17px; }
  .alert-item { grid-template-columns: 1fr; }
  .alert-action { justify-self: start; }
  .alert-heading-actions { align-items: flex-end; flex-direction: column; gap: 7px; }
  .advice-section-inline { flex-basis: 84%; }
  .family-message-form { grid-template-columns: 1fr; }
  .family-task-form-grid { grid-template-columns: 1fr; }
  .family-task-form { padding: 16px 18px 20px; }
  .observer-option-wrap { grid-template-columns: 1fr; }
  .observer-edit-button { min-height: 32px; }
  .main-content { padding-left: 12px; padding-right: 12px; }
  .dashboard-overview { grid-template-columns: 106px 1fr; }
  .score-ring { width: 64px; height: 64px; }
  .metric-heading { font-size: var(--text-12, 12px); }
  .metric-status { padding: 3px 6px; font-size: var(--text-10, 10px); }
  .metric-value strong { font-size: var(--text-22, 22px); }
  .metric-value span { font-size: var(--text-10, 10px); }
  .metric-card p { font-size: var(--text-10, 10px); line-height: 1.35; }
}

/* Content may grow independently of the viewport, especially in large-text mode. */
body { letter-spacing: 0; }
input, select, button, label, .main-content, .view-section { min-width: 0; }
input, select { max-width: 100%; }
.main-content :is(section, article, aside, header, form) { min-width: 0; }
:is(.topbar, .section-heading, .simulate-dialog-header, .family-hero) > div { min-width: 0; }
:is(p, h1, h2, h3, small, dd, .family-member-copy, .observer-option, .user-mini, .toast) { overflow-wrap: anywhere; }
.sidebar { overflow-y: auto; }
.sidebar-footer { flex-direction: column; align-items: stretch; gap: 14px; margin-top: auto; }
.account-actions { gap: 4px; }
.user-mini > div:last-child { min-width: 0; }
.avatar, .level-dot { flex-shrink: 0; }
.icon-button { flex: 0 0 auto; }
.nav-button { height: auto; min-height: 46px; padding-block: 10px; }
.brand-block > div { min-width: 0; }
.brand-block strong { font-size: var(--text-21, 21px); }
.topbar-actions, .section-heading, .advice-actions, .motto-actions,
.monitor-toolbar, .filter-row, .alert-heading-actions { flex-wrap: wrap; }
.section-heading { align-items: center; }
.advice-actions { margin-left: auto; }
.advice-actions select { width: auto; min-width: 0; max-width: 100%; }
.observer-pill, .sync-status { white-space: normal; overflow-wrap: anywhere; }
.dashboard-overview { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); }
.motto-block { grid-column: 1 / -1; border-left: 0; border-top: 1px solid #cfe7e2; padding: 12px 22px; }
.motto-block p { margin-block: 4px; }
.dashboard-motto { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 6px 16px; margin: 14px 0; padding: 12px 16px; border: 0; background: #eaf7f5; }
.dashboard-motto .motto-actions { margin-left: auto; flex-wrap: wrap; }
.dashboard-motto { margin-top: 0; }
.mobile-account-button { display: none; }
.mobile-account-actions { display: grid; gap: 12px; padding: 0 24px 24px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }
.pagination > span { min-width: 0; text-align: center; font-size: var(--text-13, 13px); overflow-wrap: anywhere; }
.pagination .icon-button { flex: 0 0 auto; display: grid; place-items: center; }
.pagination button:disabled { opacity: .4; cursor: default; }
@media (max-width: 760px) {
  .mobile-account-button { display: inline-grid; place-items: center; }
}
.score-block > div:last-child { min-width: 0; }
.metric-heading, .metric-value { flex-wrap: wrap; }
.metric-card p { line-height: 1.6; }
.family-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.family-task-item { flex-wrap: wrap; align-items: flex-start; }
.family-task-copy { flex: 1 1 220px; }
.family-task-title, .family-task-actions, .family-member-form-actions,
.family-task-form-actions, .manual-entry-actions { flex-wrap: wrap; }
.family-task-actions { max-width: 100%; }
.family-hero-status { min-width: 0; flex-shrink: 0; }
.family-hero { flex-wrap: wrap; }
.family-hero > div:first-child { flex: 1 1 320px; }
.device-layout { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.definition-list div { grid-template-columns: minmax(70px, .65fr) minmax(0, 1fr); gap: 12px; }
.date-range { max-width: 100%; flex-wrap: wrap; }
.date-range input { min-width: 0; flex: 1 1 135px; }
.chart-wrap canvas { max-width: 100%; }
.empty-overlay { padding: 18px; text-align: center; }
.alert-title { align-items: flex-start; }
.level-dot { margin-top: 6px; }
.alert-item { grid-template-columns: minmax(0, 1fr) auto; }
dialog { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.family-dialog { max-height: min(820px, calc(100dvh - 32px)); }
.family-member-form > .family-task-form-actions { grid-column: 1 / -1; }
.simulate-dialog-header .icon-button { flex-shrink: 0; }
.login-panel { max-width: 100%; }

/* All existing type sizes resolve through the same scale, including dialogs. */
body.senior-mode {
  --ink: #122c3d;
  --muted: #536d7c;
  --text-10: 16px;
  --text-11: 16px;
  --text-12: 16px;
  --text-13: 18px;
  --text-14: 20px;
  --text-15: 20px;
  --text-16: 20px;
  --text-17: 22px;
  --text-18: 22px;
  --text-19: 24px;
  --text-20: 24px;
  --text-21: 26px;
  --text-22: 28px;
  --text-23: 30px;
  --text-26: 34px;
  --text-28: 34px;
  --text-30: 36px;
  --text-32: 40px;
  --text-36: 44px;
  --text-38: 44px;
  font-size: 20px;
  line-height: 1.65;
}
body.senior-mode :is(button, input, select) { min-height: 48px; }
body.senior-mode .icon-button { width: 48px; height: 48px; padding: 0; }
body.senior-mode .nav-icon { flex: 0 0 24px; }
body.senior-mode .badge { min-width: 28px; height: 28px; }
body.senior-mode .score-ring { width: 96px; height: 96px; }
body.senior-mode .metric-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr)); }
body.senior-mode .advice-sections-inline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.senior-mode .advice-section-inline { padding: 12px 16px; }
body.senior-mode .advice-section-inline:nth-child(odd) { border-left: 0; padding-left: 0; }
body.senior-mode .family-tools-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
body.senior-mode .family-summary-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
body.senior-mode .family-member { grid-template-columns: 40px minmax(0, 1fr); }
body.senior-mode .family-member-state { grid-column: 2; }
body.senior-mode .share-setting { grid-template-columns: 28px minmax(0, 1fr); }
body.senior-mode .setting-state { grid-column: 2; }
body.senior-mode .observer-groups { grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); }
body.senior-mode .family-task-form-grid { grid-template-columns: 1fr; }
body.senior-mode .family-member-form { grid-template-columns: repeat(auto-fit, minmax(min(100%, 225px), 1fr)); }
body.senior-mode .family-task-item :is(small, em),
body.senior-mode .advice-section-inline ul { line-height: 1.7; }
body.senior-mode .segment { padding-inline: 12px; }

@media (max-width: 1100px) {
  .advice-sections-inline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .advice-section-inline:nth-child(odd) { border-left: 0; }
  body.senior-mode .dashboard-columns { grid-template-columns: minmax(0, 1fr); }
  .monitor-toolbar .date-range { flex-basis: 100%; margin-left: 0; }
  body.senior-mode .dashboard-overview { grid-template-columns: minmax(0, 1fr); }
  body.senior-mode .score-block { border-right: 0; border-bottom: 1px solid #cfe7e2; }
}
@media (max-width: 760px) {
  .mobile-brand { display: flex; align-items: center; flex-basis: 100%; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .mobile-brand img { flex: 0 0 auto; }
  .mobile-brand strong { color: #14675e; font-size: var(--text-18, 18px); white-space: nowrap; }
  .mobile-brand span { margin-left: auto; font-size: var(--text-11, 11px); color: var(--muted); }
  .topbar-actions { width: 100%; }
  .sync-status { order: -1; width: auto; margin-left: auto; }
  #seniorModeButton { margin-left: auto; }
  .topbar-actions::after { content: ""; flex-basis: 100%; order: -1; }
  .dashboard-overview { grid-template-columns: 106px minmax(0, 1fr); }
  .dashboard-columns, .device-layout { grid-template-columns: minmax(0, 1fr); }
  .main-content { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .mobile-nav { height: auto; min-height: 70px; padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav-button { padding: 10px 0; }
  .advice-actions { flex-direction: row; width: 100%; }
  .advice-actions > * { flex: 1 1 155px; }
  .family-hero > div:first-child { flex-basis: auto; }
  .family-hero-status { width: 100%; }
  .alert-item { grid-template-columns: minmax(0, 1fr); }
  .alert-action { justify-self: start; }
  body.senior-mode .main-content { padding-bottom: calc(126px + env(safe-area-inset-bottom)); }
  body.senior-mode .mobile-nav { min-height: 94px; }
  body.senior-mode .mobile-nav-button { font-size: 16px; line-height: 1.4; padding-inline: 0; }
  body.senior-mode .toast { bottom: calc(106px + env(safe-area-inset-bottom)); }
  body.senior-mode .dashboard-overview { grid-template-columns: 116px minmax(0, 1fr); }
  body.senior-mode .score-block { display: block; text-align: center; padding: 14px 8px; border-bottom: 0; border-right: 1px solid #cfe7e2; }
  body.senior-mode .score-ring { width: 88px; height: 88px; margin: 0 auto 8px; }
  body.senior-mode .score-block p { display: none; }
  body.senior-mode .overview-summary { padding: 14px 12px; }
  body.senior-mode .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.senior-mode .metric-card { padding: 14px 12px; }
  body.senior-mode .metric-value { gap: 4px; }
  body.senior-mode .metric-value strong { font-size: 30px; }
  body.senior-mode .metric-heading { font-size: 20px; }
  body.senior-mode .metric-status { font-size: 16px; }
  body.senior-mode .advice-sections-inline { grid-template-columns: minmax(0, 1fr); overflow: visible; }
  body.senior-mode .advice-section-inline { min-height: 0; padding: 14px 0; border: 0; border-top: 1px solid #d6e9e4; border-radius: 0; background: transparent; }
  body.senior-mode .advice-section-inline:first-child { border-left: 0; }
  body.senior-mode .segmented { flex-wrap: wrap; overflow: visible; }
  body.senior-mode .segment { min-width: 0; flex: 1 1 42%; }
  body.senior-mode .family-message-form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 380px) {
  body.senior-mode .dashboard-overview { grid-template-columns: minmax(0, 1fr); }
  body.senior-mode .score-block { display: flex; text-align: left; gap: 12px; border-right: 0; border-bottom: 1px solid #cfe7e2; }
  body.senior-mode .score-ring { margin: 0; }
  body.senior-mode .metric-grid { grid-template-columns: minmax(0, 1fr); }
  .date-range { display: grid; grid-template-columns: minmax(0, 1fr); }
  .date-range input { width: 100%; }
  .mobile-brand { flex-wrap: wrap; }
}

/* Keep both periods together, with the advice panel immediately below. */
.dual-score-overview { grid-template-columns: minmax(300px, .95fr) minmax(0, 1.1fr); }
.score-block.dual-score-block { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 16px; text-align: center; }
.dual-score-block .score-item { min-width: 0; display: flex; flex-direction: column; align-items: center; }
.dual-score-block .score-period { font-size: var(--text-13, 13px); font-weight: 700; color: #315d59; }
.dual-score-block .score-ring { width: 86px; height: 86px; margin: 8px 0 6px; }
.score-block.dual-score-block .score-ring strong { font-size: var(--text-23, 23px); line-height: 1; margin: 0; }
.dual-score-block .score-item .score-period { font-size: var(--text-13, 13px); }
.score-block.dual-score-block .score-ring span { font-size: var(--text-12, 12px); font-weight: 400; }
.dual-score-block .score-item .score-label { margin: 0; font-size: var(--text-13, 13px); }
.dual-score-block .score-item p { display: block; font-size: var(--text-11, 11px); line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.score-disclaimer { margin-top: 9px; color: var(--muted); font-size: var(--text-11, 11px); line-height: 1.5; }
.monitor-range-note { margin: 6px 0 0; color: var(--muted); font-size: var(--text-12, 12px); overflow-wrap: anywhere; }
.monitor-latest { display: flex; flex-direction: column; align-items: flex-end; max-width: 100%; }
.monitor-latest small { color: var(--muted); font-size: var(--text-11, 11px); }
.demo-record-label { display: inline-block; margin-left: 6px; color: #337e76; font-size: var(--text-11, 11px); }
.simulate-range { display: grid; gap: 8px; padding: 16px 24px 0; font-size: var(--text-13, 13px); }
body.senior-mode .score-block.dual-score-block { display: grid; text-align: center; padding: 16px; border-bottom: 0; border-right: 1px solid #cfe7e2; }
body.senior-mode .dual-score-block .score-ring { width: 102px; height: 102px; margin: 8px 0; }
body.senior-mode .dual-score-block .score-ring strong { font-size: 28px; }
body.senior-mode .dual-score-block .score-item p { display: block; margin: 4px 0 0; }
@media (max-width: 1100px) {
  .dashboard-overview.dual-score-overview, body.senior-mode .dashboard-overview.dual-score-overview { grid-template-columns: minmax(0, 1fr); }
  .score-block.dual-score-block, body.senior-mode .score-block.dual-score-block { border-right: 0; border-bottom: 1px solid #cfe7e2; }
  .dual-score-overview .overview-summary { padding: 12px 16px; }
}
@media (max-width: 760px) {
  .dual-score-overview .overview-meta { gap: 4px 12px; margin-top: 6px; }
  .dual-score-overview .overview-summary > span { display: none; }
  .dual-score-overview .overview-summary > strong { margin-top: 0; }
  .dual-score-overview .score-disclaimer { margin-top: 6px; }
  .dual-score-block .score-item p { margin: 4px 0 0; }
  .score-block.dual-score-block, body.senior-mode .score-block.dual-score-block { padding-block: 10px; }
}
@media (max-width: 380px) {
  .score-block.dual-score-block, body.senior-mode .score-block.dual-score-block { padding: 12px 8px; gap: 8px; }
  body.senior-mode .dual-score-block .score-ring { width: 94px; height: 94px; }
}
