/* ============================================================
   桐桐日记 — 移动端 H5
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg:        #FAF6F2;
  --bg-grad:   linear-gradient(180deg, #FDF3EE 0%, #FAF6F2 220px);
  --surface:   #FFFFFF;
  --surface-2: #F5EFE9;
  --surface-3: #EDE5DD;
  --text:      #2C2724;
  --text-2:    #8B817A;
  --text-3:    #B3A9A2;
  --line:      #EFE7E0;
  --brand:     #E28B85;
  --brand-2:   #D2766F;
  --brand-soft:#FCEDEA;
  --shadow:    0 1px 2px rgba(80, 60, 50, .04), 0 6px 18px rgba(80, 60, 50, .05);
  --shadow-lg: 0 -8px 40px rgba(60, 40, 30, .12);

  --c-breast: #E2915A;
  --c-bottle: #5E9FD1;
  --c-sleep:  #8E82D6;
  --c-diaper: #4CB0A2;
  --c-solid:  #77A961;
  --c-water:  #59AEC9;
  --c-temp:   #DE6E8B;
  --c-bili:   #D9A13B;
  --c-growth: #C08F4B;
  --c-med:    #CF655F;
  --c-note:   #9C938C;

  --c-breast-soft: #FAEEE2;
  --c-bottle-soft: #E8F1F9;
  --c-sleep-soft:  #EEEBF9;
  --c-diaper-soft: #E3F4F1;
  --c-solid-soft:  #ECF3E6;
  --c-water-soft:  #E4F2F7;
  --c-temp-soft:   #FBE9EE;
  --c-bili-soft:   #FBF0DB;
  --c-growth-soft: #F7EEDE;
  --c-med-soft:    #FBE9E7;
  --c-note-soft:   #F1EBE6;

  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 11px;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #15141A;
    --bg-grad:   linear-gradient(180deg, #221E28 0%, #15141A 240px);
    --surface:   #201E26;
    --surface-2: #2A2732;
    --surface-3: #35313D;
    --text:      #F1EBE6;
    --text-2:    #9C9490;
    --text-3:    #6F6862;
    --line:      #312E39;
    --brand:     #E28B85;
    --brand-2:   #EF9E97;
    --brand-soft:#3A2A2C;
    --shadow:    0 1px 2px rgba(0, 0, 0, .3), 0 8px 20px rgba(0, 0, 0, .22);
    --shadow-lg: 0 -8px 40px rgba(0, 0, 0, .5);
    --c-breast: #E5A274;
    --c-bottle: #74B0DE;
    --c-sleep:  #A198E2;
    --c-diaper: #63C3B5;
    --c-solid:  #8DBE76;
    --c-water:  #6FBDD5;
    --c-temp:   #E8849E;
    --c-bili:   #E0B155;
    --c-growth: #D3A467;
    --c-med:    #DE7C76;
    --c-note:   #A9A09A;

    --c-breast-soft: #38291D;
    --c-bottle-soft: #1D2B37;
    --c-sleep-soft:  #28253D;
    --c-diaper-soft: #182E2B;
    --c-solid-soft:  #222E1D;
    --c-water-soft:  #192A31;
    --c-temp-soft:   #372229;
    --c-bili-soft:   #352C18;
    --c-growth-soft: #32291A;
    --c-med-soft:    #372320;
    --c-note-soft:   #282420;
  }
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
               "MiSans", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input, textarea, select {
  font: inherit;
  color: inherit;
}

/* ---------------- 登录 ---------------- */

