/* 全局变量、基础元素、登录页、应用外壳、顶部栏、页面切换。
   样式按原 styles.css 的顺序拆成 base → home → components → forms → features，index.html 按这个顺序加载；后面的覆盖前面的，调整时不要打乱顺序。 */

:root {
  color-scheme: light;
  --bg: #eef7fd;
  --surface: #ffffff;
  --surface-soft: #f4fbff;
  --text: #26313d;
  --muted: #7b8a98;
  --line: #d9eaf4;
  --green: #5dc8a1;
  --blue: #58a9d4;
  --rose: #ef92a7;
  --gold: #d7a94f;
  --lavender: #9b8fe9;
  --shadow: 0 16px 38px rgba(77, 143, 177, 0.16);
}

* {
  box-sizing: border-box;
}

/* 整页不滚动，只有 #app-shell（和登录页）在内部滚动：主屏幕 App 里整页“橡皮筋”回弹会把底部导航
   一起拉起来，只写 overscroll-behavior 在 iOS 上无效（2026-10-07 用户实测）。 */
html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

/* 状态栏（时间、电量）下面垫一条底色，内容滚上去时不和时间叠在一起 */
body::after {
  content: "";
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 30;
  height: env(safe-area-inset-top);
  background: rgba(245, 251, 255, 0.94);
  pointer-events: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button {
  font: inherit;
}

input {
  font: inherit;
  font-size: max(16px, calc(16px * var(--fs, 1)));
}

select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.login-screen {
  display: grid;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(24px + env(safe-area-inset-top)) 16px 24px;
  place-items: center;
}

.login-card {
  width: min(100%, 360px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.login-card .avatar {
  margin-bottom: 14px;
}

.login-card p {
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: calc(14px * var(--fs, 1));
  line-height: 1.6;
}

.login-card label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: calc(13px * var(--fs, 1));
  font-weight: 500;
}

.login-card input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.login-card button {
  width: 100%;
  min-height: 46px;
  margin-top: 18px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-weight: 600;
}

.login-card small {
  display: block;
  min-height: 18px;
  margin-top: 10px;
  color: var(--rose);
  font-weight: 500;
}

.app-shell {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(100%, 480px);
  margin: 0 auto;
  overflow-x: hidden; /* 有元素伸出屏幕时也不能左右拖动整页（2026-10-10 记录页给读屏用的隐藏奶量表格撑出过，见 index.html #milk-table） */
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(104px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #f5fbff 0, var(--bg) 260px);
}

.topbar,
.baby-profile,
.top-actions,
.section-heading,
.profile-card,
.module-row,
.bottom-nav {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: calc(18px * var(--fs, 1));
  line-height: 1.15;
}

h2 {
  font-size: calc(24px * var(--fs, 1));
  line-height: 1.25;
}

h3 {
  font-size: calc(17px * var(--fs, 1));
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--blue);
  font-size: calc(13px * var(--fs, 1));
  font-weight: 500;
}

.baby-profile {
  gap: 10px;
}

.baby-profile p {
  margin-top: 3px;
  color: var(--muted);
  font-size: calc(13px * var(--fs, 1));
}

.profile-button,
.avatar {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: #fff;
  font-weight: 500;
}

.top-actions {
  gap: 10px;
}

.top-actions button {
  min-width: 64px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(86, 151, 187, 0.13);
  color: var(--blue);
  font-weight: 500;
}

.sync-button {
  padding: 0 14px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.sync-button.warn {
  color: var(--rose);
}

.primary-action,
.secondary-action,
.feature-panel button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-weight: 600;
}

.primary-action {
  width: 128px;
}

.secondary-action {
  padding: 0 18px;
}

.button-pair {
  display: flex;
  gap: 8px;
}

.feature-panel,
.placeholder-panel,
.profile-card,
.timeline article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.module-row small,
.timeline small,
.placeholder-panel p,
.feature-panel p,
.profile-card p {
  color: var(--muted);
}

.module-row small,
.timeline small {
  display: block;
  font-size: calc(12px * var(--fs, 1));
}
