:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #8b91a1;
  --line: #eceef2;
  --accent: #f2543d;
  --accent-soft: #ffe9e4;
  --accent-2: #ff8a5b;
  --ok: #2fae6a;
  --warn: #e8a33d;
  --danger: #e5484d;
  --shadow: 0 1px 3px rgba(31, 36, 48, 0.04), 0 8px 24px rgba(31, 36, 48, 0.05);
  --shadow-press: 0 1px 2px rgba(31, 36, 48, 0.05);
  --radius: 16px;
  --tabbar-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 15px; }

#app { min-height: 100vh; padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px); }

/* ---------- 顶部 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 10px;
  background: linear-gradient(180deg, #fff 60%, rgba(255, 255, 255, 0.86));
  backdrop-filter: blur(10px);
}
.app-header h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.app-header__titles { min-width: 0; }
.app-header__sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.app-header__sub:empty { display: none; }
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
}
.today-btn { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; gap: 1px; padding: 6px 12px; font-size: 12px; white-space: nowrap; }
.today-btn__lunar { font-size: 11px; font-weight: 400; color: var(--muted); }
.today-btn__lunar:empty { display: none; }

.view { padding: 0 14px 12px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid rgba(236, 238, 242, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.card--alert { border-left: 3px solid var(--danger); }
.view > .card { animation: view-in 0.3s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
.view > .card:nth-child(2) { animation-delay: 45ms; }
.view > .card:nth-child(3) { animation-delay: 90ms; }
.view > .card:nth-child(4) { animation-delay: 135ms; }
.view > .card:nth-child(n + 5) { animation-delay: 180ms; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes item-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.card__title { font-size: 14px; font-weight: 600; margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- 倒计时卡片 ---------- */
.countdown {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scroll-snap-type: x mandatory;
}
.countdown::-webkit-scrollbar { display: none; }
.cd-card {
  flex: 0 0 auto;
  width: 132px;
  scroll-snap-align: start;
  border-radius: 18px;
  padding: 14px;
  background: linear-gradient(155deg, #ffffff 25%, #fff1ea 100%);
  border: 1px solid #ffe3da;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  text-align: left;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  animation: item-in 0.36s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.cd-card::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 84, 61, 0.14), rgba(242, 84, 61, 0) 72%);
  pointer-events: none;
}
.cd-card:active { transform: scale(0.95); box-shadow: var(--shadow-press); }
.cd-card__title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-card__num { font-size: 40px; font-weight: 800; line-height: 1.05; margin: 6px 0 0; color: var(--accent); font-variant-numeric: tabular-nums; }
.cd-card__num small { font-size: 14px; font-weight: 600; margin-left: 3px; color: var(--muted); }
.cd-card__date { font-size: 11px; color: var(--muted); margin-top: 4px; }
.cd-card__today { color: var(--accent-2); }

/* ---------- 日历 ---------- */
.cal-card { padding: 10px 8px 6px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 10px; }
.cal-nav__label { font-size: 16px; font-weight: 700; }
.cal-nav__label small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.cal-nav__btns { display: flex; gap: 6px; }
.cal-nav button {
  border: none; background: #f2f3f6; color: var(--text);
  width: 32px; height: 32px; border-radius: 50%; font-size: 15px; display: grid; place-items: center;
}
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 4px; }
.cal-week span { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 0 2px; }
.cal-cell {
  position: relative;
  min-height: 50px;
  border-radius: 12px;
  padding: 5px 3px 4px;
  display: flex; flex-direction: column; align-items: center;
  border: none; background: transparent; color: inherit;
  transition: background 0.18s ease, transform 0.14s ease;
}
.cal-cell:active { transform: scale(0.92); }
.cal-cell__day { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-cell__lunar { font-size: 10px; color: var(--muted); line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-cell__lunar.is-festival { color: var(--accent); }
.cal-cell.is-out { opacity: 0.32; }
.cal-cell.is-today { background: var(--accent-soft); }
.cal-cell.is-today .cal-cell__day { color: var(--accent); }
.cal-cell.is-selected { background: var(--accent); }
.cal-cell.is-selected .cal-cell__day, .cal-cell.is-selected .cal-cell__lunar { color: #fff; }
.cal-cell__dots { position: absolute; bottom: 3px; display: flex; gap: 3px; }
.cal-cell__dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.cal-cell.is-selected .cal-cell__dot { background: #fff; }
.cal-cell__badge {
  position: absolute; top: 2px; right: 4px; min-width: 14px; height: 14px; padding: 0 3px;
  border-radius: 7px; background: var(--accent); color: #fff; font-size: 9px; line-height: 14px; text-align: center;
}

/* ---------- 列表 ---------- */
.list-item {
  position: relative;
  display: flex; align-items: center; gap: 13px;
  background: var(--card);
  border: 1px solid rgba(236, 238, 242, 0.9);
  border-radius: 18px;
  padding: 14px 15px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: item-in 0.36s cubic-bezier(0.22, 0.61, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.list-item:active { transform: scale(0.982); box-shadow: var(--shadow-press); border-color: #f6d9d2; }
.list-item.is-disabled { opacity: 0.6; }
@media (hover: hover) {
  .list-item:hover { transform: translateY(-1px); border-color: #f6d9d2; box-shadow: 0 2px 5px rgba(31, 36, 48, 0.05), 0 12px 28px rgba(31, 36, 48, 0.07); }
  .list-item:hover:active { transform: scale(0.982); }
}
.date-badge {
  flex: 0 0 auto;
  width: 52px; height: 56px;
  border-radius: 14px;
  background: linear-gradient(155deg, #fff3ef, #ffe3da);
  color: var(--accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.15;
}
.date-badge__day { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.date-badge__month { font-size: 10px; font-weight: 600; opacity: 0.75; margin-top: 1px; }
.date-badge--empty { background: #f4f5f7; color: var(--muted); }
.list-item__main { flex: 1; min-width: 0; }
.list-item__title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; letter-spacing: 0.2px; }
.list-item__meta { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item__meta--remind { color: rgba(242, 84, 61, 0.78); }
.list-item__right { text-align: right; flex: 0 0 auto; padding-left: 4px; }
.days-big {
  font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.days-big small { font-size: 11px; font-weight: 600; margin-left: 2px; -webkit-text-fill-color: var(--muted); }
.days-today {
  display: inline-block;
  font-size: 14px; font-weight: 700; color: #fff;
  padding: 5px 12px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px rgba(242, 84, 61, 0.35);
}
.pill {
  display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: 0.2px;
  padding: 2px 8px; border-radius: 999px;
  background: #f2f3f6; color: var(--muted);
}
.pill--ok { background: #e7f7ee; color: var(--ok); }
.pill--off { background: #f3f4f6; color: #a3a8b5; }
.pill--fail { background: #fdeaea; color: var(--danger); }
.pill--accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- 记录列表 ---------- */
.log-item {
  background: var(--card);
  border: 1px solid rgba(236, 238, 242, 0.9);
  border-radius: 16px;
  padding: 13px 15px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  animation: item-in 0.36s cubic-bezier(0.22, 0.61, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.log-item__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 5px; }
.log-item__title { font-size: 14px; font-weight: 600; }
.log-item__msg {
  font-size: 12px; color: var(--muted);
  background: #f8f9fb; border-radius: 10px; padding: 8px 10px; margin-top: 8px;
  white-space: pre-wrap; word-break: break-all;
}
.log-item__error { color: var(--danger); margin-top: 6px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 13px; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px;
  background: #fbfbfc; outline: none; color: var(--text);
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); background: #fff; }
.textarea { min-height: 74px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.segment { display: flex; background: #f2f3f6; border-radius: 11px; padding: 3px; gap: 3px; }
.segment button {
  flex: 1; border: none; background: transparent; padding: 8px 0; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted);
}
.segment button.is-active { background: #fff; color: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px; font-size: 13px; color: var(--text);
}
.chip.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip.is-disabled { opacity: 0.45; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.switch input { width: 46px; height: 26px; appearance: none; background: #dfe2e8; border-radius: 999px; position: relative; transition: 0.2s; }
.switch input:checked { background: var(--accent); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: 0.2s; }
.switch input:checked::after { left: 22px; }

.plan-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.plan-row .select { flex: 1; }
.plan-row .input { width: 110px; flex: 0 0 auto; }
.plan-row .del { border: none; background: #fdeaea; color: var(--danger); width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto; }

/* ---------- 按钮 ---------- */
.btn {
  border: none; border-radius: 12px; padding: 11px 16px; font-size: 14px; font-weight: 600;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, opacity 0.16s;
}
.btn:active { transform: scale(0.96); }
.btn--primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 4px 14px rgba(242, 84, 61, 0.3); }
.btn--primary:active { box-shadow: 0 2px 6px rgba(242, 84, 61, 0.3); }
.btn--ghost { background: #f2f3f6; color: var(--text); }
.btn--danger { background: #fdeaea; color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.actions--split { justify-content: space-between; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  width: 54px; height: 54px; border-radius: 50%; border: none; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 26px; line-height: 1; padding-bottom: 3px;
  box-shadow: 0 10px 24px rgba(242, 84, 61, 0.42); z-index: 30;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.fab:active { transform: scale(0.9); box-shadow: 0 5px 12px rgba(242, 84, 61, 0.35); }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
}
.tabbar__item {
  border: none; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--muted); padding: 6px 0;
}
.tabbar__item.is-active { color: var(--accent); font-weight: 600; }
.tabbar__ico { font-size: 19px; }

/* ---------- 抽屉 ---------- */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(20, 22, 30, 0.42); opacity: 0; pointer-events: none;
  transition: opacity 0.24s; z-index: 50;
}
.drawer-mask.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-radius: 22px 22px 0 0; max-height: 90vh;
  transform: translateY(102%); transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: translateY(0); }
.drawer__handle { width: 40px; height: 4px; border-radius: 2px; background: #dfe2e8; margin: 10px auto 4px; flex: 0 0 auto; }
.drawer__body { overflow-y: auto; padding: 8px 18px calc(20px + var(--safe-bottom)); -webkit-overflow-scrolling: touch; }
.drawer h2 { font-size: 18px; margin: 6px 0 12px; }
.drawer h3 { font-size: 14px; margin: 16px 0 8px; }

/* ---------- 其他 ---------- */
.empty { text-align: center; padding: 40px 20px; }
.empty__ico { font-size: 46px; }
.empty h3 { margin: 12px 0 6px; font-size: 17px; }
.empty p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.meta-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 2px 0; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 30px); transform: translate(-50%, 20px);
  background: rgba(20, 22, 30, 0.9); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: 0.24s; z-index: 80; max-width: 80vw;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.login-mask { position: fixed; inset: 0; background: var(--bg); z-index: 90; display: grid; place-items: center; padding: 24px; }
.login-mask[hidden] { display: none; }
.login-card { width: 100%; max-width: 340px; background: #fff; border-radius: 18px; padding: 22px; box-shadow: var(--shadow); text-align: center; }
.login-card h2 { margin: 0 0 4px; font-size: 18px; }
.login-card input { width: 100%; margin: 16px 0 12px; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; text-align: center; }
.login-code-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.login-code-row input { min-width: 0; flex: 1; margin: 0; }
.login-code-row button { white-space: nowrap; }
.login-card > .btn { width: 100%; }
button:disabled { cursor: default; opacity: .55; }
.login-error { color: var(--danger); font-size: 12px; min-height: 16px; margin: 8px 0 0; }
.channel-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.channel-item:last-child { border-bottom: none; }

/* ---------- 交互动效补充 ---------- */
.icon-btn, .chip, .cal-nav button { transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease; }
.icon-btn:active, .chip:active, .cal-nav button:active { transform: scale(0.93); }
.empty.card { background: linear-gradient(170deg, #ffffff, #fff8f5); border-color: #ffe9e2; }
.empty__ico { display: inline-block; filter: drop-shadow(0 6px 12px rgba(242, 84, 61, 0.2)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}