.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(165deg, #FBE9E4 0%, #FAF6F2 45%, #F0F4F7 100%);
}
@media (prefers-color-scheme: dark) {
  .login { background: linear-gradient(165deg, #241C22 0%, #15141A 50%, #191D24 100%); }
}

.login-inner {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.login-logo {
  line-height: 1;
  margin-bottom: 18px;
}
.login-logo img {
  width: 92px;
  height: 92px;
  border-radius: 23px;
  display: block;
  margin: 0 auto;
  box-shadow: 0 10px 28px rgba(190, 120, 110, .3);
}

.login h1 {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: .5px;
  margin: 0 0 6px;
}

.login-sub {
  color: var(--text-2);
  font-size: 13.5px;
  margin: 0 0 26px;
}

.pin-wrap input {
  width: 100%;
  height: 52px;
  padding: 0 18px;
  border-radius: 15px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 16px;
  text-align: center;
  letter-spacing: 2px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.pin-wrap input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.btn-primary {
  width: 100%;
  height: 50px;
  margin-top: 14px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 1px;
  box-shadow: 0 6px 18px rgba(210, 118, 111, .3);
  transition: transform .12s, opacity .12s;
}
.btn-primary:active { transform: scale(.975); }
.btn-primary:disabled { opacity: .55; }

.pin-error {
  color: #D2554E;
  font-size: 13px;
  min-height: 20px;
  margin-top: 10px;
}

.login-hint {
  margin-top: 22px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.7;
}
.login-hint code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12px;
}

/* ---------------- 顶部栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }

.baby-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: 99px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.baby-chip .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: linear-gradient(135deg, #FDE6E0, #E9EEF4);
}
@media (prefers-color-scheme: dark) {
  .baby-chip .avatar { background: linear-gradient(135deg, #3B2C2C, #2A2E36); }
}
.baby-chip .meta { line-height: 1.25; text-align: left; }
.baby-chip .nm { font-size: 14.5px; font-weight: 600; }
.baby-chip .age { font-size: 11.5px; color: var(--text-2); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text-2);
  transition: transform .12s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }

/* ---------------- 视图容器 ---------------- */

.main {
  min-height: 100vh;
  background: var(--bg-grad);
  background-repeat: no-repeat;
}

.view {
  padding: 4px 16px calc(var(--tabbar-h) + var(--safe-b) + 26px);
  animation: fade-up .26s ease both;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------- 今日概览 ---------------- */

.sec-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 20px 2px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .6px;
}
.sec-title .more { font-size: 12.5px; font-weight: 500; color: var(--text-3); }

/* 出生天数条 */
.birth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 0;
}
.bb-days {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 7px 15px;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .3px;
  box-shadow: 0 5px 16px rgba(210, 118, 111, .26);
  flex: none;
}
.bb-days b {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.6px;
  font-variant-numeric: tabular-nums;
  padding: 0 1px;
}
.bb-meta {
  font-size: 11.5px;
  color: var(--text-3);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 16px 6px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.ov-cell {
  text-align: center;
  padding: 0 2px;
  position: relative;
}
.ov-cell + .ov-cell::before {
  content: '';
  position: absolute;
  left: 0; top: 12%;
  height: 76%;
  border-left: 1px solid var(--line);
}
.ov-val {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.ov-val small { font-size: 11px; font-weight: 600; color: var(--text-2); margin-left: 1px; }
.ov-lab { font-size: 11px; color: var(--text-3); margin-top: 3px; }

.ov-val.warn { color: #D9803F; }

/* ---------------- 进行中 ---------------- */

.running {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.run-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--rc-soft);
}
.run-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--rc);
  animation: pulse 1.8s ease-in-out infinite;
  flex: none;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .38; transform: scale(.82); }
}
.run-body { flex: 1; min-width: 0; }
.run-name { font-size: 14px; font-weight: 600; }
.run-time {
  font-size: 20px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--rc);
  letter-spacing: -.5px;
}
.run-btn {
  flex: none;
  height: 34px;
  padding: 0 16px;
  border-radius: 99px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  background: var(--rc);
  transition: transform .12s;
}
.run-btn:active { transform: scale(.95); }

/* ---------------- 快捷记录 ---------------- */

.quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.q-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 13px 2px 10px;
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s;
  overflow: hidden;
}
.q-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 78% at 50% 0%, var(--qc-soft), transparent 72%);
  pointer-events: none;
}
.q-btn:active { transform: scale(.965); }
.q-ico {
  width: 31px; height: 31px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--qc-soft);
  color: var(--qc);
  font-size: 17px;
}
.q-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; }
.q-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.q-last { font-size: 9.5px; color: var(--text-3); letter-spacing: -.1px; white-space: nowrap; }

/* ---------------- 今日列表 / 时间线 ---------------- */

.day-group { margin-top: 4px; }
.day-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 2px 6px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 600;
}
.day-head .line { flex: 1; height: 1px; background: var(--line); }

.date-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 12px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: none;
}
.date-strip::-webkit-scrollbar { display: none; }
.dchip {
  flex: none;
  min-width: 52px;
  padding: 7px 12px;
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  color: var(--text-2);
  text-align: center;
  transition: .16s;
}
.dchip b { display: block; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.dchip.on {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(210, 118, 111, .3);
}
.dchip.on b { color: #fff; }

.rec-list { display: flex; flex-direction: column; gap: 8px; }

.rec {
  display: flex;
  gap: 11px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .12s;
}
.rec:active { transform: scale(.99); }
.rec-ico {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--rc-soft);
  color: var(--rc);
  font-size: 17px;
}
.rec-ico svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; }
.rec-body { flex: 1; min-width: 0; }
.rec-top {
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.rec-time {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.2px;
}
.rec-gap {
  font-size: 11px;
  color: var(--text-3);
  margin-left: auto;
  flex: none;
}
.rec-main {
  font-size: 13.5px;
  color: var(--text);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rec-sub {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.rec-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 11px;
}

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-3);
  font-size: 13.5px;
}
.empty .em { font-size: 34px; display: block; margin-bottom: 10px; opacity: .55; }

/* ---------------- 统计 ---------------- */

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 15px 16px 12px;
  margin-bottom: 12px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.card-title { font-size: 14px; font-weight: 650; }
.card-sub { font-size: 11.5px; color: var(--text-3); }

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
  transition: .16s;
}
.seg button.on {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.chart-wrap { margin: 6px -4px 0; }
.chart-wrap svg { display: block; width: 100%; overflow: visible; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.stat-box {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 13px 14px;
}
.stat-box .k { font-size: 11.5px; color: var(--text-3); }
.stat-box .v {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.6px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.stat-box .v small { font-size: 12px; font-weight: 600; color: var(--text-2); }
.stat-box .d { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.bar-legend { display: flex; gap: 12px; font-size: 11px; color: var(--text-3); margin-top: 8px; flex-wrap: wrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 4px; }

/* ---------------- 我的 ---------------- */

.group {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 14px;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  text-align: left;
  width: 100%;
  transition: background .14s;
}
.row:active { background: var(--surface-2); }
.row + .row { border-top: 1px solid var(--line); }
.row-ico {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-size: 15px;
  flex: none;
}
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 14.5px; font-weight: 550; }
.row-desc { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.row-chev { color: var(--text-3); flex: none; }
.row-chev svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.member-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
}
.member-line + .member-line { border-top: 1px solid var(--line); }
.m-av {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: var(--surface-2);
  color: var(--mc);
  flex: none;
}
.m-name { flex: 1; font-size: 14px; }
.badge {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--brand-soft);
  color: var(--brand-2);
  font-weight: 600;
}
.badge.off { background: var(--surface-2); color: var(--text-3); }
.link-btn {
  font-size: 12.5px;
  color: var(--brand-2);
  padding: 4px 6px;
  font-weight: 600;
}
.link-btn.danger { color: #C9544D; }

.footnote {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.8;
  padding: 6px 10px 20px;
}

/* ---------------- 底部导航 ---------------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-3);
  transition: color .16s;
}
.tab svg {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .18s;
}
.tab svg .fill { fill: currentColor; stroke: none; }
.tab span { font-size: 10.5px; letter-spacing: .2px; }
.tab.active { color: var(--brand-2); }
.tab.active svg { transform: translateY(-1px) scale(1.04); }

/* ---------------- 底部抽屉 ---------------- */

.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(30, 22, 18, .34);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: mask-in .2s ease both;
}
@keyframes mask-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 61;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheet-up .28s cubic-bezier(.32, .9, .3, 1) both;
  padding-bottom: var(--safe-b);
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: none; }
}
.sheet.closing { animation: sheet-down .2s ease both; }
@keyframes sheet-down { to { transform: translateY(100%); } }

