:root {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #30384b;
  background: #e8f4ef;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding: 24px; background: linear-gradient(145deg, #d9eee5, #f3f5f8); }
.app-shell { position: relative; max-width: 1060px; margin: 0 auto 30px; padding: 28px 36px 96px; border-radius: 34px; background: #fff; box-shadow: 0 18px 60px #27483812; }
.topbar { display: grid; height: 86px; grid-template-columns: 1fr auto 1fr; align-items: center; }
.text-button { border: 0; background: none; color: #e4a23b; font-size: 18px; font-weight: 700; cursor: pointer; }
.topbar > .text-button { text-align: left; }
.month-nav { display: flex; align-items: center; gap: 20px; }
.month-nav > button { width: 36px; border: 0; background: none; color: #788095; font-size: 34px; cursor: pointer; }
.select-date { display: flex; align-items: center; gap: 4px; }
.select-date select { appearance: none; padding: 3px; border: 0; background: transparent; color: #30384b; font: 700 29px system-ui, sans-serif; cursor: pointer; }
.select-date select:last-child { font-size: 25px; }
.menu-wrap { position: relative; justify-self: end; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: #f2f7f4; color: #647168; font-size: 24px; cursor: pointer; }
.menu { position: absolute; z-index: 5; top: 50px; right: 0; width: 145px; padding: 6px; border-radius: 12px; background: #fff; box-shadow: 0 8px 28px #26342b24; }
.menu button { display: block; width: 100%; padding: 11px; border: 0; border-radius: 8px; background: none; color: #384154; text-align: left; cursor: pointer; }
.menu button:hover { background: #f1f7f3; }
.menu .danger-menu-item { color: #c74654; }
.menu .danger-menu-item:hover { background: #fff0f1; }
.hidden { display: none !important; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 16px 0 42px; }
.stats article { padding: 20px 8px; border-radius: 22px; background: #f0f7f4; text-align: center; }
.stats h2 { margin: 0 0 8px; font-size: 21px; }
.stats p { margin: 0; white-space: nowrap; }
.stats strong { font-size: 30px; }
.stats p span { margin-left: 5px; color: #778094; font-size: 19px; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 9px; }
.weekdays { padding: 8px 0 16px; color: #a0a4b1; font-size: 20px; font-weight: 700; text-align: center; }
.day { display: flex; min-height: 126px; flex-direction: column; align-items: stretch; gap: 5px; padding: 8px 5px; border: 0; border-radius: 14px; background: transparent; color: inherit; text-align: center; cursor: pointer; }
.day:hover { background: #f7faf8; }
.day.empty { pointer-events: none; }
.day.future { opacity: .47; cursor: default; }
.date-line { display: flex; min-height: 33px; align-items: center; justify-content: center; gap: 5px; color: #626a7d; font-size: 23px; font-weight: 700; }
.flag { width: 25px; height: 25px; border-radius: 9px; background: #ffe0e3; color: #ec6170; font-size: 15px; line-height: 25px; }
.detail { display: block; overflow-wrap: anywhere; padding: 5px 2px; border-radius: 9px; font-size: 15px; line-height: 1.25; }
.calories-pill { background: #fff1e3; color: #c78f36; }
.activity-pill { background: #e8f5ef; color: #40a986; }
.day.today .date-line { color: #04a977; }
.add-button { position: fixed; z-index: 2; bottom: 20px; left: 50%; width: min(720px, calc(100vw - 48px)); height: 64px; transform: translateX(-50%); border: 0; border-radius: 40px; background: #08b87d; box-shadow: 0 8px 26px #038f6335; color: white; font-size: 23px; font-weight: 800; cursor: pointer; }
.overlay { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 18px; background: #16231d66; }
.editor { width: min(520px, 100%); max-height: 95vh; overflow: auto; padding: 24px 28px; border-radius: 24px; background: #fff; box-shadow: 0 18px 70px #1114; }
.editor-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.editor-header h2 { margin: 0; font-size: 23px; }
.editor-header .text-button { font-size: 16px; }
.field { display: block; margin: 0 0 18px; font-weight: 700; }
.field input[type="date"], .field input[type="number"] { display: block; width: 100%; height: 48px; margin-top: 7px; padding: 0 13px; border: 1px solid #dce4e0; border-radius: 11px; background: white; color: #30384b; font: inherit; }
.activities { padding: 0; border: 0; }
.activities legend { margin-bottom: 10px; }
.activities label { display: inline-flex; align-items: center; gap: 7px; margin: 0 7px 8px 0; padding: 9px 12px; border-radius: 10px; background: #f1f7f4; cursor: pointer; }
.activities input { width: 17px; height: 17px; accent-color: #08b87d; }
.error { display: block; min-height: 0; margin-top: 3px; color: #d44959; font-size: 13px; font-weight: 400; }
.form-actions { display: grid; gap: 10px; margin-top: 24px; }
.save-button, .delete-button { height: 50px; border: 0; border-radius: 13px; font-size: 17px; font-weight: 700; cursor: pointer; }
.save-button { background: #08b87d; color: white; }
.delete-button { background: #fff0f1; color: #c74654; }
.toast { position: fixed; z-index: 20; bottom: 98px; left: 50%; transform: translate(-50%, 10px); padding: 12px 18px; border-radius: 12px; background: #30384b; color: white; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 720px) {
  body { padding: 10px; }
  .app-shell { padding: 14px 12px 94px; border-radius: 22px; }
  .topbar { height: 65px; }
  .month-nav { gap: 5px; }
  .month-nav > button { width: 26px; font-size: 27px; }
  .select-date select { font-size: 20px; }
  .select-date select:last-child { font-size: 18px; }
  .topbar > .text-button { font-size: 15px; }
  .stats { gap: 7px; margin: 14px 0 25px; }
  .stats article { padding: 13px 3px; border-radius: 15px; }
  .stats h2 { font-size: 14px; }
  .stats strong { font-size: 20px; }
  .stats p span { margin-left: 2px; font-size: 12px; }
  .weekdays, .calendar-grid { gap: 3px; }
  .weekdays { font-size: 15px; }
  .day { min-height: 87px; gap: 3px; padding: 5px 1px; border-radius: 8px; }
  .date-line { min-height: 25px; font-size: 17px; }
  .flag { width: 18px; height: 18px; border-radius: 6px; font-size: 11px; line-height: 18px; }
  .detail { padding: 4px 1px; border-radius: 6px; font-size: 10px; }
  .add-button { bottom: 12px; height: 56px; font-size: 19px; }
  .editor { padding: 20px 18px; }
}

/* V1.1: weekly summaries are aligned with each complete Monday–Sunday row. */
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.weight-diff-card { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.weight-diff-card:hover, .weight-diff-card:focus-visible { outline: none; transform: translateY(-2px); box-shadow: 0 5px 18px #27483818; }
.weight-diff-card.warning strong { color: #d64545; }
.weight-diff-card.normal strong { color: #2e8b57; }
.calendar { overflow-x: auto; padding-bottom: 6px; }
.weekdays, .calendar-grid { min-width: 850px; grid-template-columns: repeat(8, minmax(0, 1fr)); }
.weekdays span:last-child { display: grid; place-items: center; padding: 8px 4px; border: 1px solid #f6e9c9; border-radius: 12px; background: #fff9e8; color: #665b3c; font-size: 15px; line-height: 1.25; }
.week-average { display: flex; min-height: 126px; align-items: center; justify-content: center; padding: 12px 5px; border: 1px solid #f6e9c9; border-radius: 14px; background: #fff9e8; color: #51472e; font-size: 16px; font-weight: 700; text-align: center; }
.weight-tip { width: min(720px, 100%); max-height: 92vh; overflow: auto; padding: 26px 28px; border-radius: 24px; background: #fff; box-shadow: 0 18px 70px #1114; }
.weight-tip-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.weight-tip-header h2 { margin: 0 0 6px; font-size: 23px; }
.weight-tip-header p { margin: 0; color: #778094; font-size: 14px; }
.weight-tip-header button { width: 38px; height: 38px; flex: 0 0 38px; border: 0; border-radius: 50%; background: #f0f7f4; color: #586174; font-size: 27px; cursor: pointer; }
.weight-tip table { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; border: 1px solid #e4ebe7; border-radius: 14px; }
.weight-tip th, .weight-tip td { padding: 15px 16px; border-bottom: 1px solid #e4ebe7; text-align: left; vertical-align: top; line-height: 1.6; }
.weight-tip th { background: #f0f7f4; font-size: 15px; }
.weight-tip th:first-child, .weight-tip td:first-child { width: 43%; }
.weight-tip tr:last-child td { border-bottom: 0; }
.tip-warning { color: #bd6865; }
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .weekdays, .calendar-grid { min-width: 760px; }
  .weight-tip { padding: 20px 16px; border-radius: 20px; }
  .weight-tip-header h2 { font-size: 19px; }
  .weight-tip th, .weight-tip td { padding: 11px 9px; font-size: 13px; }
  .weight-tip th:first-child, .weight-tip td:first-child { width: 42%; }
}
