:root {
  --primary: #2E7D6B;
  --primary-d: #246157;
  --confirmed: #34C759;
  --alert: #FF3B30;
  --pending: #C7C7CC;
  --ink: #1C1C1E;
  --sub: #6B6B70;
  --bg: #F2F5F4;
  --card: #FFFFFF;
  --line: #E5E7E6;
  --warn: #FF9500;
  --radius: 18px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 17px;
  color: var(--ink);
  background: var(--bg);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

.view { display: flex; flex-direction: column; min-height: 100vh; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-card {
  margin: auto;
  width: 100%;
  max-width: 360px;
  padding: 32px 24px;
  text-align: center;
}
.brand { font-size: 64px; line-height: 1; }
.brand-title { font-size: 30px; margin: 12px 0 4px; color: var(--primary); }
.brand-sub { color: var(--sub); margin: 0 0 28px; font-size: 16px; }

.field { text-align: left; margin-bottom: 16px; }
.field label { display: block; font-size: 15px; color: var(--sub); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  height: 52px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 0 16px;
  font-size: 17px;
  background: #fff;
  color: var(--ink);
}
.field textarea { height: 80px; padding: 12px 16px; resize: none; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
}

.msg { min-height: 22px; font-size: 15px; margin: 10px 0 0; }
.msg.err { color: var(--alert); }
.msg.ok { color: var(--primary); }

/* ---------- 按钮 ---------- */
.btn {
  border: none;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
  height: 56px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .05s, background .15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:disabled { background: var(--pending); color: #fff; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-block { width: 100%; }
.btn-lg { height: 64px; font-size: 19px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 10px;
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.topbar h1 { font-size: 22px; margin: 0; }
.icon-btn {
  border: none; background: #fff; width: 46px; height: 46px; border-radius: 50%;
  font-size: 22px; cursor: pointer; box-shadow: var(--shadow);
}

#page-content { flex: 1; padding: 8px 16px 100px; }

/* ---------- 底部导航 ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.nav-btn {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0; color: var(--sub); font-size: 12px;
}
.nav-btn span { font-size: 24px; }
.nav-btn.active { color: var(--primary); font-weight: 700; }

/* ---------- 今日用药卡片 ---------- */
.section-title { font-size: 16px; color: var(--sub); margin: 14px 4px 8px; font-weight: 600; }
.med-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  margin-bottom: 14px; box-shadow: var(--shadow);
  border-left: 6px solid var(--primary);
}
.med-card.done { border-left-color: var(--confirmed); opacity: .92; }
.med-card.missed { border-left-color: var(--alert); }
.med-head { display: flex; align-items: center; justify-content: space-between; }
.med-name { font-size: 20px; font-weight: 700; }
.med-dose { color: var(--sub); font-size: 16px; margin-top: 2px; }
.med-time-tag {
  background: var(--bg); color: var(--sub); border-radius: 10px;
  padding: 4px 10px; font-size: 15px; font-weight: 600;
}
.med-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 15px; font-weight: 600; margin-top: 10px;
}
.med-status.ok { color: var(--confirmed); }
.med-status.wait { color: var(--warn); }
.med-status.miss { color: var(--alert); }
.btn-take {
  width: 100%; height: 56px; margin-top: 12px; border: none; border-radius: 14px;
  background: var(--primary); color: #fff; font-size: 18px; font-weight: 700; cursor: pointer;
}
.btn-take:active { transform: scale(.99); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--confirmed); }
.dot.red { background: var(--alert); }
.dot.gray { background: var(--pending); }

/* ---------- 加药表单 ---------- */
.time-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 22px;
  padding: 10px 16px; font-size: 16px; cursor: pointer; color: var(--ink);
}
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.color-row { display: flex; gap: 12px; margin-top: 8px; }
.color-dot {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent;
}
.color-dot.on { border-color: var(--ink); }
.stepper { display: flex; align-items: center; gap: 16px; margin-top: 6px; }
.stepper button {
  width: 50px; height: 50px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 26px; cursor: pointer;
}
.stepper .val { font-size: 24px; font-weight: 700; min-width: 40px; text-align: center; }

/* ---------- 弹层 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 20;
}
.sheet, .dialog {
  background: #fff; width: 100%; max-width: 480px;
  border-radius: 22px 22px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: up .2s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h2 { margin: 0 0 4px; font-size: 22px; }
.sheet-sub { color: var(--sub); margin: 0 0 16px; font-size: 16px; }
.pills { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; padding: 10px 0; }
.pill {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--pending); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #fff; transition: transform .1s, background .15s;
  border: 3px solid rgba(0,0,0,.05);
}
.pill:active { transform: scale(.92); }
.pill.done { background: var(--confirmed); }
.sheet-progress {
  text-align: center; font-size: 17px; color: var(--sub); margin: 10px 0 16px; font-weight: 600;
}
.sheet-actions, .dialog-actions { display: flex; gap: 12px; }
.sheet-actions .btn, .dialog-actions .btn { flex: 1; }

.dialog { border-radius: 18px; margin: auto; width: 88%; max-width: 360px; animation: pop .15s ease; }
@keyframes pop { from { transform: scale(.9); opacity: .5; } to { transform: none; opacity: 1; } }
.dialog p { font-size: 18px; margin: 4px 0 18px; line-height: 1.5; }

/* ---------- 记录 ---------- */
.rec-date { font-size: 16px; color: var(--sub); font-weight: 700; margin: 16px 4px 8px; }
.rec-item {
  background: var(--card); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow);
}
.rec-name { font-size: 18px; font-weight: 600; }
.rec-time { color: var(--sub); font-size: 15px; margin-top: 2px; }
.rec-state { font-size: 15px; font-weight: 700; }

/* ---------- 我的 ---------- */
.mine-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow); font-size: 17px;
}
.mine-row .k { color: var(--sub); }
.sync-badge {
  display: inline-block; padding: 4px 12px; border-radius: 12px; font-size: 15px; font-weight: 700;
  background: var(--bg); color: var(--sub);
}
.sync-badge.ok { background: rgba(52,199,89,.15); color: var(--confirmed); }
.sync-badge.err { background: rgba(255,59,48,.12); color: var(--alert); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(28,28,30,.92); color: #fff; padding: 12px 20px; border-radius: 14px;
  font-size: 16px; z-index: 40; max-width: 90%; text-align: center;
}
.empty { text-align: center; color: var(--sub); padding: 50px 20px; font-size: 17px; }
.empty .big { font-size: 56px; margin-bottom: 12px; }
