/* PillPal — 移动端优先样式，青绿色医疗风 */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-light: #f0fdfa;
  --bg: #f6f8f7;
  --card: #ffffff;
  --text: #1c2b29;
  --muted: #6b7a77;
  --danger: #dc2626;
  --ok: #059669;
  --border: #e2e8e4;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(13, 60, 53, .08), 0 4px 14px rgba(13, 60, 53, .06);
}

html { font-size: 16px; }
body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .8rem; line-height: 1.6; }
.center { text-align: center; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(180deg, var(--teal-light), var(--bg));
}
.topbar h1 { font-size: 1.25rem; font-weight: 700; }
.chip {
  display: inline-block; margin-top: 4px;
  font-size: .72rem; color: #fff; background: var(--teal);
  border-radius: 999px; padding: 2px 10px;
}
.next-hint { font-size: .78rem; color: var(--teal-dark); margin-top: 6px; text-align: right; line-height: 1.5; }
.next-hint b { font-weight: 700; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin: 0 14px 12px;
}
.progress-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.progress-track { height: 8px; border-radius: 999px; background: #e5efeb; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), #2dd4bf); border-radius: 999px; transition: width .3s; }

/* ---------- 按钮 ---------- */
button {
  font: inherit; border: none; border-radius: 10px; cursor: pointer;
}
.primary {
  background: var(--teal); color: #fff; padding: 12px 20px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(13, 148, 136, .35);
}
.primary:active { background: var(--teal-dark); }
.primary.big { display: block; margin: 14px auto; padding: 14px 28px; font-size: 1.05rem; }
.ghost { background: transparent; color: var(--teal-dark); padding: 6px 8px; font-size: .82rem; }
.ghost:active { background: var(--teal-light); }

/* ---------- 剂量列表 ---------- */
.dose-list { display: flex; flex-direction: column; gap: 8px; padding: 0 14px; }
.dose {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px;
}
.dose .time {
  min-width: 52px; font-size: 1.05rem; font-weight: 700; color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
}
.dose.overdue .time { color: var(--danger); }
.dose.overdue .time::after { content: ' 过期'; font-size: .62rem; font-weight: 600; display: block; color: var(--danger); }
.dose .info { flex: 1; min-width: 0; }
.dose .name { font-weight: 600; font-size: .95rem; }
.dose .meta { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.dose .anchor {
  display: inline-block; font-size: .68rem; color: var(--teal-dark);
  background: var(--teal-light); border-radius: 6px; padding: 1px 6px; margin-left: 6px;
}
.dose.done { opacity: .55; }
.dose.done .name { text-decoration: line-through; }
.dose .check {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  border: 2px solid var(--teal); background: transparent; color: var(--teal);
  font-size: 1.1rem; font-weight: 700;
}
.dose .check:active { background: var(--teal-light); }
.dose.done .check { background: var(--teal); color: #fff; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 60px 24px 20px; }
.empty p:first-child { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.empty .muted { margin-top: 18px; }

/* ---------- 统计 ---------- */
.view-title { font-size: 1.05rem; padding: 6px 16px 10px; }
.stats-list { display: flex; flex-direction: column; gap: 8px; padding: 0 14px; }
.stat {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px;
}
.stat .day { min-width: 76px; font-size: .85rem; font-weight: 600; }
.stat .bar { flex: 1; height: 8px; border-radius: 999px; background: #e5efeb; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), #2dd4bf); }
.stat .cnt { min-width: 56px; text-align: right; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.stat.empty-stat { justify-content: center; color: var(--muted); font-size: .82rem; }

/* ---------- 规则页 ---------- */
.rule-item { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: .88rem; }
.rule-item + .rule-item { border-top: 1px solid var(--border); }
.rule-label { color: var(--muted); }
.rules-list { list-style: none; padding: 0 14px; display: flex; flex-direction: column; gap: 8px; }
.rules-list li {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; font-size: .86rem; line-height: 1.6;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: none; padding: 12px 0 10px;
  font-size: .86rem; color: var(--muted); font-weight: 600;
}
.tabbar button.active { color: var(--teal); }

/* ---------- 设定弹层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(20, 40, 36, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 480px; max-height: 92dvh; overflow-y: auto;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
}
.sheet h2 { font-size: 1.1rem; }
.sheet .hint { font-size: .8rem; color: var(--muted); margin: 6px 0 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .84rem; color: var(--muted); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; font: inherit; font-size: 1rem;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; background: #fafcfb; color: var(--text);
}
.field select { appearance: auto; }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.actions button { flex: 1; }
.actions .ghost { border: 1px solid var(--border); padding: 12px; font-weight: 500; color: var(--muted); }
.actions .danger { border: 1px solid #fecaca; color: var(--danger); }

/* ---------- 通用 ---------- */
.view-head { display: flex; align-items: center; justify-content: space-between; padding-right: 14px; }
.view-title { font-size: 1.05rem; padding: 6px 16px 4px; flex: 1; }
.pad { padding: 4px 16px 10px; }
.primary.small { padding: 8px 14px; font-size: .85rem; border-radius: 999px; }
.chips { display: flex; gap: 6px; margin-top: 4px; }
.chip.smart { background: #7c3aed; }
.chip.ver { background: #64748b; }
.chip.streak { background: #ea580c; }

/* ---------- 药物欢迎横幅 ---------- */
.welcome {
  margin: 0 14px 12px; padding: 14px 16px;
  background: linear-gradient(135deg, #f0fdfa, #f5f3ff);
  border: 1px solid #c7e8e2; border-radius: var(--radius);
}
.welcome h3 { font-size: 1rem; margin-bottom: 6px; color: var(--teal-dark); }
.welcome p { font-size: .84rem; color: var(--text); line-height: 1.7; }
.welcome .small-btn { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row .grow { flex: 1; }
.sub-title { font-size: .92rem; font-weight: 600; margin: 14px 0 8px; color: var(--teal-dark); }
.sub-label { display: block; font-size: .78rem; color: var(--muted); margin: 8px 0 4px; }
.small-btn { border: 1px dashed var(--teal); color: var(--teal-dark); border-radius: 8px; padding: 8px 12px; font-size: .85rem; }
.pill-sep { align-self: center; color: var(--muted); font-size: .85rem; padding-bottom: 10px; }
.mt-offset-hint { font-size: .72rem; color: var(--muted); align-self: center; padding-bottom: 10px; white-space: nowrap; }

/* ---------- 滚轮式时间选择器 ---------- */
.med-time-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.time-pick {
  position: relative;
  padding: 10px 12px 12px;
  background: linear-gradient(135deg, #f0fdfa 0%, #f5f3ff 100%);
  border: 1px solid #c7ece4;
  border-radius: 16px;
  box-shadow: inset 0 1px 2px rgba(255,255,255,.8), 0 2px 8px rgba(13,60,53,.06);
}
.tp-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; padding-right: 30px; }
.tp-preset {
  font-size: .72rem; font-weight: 600; color: var(--teal-dark);
  background: rgba(255,255,255,.85); border: 1px solid #bfe8e0;
  border-radius: 999px; padding: 5px 12px;
  transition: background .15s, color .15s;
}
.tp-preset:active { background: var(--teal); color: #fff; border-color: var(--teal); }
.tp-wheel-row {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.tp-wheel {
  width: 64px; height: 132px; overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 28%, #000 72%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 28%, #000 72%, transparent 100%);
  overscroll-behavior: contain;
}
.tp-wheel::-webkit-scrollbar { display: none; }
.tp-w-item {
  height: 44px; line-height: 44px; text-align: center;
  font-size: 1.2rem; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums;
  scroll-snap-align: center;
  transition: color .15s, font-size .15s;
}
.tp-w-item.sel { color: var(--teal-dark); font-size: 1.5rem; }
.tp-colon {
  font-size: 1.6rem; font-weight: 800; color: var(--teal);
  animation: tp-blink 1.4s ease-in-out infinite;
}
@keyframes tp-blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
/* 生效日星期选择 */
.tp-days { display: flex; align-items: center; gap: 5px; margin-top: 10px; flex-wrap: wrap; }
.tp-days-label { font-size: .7rem; color: var(--muted); margin-right: 2px; }
.tp-day {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid #cdeee7; background: #fff; color: var(--muted);
  font-size: .76rem; font-weight: 600;
  transition: background .15s, color .15s;
}
.tp-day.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.tp-day-all {
  margin-left: auto;
  font-size: .7rem; font-weight: 600; color: var(--teal-dark);
  border: 1px dashed var(--teal); background: transparent;
  border-radius: 999px; padding: 4px 12px;
}
.tp-day-all:active { background: var(--teal); color: #fff; }

.tp-center-band {
  position: absolute; left: 8px; right: 8px; top: 50%;
  transform: translateY(-50%); height: 44px;
  border-top: 1.5px solid rgba(13,148,136,.55);
  border-bottom: 1.5px solid rgba(13,148,136,.55);
  border-radius: 10px;
  background: rgba(13,148,136,.05);
  pointer-events: none;
}
/* 简约 ✕ 删除：卡片右上角小圆点，只有一个时间时不显示 */
.mt-del {
  position: absolute; top: 8px; right: 10px;
  width: 26px; height: 26px; border-radius: 50%;
  border: none; background: transparent;
  color: var(--muted); font-size: .82rem; line-height: 1;
  transition: background .15s, color .15s;
}
.mt-del:active { background: #fee2e2; color: var(--danger); }

/* ---------- 达成情况日历 ---------- */
.cal-card {
  margin: 0 14px 12px; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head b { font-size: .95rem; }
.cal-head .ghost { font-size: 1.1rem; padding: 0 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-week { text-align: center; font-size: .68rem; color: var(--muted); padding: 2px 0; }
.cal-cell {
  border: none; background: #f1f5f4; border-radius: 8px;
  padding: 5px 0 3px; display: flex; flex-direction: column; align-items: center; gap: 1px;
  cursor: pointer; font: inherit;
}
.cal-cell:active { transform: scale(.95); }
.cal-day { font-size: .78rem; color: var(--muted); font-weight: 600; }
.cal-cnt { font-size: .6rem; color: var(--muted); }
.cal-cell.ok { background: #ecfdf5; }
.cal-cell.ok .cal-mark { color: #059669; }
.cal-cell.no { background: #fef2f2; }
.cal-cell.no .cal-mark { color: #dc2626; }
.cal-mark { font-size: 1.1rem; font-weight: 700; line-height: 1; }
.cal-cell.future { opacity: .35; }
.legend { display: flex; gap: 8px; justify-content: center; margin-top: 12px; font-size: .66rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 3px; vertical-align: -1px; }
.lg-empty { background: #f1f5f4; }
.lg-ok { background: #059669; }
.lg-no { background: #dc2626; }

/* 日历日详情 */
.detail-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .88rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-time { font-weight: 700; color: var(--teal-dark); font-variant-numeric: tabular-nums; min-width: 44px; }
.status-chip { margin-left: auto; font-size: .7rem; padding: 2px 8px; border-radius: 999px; flex: none; }
.status-chip.done { background: var(--teal-light); color: var(--teal-dark); }
.status-chip.skipped { background: #fef3c7; color: #b45309; }
.status-chip.missed { background: #fee2e2; color: #b91c1c; }

/* ---------- 智能模式 ---------- */
.smart-note {
  margin: 0 14px 12px; padding: 10px 14px;
  background: #f5f3ff; color: #5b21b6; border-radius: var(--radius);
  font-size: .8rem; line-height: 1.6;
}

/* ---------- 开关 ---------- */
.switch-field { display: flex; align-items: center; justify-content: space-between; }
.switch-field label { margin-bottom: 0 !important; }
.update-row { display: flex; align-items: center; gap: 8px; padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--border); }
.update-row .muted { flex: 1; font-size: .76rem; }

/* 提醒方式：响铃/震动/语音 独立打钩 */
.alert-style-row { display: flex; align-items: center; gap: 6px; padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.as-label { font-size: .76rem; color: var(--muted); margin-right: 2px; }
.as-chip {
  font-size: .74rem; font-weight: 600; color: var(--muted);
  background: #fafcfb; border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px;
  transition: all .15s;
}
.as-chip.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.as-chip.on::after { content: ' ✓'; }
.switch { position: relative; display: inline-block; width: 48px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #cbd5d1; border-radius: 999px; transition: .2s;
}
.slider::before {
  content: ''; position: absolute; width: 20px; height: 20px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--teal); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ---------- 药物清单 ---------- */
.med-list { display: flex; flex-direction: column; gap: 8px; padding: 0 14px 20px; }
.med-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px;
}
.med-card.off { opacity: .5; }
.med-head { display: flex; align-items: center; gap: 10px; }
.med-name { font-weight: 600; flex: 1; font-size: .95rem; }
.med-head .ghost { font-size: .8rem; padding: 4px 6px; }
.med-meta { font-size: .78rem; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.med-times-sum {
  margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px;
}
.time-tag {
  font-size: .72rem; background: var(--teal-light); color: var(--teal-dark);
  border-radius: 999px; padding: 2px 8px;
}
.time-tag.cond { background: #fff7ed; color: #c2410c; }
.med-foot { display: flex; gap: 8px; margin-top: 8px; }
.med-foot .ghost { border: 1px solid var(--border); border-radius: 8px; }

/* ---------- 星期选择器 ---------- */
.weekday-picker { display: flex; gap: 6px; }
.weekday-picker button {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: #fafcfb; color: var(--muted);
  font-size: .82rem;
}
.weekday-picker button.on { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ---------- 提醒弹窗 ---------- */
.prompt-list { display: flex; flex-direction: column; gap: 10px; }
.prompt-item {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px;
}
.prompt-item .p-head { display: flex; align-items: baseline; gap: 8px; }
.prompt-item .p-time { font-weight: 700; color: var(--teal-dark); font-size: .95rem; font-variant-numeric: tabular-nums; }
.prompt-item .p-name { font-weight: 600; }
.prompt-item .p-meta { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.prompt-item .p-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.prompt-item .p-btns button {
  font-size: .82rem; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: #fafcfb; color: var(--text);
}
.prompt-item .p-btns .done { background: var(--teal); color: #fff; border-color: var(--teal); font-weight: 600; }
.prompt-item .p-btns .off { color: var(--danger); border-color: #fecaca; }
.prompt-item.urgent { border: 1.5px solid #f87171; background: #fff7f7; }

/* ---------- 系统通知状态横幅 ---------- */
.notify-status {
  margin: 0 14px 12px; padding: 10px 14px;
  background: #fffbeb; border: 1px solid #fcd34d; border-radius: var(--radius);
  font-size: .8rem; color: #92400e; line-height: 1.6;
}
.ns-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ns-btns .small-btn { border: 1px solid #fcd34d; color: #92400e; }
.notify-status.ok { background: #f0fdf4; border-color: #86efac; color: #166534; }
.notify-status.ok .ns-btns .small-btn { border-color: #86efac; color: #166534; }

/* ---------- 预览模式 ---------- */
.preview-bar {
  margin: 0 14px 12px; padding: 12px 14px;
  background: var(--teal-light); border: 1px dashed var(--teal);
  border-radius: var(--radius);
}
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.preview-head span { font-weight: 600; font-size: .92rem; color: var(--teal-dark); }
.preview-bar .muted { margin-top: 6px; }
.dose.preview { border: 1px dashed var(--border); opacity: .9; }
.dose.preview .time::after { content: ' 预览'; font-size: .6rem; font-weight: 600; color: var(--muted); display: block; }
.dose.inactive { opacity: .4; }

/* ---------- 剂量状态 ---------- */
.dose.skipped { opacity: .55; }
.dose.skipped .name { text-decoration: line-through; color: var(--muted); }
.dose.skipped .time { color: var(--muted); }
.smart-tag {
  display: inline-block; font-size: .68rem; color: #6d28d9;
  background: #f5f3ff; border-radius: 6px; padding: 1px 6px; margin-left: 6px;
}