.sheet-grip {
  width: 38px; height: 4.5px;
  border-radius: 99px;
  background: var(--surface-3);
  margin: 9px auto 0;
  flex: none;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
  flex: none;
}
.sheet-head h2 { font-size: 17px; font-weight: 680; margin: 0; }
.sheet-head .icon-btn { width: 32px; height: 32px; background: var(--surface-2); box-shadow: none; }
.sheet-head .icon-btn svg { width: 16px; height: 16px; }

.sheet-body {
  padding: 6px 16px 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.sheet-foot {
  padding: 10px 16px calc(12px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  flex: none;
}
.sheet-foot .btn-primary { margin: 0; flex: 1; }
.btn-ghost {
  height: 50px;
  padding: 0 18px;
  border-radius: 15px;
  background: var(--surface-2);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  transition: transform .12s;
}
.btn-ghost:active { transform: scale(.97); }
.btn-ghost.danger { color: #C9544D; }

/* ---------------- 表单 ---------------- */

.field { margin-bottom: 15px; }
.field > label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 7px;
  letter-spacing: .2px;
}

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 9px 15px;
  border-radius: 12px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  font-size: 13.5px;
  color: var(--text-2);
  transition: .15s;
  white-space: nowrap;
}
.pill:active { transform: scale(.96); }
.pill.on {
  background: var(--surface-2);
  background: color-mix(in srgb, var(--pc, var(--brand)) 12%, transparent);
  border-color: var(--pc, var(--brand));
  color: var(--pc, var(--brand-2));
  font-weight: 600;
}

.inp {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 16px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
  -webkit-appearance: none;
  appearance: none;
}
.inp:focus { border-color: var(--brand); box-shadow: 0 0 0 3.5px var(--brand-soft); }
textarea.inp { height: auto; min-height: 74px; padding: 12px 14px; resize: none; line-height: 1.55; }

.inp-row { display: flex; gap: 10px; }
.inp-row > * { flex: 1; min-width: 0; }

.num-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.num-wrap .inp { padding-right: 46px; font-weight: 600; font-size: 17px; }
.num-wrap .unit {
  position: absolute;
  right: 14px;
  font-size: 13px;
  color: var(--text-3);
  pointer-events: none;
}

/* 步进器 */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
  height: 48px;
}
.stepper button {
  width: 46px;
  height: 100%;
  font-size: 20px;
  color: var(--text-2);
  font-weight: 400;
  display: grid;
  place-items: center;
  flex: none;
}
.stepper button:active { background: var(--surface-2); }
.stepper .val {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stepper .val small { font-size: 12px; color: var(--text-3); font-weight: 500; }

/* 时间选择 */
.time-box {
  display: flex;
  align-items: center;
  gap: 10px;
}
.time-box .inp { flex: 1; }

/* ---------- 时间按钮（点开滚轮）---------- */
.time-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.time-btn:active { background: var(--surface); border-color: var(--line); }
.tb-date { font-size: 13px; color: var(--text-2); font-weight: 500; }
.tb-clock {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.tb-arrow { margin-left: auto; font-size: 17px; color: var(--text-3); line-height: 1; }

/* ---------- iOS 风格滚轮 ---------- */
.picker { position: fixed; inset: 0; z-index: 95; }
.picker-mask {
  position: absolute;
  inset: 0;
  background: rgba(24, 18, 20, .42);
  animation: pkFade .22s ease both;
}
.picker-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -14px 44px rgba(0, 0, 0, .2);
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  animation: pkUp .28s cubic-bezier(.32, .72, 0, 1) both;
}
.picker.closing .picker-mask { animation: pkFade .18s ease both reverse; }
.picker.closing .picker-panel { animation: pkUp .2s ease both reverse; }
@keyframes pkFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pkUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 4px;
}
.picker-head button {
  font-size: 15px;
  color: var(--text-3);
  padding: 8px 10px;
  border-radius: 10px;
}
.picker-head button:active { background: var(--surface-2); }
.picker-head .pk-ok { color: var(--brand-2); font-weight: 600; }
.picker-title { font-size: 13.5px; font-weight: 600; color: var(--text-2); }

