/* 好孕药盒：薄荷绿底，早中晚各一个奶油色格子 */
:root {
  --bg: #E3F3EC;
  --ink: #2E4756;
  --muted: #6D8A92;
  --faint: #8BA3A9;
  --card: #FFFFFF;
  --soft: #F4FAF7;
  --shadow: #C3E2D5;
  --rose: #D6566E;
  --ok: #3E9473;
  --warn: #C9772E;
  --violet: #8A7FD0;
  --c-am: #FFF0BF;
  --c-noon: #FFD9E0;
  --c-aft: #FFE2C9;
  --c-pm: #E1DAFF;
  --c-bed: #D8E4F5;
  --c-once: #D9EEFF;
  --f-body: 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --f-cute: 'ZCOOL KuaiLe', 'Noto Sans SC', 'PingFang SC', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(14px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.loading { text-align: center; color: var(--muted); padding: 40vh 0 0; }

/* 顶栏 */
.top { display: flex; align-items: center; gap: 8px; padding: 2px 2px 0; }
.top h1 { margin: 0; flex: 1; font-family: var(--f-cute); font-weight: 400; font-size: 22px; }
.top .icon-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--card); display: grid; place-items: center; box-shadow: 0 3px 0 var(--shadow); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.back { font-size: 15px; padding: 8px 12px 8px 4px; color: var(--ink); display: inline-flex; align-items: center; gap: 2px; }
.back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* 日期栏 */
.nav { display: flex; align-items: center; gap: 8px; }
.arrow { width: 40px; height: 40px; border-radius: 50%; background: var(--card); display: grid; place-items: center; flex: none; box-shadow: 0 3px 0 var(--shadow); }
.arrow svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.datebtn { flex: 1; min-width: 0; background: var(--card); border-radius: 18px; padding: 6px 10px; display: flex; flex-direction: column; align-items: center; line-height: 1.25; box-shadow: 0 3px 0 var(--shadow); }
.datebtn .d { font-family: var(--f-cute); font-size: 23px; }
.datebtn .w { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.badge { font-size: 11px; padding: 0 7px; border-radius: 99px; color: #fff; }
.badge.today { background: var(--rose); }
.badge.past { background: #7FA79A; }
.badge.future { background: var(--violet); }
.subrow { display: flex; align-items: center; gap: 8px; padding: 0 4px; font-size: 13px; color: #4F6E79; min-height: 26px; }
.subrow span { flex: 1; min-width: 0; }
.pill-btn { background: var(--ink); color: #fff; font-size: 12px; padding: 3px 11px; border-radius: 99px; flex: none; }

/* 月历 */
.cal { background: var(--card); border-radius: 22px; padding: 10px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.cal-h { display: flex; justify-content: space-between; align-items: center; font-family: var(--f-cute); font-size: 17px; }
.cal-h .arrow { width: 32px; height: 32px; box-shadow: none; background: var(--soft); }
.grid7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.grid7 .wd { font-size: 11px; color: var(--faint); padding-bottom: 2px; }
.day { border-radius: 10px; padding: 5px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; font-variant-numeric: tabular-nums; position: relative; }
.day i { width: 6px; height: 6px; border-radius: 50%; }
.day.full i { background: var(--ok); }
.day.miss i { background: #E8964A; }
.day.future i { background: #C5CED1; }
.day.part i { box-shadow: inset 0 0 0 1.5px var(--rose); }
.day.chg::after { content: ""; position: absolute; top: 3px; right: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--violet); }
.day.is-today { font-weight: 700; color: var(--rose); }
.day.sel { background: var(--bg); }
.day.none { color: #B9C7CB; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--muted); padding: 2px 4px 0; }
.legend i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }

/* 药盒格子 */
.box { background: var(--card); border-radius: 24px; padding: 10px; display: grid; gap: 6px; box-shadow: 0 6px 0 var(--shadow); }
.box.wide { grid-template-columns: 1fr; }
.cell { border-radius: 17px; padding: 14px 4px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; transition: transform .15s; }
.cell:active { transform: scale(.97); }
.c-am { background: var(--c-am); } .c-noon { background: var(--c-noon); } .c-aft { background: var(--c-aft); }
.c-pm { background: var(--c-pm); } .c-bed { background: var(--c-bed); } .c-once { background: var(--c-once); }
.cell.empty { opacity: .45; }
.cell.sel { box-shadow: inset 0 0 0 3px var(--ink); }
.cell .big { font-family: var(--f-cute); font-size: 30px; line-height: 30px; }
.cell .big.two { font-size: 20px; }
.cell .cnt { font-size: 12px; font-variant-numeric: tabular-nums; min-height: 1.4em; }
.box.wide .cell { flex-direction: row; justify-content: center; gap: 10px; padding: 12px 6px; }
.box.wide .cell .big { font-size: 20px; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; min-height: 9px; padding: 0 2px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ink); opacity: .55; }
.dots i.on { background: var(--ink); opacity: 1; }
.cell.full .big { opacity: .35; }
.stamp { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -62%) rotate(-12deg); font-family: var(--f-cute); font-size: 14px; color: var(--rose); border: 2px solid var(--rose); border-radius: 10px; padding: 1px 6px; background: rgba(255,255,255,.78); white-space: nowrap; }
.stamp.pop { animation: stamp .35s ease; }
.stamp.miss { color: var(--warn); border-color: var(--warn); }
.box.wide .stamp { left: auto; right: 14px; transform: translateY(-50%) rotate(-8deg); top: 50%; }
@keyframes stamp { from { opacity: 0; scale: 1.6; } }

/* 清单 */
.tray { background: var(--card); border-radius: 24px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.tray h2 { margin: 0 0 2px; font-family: var(--f-cute); font-weight: 400; font-size: 18px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tray h2 small { font-family: var(--f-body); font-size: 12px; color: var(--muted); text-align: right; }
.item { display: flex; align-items: stretch; gap: 6px; }
.item-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: var(--soft); text-align: left; }
.ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.r-oral { background: #FFE6E1; color: #D9706F; }
.r-topical { background: #E3EEFA; color: #5487C4; }
.r-vaginal { background: #EDE6FA; color: #8A68C4; }
.r-injection { background: #DDF2EA; color: #3E9473; }
.r-event { background: #DDF2EA; color: #3E9473; }
.r-other { background: #FFF0CC; color: #C28A12; }
.tx { flex: 1; min-width: 0; line-height: 1.35; overflow-wrap: anywhere; }
.tx b { font-weight: 500; }
.tx small { display: block; font-size: 12px; color: var(--muted); }
.tx em { display: block; font-style: normal; font-size: 11px; margin-top: 2px; color: #7A6BC9; }
.tx em.memo { color: #8A7356; }
.st { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--ink); color: #fff; flex: none; text-align: center; line-height: 1.35; }
.item.done .item-main { background: #fff; box-shadow: inset 0 0 0 1.5px #E3EEE9; }
.item.done .tx b { text-decoration: line-through; text-decoration-color: #9FB9C0; color: #7D959C; }
.item.done .st { background: transparent; color: var(--ok); padding: 3px 0; }
.item.pending .st { opacity: .5; }
.item.fut .st { background: #EEF1F2; color: var(--faint); }
.item.miss .st { background: #FBE7D6; color: #B4652A; }
.item-edit { flex: none; font-size: 12px; color: var(--muted); background: var(--soft); border-radius: 14px; padding: 0 10px; }
.empty-line { font-size: 13px; color: var(--faint); text-align: center; padding: 10px 0; }
.tray-actions { display: flex; gap: 8px; }
.ghost { flex: 1; background: #EAF5F0; border-radius: 14px; padding: 10px; font-size: 14px; font-weight: 500; }
.extras { background: #FFFBF3; border-radius: 16px; padding: 10px 12px; font-size: 13px; color: #6F6353; display: flex; flex-direction: column; gap: 3px; }
.extras b { font-weight: 500; }
.extras small { color: #A0937F; font-size: 11px; }

/* 今日的话 */
.note { background: #FFFDF2; border-radius: 18px; padding: 14px 16px; text-align: left; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 6px 14px -12px rgba(80, 60, 20, .5); width: 100%; }
.note .q { font-family: var(--f-cute); font-size: 17px; line-height: 1.5; color: #5A4630; }
.note small { font-size: 12px; color: #A0937F; }
.note textarea { width: 100%; border: 1px solid #EADFC6; border-radius: 12px; padding: 10px; background: #fff; resize: vertical; font-size: 16px; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; }

/* 表单页 */
.page-h { display: flex; align-items: center; gap: 6px; }
.page-h h1 { margin: 0; font-family: var(--f-cute); font-weight: 400; font-size: 22px; flex: 1; }
.card { background: var(--card); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.card h2 { margin: 0; font-family: var(--f-cute); font-weight: 400; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .lbl { font-size: 12px; color: var(--muted); }
.field input[type="text"], .field input[type="date"], .field input[type="time"], .field textarea, .login input {
  width: 100%; border: 1px solid #D7E8E1; border-radius: 12px; padding: 10px 12px; background: var(--soft); font-size: 16px; min-height: 44px;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 14px; padding: 6px 13px; border-radius: 99px; background: var(--soft); box-shadow: inset 0 0 0 1px #D7E8E1; }
.chip.on { background: var(--ink); color: #fff; box-shadow: none; }
.doses { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.dose { min-width: 0; border-radius: 14px; padding: 8px 2px; background: var(--soft); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dose.on { background: #E6F4EE; box-shadow: inset 0 0 0 1.5px var(--ok); }
.dose .lbl { font-size: 12px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper button { width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 1px #D7E8E1; font-size: 17px; line-height: 1; flex: none; }
.stepper b { min-width: 1.7em; text-align: center; font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }
.seg3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg3 button { border-radius: 12px; padding: 8px 4px; background: var(--soft); box-shadow: inset 0 0 0 1px #D7E8E1; font-size: 14px; line-height: 1.3; }
.seg3 button small { display: block; font-size: 11px; color: var(--muted); }
.seg3 button.on { background: #fff; box-shadow: inset 0 0 0 2px var(--ink); }
.primary { background: var(--ink); color: #fff; border-radius: 14px; padding: 13px; font-weight: 500; font-size: 15px; width: 100%; }
.primary:disabled { opacity: .5; }
.danger { color: var(--rose); background: #FBEFF1; border-radius: 14px; padding: 11px; font-size: 14px; width: 100%; }
.danger.confirm { background: var(--rose); color: #fff; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.error { font-size: 13px; color: var(--rose); background: #FBEFF1; padding: 8px 12px; border-radius: 12px; margin: 0; }
.history { display: flex; flex-direction: column; gap: 6px; }
.history div { display: flex; align-items: center; gap: 8px; font-size: 13px; background: var(--soft); border-radius: 12px; padding: 8px 10px; }
.history div span { flex: 1; min-width: 0; }
.history button { font-size: 12px; color: var(--rose); padding: 4px 8px; border-radius: 10px; background: #fff; flex: none; }
.history button.confirm { background: var(--rose); color: #fff; }

/* 药品列表 */
.med-list { display: flex; flex-direction: column; gap: 8px; }
.med-row { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 18px; padding: 12px 14px; text-align: left; width: 100%; }
.med-row.off { opacity: .6; }
.med-row .chev { color: var(--faint); font-size: 18px; }
.section-t { font-size: 13px; color: var(--muted); margin: 6px 4px 0; }

/* 暗号、选身份 */
.login { margin: auto 0; display: flex; flex-direction: column; gap: 16px; padding: 24px 6px; text-align: center; }
.login h1 { font-family: var(--f-cute); font-weight: 400; font-size: 34px; margin: 0; }
.login p { margin: 0; color: var(--muted); }
.login form { display: flex; flex-direction: column; gap: 12px; }
.who-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.who-btns button { background: var(--card); border-radius: 22px; padding: 26px 8px; font-family: var(--f-cute); font-size: 22px; box-shadow: 0 6px 0 var(--shadow); }
.who-btns button.on { box-shadow: inset 0 0 0 3px var(--ink), 0 6px 0 var(--shadow); }

/* 确认框 */
.modal { position: fixed; inset: 0; z-index: 15; background: rgba(46, 71, 86, .35); display: flex; align-items: flex-end; justify-content: center; padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); animation: fade .15s ease; }
.sheet { background: var(--card); border-radius: 24px; padding: 20px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; animation: rise .2s ease; }
.sheet h2 { margin: 0; font-family: var(--f-cute); font-weight: 400; font-size: 20px; }
.sheet p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; }
.sheet p b { color: var(--ink); font-weight: 500; }
.sheet .row-btns button { padding: 12px; }
@media (min-width: 600px) { .modal { align-items: center; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; font-size: 14px; padding: 10px 18px; border-radius: 18px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; max-width: calc(100% - 32px); text-align: center; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
