:root {
  --ink: #171714;
  --muted: #716d63;
  --paper: #f5f0e7;
  --card: #fffdf8;
  --line: #ddd3c2;
  --gold: #b88932;
  --gold-dark: #8c641f;
  --green: #285b4e;
  --red: #a94b3c;
  --shadow: 0 14px 34px rgba(46, 34, 15, .08);
  --keyboard-inset: 0px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: clip; }
body { background: var(--paper); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif; line-height: 1.5; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(184, 137, 50, .35); outline-offset: 2px; }
[hidden] { display: none !important; }
.boot-overlay { position: fixed; inset: 0; display: grid; place-items: center; background: var(--paper); color: var(--ink); font-size: 15px; font-weight: 700; z-index: 100; }
body.booting > #authPage { visibility: visible; }
body.booting > #app { visibility: hidden; }
body.booting > #bootOverlay { display: none !important; }
body.booting > #bootOverlay button { pointer-events: auto; }

.auth-page { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 28px 16px calc(28px + env(safe-area-inset-bottom)); }
.auth-shell { width: min(900px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); align-items: center; gap: 56px; }
.auth-brand { text-align: center; }
.auth-logo-image { display: block; width: min(250px, 72vw); height: min(250px, 72vw); object-fit: cover; border-radius: 24px; background: #080807; box-shadow: 0 22px 42px rgba(26, 20, 7, .18); margin: 0 auto 20px; }
.wordmark { color: var(--gold-dark); font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 7vw, 56px); letter-spacing: .22em; font-weight: 700; line-height: 1; }
.brand-subtitle { color: var(--ink); font-size: 18px; letter-spacing: .42em; margin: 14px 0 0; }
.auth-brand p { color: var(--muted); margin: 22px 0 0; font-size: 16px; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 30px; }
.auth-card h1 { margin: 0 0 24px; font-size: 28px; }
.auth-card label, .today-card label { display: grid; gap: 8px; color: var(--muted); font-weight: 700; margin: 0 0 18px; }
.auth-card input, .today-card input, .page-heading input { min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); padding: 12px 14px; font-size: 17px; }
.password-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch; }
.password-row input { min-width: 0; }
.field-toggle { min-width: 56px; border: 1px solid var(--line); border-radius: 10px; background: #f6f0e5; color: var(--green); font-size: 13px; font-weight: 800; }
.field-toggle[aria-pressed="true"] { background: #edf5ef; border-color: #a9cbbb; }
.primary { width: 100%; min-height: 48px; border: 0; border-radius: 12px; background: var(--ink); color: #f8e6b8; font-weight: 800; }
.primary:hover { background: #2b2b26; }
.form-message { min-height: 1.5em; margin: 12px 0 0; color: var(--red); font-size: 14px; }
.form-message[data-state="saving"] { color: var(--muted); }
.form-message[data-state="saved"] { color: var(--green); font-weight: 700; }
.form-message[data-state="pending"] { color: var(--gold-dark); font-weight: 700; }
.form-message[data-state="conflict"], .form-message[data-state="error"] { color: var(--red); }
.boot-status { min-height: 1.5em; margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.saved-time { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.retry-save-button { margin-top: 8px; color: var(--red); border-color: #e6b9b0; background: #fff4f1; }
.draft-notice { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--gold-dark); font-size: 13px; }
.draft-notice .small-button { min-height: 32px; padding: 4px 9px; }
.pending-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: 13px; }
.pending-center { flex: 1 0 100%; margin-top: 2px; border-top: 1px solid var(--line); }
.pending-center summary { padding-top: 8px; color: var(--green); cursor: pointer; font-weight: 800; list-style: none; }
.pending-center summary::-webkit-details-marker { display: none; }
.pending-center summary::after { content: '＋'; float: right; font-size: 16px; }
.pending-center[open] summary::after { content: '−'; }
.pending-center-list { display: grid; gap: 6px; margin: 8px 0 2px; }
.pending-center-item { display: flex; justify-content: space-between; gap: 10px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: #faf7f0; color: var(--muted); font-size: 12px; min-width: 0; }
.pending-center-item strong, .pending-center-item em { min-width: 0; overflow-wrap: anywhere; }
.pending-center-item strong { color: var(--ink); }
.pending-center-item em { color: var(--gold-dark); font-style: normal; text-align: right; }
.pending-center-item > div { min-width: 0; display: grid; gap: 2px; }
.pending-retry-button { flex: 0 0 auto; min-height: 32px; padding: 5px 9px; color: var(--green); }
.date-nav { min-width: 40px; padding-inline: 8px; font-size: 22px; line-height: 1; }
.undo-button { width: auto; margin-top: 10px; color: var(--green); background: #edf5ef; }
.warning-outline { color: var(--gold-dark); border-color: #d9b76b; background: #fff8e9; }
.danger-outline { color: var(--red); border-color: #e6b9b0; background: #fff4f1; }
.duplicate-message { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.app { width: min(1050px, 100%); margin: 0 auto; padding: 24px 24px calc(56px + env(safe-area-inset-bottom)); }
.app-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 66px; }
.header-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 52px; height: 52px; border-radius: 14px; overflow: hidden; display: block; flex: 0 0 auto; background: #080807; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.wordmark.small { font-size: 24px; letter-spacing: .14em; }
.brand-subtitle.small { font-size: 11px; letter-spacing: .3em; margin: 6px 0 0; }
.header-actions { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 700; }
.header-more { display: contents; position: relative; }
.header-more > summary { display: none; }
.header-more-panel { display: flex; align-items: center; gap: 12px; }
.current-date-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.current-time-zone { color: var(--muted); font-size: 11px; white-space: nowrap; }
.clock-warning { color: var(--gold-dark); font-size: 11px; white-space: nowrap; }
.date-hint { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.date-sync-status { display: block; min-height: 1.3em; color: var(--green); font-size: 12px; font-weight: 700; }
.timezone-control { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.timezone-control select { min-height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); padding: 6px 8px; font-size: 12px; }
.text-button { border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--ink); padding: 9px 14px; font-weight: 700; }
.top-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 28px 0 24px; }
.top-nav button { min-height: 48px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 253, 248, .65); color: var(--muted); font-weight: 800; }
.top-nav button.active { background: var(--ink); color: #f8e6b8; border-color: var(--ink); }
.top-nav button span { margin-right: 5px; font-size: 18px; font-weight: 500; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 0 0 18px; }
.page-heading h1 { margin: 2px 0 0; font-size: clamp(30px, 5vw, 42px); letter-spacing: -.03em; }
.page-heading input { width: auto; min-width: 145px; }
.heading-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; min-width: 0; }
.history-filter-menu { display: contents; position: relative; }
.history-filter-menu > summary { display: none; }
.history-filter-panel { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.heading-tools input, .heading-tools select { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); padding: 8px 10px; }
.small-button { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #f6f0e5; color: var(--ink); padding: 8px 10px; font-size: 13px; font-weight: 800; }
.sync-status { color: var(--green); border: 1px solid #c8ddd3; border-radius: 999px; background: #edf5ef; padding: 7px 11px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.sync-status.pending { color: var(--gold-dark); border-color: #e3c98e; background: #fff7e7; }
.sync-status.conflict { color: #9a3d32; border-color: #e3aaa2; background: #fff1ee; }
.sync-status.offline { color: var(--red); border-color: #e6b9b0; background: #fff0ed; }
.eyebrow { color: var(--gold-dark); font-size: 11px; font-weight: 800; letter-spacing: .24em; }
.runtime-status { display: inline-block; margin-left: 10px; color: var(--red); font-size: 12px; font-weight: 700; }
.backup-status { display: block; color: var(--muted); font-size: 12px; }
.backup-status[data-status="healthy"] { color: var(--green); }
.backup-status[data-status="warning"] { color: var(--gold-dark); }
.backup-status[data-status="critical"] { color: var(--red); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; margin-bottom: 16px; min-width: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-title h2, .month-note h2 { font-size: 20px; margin: 0; }
.card-title > span { color: var(--muted); font-size: 13px; }
.last-sync-label { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
.last-sync-label.pending { color: var(--gold-dark); }
.last-sync-label.offline { color: var(--red); }
.goal-progress-card { padding: 16px 18px; }
.goal-progress-values { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 8px; }
.goal-progress-values strong { color: var(--ink); font-size: 21px; }
.goal-progress-values span { color: var(--muted); }
.goal-progress-bar { width: 100%; height: 10px; overflow: hidden; border-radius: 999px; background: #e9e2d5; }
.goal-progress-bar > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--green); transition: width .25s ease; }
.goal-progress-bar.stable > span { background: var(--gold); }
.goal-progress-bar.away > span { background: var(--red); }
.goal-progress-bar.achieved > span { background: #2f806c; }
.goal-progress-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 7px; color: var(--muted); font-size: 12px; }
.goal-status { font-weight: 800; }
.goal-status.tracking, .goal-status.achieved { color: var(--green) !important; }
.goal-status.stable { color: var(--gold-dark) !important; }
.goal-status.away { color: var(--red) !important; }
.goal-status.insufficient { color: var(--muted) !important; }
.goal-link { display: inline-flex; min-height: 36px; align-items: center; border: 1px solid #c8ddd3; border-radius: 10px; background: #edf5ef; color: var(--green); padding: 7px 11px; font-size: 13px; font-weight: 800; }
.goal-link:hover { background: #e3efe8; }
.trend-down { color: var(--green) !important; }
.trend-up { color: var(--red) !important; }
.trend-flat { color: var(--muted) !important; }
.state { color: var(--gold-dark) !important; }
.progress-pill { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #f6f0e5; color: var(--green); font-size: 12px; font-weight: 800; }
.weight-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 20px 0 4px; }
.weight-grid label { margin: 0; }
.weight-grid label > span { color: var(--muted); font-size: 14px; }
.weight-grid small { color: var(--gold-dark); font-weight: 800; }
.weight-grid input { font-size: 28px; font-weight: 800; padding: 16px; }
.weight-grid input.suggested { border-color: var(--green); box-shadow: 0 0 0 3px rgba(40, 91, 78, .12); }
.training-check { display: flex !important; align-items: center; gap: 10px !important; color: var(--ink) !important; margin: 16px 0 20px !important; }
.training-check input { width: 20px; height: 20px; accent-color: var(--gold-dark); }
.training-check span { font-weight: 800; }
.training-check em { margin-left: auto; color: var(--muted); font-size: 13px; font-style: normal; font-weight: 500; }
.today-delta { margin: 4px 0 12px; color: var(--muted); font-size: 13px; font-weight: 700; }
.today-delta.positive { color: var(--gold-dark); }
.today-delta.negative { color: var(--green); }
.today-comparison { margin: -4px 0 12px; color: var(--muted); font-size: 13px; }
.today-previous { margin: -4px 0 12px; color: var(--muted); font-size: 13px; }
.today-week-glance { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin: 10px 0 2px; padding: 9px 11px; border: 1px solid #d9e3da; border-radius: 11px; background: #f4f8f3; color: var(--muted); font-size: 12px; }
.today-week-glance strong { margin-left: 3px; color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.today-week-glance strong.trend-down { color: var(--green); }
.today-week-glance strong.trend-up { color: var(--gold-dark); }
.training-week-progress { margin: 2px 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: #faf7f0; }
.training-week-progress > div:first-child { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.training-week-progress b { color: var(--green); }
.training-progress-bar { height: 8px; margin-top: 7px; overflow: hidden; border-radius: 999px; background: #e7e1d5; }
.training-progress-bar > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--green); transition: width .25s ease; }
.save-button { max-width: 260px; bottom: calc(12px + env(safe-area-inset-bottom) + var(--keyboard-inset)); }
.save-button[data-state="saving"] { cursor: wait; opacity: .78; }
.summary-freshness { color: var(--muted); font-size: .78rem; }
.quick-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; color: var(--muted); font-size: 13px; }
.quick-actions .small-button { min-height: 44px; color: var(--green); background: #edf5ef; }
.quick-copy-button { border-color: #a9cbbb; background: #e4f2e8 !important; }
.quick-more { position: relative; }
.quick-more summary { min-height: 44px; display: inline-flex; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #f6f0e5; color: var(--green); cursor: pointer; font-size: 13px; font-weight: 800; list-style: none; }
.quick-more summary::-webkit-details-marker { display: none; }
.quick-more[open] summary { background: #edf5ef; border-color: #c8ddd3; }
.quick-more > div { position: absolute; z-index: 4; right: 0; top: calc(100% + 6px); display: flex; gap: 6px; min-width: max-content; max-width: min(360px, calc(100vw - 48px)); padding: 7px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); box-shadow: var(--shadow); }
.save-error-details { margin-top: 8px; border: 1px solid #e6b9b0; border-radius: 10px; background: #fff4f1; color: var(--red); font-size: 12px; }
.save-error-details summary { padding: 7px 10px; cursor: pointer; font-weight: 800; list-style: none; }
.save-error-details summary::-webkit-details-marker { display: none; }
.save-error-details code { display: block; padding: 0 10px 9px; overflow-wrap: anywhere; white-space: pre-wrap; font: inherit; }
.error-copy-button { display: block; min-height: 36px; margin: 0 10px 10px; color: var(--red); border-color: #e6b9b0; background: #fff; }
.error-copy-button[hidden] { display: none; }
.previous-evening-button { color: var(--green); background: #edf5ef; }
.today-more { margin: 8px 0 14px; border: 1px solid var(--line); border-radius: 11px; background: #faf7f0; }
.today-more summary { min-height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; color: var(--green); cursor: pointer; font-size: 13px; font-weight: 800; list-style: none; }
.today-more summary::-webkit-details-marker { display: none; }
.today-more summary::after { content: '＋'; color: var(--muted); font-size: 17px; line-height: 1; }
.today-more[open] summary::after { content: '−'; }
.today-more .training-week-progress { margin: 0 12px 10px; }
.today-more .today-state-strip { margin: 0 12px 12px; }
.today-state-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0 14px; }
.today-state-strip > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: #faf7f0; color: var(--muted); font-size: 13px; }
.today-state-strip b { color: var(--muted); font-size: 12px; }
.today-state-strip b.done { color: var(--green); }
.system-check-card { padding: 0; overflow: hidden; }
.system-check-card > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding: 14px 22px; cursor: pointer; list-style: none; }
.system-check-card > summary::-webkit-details-marker { display: none; }
.system-check-card > summary::after { content: '＋'; color: var(--muted); font-size: 18px; }
.system-check-card[open] > summary::after { content: '−'; }
.system-check-card > summary strong { color: var(--ink); font-size: 17px; }
.system-check-card > summary span { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 700; }
.system-check-card > summary span[data-status="healthy"] { color: var(--green); }
.system-check-card > summary span[data-status="warning"] { color: var(--gold-dark); }
.system-check-card > summary span[data-status="critical"] { color: var(--red); }
.system-check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 22px 12px; }
.system-check-item { display: grid; gap: 3px; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #faf7f0; }
.system-check-item b { color: var(--ink); font-size: 13px; }
.system-check-item span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.system-check-item[data-status="healthy"] { border-color: #b9d7c6; background: #edf5ef; }
.system-check-item[data-status="healthy"] span { color: var(--green); }
.system-check-item[data-status="warning"] { border-color: #e3c98e; background: #fff7e7; }
.system-check-item[data-status="warning"] span { color: var(--gold-dark); }
.system-check-item[data-status="critical"] { border-color: #e6b9b0; background: #fff0ed; }
.system-check-item[data-status="critical"] span { color: var(--red); }
.system-check-actions { display: flex; align-items: center; gap: 10px; padding: 0 22px 16px; }
.system-check-actions .summary-hint { margin: 0; }
.record-list { display: grid; gap: 8px; margin-top: 14px; }
.history-month-group { border-top: 1px solid #eee7dc; padding-top: 8px; }
.history-month-group:first-child { border-top: 0; padding-top: 0; }
.history-month-group > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; cursor: pointer; list-style: none; }
.history-month-group > summary::-webkit-details-marker { display: none; }
.history-month-group > summary::after { content: '＋'; color: var(--muted); font-size: 17px; }
.history-month-group[open] > summary::after { content: '−'; }
.history-month-group h3 { color: var(--gold-dark); font-size: 14px; margin: 6px 0; letter-spacing: .06em; }
.history-month-group > summary > span { color: var(--muted); font-size: 12px; }
.history-month-records { display: grid; gap: 8px; }
.history-count, .history-search-status { color: var(--muted); font-size: 13px; }
.history-search-status { font-weight: 700; }
.history-date-jump { min-width: 0; }
.summary-more { padding: 0; overflow: hidden; }
.summary-more > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 15px 22px; cursor: pointer; list-style: none; }
.summary-more > summary::-webkit-details-marker { display: none; }
.summary-more > summary::after { content: '＋'; color: var(--muted); font-size: 18px; }
.summary-more[open] > summary::after { content: '−'; }
.summary-more > summary strong { color: var(--ink); font-size: 17px; }
.summary-more > summary span { margin-left: auto; color: var(--muted); font-size: 12px; }
.summary-more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 0 22px 22px; }
.summary-more-item { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #faf7f0; }
.summary-more-item .card-title h2 { font-size: 17px; }
.secondary-button { width: 100%; min-height: 44px; margin-top: 14px; border: 1px solid var(--line); border-radius: 11px; background: #f6f0e5; color: var(--ink); font-weight: 800; }
.record-row { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid #eee7dc; }
.record-row:first-child { border-top: 0; }
.record-date { color: var(--muted); font-size: 13px; }
.record-values { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.record-values strong { font-size: 18px; }
.record-values span { color: var(--muted); font-size: 14px; }
.training-badge { color: var(--green) !important; font-weight: 800; }
.pending-badge { color: var(--gold-dark) !important; font-weight: 800; }
.empty { color: var(--muted); padding: 16px 0 2px; }

.summary-period { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--muted); }
.summary-period strong { color: var(--ink); font-size: 20px; }
.summary-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: -2px 0 16px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #f6f0e5; }
.summary-switch button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 800; }
.summary-switch button.active { background: var(--ink); color: #f8e6b8; }
.summary-hint { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.target-strip { display: flex; align-items: center; gap: 10px; margin: -4px 0 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 253, 248, .75); }
.target-strip label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 700; font-size: 14px; }
.target-strip input { width: 92px; min-height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; background: #fff; color: var(--ink); }
.target-strip select { min-height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; background: #fff; color: var(--ink); }
.target-strip #targetMessage { color: var(--muted); font-size: 13px; }
.target-strip span { color: var(--muted); font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.metric-grid article { background: #f6f0e5; border: 1px solid #eadfce; border-radius: 13px; padding: 15px; min-width: 0; }
.metric-grid span, .metric-grid small { display: block; color: var(--muted); font-size: 13px; }
.metric-grid b { display: block; margin: 4px 0; font-size: 26px; letter-spacing: -.03em; }
.metric-grid small { color: var(--gold-dark); }
.compare-row { display: grid; grid-template-columns: 90px 110px minmax(0, 1fr); gap: 12px; align-items: baseline; border-top: 1px solid #eee7dc; padding: 14px 0 0; margin-top: 14px; }
.compare-row:first-of-type { border-top: 0; padding-top: 0; margin-top: 4px; }
.compare-row span, .compare-row em { color: var(--muted); font-style: normal; }
.compare-row strong { color: var(--ink); font-size: 20px; }
.week-rows { display: grid; gap: 8px; margin-top: 12px; }
.week-row { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 12px; align-items: center; border-top: 1px solid #eee7dc; padding-top: 10px; }
.week-row:first-child { border-top: 0; }
.week-row.missing-row { opacity: .72; }
.missing-label { color: var(--muted); font-size: 14px; }
.week-row time { color: var(--muted); font-size: 13px; }
.week-line { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.week-line strong { font-size: 17px; }
.week-line span { color: var(--muted); font-size: 14px; }
.month-note p { color: var(--muted); margin: 8px 0 0; }
.weekly-reminder-toggle { display: inline-flex; align-items: center; gap: 7px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.weekly-reminder-toggle input { accent-color: var(--green); }
.chart-point { cursor: pointer; }
.chart-point:hover { stroke: var(--ink); stroke-width: 2; }
.chart-summary { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.year-chart { width: 100%; height: 230px; margin-top: 14px; border-radius: 12px; background: linear-gradient(to bottom, rgba(246,240,229,.75), rgba(255,253,248,.2)); overflow: hidden; }
.year-chart svg { display: block; width: 100%; height: 100%; }
.year-chart-labels { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; color: var(--muted); font-size: 11px; text-align: center; margin-top: 5px; }
.mobile-chart-details > summary { display: none; }
.mobile-chart-panel { display: block; }
.mobile-chart-details:not([open]) .mobile-chart-panel { display: block; }
.mobile-summary-detail > summary { display: none; }
.mobile-summary-detail-panel { display: block; }
.mobile-summary-detail:not([open]) .mobile-summary-detail-panel { display: block; }
.month-chart-labels { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.week-chart { height: 210px; background: #faf7f0; }
.week-chart svg { height: calc(100% - 25px); }
.week-chart-labels { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekly-conclusion { margin: 16px 0 0; padding: 12px 14px; border-radius: 12px; background: #edf5ef; color: var(--green); font-weight: 800; }
.weekly-conclusion.down { background: #e4f2e8; }
.weekly-conclusion.up { background: #fff3e5; color: var(--gold-dark); }
.calendar-tools { display: inline-flex; align-items: center; gap: 8px; }
.calendar-tools .small-button { min-width: 44px; min-height: 44px; padding: 5px 9px; }
.calendar-tools strong { min-width: 84px; text-align: center; color: var(--ink); font-size: 14px; }
.record-calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.calendar-weekday { color: var(--muted); font-size: 12px; text-align: center; padding: 4px 0; }
.calendar-day { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #faf7f0; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px; }
button.calendar-day { cursor: pointer; }
.calendar-day b { font-size: 14px; color: var(--ink); }
.calendar-day i { min-height: 12px; color: var(--green); font-size: 10px; font-style: normal; }
.calendar-day.has-record { border-color: #a9cbbb; background: #edf5ef; }
.calendar-day.complete { background: #dcefe3; }
.calendar-day.trained b { color: var(--green); }
.calendar-day.today { outline: 2px solid var(--gold); outline-offset: -2px; }
.empty-day { border-color: transparent; background: transparent; }
.offline-readonly-notice { margin-bottom: 14px; padding: 11px 14px; border: 1px solid #e3c98e; border-radius: 12px; background: #fff7e7; color: var(--gold-dark); font-size: 13px; font-weight: 700; }
.offline-view-button { grid-column: 1 / -1; width: min(360px, 100%); min-height: 44px; margin: 14px auto 0; border: 1px solid var(--line); border-radius: 12px; background: #edf5ef; color: var(--green); font-weight: 800; }
.offline-readonly #saveRecordBtn, .offline-readonly #undoSaveBtn, .offline-readonly #retrySaveBtn, .offline-readonly #recordGoalBtn, .offline-readonly #saveTargetBtn, .offline-readonly #resetTargetProgressBtn { display: none; }
.chart-legend { display: flex; gap: 14px; align-items: center; padding: 0 10px 8px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 4px; }
.chart-legend i { width: 9px; height: 3px; display: inline-block; border-radius: 2px; background: var(--green); }
.chart-legend .legend-evening { background: var(--ink); opacity: .62; }
.chart-legend .legend-target { background: var(--gold-dark); border-top: 1px dashed var(--gold-dark); }
.streak-card { margin-bottom: 0; }
.year-row { grid-template-columns: 70px minmax(0, 1fr) auto; }
.year-row .record-values { justify-content: flex-start; }
.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom) + var(--keyboard-inset)); transform: translate(-50%, 20px); background: var(--ink); color: #f8e6b8; border-radius: 999px; padding: 10px 18px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.privacy-blurred #app { filter: blur(18px); transition: filter .15s ease; }
body.large-text { font-size: 112.5%; }
body.large-text .page-heading h1 { font-size: clamp(32px, 5.2vw, 46px); }
body.large-text .record-values strong, body.large-text .metric-grid b { font-size: 1.12em; }
.update-banner { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; width: min(520px, calc(100vw - 32px)); padding: 10px 12px 10px 16px; border: 1px solid var(--gold); border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: 0 12px 28px rgba(23, 28, 25, .14); z-index: 20; }
.update-banner span { flex: 1; font-size: 13px; }
.boot-fallback { display: block; margin: 14px auto 0; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf8; color: var(--green); padding: 8px 12px; font-weight: 800; }
.minimal-mode #todayGoalCard, .minimal-mode #summaryPage .quality-card, .minimal-mode #summaryPage .training-compare-card, .minimal-mode #summaryPage .target-forecast-card, .minimal-mode #summaryPage .streak-card, .minimal-mode .today-more { display: none !important; }
#minimalModeBtn[aria-pressed="true"] { background: var(--green); color: #fff; border-color: var(--green); }
.nav-icon { width: 17px; height: 17px; margin-right: 5px; vertical-align: -3px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.quality-card { border-color: #d9e3da; }
.quality-card .card-title > span { color: var(--muted); font-size: 13px; text-align: right; }
.training-compare-card, .target-forecast-card { margin-bottom: 16px; }
.target-forecast-card .goal-progress-bar { margin-top: 14px; }

body.high-contrast { --ink: #08120f; --muted: #243a32; --paper: #fff; --card: #fff; --line: #49675b; --gold-dark: #754b00; --green: #075d4c; --red: #9d2018; --shadow: 0 8px 20px rgba(0,0,0,.12); }
body.high-contrast .top-nav button, body.high-contrast .summary-switch, body.high-contrast .small-button, body.high-contrast .training-week-progress { background: #fff; }
body.high-contrast .top-nav button.active, body.high-contrast .summary-switch button.active, body.high-contrast .primary { background: #08120f; color: #fff; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
body.low-data .year-chart, body.low-data .year-chart-labels, body.low-data .export-image-btn { display: none !important; }
body.low-data .chart-summary { margin-top: 0; }

@media (max-width: 760px) {
  .auth-shell { grid-template-columns: 1fr; gap: 22px; max-width: 430px; }
  .auth-page { padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); }
  .auth-shell { gap: 16px; }
  .auth-logo-image { width: 112px; height: 112px; border-radius: 16px; margin-bottom: 10px; }
  .auth-card { padding: 20px; }
  .auth-brand p { margin-top: 10px; }
  .header-actions { position: relative; flex: 1 1 auto; min-width: 0; max-width: none; gap: 7px; }
  .header-actions .current-time-zone { display: none; }
  .header-more { display: block; position: relative; flex: 0 0 auto; }
  .header-more > summary { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: #f6f0e5; color: var(--green); cursor: pointer; font-size: 13px; font-weight: 800; list-style: none; }
  .header-more > summary::-webkit-details-marker { display: none; }
  .header-more[open] > summary { background: #edf5ef; border-color: #c8ddd3; }
  .header-more-panel { position: absolute; z-index: 8; top: calc(100% + 6px); right: 0; display: none; flex-direction: column; align-items: stretch; gap: 5px; width: min(210px, calc(100vw - 32px)); padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
  .header-more[open] .header-more-panel { display: flex; }
  .header-more-panel .text-button { width: 100%; min-height: 44px; text-align: left; }
  .app { padding: 16px 16px calc(48px + env(safe-area-inset-bottom)); }
  .app-header { min-height: 58px; }
  .brand-mark { width: 44px; height: 44px; }
  .wordmark.small { font-size: 21px; }
  .header-actions { font-size: 12px; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: 62%; }
  .current-date-time { font-size: 11px; }
  .clock-warning { flex: 1 0 100%; text-align: right; }
  .top-nav { margin: 18px 0 18px; }
  .top-nav { gap: 5px; }
  .top-nav button { min-height: 46px; font-size: 13px; padding: 0 4px; }
  .page-heading { align-items: start; flex-direction: column; gap: 10px; }
  .page-heading input { width: 100%; }
  .timezone-control { width: 100%; justify-content: space-between; }
  .timezone-control select { flex: 1; min-width: 0; }
  .heading-tools { width: 100%; justify-content: stretch; }
  .history-tools { position: relative; align-items: center; }
  .history-filter-menu { display: block; position: relative; flex: 1 1 100%; }
  .history-filter-menu > summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f6f0e5; color: var(--green); cursor: pointer; font-size: 13px; font-weight: 800; list-style: none; }
  .history-filter-menu > summary::-webkit-details-marker { display: none; }
  .history-filter-menu > summary::after { content: '＋'; color: var(--muted); font-size: 17px; }
  .history-filter-menu[open] > summary { background: #edf5ef; border-color: #c8ddd3; }
  .history-filter-menu[open] > summary::after { content: '−'; }
  .history-filter-panel { position: absolute; z-index: 7; top: calc(100% + 6px); right: 0; display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(360px, calc(100vw - 32px)); padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
  .history-filter-menu[open] .history-filter-panel { display: grid; }
  .history-filter-panel input, .history-filter-panel select, .history-filter-panel .small-button { width: 100%; min-width: 0; }
  .history-filter-panel input[type="search"], .history-filter-panel button[id="clearHistorySearchBtn"] { grid-column: 1 / -1; }
  .history-filter-panel input[type="file"] { display: none; }
  .heading-tools input { width: auto; }
  .heading-tools input, .heading-tools select { flex: 1 1 120px; min-width: 0; }
  .heading-tools .small-button { flex: 1 1 90px; }
  .heading-tools .date-nav { flex: 0 0 44px; }
  .heading-tools select { min-width: 0; }
  .history-search-status { flex: 1 0 100%; min-height: 1.3em; }
  .system-check-card > summary { padding-inline: 18px; }
  .system-check-grid { grid-template-columns: 1fr; padding-inline: 18px; }
  .system-check-actions { padding-inline: 18px; }
  .target-strip { flex-wrap: wrap; }
  .target-strip label { flex: 1 1 160px; }
  .target-strip .small-button { flex: 0 0 auto; }
  .target-strip span { flex: 1 0 100%; }
  .card { padding: 18px; border-radius: 16px; }
  .today-more summary { min-height: 44px; }
  .goal-progress-card { padding: 15px 16px; }
  .goal-progress-meta { align-items: flex-start; flex-direction: column; gap: 2px; }
  .weight-grid, .metric-grid { grid-template-columns: 1fr; }
  .today-state-strip { grid-template-columns: 1fr; }
  .quick-actions { align-items: stretch; }
  .quick-actions .small-button { flex: 1 1 90px; }
  .quick-copy-button { flex-basis: 100%; }
  .quick-more > div { min-width: 0; flex-wrap: wrap; }
  .weight-grid input { font-size: 25px; }
  .weight-grid input { min-height: 58px; }
  .save-button { max-width: none; min-height: 52px; }
  .save-button { width: 100%; }
  .save-button { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom) + var(--keyboard-inset)); z-index: 3; box-shadow: 0 8px 18px rgba(23, 23, 20, .16); }
  .today-card input { scroll-margin-bottom: calc(110px + env(safe-area-inset-bottom) + var(--keyboard-inset)); }
  .summary-freshness { display: block; width: 100%; margin-top: 4px; }
  .summary-more-grid { grid-template-columns: 1fr; padding: 0 18px 18px; }
  .summary-more > summary { padding-inline: 18px; }
  .mobile-chart-details { padding: 0; overflow: hidden; }
  .mobile-chart-details > summary { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 14px 18px; color: var(--ink); cursor: pointer; list-style: none; }
  .mobile-chart-details > summary::-webkit-details-marker { display: none; }
  .mobile-chart-details > summary::after { content: '＋'; color: var(--muted); font-size: 18px; }
  .mobile-chart-details[open] > summary::after { content: '−'; }
  .mobile-chart-details > summary span { color: var(--muted); font-size: 12px; font-weight: 700; }
  .mobile-chart-details:not([open]) .mobile-chart-panel { display: none; }
  .mobile-chart-panel { padding: 0 18px 18px; }
  .mobile-summary-detail { padding: 0; overflow: hidden; }
  .mobile-summary-detail > summary { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 14px 18px; color: var(--ink); cursor: pointer; list-style: none; }
  .mobile-summary-detail > summary::-webkit-details-marker { display: none; }
  .mobile-summary-detail > summary::after { content: '＋'; color: var(--muted); font-size: 18px; }
  .mobile-summary-detail[open] > summary::after { content: '−'; }
  .mobile-summary-detail > summary span { color: var(--muted); font-size: 12px; font-weight: 700; }
  .mobile-summary-detail:not([open]) .mobile-summary-detail-panel { display: none; }
  .mobile-summary-detail-panel { padding: 0 18px 18px; }
  .record-row { grid-template-columns: 74px minmax(0, 1fr); }
  .record-row > .record-date { grid-row: span 2; }
  .record-row > .record-actions { grid-column: 2; }
  .compare-row { grid-template-columns: 78px 90px minmax(0, 1fr); gap: 8px; font-size: 13px; }
  .week-row { grid-template-columns: 72px minmax(0, 1fr); }
  .summary-switch { margin-top: -4px; }
  .record-calendar { gap: 4px; }
  .calendar-day { min-height: 38px; border-radius: 8px; }
  .pending-center-item { align-items: stretch; flex-direction: column; gap: 6px; }
  .pending-center-item em { text-align: left; }
  .pending-retry-button { width: 100%; }
  body.keyboard-open .toast { bottom: calc(78px + env(safe-area-inset-bottom) + var(--keyboard-inset)); }
  body.keyboard-open .auth-page { place-items: start center; padding-top: 12px; }
  body.keyboard-open .auth-brand { display: none; }
  body.keyboard-open .auth-shell { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; } }