.wheel { position: relative; height: 210px; margin-top: 2px; }
/* 中间选中带：覆盖时分两列 */
.wheel-band {
  position: absolute;
  left: 50%;
  width: 176px;
  top: 84px; height: 42px;
  transform: translateX(-50%);
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  pointer-events: none;
}
.wheel-cols {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 88px 88px 1fr;
  grid-template-rows: 100%;
  /* 上下渐隐，做出滚轮的纵深 */
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 21%, #000 79%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 21%, #000 79%, transparent 100%);
}
.wpad { pointer-events: none; }
/* 数字列 + 右侧单位 */
.wgroup {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 15px;
  height: 100%;
  min-height: 0;
}

/* 日期栏（‹ 昨天 · 10月22日 ›）*/
.pk-datebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 16px 2px;
}
.pk-dbtn {
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  color: var(--text-2);
  background: var(--surface-2);
  flex: none;
}
.pk-dbtn:active { background: var(--line); }
.pk-dbtn:disabled { opacity: .28; }
.pk-dtext {
  font-size: 14px;
  font-weight: 600;
  min-width: 128px;
  text-align: center;
  letter-spacing: .2px;
}
.wcol {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  padding: 84px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  text-align: center;
  overscroll-behavior: contain;
}
.wcol::-webkit-scrollbar { display: none; }
/* 单位「时/分/秒」，垂直居中于列右侧 */
.wunit {
  align-self: center;
  font-size: 12px;
  line-height: 1;
  color: var(--text-3);
  font-weight: 500;
  pointer-events: none;
  white-space: nowrap;
}
.witem {
  height: 42px;
  line-height: 42px;
  scroll-snap-align: center;
  font-size: 21px;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: transform .12s ease, color .12s ease;
  transform: scale(.92);
  will-change: transform;
}
.witem.on {
  color: var(--text);
  font-weight: 700;
  transform: scale(1.45);
}

/* 睡眠“还在睡”开关 */
.chk-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--text-2);
}
.chk-line input { width: 17px; height: 17px; accent-color: var(--brand); }

