:root {
  --ink: #17332f;
  --muted: #73827f;
  --paper: #f4f1e9;
  --card: #fffdf8;
  --line: #dedbd2;
  --green: #1d5d52;
  --green-2: #2f8071;
  --mint: #dcebe4;
  --amber: #d78e43;
  --amber-soft: #f5e5c9;
  --rose: #bd645d;
  --shadow: 0 18px 45px rgba(35, 57, 52, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 82% 0%, rgba(213,231,221,.8), transparent 28rem), var(--paper); }
button, input, select, textarea { font: inherit; }
button, label, select, input[type="range"] { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.app-shell { width: min(1180px, 100%); margin: 0 auto; padding: 0 28px 120px; }
.topbar { height: 88px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px 14px 14px 4px; color: #fff; background: var(--ink); font-family: Georgia, serif; font-size: 21px; box-shadow: 0 8px 20px rgba(23,51,47,.16); }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, "Songti SC", serif; font-size: 20px; letter-spacing: .12em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.privacy-pill { display: flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid rgba(29,93,82,.16); border-radius: 999px; color: var(--green); background: rgba(255,253,248,.62); font-size: 12px; }
.privacy-pill span { color: #75ab77; font-size: 8px; }
.privacy-pill b { font-size: 11px; }
.sync-pill { cursor: pointer; transition: .2s ease; }
.sync-pill:hover { border-color: var(--green-2); background: #fffdf8; transform: translateY(-1px); }
.sync-pill.syncing #sync-dot { color: var(--amber); }
.sync-pill.synced #sync-dot { color: #4f9a68; }
.sync-pill.offline #sync-dot { color: #a5aaa7; }

.view { animation: rise .3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.hero-row { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin: 24px 0 26px; }
.eyebrow { margin: 0 0 5px; color: var(--green-2); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-family: Georgia, "Songti SC", serif; font-size: clamp(30px, 4vw, 48px); font-weight: 600; letter-spacing: -.03em; }
h2 { margin-bottom: 0; font-family: Georgia, "Songti SC", serif; font-size: 21px; font-weight: 600; }
.subtle { margin-bottom: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.date-nav, .month-nav { display: flex; align-items: center; gap: 9px; }
.month-nav strong { min-width: 110px; text-align: center; }
.icon-button, .text-button { height: 42px; border: 1px solid var(--line); background: rgba(255,253,248,.72); cursor: pointer; transition: .2s ease; }
.icon-button { width: 42px; border-radius: 50%; }
.text-button { padding: 0 17px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.icon-button:hover, .text-button:hover { border-color: var(--green-2); transform: translateY(-1px); }

.card { margin-bottom: 18px; padding: 26px; border: 1px solid rgba(117,126,121,.18); border-radius: 22px; background: rgba(255,253,248,.94); box-shadow: var(--shadow); }
.card-heading { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 14px; margin-bottom: 24px; }
.card-heading.compact { margin-bottom: 20px; }
.section-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 16px; font-size: 21px; }
.moon { color: #4d6586; background: #e6ebf1; }
.sun { color: #b57825; background: var(--amber-soft); }
.energy { color: var(--green); background: var(--mint); }
.factors { color: #795c82; background: #eee6ef; }
.insight { color: #9a652d; background: var(--amber-soft); }
.mood { color: #496f99; background: #dfebf7; }
.metric-badge { padding: 9px 13px; border-radius: 12px; color: #4d6586; background: #e8edf2; font-size: 13px; font-weight: 800; }
.metric-badge.warm { color: #9a652d; background: var(--amber-soft); }

.field-grid { display: grid; gap: 14px; }
.field-grid.four { grid-template-columns: repeat(4, 1fr); }
.field-grid.three { grid-template-columns: repeat(3, 1fr); }
.field-grid label, .full-label { position: relative; color: var(--muted); font-size: 12px; font-weight: 700; }
input[type="time"], input[type="number"], input[type="text"], select, textarea { width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #faf9f5; outline: none; transition: .2s ease; }
input[type="time"], input[type="number"], select { height: 48px; padding: 0 13px; }
input[type="text"] { height: 43px; padding: 0 13px; }
textarea { padding: 12px 13px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(47,128,113,.1); }
.field-unit { position: absolute; right: 12px; bottom: 16px; color: var(--muted); font-size: 11px; pointer-events: none; }
.choice-field { margin: 20px 0 0; padding: 0; border: 0; }
.choice-field legend { margin-bottom: 9px; color: var(--muted); font-size: 12px; font-weight: 700; }
.segmented { display: grid; gap: 8px; }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented label input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label span, .segmented button { display: grid; place-items: center; min-height: 43px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 12px; background: #faf9f5; cursor: pointer; font-size: 13px; font-weight: 700; transition: .2s ease; }
.segmented label input:checked + span { color: #fff; border-color: var(--green); background: var(--green); box-shadow: 0 8px 18px rgba(29,93,82,.18); }

.switch { display: inline-flex; justify-self: end; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: relative; width: 44px; height: 24px; border-radius: 999px; background: #d4d6d1; transition: .2s ease; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.16); transition: .2s ease; }
.switch input:checked + span { background: var(--green-2); }
.switch input:checked + span::after { transform: translateX(20px); }
#nap-fields.disabled { opacity: .35; pointer-events: none; filter: grayscale(.5); }

.anchor-note { margin: -8px 0 14px; padding: 10px 13px; border-radius: 11px; color: #697a76; background: #f2f3ed; font-size: 11px; line-height: 1.5; }
.energy-list { display: grid; }
.energy-row { display: grid; grid-template-columns: 90px minmax(250px, 1fr) 64px minmax(180px, .7fr); gap: 16px; align-items: center; padding: 18px 0; border-top: 1px solid #ebe8e0; }
.energy-row:first-child { border-top: 0; padding-top: 0; }
.energy-row:last-child { padding-bottom: 0; }
.period strong, .period span { display: block; }
.period strong { font-family: Georgia, "Songti SC", serif; font-size: 17px; }
.period span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.state-select select { height: 48px; margin: 0; color: var(--ink); font-weight: 700; }
.score-output { display: grid; place-items: center; width: 60px; height: 48px; border-radius: 15px; color: var(--green); background: var(--mint); font-family: Georgia, "Songti SC", serif; font-size: 18px; font-weight: 700; }
.score-output.empty { color: var(--muted); background: #eeece6; }
.note-input { margin: 0 !important; }
.factor-grid { align-items: end; }
.check-line { display: flex; align-items: center; gap: 10px; min-height: 48px; margin-top: 19px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: #faf9f5; cursor: pointer; }
.check-line input { width: 17px; height: 17px; accent-color: var(--green); }
.full-label { display: block; margin-top: 18px; }
.quick-entry-grid { display: grid; grid-template-columns: 120px minmax(230px, 1.1fr) minmax(220px, 1fr) auto; gap: 12px; align-items: end; }
.quick-entry-grid label { color: var(--muted); font-size: 12px; font-weight: 700; }
.quick-entry-grid input, .quick-entry-grid select { margin-top: 8px; }
.quick-add { min-width: 132px; height: 48px; justify-content: center; }
.context-field { margin: 18px 0 0; padding: 0; border: 0; }
.context-field legend { margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.context-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.context-chips label input { position: absolute; opacity: 0; pointer-events: none; }
.context-chips label span { display: block; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #faf9f5; cursor: pointer; font-size: 11px; font-weight: 700; transition: .2s ease; }
.context-chips label input:checked + span { color: #fff; border-color: var(--green); background: var(--green); }
.event-option-row { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 19px; padding: 15px 16px; border: 1px solid var(--line); border-radius: 15px; background: #f8f6f0; }
.event-option-row strong, .event-option-row small, .event-panel-heading strong, .event-panel-heading small { display: block; }
.event-option-row strong, .event-panel-heading strong { font-size: 12px; }
.event-option-row small, .event-panel-heading small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.event-toggle { flex: 0 0 auto; min-width: 126px; }
.event-toggle span { margin-right: 4px; font-size: 16px; }
.event-entry-panel { margin-top: 10px; padding: 17px; border: 1px solid rgba(117,126,121,.22); border-radius: 16px; background: #fffdf8; }
.event-entry-panel[hidden] { display: none; }
.event-panel-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }
.section-icon.mini { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 11px; font-size: 14px; }
.timeline-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 22px; padding-top: 18px; border-top: 1px solid #ebe8e0; }
.timeline-heading strong { font-size: 13px; }
.timeline-heading span { color: var(--muted); font-size: 10px; }
.timeline-list { display: grid; gap: 8px; margin-top: 18px; }
.timeline-empty { padding: 18px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); background: #faf9f5; text-align: center; font-size: 11px; }
.timeline-item { display: grid; grid-template-columns: 62px 58px 1fr auto; gap: 12px; align-items: center; padding: 11px 13px; border-radius: 13px; background: #f5f3ec; }
.timeline-item.event-item { grid-template-columns: 62px 90px 1fr auto; }
.timeline-item.event-item { background: #f8f3e8; }
.timeline-item time { color: var(--ink); font-family: Georgia, serif; font-size: 15px; font-weight: 700; }
.timeline-score { display: grid; place-items: center; min-height: 34px; border-radius: 10px; color: var(--green); background: var(--mint); font-size: 12px; font-weight: 800; }
.timeline-copy strong, .timeline-copy small { display: block; }
.timeline-copy strong { font-size: 12px; }
.timeline-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.delete-mini { width: 31px; height: 31px; border: 0; border-radius: 9px; color: var(--muted); background: #e8e6df; cursor: pointer; }
.event-badge { display: inline-grid; place-items: center; min-height: 30px; padding: 0 8px; border-radius: 9px; color: #705a3d; background: var(--amber-soft); font-size: 10px; font-weight: 800; }
.peak-list { display: grid; gap: 10px; }
.peak-item { display: grid; grid-template-columns: 44px 1fr auto; gap: 11px; align-items: center; padding: 13px; border-radius: 13px; background: #f5f3ec; }
.peak-rank { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: var(--green); background: var(--mint); font-family: Georgia, serif; font-weight: 800; }
.peak-item.low .peak-rank { color: #984b45; background: #f4d8d4; }
.peak-item strong, .peak-item small { display: block; }
.peak-item small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.peak-value { font-family: Georgia, serif; font-size: 19px; font-weight: 800; }
.energy-heatmap { overflow-x: auto; }
.heatmap-grid { display: grid; grid-template-columns: 42px repeat(12, minmax(58px, 1fr)); gap: 5px; min-width: 900px; }
.heatmap-label { display: grid; place-items: center; min-height: 34px; color: var(--muted); font-size: 9px; font-weight: 700; }
.heatmap-cell { display: grid; place-items: center; min-height: 42px; border-radius: 9px; color: var(--ink); background: #ecebe5; font-size: 10px; font-weight: 800; }
.heatmap-cell.empty { color: #a9afad; background: #f1f0eb; }
.factor-analysis { display: grid; gap: 10px; }
.factor-row { display: grid; grid-template-columns: 110px 1fr 82px; gap: 14px; align-items: center; }
.factor-row strong { font-size: 12px; }
.effect-track { height: 10px; border-radius: 999px; background: linear-gradient(90deg, #f1d4d0 0 49%, #e4e4de 49% 51%, #d8e9e1 51% 100%); overflow: hidden; }
.effect-marker { position: relative; width: 8px; height: 18px; margin-top: -4px; border-radius: 5px; background: var(--ink); transform: translateX(-50%); }
.effect-copy { text-align: right; }
.effect-copy b, .effect-copy small { display: block; }
.effect-copy b { font-family: Georgia, serif; }
.effect-copy small { color: var(--muted); font-size: 9px; }

.form-footer { position: sticky; bottom: 78px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 22px 0; padding: 13px 15px 13px 20px; border: 1px solid rgba(29,93,82,.18); border-radius: 20px; background: rgba(245,242,233,.9); backdrop-filter: blur(14px); box-shadow: 0 14px 40px rgba(23,51,47,.12); }
.completion { display: flex; align-items: center; gap: 12px; }
#completion-ring { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; color: var(--green); background: conic-gradient(var(--green-2) 0deg, #d8ddd8 0deg); font-size: 11px; font-weight: 800; }
.completion strong, .completion small { display: block; }
.completion strong { font-size: 13px; }
.completion small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.primary-button, .secondary-button, .danger-button { min-height: 44px; border-radius: 13px; cursor: pointer; font-weight: 800; transition: .2s ease; }
.primary-button { display: flex; align-items: center; gap: 28px; padding: 0 10px 0 20px; border: 0; color: #fff; background: var(--ink); box-shadow: 0 10px 24px rgba(23,51,47,.22); }
.primary-button b { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; color: var(--ink); background: #fff; }
.primary-button:hover { transform: translateY(-2px); }
.primary-button:disabled { opacity: .58; cursor: not-allowed; transform: none; }
.secondary-button { padding: 0 15px; border: 1px solid var(--line); color: var(--ink); background: #fffdf8; }
.danger-button { padding: 0 15px; border: 1px solid rgba(189,100,93,.3); color: #a14944; background: #fbefec; }

.bottom-nav { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 20; display: grid; grid-template-columns: repeat(4, 84px); padding: 7px; border: 1px solid rgba(255,255,255,.36); border-radius: 22px; background: rgba(23,51,47,.94); box-shadow: 0 18px 45px rgba(23,51,47,.28); backdrop-filter: blur(16px); transform: translateX(-50%); }
.bottom-nav button { display: flex; justify-content: center; align-items: center; gap: 7px; height: 46px; border: 0; border-radius: 15px; color: rgba(255,255,255,.58); background: transparent; cursor: pointer; }
.bottom-nav button.active { color: var(--ink); background: #f7f4ec; }
.bottom-nav button span { font-size: 18px; }
.bottom-nav button b { font-size: 12px; }

.calendar-card { padding: 24px; }
.calendar-week, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.calendar-week { margin-bottom: 9px; color: var(--muted); text-align: center; font-size: 11px; font-weight: 800; }
.calendar-day { position: relative; display: grid; place-items: center; min-height: 68px; border: 1px solid transparent; border-radius: 15px; background: #f8f6f0; cursor: pointer; transition: .18s ease; }
.calendar-day:hover { border-color: var(--green-2); transform: translateY(-2px); }
.calendar-day.outside { opacity: .25; pointer-events: none; }
.calendar-day.today { border-color: var(--amber); }
.calendar-day.recorded.low { color: #8d4742; background: #f4d8d4; }
.calendar-day.recorded.mid { color: #855b28; background: #f2e2c3; }
.calendar-day.recorded.high { color: #255a4f; background: #d6e8df; }
.calendar-day.recorded.empty { color: #566966; background: #e5e9e5; }
.calendar-day strong { font-family: Georgia, serif; font-size: 18px; }
.calendar-day small { font-size: 9px; opacity: .8; }
.calendar-legend { display: flex; justify-content: end; gap: 16px; margin-top: 18px; color: var(--muted); font-size: 10px; }
.calendar-legend span { display: flex; align-items: center; gap: 5px; }
.calendar-legend i { width: 9px; height: 9px; border-radius: 3px; }
.calendar-legend .low { background: #eab9b4; }.calendar-legend .mid { background: #e8cb94; }.calendar-legend .high { background: #9fcdba; }.calendar-legend .empty { background: #ccd4ce; }
.section-title { display: flex; justify-content: space-between; align-items: end; margin: 28px 2px 14px; }
.section-title span { color: var(--muted); font-size: 13px; }
.history-list { display: grid; gap: 10px; }
.history-item { display: grid; grid-template-columns: 88px 1.1fr 1fr 1fr 36px; align-items: center; gap: 18px; padding: 17px 20px; border: 1px solid rgba(117,126,121,.18); border-radius: 17px; background: rgba(255,253,248,.86); cursor: pointer; transition: .2s ease; }
.history-item:hover { border-color: var(--green-2); transform: translateY(-1px); box-shadow: 0 10px 25px rgba(35,57,52,.06); }
.history-item .date strong, .history-item .date span { display: block; }
.history-item .date strong { font-family: Georgia, serif; font-size: 17px; }
.history-item .date span, .history-item small { color: var(--muted); font-size: 10px; }
.history-stat strong, .history-stat small { display: block; }
.history-stat strong { margin-bottom: 2px; font-size: 13px; }
.energy-dot { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 50%; background: var(--green-2); }
.empty-state { padding: 48px 20px; border: 1px dashed var(--line); border-radius: 18px; color: var(--muted); text-align: center; }

.compact-control { grid-template-columns: repeat(3, auto) !important; display: grid; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,253,248,.72); }
.compact-control button { min-height: 34px; padding: 0 13px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 800; cursor: pointer; }
.compact-control button.active { color: #fff; background: var(--green); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 21px; border: 1px solid rgba(117,126,121,.18); border-radius: 19px; background: rgba(255,253,248,.92); box-shadow: var(--shadow); }
.kpi span, .kpi small { display: block; color: var(--muted); }
.kpi span { font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.kpi strong { display: block; margin: 12px 0 4px; font-family: Georgia, serif; font-size: 31px; font-weight: 600; }
.kpi small { font-size: 10px; }
.chart-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 18px; }
.chart-card { min-width: 0; }
.chart-heading { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.chart-key { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 10px; }
.chart-key span { display: flex; align-items: center; gap: 5px; }
.chart-key i { width: 16px; height: 3px; border-radius: 3px; }
.chart-key .sleep { background: #647997; }.chart-key .energy-key { background: var(--amber); }
.chart { min-height: 250px; overflow: hidden; }
.chart svg { width: 100%; height: 250px; overflow: visible; }
.chart text { fill: #83908d; font-size: 9px; }
.chart .grid-line { stroke: #e8e5dd; stroke-width: 1; }
.chart .sleep-line { fill: none; stroke: #647997; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart .energy-line { fill: none; stroke: var(--amber); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.bar-chart { display: flex; justify-content: center; align-items: end; gap: 26px; min-height: 250px; padding: 12px 8px 0; }
.bar-item { display: grid; grid-template-rows: 1fr auto auto; justify-items: center; height: 230px; gap: 8px; }
.bar-track { display: flex; align-items: end; width: 54px; height: 180px; border-radius: 18px 18px 8px 8px; background: #f0eee8; overflow: hidden; }
.bar-fill { width: 100%; min-height: 3px; border-radius: 18px 18px 0 0; background: linear-gradient(180deg, #67a392, var(--green)); }
.bar-item strong { font-family: Georgia, serif; font-size: 17px; }.bar-item span { color: var(--muted); font-size: 11px; }
.insight-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.insight-item { padding: 16px; border-radius: 14px; background: #f6f2e8; }
.insight-item strong { display: block; margin-bottom: 6px; font-size: 13px; }.insight-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.data-card { display: flex; justify-content: space-between; align-items: center; gap: 28px; }
.data-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.file-button { display: inline-grid; place-items: center; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.toast { position: fixed; left: 50%; bottom: 96px; z-index: 40; padding: 11px 16px; border-radius: 999px; color: #fff; background: var(--ink); box-shadow: 0 10px 30px rgba(23,51,47,.25); font-size: 12px; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog { max-width: 390px; padding: 30px; border: 0; border-radius: 22px; color: var(--ink); background: var(--card); box-shadow: 0 30px 80px rgba(23,51,47,.28); text-align: center; }
dialog::backdrop { background: rgba(18,34,31,.5); backdrop-filter: blur(4px); }
.dialog-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 16px; border-radius: 50%; color: #a14944; background: #fbefec; font-size: 22px; font-weight: 900; }
dialog p { color: var(--muted); line-height: 1.6; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }

@media (max-width: 850px) {
  .field-grid.four { grid-template-columns: repeat(2, 1fr); }
  .energy-row { grid-template-columns: 74px 1fr 60px; }
  .energy-row .note-input { grid-column: 2 / 4; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .insight-list { grid-template-columns: 1fr; }
  .data-card { align-items: flex-start; flex-direction: column; }
  .data-actions { justify-content: flex-start; }
  .quick-entry-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-add { width: 100%; }
}

@media (max-width: 600px) {
  .app-shell { padding: 0 14px 116px; }
  .topbar { height: 72px; }
  .privacy-pill { max-width: 145px; padding: 7px 10px; font-size: 10px; }
  .hero-row { align-items: flex-start; flex-direction: column; margin: 20px 2px 21px; }
  .hero-row .date-nav, .hero-row .month-nav, .hero-row .compact-control { align-self: stretch; justify-content: space-between; }
  h1 { font-size: 32px; }
  .card { padding: 19px; border-radius: 18px; }
  .card-heading { grid-template-columns: 42px 1fr; gap: 11px; margin-bottom: 20px; }
  .card-heading .metric-badge, .card-heading .switch { grid-column: 1 / 3; justify-self: stretch; justify-content: center; }
  .event-option-row { align-items: stretch; flex-direction: column; }
  .event-toggle { width: 100%; }
  .timeline-heading { align-items: flex-start; flex-direction: column; }
  .section-icon { width: 42px; height: 42px; border-radius: 14px; }
  h2 { font-size: 19px; }
  .field-grid.four, .field-grid.three { grid-template-columns: repeat(2, 1fr); }
  .segmented.three { grid-template-columns: 1fr; }
  .energy-row { grid-template-columns: 55px 1fr 55px; gap: 9px; }
  .score-output { width: 55px; height: 46px; border-radius: 13px; font-size: 15px; }
  .period strong { font-size: 15px; }
  .energy-row .note-input { grid-column: 1 / 4; }
  .factor-grid .check-line { margin-top: 8px; }
  .quick-entry-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-entry-grid label:nth-child(3), .quick-entry-grid .quick-add { grid-column: 1 / 3; }
  .timeline-item { grid-template-columns: 50px 48px 1fr 31px; gap: 7px; padding: 10px; }
  .timeline-item.event-item { grid-template-columns: 50px 72px 1fr 31px; }
  .factor-row { grid-template-columns: 88px 1fr 66px; gap: 8px; }
  .form-footer { position: static; bottom: auto; margin-bottom: 20px; padding: 10px; }
  .completion div { display: none; }
  .primary-button { flex: 1; justify-content: space-between; }
  .bottom-nav { grid-template-columns: repeat(4, 70px); }
  .calendar-card { padding: 13px; }
  .calendar-week, .calendar-grid { gap: 4px; }
  .calendar-day { min-height: 51px; border-radius: 11px; }
  .calendar-day strong { font-size: 15px; }
  .calendar-day small { display: none; }
  .calendar-legend { justify-content: flex-start; flex-wrap: wrap; gap: 9px; }
  .history-item { grid-template-columns: 72px 1fr 30px; gap: 10px; padding: 14px; }
  .history-item .history-stat:nth-of-type(2), .history-item .history-stat:nth-of-type(3) { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .kpi { padding: 16px; }
  .kpi strong { font-size: 25px; }
  .chart-card { padding: 18px 14px; }
  .bar-chart { gap: 18px; }
  .data-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
.data-actions > * { width: 100%; }
}

.mood-badge { color: #496f99; background: #dfebf7; }
.mood-meta-grid { display: grid; grid-template-columns: 180px 160px; gap: 12px; margin-bottom: 14px; }
.mood-meta-grid label, .mood-field label { color: var(--muted); font-size: 11px; font-weight: 700; }
.mood-meta-grid input { width: 100%; height: 44px; margin-top: 7px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #faf9f5; }
.mood-four-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid #c8d5e2; border-radius: 16px; overflow: hidden; }
.mood-field { min-width: 0; padding: 0 14px 16px; border-right: 1px solid #d9e0e6; background: #fbfaf6; }
.mood-field:last-child { border-right: 0; }
.mood-column-title { display: flex; align-items: center; gap: 9px; margin: 0 -14px 14px; padding: 12px 14px; color: #294f75; background: #a9cae9; }
.mood-column-title span { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; color: #fff; background: #496f99; font-size: 11px; font-weight: 900; }
.mood-column-title strong { font-size: 13px; }
.mood-field label { display: block; margin-top: 11px; }
.mood-field select, .mood-field textarea { width: 100%; margin-top: 7px; }
.mood-field select { height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fffdf9; }
.mood-field select:disabled { color: #9aa3a1; background: #f0efea; }
.mood-field textarea { padding: 10px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fffdf9; resize: vertical; line-height: 1.5; }
.mood-emotion-pickers { display: grid; gap: 2px; }
.mood-recent { margin-top: 10px; }
.mood-recent > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 700; }
.mood-recent > div { display: flex; flex-wrap: wrap; gap: 6px; }
.mood-recent button { padding: 6px 9px; border: 1px solid #bdd0e2; border-radius: 999px; color: #365f86; background: #edf5fb; cursor: pointer; font-size: 10px; font-weight: 700; }
.mood-intensity-label > span { display: flex; justify-content: space-between; }
.mood-intensity-label b { color: #496f99; }
#mood-intensity { width: 100%; margin-top: 12px; accent-color: #496f99; }
.mood-thought-panel { margin-top: 14px; padding: 13px 15px; border: 1px solid #d5dfe8; border-radius: 14px; background: #f7fafc; }
.mood-thought-panel summary { color: #365f86; cursor: pointer; font-size: 11px; font-weight: 800; }
.mood-thought-panel label { display: block; margin-top: 12px; color: var(--muted); font-size: 10px; font-weight: 700; }
.mood-thought-panel textarea { width: 100%; margin-top: 7px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fff; resize: vertical; }
.mood-save-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 18px; }
.mood-save-row p { margin: 0; color: var(--muted); font-size: 11px; }
.mood-distribution, .mood-patterns { display: grid; gap: 10px; }
.mood-bar-row { display: grid; grid-template-columns: 110px 1fr 44px; gap: 10px; align-items: center; }
.mood-bar-label strong, .mood-bar-label small { display: block; }
.mood-bar-label strong { font-size: 12px; }
.mood-bar-label small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.mood-bar-track { height: 12px; border-radius: 999px; background: #eef0ed; overflow: hidden; }
.mood-bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8eb9de, #496f99); }
.mood-bar-row span { color: var(--muted); font-size: 10px; text-align: right; }
.mood-pattern-item { padding: 14px; border-radius: 13px; background: #f5f3ec; }
.mood-pattern-item strong, .mood-pattern-item small { display: block; }
.mood-pattern-item strong { font-size: 12px; }
.mood-pattern-item small { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.mood-record-table { overflow-x: auto; }
.mood-record-head, .mood-record-row { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); min-width: 840px; }
.mood-record-head { color: #294f75; background: #a9cae9; font-size: 12px; font-weight: 800; }
.mood-record-head span { padding: 12px; border-right: 1px solid rgba(41,79,117,.25); }
.mood-record-head span:last-child { border-right: 0; }
.mood-record-row { position: relative; border: 1px solid #e1ded6; border-top: 0; background: #fffdf9; }
.mood-record-cell { min-height: 96px; padding: 13px; border-right: 1px solid #e1ded6; }
.mood-record-cell:last-of-type { border-right: 0; }
.mood-record-cell strong, .mood-record-cell small { display: block; }
.mood-record-cell strong { font-size: 12px; line-height: 1.5; }
.mood-record-cell small { margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.mood-record-meta { color: #496f99 !important; font-weight: 800; }
.mood-record-cell:last-of-type { padding-right: 104px; }
.mood-row-actions { position: absolute; top: 7px; right: 7px; z-index: 2; display: flex; gap: 5px; }
.mood-followup-button { height: 31px; padding: 0 9px; border: 1px solid #bdd0e2; border-radius: 9px; color: #365f86; background: #edf5fb; cursor: pointer; font-size: 10px; font-weight: 800; }
.mood-followup-status { color: #2f8071 !important; font-weight: 800; }
.mood-empty { min-width: 840px; padding: 28px; border: 1px dashed var(--line); border-top: 0; color: var(--muted); text-align: center; font-size: 11px; }
.mood-data-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid #ebe8e0; }
.mood-dialog { width: min(430px, calc(100% - 28px)); text-align: left; }
.mood-dialog .dialog-section-icon { margin-bottom: 12px; }
.mood-dialog label { display: block; margin-top: 18px; color: var(--muted); font-size: 11px; font-weight: 700; }
.mood-dialog textarea { width: 100%; margin-top: 8px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; resize: vertical; }
.followup-intensity span { display: flex; justify-content: space-between; }
.followup-intensity b { color: #496f99; }
#mood-followup-intensity { width: 100%; margin-top: 12px; accent-color: #496f99; }
.dialog-save { min-height: 44px; justify-content: space-between; }
.sync-dialog { position: relative; width: min(460px, calc(100% - 28px)); text-align: left; }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border: 0; border-radius: 10px; color: var(--muted); background: #eeece6; cursor: pointer; font-size: 18px; }
.sync-explain { margin: 12px 0 18px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.sync-notice { margin-bottom: 14px; padding: 12px; border: 1px solid #ead2a9; border-radius: 12px; color: #8a5c25; background: #fff6e6; font-size: 11px; line-height: 1.6; }
.sync-email-label { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.sync-email-label input { width: 100%; height: 46px; margin-top: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #faf9f5; }
.sync-main-button { width: 100%; justify-content: space-between; margin-top: 12px; }
.sync-help { display: block; margin-top: 10px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.sync-account { padding: 13px; border-radius: 12px; background: #f5f3ec; }
.sync-account span, .sync-account strong { display: block; }
.sync-account span { color: var(--muted); font-size: 10px; }
.sync-account strong { margin-top: 4px; font-size: 12px; }
.sync-summary { display: flex; align-items: center; gap: 11px; margin-top: 12px; padding: 13px; border: 1px solid #d7e4dd; border-radius: 12px; background: #f5faf7; }
.sync-summary > span { color: #4f9a68; font-size: 10px; }
.sync-summary strong, .sync-summary small { display: block; }
.sync-summary strong { font-size: 12px; }
.sync-summary small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.sync-actions { display: grid; grid-template-columns: 1fr auto; gap: 9px; margin-top: 13px; }
.sync-actions .primary-button { justify-content: space-between; }
.sync-message { min-height: 18px; margin: 13px 0 0; color: #496f99; font-size: 10px; line-height: 1.5; }

@media (max-width: 850px) {
  .mood-four-grid { grid-template-columns: repeat(2, 1fr); }
  .mood-field:nth-child(2) { border-right: 0; }
  .mood-field:nth-child(-n+2) { border-bottom: 1px solid #d9e0e6; }
}

@media (max-width: 600px) {
  .mood-meta-grid { grid-template-columns: 1fr 1fr; }
  .mood-four-grid { display: grid; grid-template-columns: 1fr; border: 0; gap: 10px; overflow: visible; }
  .mood-field, .mood-field:nth-child(2) { border: 1px solid #d9e0e6; border-radius: 14px; overflow: hidden; }
  .mood-field:nth-child(-n+2) { border-bottom: 1px solid #d9e0e6; }
  .mood-save-row { align-items: stretch; flex-direction: column; }
  .mood-record-table { overflow: visible; }
  .mood-record-head { display: none; }
  .mood-record-row { grid-template-columns: 1fr; min-width: 0; margin-bottom: 12px; border: 1px solid #d9e0e6; border-radius: 14px; overflow: hidden; }
  .mood-record-cell { min-height: 0; padding: 13px 42px 13px 13px; border-right: 0; border-bottom: 1px solid #e1ded6; }
  .mood-record-cell:last-of-type { border-bottom: 0; }
  .mood-record-cell:last-of-type { padding-right: 104px; }
  .mood-record-cell::before { display: block; margin-bottom: 5px; color: #496f99; font-size: 10px; font-weight: 800; }
  .mood-record-cell:nth-child(1)::before { content: "客观发生了什么事"; }
  .mood-record-cell:nth-child(2)::before { content: "我的情绪感受"; }
  .mood-record-cell:nth-child(3)::before { content: "身体反应"; }
  .mood-record-cell:nth-child(4)::before { content: "我的本能做法"; }
  .mood-empty { min-width: 0; border-top: 1px dashed var(--line); border-radius: 14px; }
  .mood-data-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .mood-data-actions > * { width: 100%; }
  .mood-bar-row { grid-template-columns: 92px 1fr 38px; gap: 7px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