.quick-times { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.qt {
  padding: 5px 10px;
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
}

.member-pick { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.member-pick::-webkit-scrollbar { display: none; }
.mp {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px 7px 8px;
  border-radius: 99px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  font-size: 13px;
  color: var(--text-2);
  transition: .15s;
}
.mp .e { font-size: 15px; }
.mp.on {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-2);
  font-weight: 600;
}

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px);
  z-index: 130;
  transform: translate(-50%, 14px);
  padding: 10px 20px;
  border-radius: 99px;
  background: rgba(38, 30, 27, .92);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  max-width: 82vw;
  text-align: center;
  backdrop-filter: blur(8px);
}
@media (prefers-color-scheme: dark) {
  .toast { background: rgba(240, 235, 230, .95); color: #1B1917; }
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 宽屏（iPad / 电脑预览） ---------------- */

@media (min-width: 620px) {
  .main, .login { max-width: 520px; margin: 0 auto; }
  .tabbar {
    max-width: 520px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 18px 18px 0 0;
  }
  .sheet {
    max-width: 520px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 26px 26px 0 0;
  }
  @keyframes sheet-up {
    from { transform: translate(-50%, 100%); }
    to   { transform: translate(-50%, 0); }
  }
  .sheet.closing { animation: sheet-down-w .2s ease both; }
  @keyframes sheet-down-w { to { transform: translate(-50%, 100%); } }
  .main { box-shadow: 0 0 60px rgba(0, 0, 0, .07); }
}

/* ============================================================
   AI 分析
   ============================================================ */

.ai-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
/* 国内习惯：多/涨=红，少/跌=绿 */
.ai-chip.up { background: rgba(226, 106, 96, .12); color: #C6544B; }
.ai-chip.down { background: rgba(74, 144, 108, .12); color: #3F8560; }
.ai-tip {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-2);
}
.ai-tip-dot {
  flex: none;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  margin-top: 6px;
}
.ai-tip.warn { color: #B96A3C; }
.ai-tip.warn .ai-tip-dot { background: #D98A4B; }
.ai-comment {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 11px;
  border-radius: 13px;
  background: var(--brand-soft);
  font-size: 12.5px;
  line-height: 1.55;
}
.ai-c-label {
  flex: none;
  font-weight: 700;
  color: var(--brand-2);
  font-size: 11.5px;
  padding-top: 1px;
}
.ai-c-body { color: var(--text-2); word-break: break-word; }
.ai-enable {
  border: 1px dashed var(--line);
  background: transparent;
  border-radius: 13px;
  padding: 10px;
  font-size: 12.5px;
  color: var(--text-3);
  width: 100%;
  text-align: center;
}

/* ---------- 问 AI 对话页 ---------- */

.chat-wrap { display: flex; flex-direction: column; }
.chat-msgs {
  padding: 6px 2px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-hello {
  margin: 18px auto 4px;
  font-size: 12.5px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.6;
}
.chat-sugg { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 10px 8px; }
.sugg {
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
}
.sugg:active { background: var(--surface-2); }
.msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.msg.ai {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-bottom-left-radius: 5px;
}
.cursor { animation: blink 1s step-end infinite; color: var(--brand-2); }
@keyframes blink { 50% { opacity: 0; } }
.chat-setup {
  text-align: center;
  padding: 14px;
  color: var(--text-2);
  font-size: 13px;
}
.chat-setup .btn-primary { margin-top: 10px; padding: 9px 26px; }

.chat-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 2px 10px;
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 4px);
  background: var(--bg);
  z-index: 5;
}
.chat-bar input {
  flex: 1;
  height: 42px;
  border-radius: 21px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0 16px;
  font-size: 14.5px;
  outline: none;
}
.chat-bar input:focus { border-color: var(--brand); }
.chat-send {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
}
.chat-send svg { width: 20px; height: 20px; fill: currentColor; }
.chat-send:disabled { opacity: .5; }

/* ============================================================
   一键计时 + 喂奶补量
   ============================================================ */

.qt-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 12px;
}
.qt-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: left;
}
.qt-btn:active { background: var(--surface-2); }
.qt-btn.on {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.qt-btn[disabled] { opacity: .92; }
.qt-ico {
  width: 32px; height: 32px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--brand-2);
}
.qt-ico svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor;
  stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round;
}
.qt-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.qt-txt b { font-size: 13px; font-weight: 650; }
.qt-txt i { font-style: normal; font-size: 10.5px; color: var(--text-3); white-space: nowrap; }

.milk-hero { text-align: center; padding: 2px 0 10px; }
.mh-num {
  font-size: 42px;
  font-weight: 750;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.mh-num small { font-size: 14px; font-weight: 600; color: var(--text-3); margin-left: 4px; }
.mh-sub { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.milk-quick {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 14px;
}
.milk-quick button {
  min-width: 52px;
  padding: 7px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.milk-quick button.on {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-2);
}

/* toast 带撤销按钮时才能点 */
.toast.has-undo {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 10px 9px 18px;
  text-align: left;
}
.toast.has-undo.show { pointer-events: auto; }
.toast-undo {
  flex: none;
  padding: 5px 13px;
  border: 0;
  border-radius: 99px;
  background: color-mix(in srgb, currentColor 16%, transparent);
  color: inherit;
  font-size: 13px;
  font-weight: 600;
}

/* ---------------- 参考表入口（统计页） ---------------- */

.ref-entry {
  margin-top: 10px;
  padding: 13px 15px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.ref-entry:active { background: var(--surface-2); }
.re-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.re-title { font-size: 14px; font-weight: 600; }
.re-age { font-size: 12px; color: var(--text-3); }
.re-bits {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.re-bits b {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 参考表详情 ---------------- */

.rt-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin: 0 2px 12px;
}
.rt-age { font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.rt-now {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--brand-soft);
  color: var(--brand-2);
}
.rt-now.ghost { background: var(--surface-2); color: var(--text-3); font-weight: 500; }

.rt-target {
  padding: 13px 15px;
  border-radius: 15px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--c-bottle-soft), var(--surface) 78%);
  border: 1px solid color-mix(in srgb, var(--c-bottle) 20%, transparent);
}
.rt-tg-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-2);
}
.rt-tg-tag {
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-3);
  font-size: 10.5px;
}
.rt-tg-val {
  margin: 7px 0 4px;
  font-size: 13.5px;
  color: var(--text-2);
}
.rt-tg-val b {
  font-size: 23px;
  color: var(--c-bottle);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.4px;
}
.rt-tg-note {
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-3);
}

.rt-card {
  padding: 12px 15px;
  border-radius: 15px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.rt-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 2px;
}
.rt-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  column-gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.rt-row:first-of-type { border-top: 0; }
.rt-k { font-size: 12.5px; color: var(--text-2); }
.rt-v {
  font-size: 14.5px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rt-v i {
  font-size: 10.5px;
  font-weight: 400;
  font-style: normal;
  color: var(--text-3);
  margin-left: 2px;
}
.rt-s {
  grid-column: 2;
  margin-top: 2px;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--text-3);
  text-align: right;
}
.rt-s:empty { display: none; }

.rt-foot {
  margin: 4px 4px 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-3);
}

/* ---------------- 黄疸 ---------------- */

.bili-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.bili-row .inp { flex: 1; min-width: 0; }
.bili-row .seg { flex: none; }

.jl-sum {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 10px;
  padding: 2px 2px 10px;
}
.jl-big b {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
  color: var(--c-bili);
}
.jl-big i {
  font-size: 11px;
  font-style: normal;
  color: var(--text-3);
  margin-left: 3px;
}
.jl-meta { font-size: 11.5px; color: var(--text-2); }
.jl-tag {
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
}
.jl-tag.ok    { background: var(--c-diaper-soft); color: var(--c-diaper); }
.jl-tag.watch { background: var(--c-bili-soft);   color: var(--c-bili); }
.jl-tag.near  { background: var(--c-bili-soft);   color: var(--c-bili); }
.jl-tag.over  { background: var(--c-med-soft);    color: var(--c-med); }

.jl-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--text-3);
}
.jl-legend i {
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}
.jl-dot  { width: 7px; height: 7px; border-radius: 50%; background: var(--c-bili); }
.jl-dash { width: 14px; height: 0; border-top: 1.5px dashed var(--c-med); }
.jl-band { width: 14px; height: 8px; border-radius: 2px; background: var(--c-med); opacity: .16; }

.jl-foot {
  margin-top: 8px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--text-3);
}

/* 还没有实测值时的引导语（曲线仍会画出来） */
.jl-noempty {
  margin-top: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

.rt-tag-inline {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  vertical-align: 1px;
}
