:root {
  --app-width: min(100vw, 430px);
  --rpx: calc(var(--app-width) / 750);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: calc(28 * var(--rpx));
  color: #1e293b;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100%;
  min-height: 100dvh;
  background: #f8fafc;
  position: relative;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #ffffff;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  grid-template-rows: auto auto;
  align-items: center;
  font-size: calc(32 * var(--rpx));
  font-weight: 600;
  padding: calc(20 * var(--rpx)) calc(8 * var(--rpx));
  padding-top: calc(20 * var(--rpx) + env(safe-area-inset-top, 0px));
  border-bottom: calc(1 * var(--rpx)) solid #eef2f6;
}

.app-header-title {
  grid-column: 2;
  margin: 0;
  text-align: center;
  font-size: inherit;
  font-weight: inherit;
}

.app-header-email {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: calc(4 * var(--rpx)) calc(16 * var(--rpx)) 0;
  text-align: center;
  font-size: calc(22 * var(--rpx));
  font-weight: 400;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-header-email[hidden] {
  display: none !important;
}

.nav-back {
  grid-column: 1;
  justify-self: start;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: #1e293b;
  cursor: pointer;
  font-family: inherit;
  padding: 0 8px;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(110 * var(--rpx) + var(--safe-bottom) + 96px);
}

.app-main.no-tab {
  padding-bottom: calc(40 * var(--rpx));
}

.container { padding: calc(24 * var(--rpx)); }

.card {
  background: #ffffff;
  border-radius: calc(32 * var(--rpx));
  padding: calc(32 * var(--rpx));
  margin-bottom: calc(24 * var(--rpx));
  box-shadow: 0 calc(4 * var(--rpx)) calc(12 * var(--rpx)) rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
  border: calc(1 * var(--rpx)) solid #eef2f6;
}

.card:active { transform: scale(0.98); }
.card.static:active { transform: none; }

input, textarea, select {
  background: #f9fafb;
  border-radius: calc(48 * var(--rpx));
  padding: calc(28 * var(--rpx)) calc(32 * var(--rpx));
  font-size: calc(32 * var(--rpx));
  color: #1e293b;
  border: calc(1 * var(--rpx)) solid #e2e8f0;
  width: 100%;
  font-family: inherit;
}

input:focus, textarea:focus, select:focus {
  border-color: #3b82f6;
  outline: none;
}

.btn, .btn-small, .btn-outline {
  border-radius: calc(48 * var(--rpx));
  padding: calc(20 * var(--rpx)) calc(40 * var(--rpx));
  text-align: center;
  font-size: calc(28 * var(--rpx));
  font-weight: 500;
  display: inline-block;
  min-width: calc(140 * var(--rpx));
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.btn {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  box-shadow: 0 calc(4 * var(--rpx)) calc(12 * var(--rpx)) rgba(59, 130, 246, 0.3);
}

.btn-outline {
  background: transparent;
  border: calc(2 * var(--rpx)) solid #3b82f6;
  color: #3b82f6;
}

.btn-small {
  padding: calc(16 * var(--rpx)) calc(28 * var(--rpx));
  font-size: calc(26 * var(--rpx));
  min-width: calc(100 * var(--rpx));
  min-height: 44px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
}

.tag {
  background: #eef2ff;
  padding: calc(12 * var(--rpx)) calc(24 * var(--rpx));
  border-radius: calc(40 * var(--rpx));
  font-size: calc(26 * var(--rpx));
  color: #3b82f6;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}

.flex-row { display: flex; flex-direction: row; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-column { display: flex; flex-direction: column; }

.text-primary { color: #3b82f6; }
.text-warning { color: #f59e0b; }
.text-danger { color: #ef4444; }
.text-secondary { color: #64748b; }
.font-bold { font-weight: 600; }
.font-32 { font-size: calc(32 * var(--rpx)); }
.font-36 { font-size: calc(36 * var(--rpx)); }
.mt-20 { margin-top: calc(20 * var(--rpx)); }
.mb-20 { margin-bottom: calc(20 * var(--rpx)); }
.ml-20 { margin-left: calc(20 * var(--rpx)); }
.divider { height: 1px; background: #eef2f6; margin: calc(20 * var(--rpx)) 0; }

.filter-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: calc(12 * var(--rpx));
  padding: calc(16 * var(--rpx)) calc(16 * var(--rpx));
  background: #ffffff;
  border-radius: calc(48 * var(--rpx));
  margin-bottom: calc(20 * var(--rpx));
  border: calc(1 * var(--rpx)) solid #eef2f6;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar { display: none; width: 0; height: 0; }

.filter-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 calc(22 * var(--rpx));
  background: #f1f5f9;
  border-radius: calc(48 * var(--rpx));
  font-size: calc(24 * var(--rpx));
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
}

.filter-item.active { background: #3b82f6; color: white; }

.progress-bar-bg {
  background: #e2e8f0;
  border-radius: calc(20 * var(--rpx));
  height: calc(16 * var(--rpx));
  overflow: hidden;
  margin-top: calc(8 * var(--rpx));
}
.progress-fill {
  background: #3b82f6;
  height: 100%;
  border-radius: calc(20 * var(--rpx));
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #ffffff;
  border-radius: calc(32 * var(--rpx));
  padding: calc(20 * var(--rpx));
  box-shadow: 0 calc(2 * var(--rpx)) calc(12 * var(--rpx)) rgba(0,0,0,0.04);
}
.weekday {
  text-align: center;
  padding: calc(8 * var(--rpx)) 0;
  font-weight: bold;
  color: #64748b;
  font-size: calc(24 * var(--rpx));
}
.day-cell {
  background: #f9fafb;
  text-align: center;
  padding: calc(12 * var(--rpx)) 0;
  min-height: calc(64 * var(--rpx));
  position: relative;
  border-radius: calc(16 * var(--rpx));
  margin: calc(3 * var(--rpx));
  cursor: pointer;
}
.day-num {
  font-size: calc(26 * var(--rpx));
  line-height: 1.2;
}
.day-cell.today .day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: calc(44 * var(--rpx));
  height: calc(44 * var(--rpx));
  padding: 0 calc(8 * var(--rpx));
  border-radius: 999px;
  background: #3b82f6;
  color: #fff;
  font-weight: 700;
}
.day-cell.today.picked .day-num {
  box-shadow: 0 0 0 2px #1d4ed8;
}
.day-cell.gray { color: #94a3b8; background: #f1f5f9; }
.expire-badge {
  position: absolute;
  top: calc(2 * var(--rpx));
  right: calc(2 * var(--rpx));
  background: #3b82f6;
  color: white;
  font-size: calc(16 * var(--rpx));
  line-height: 1;
  border-radius: calc(20 * var(--rpx));
  padding: calc(2 * var(--rpx)) calc(6 * var(--rpx));
  white-space: nowrap;
  transform: scale(0.92);
  transform-origin: top right;
}

.grave-card { opacity: 0.7; filter: grayscale(0.2); position: relative; }
.grave-card::after {
  content: "已过期";
  position: absolute;
  bottom: calc(16 * var(--rpx));
  right: calc(24 * var(--rpx));
  font-size: calc(22 * var(--rpx));
  color: #94a3b8;
  opacity: 0.9;
}

.install-banner,
.mock-banner {
  background: #eff6ff;
  color: #1e3a8a;
  font-size: calc(24 * var(--rpx));
  padding: calc(16 * var(--rpx)) calc(20 * var(--rpx));
  border-radius: calc(16 * var(--rpx));
  margin-bottom: calc(20 * var(--rpx));
  line-height: 1.6;
}
.mock-banner {
  background: #fff7ed;
  color: #c2410c;
}
.install-banner .flex-between { margin-top: calc(12 * var(--rpx)); }
.demo-tag {
  background: #fff7ed;
  color: #c2410c;
  margin-left: calc(12 * var(--rpx));
}

[hidden] {
  display: none !important;
}

.ui-toast {
  position: fixed;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  padding: calc(20 * var(--rpx)) calc(36 * var(--rpx));
  border-radius: calc(16 * var(--rpx));
  z-index: 1000;
  max-width: 70%;
  text-align: center;
  pointer-events: none;
}

.ui-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(40 * var(--rpx));
}
.ui-mask[hidden] {
  display: none !important;
}

.ui-modal {
  background: #fff;
  border-radius: calc(24 * var(--rpx));
  padding: calc(40 * var(--rpx)) calc(32 * var(--rpx)) calc(24 * var(--rpx));
  width: min(86%, 360px);
}

.ui-modal h3 { margin: 0 0 calc(16 * var(--rpx)); text-align: center; }
.ui-modal p { margin: 0 0 calc(24 * var(--rpx)); color: #475569; }
.ui-modal-input { margin-bottom: calc(24 * var(--rpx)); }
.ui-modal-actions {
  display: flex;
  border-top: calc(1 * var(--rpx)) solid #eef2f6;
  margin: 0 calc(-32 * var(--rpx)) calc(-24 * var(--rpx));
}
.ui-modal-actions button {
  flex: 1;
  background: none;
  border: none;
  padding: calc(24 * var(--rpx));
  font-size: calc(30 * var(--rpx));
  cursor: pointer;
  font-family: inherit;
}
.ui-modal-actions button + button {
  border-left: calc(1 * var(--rpx)) solid #eef2f6;
  color: #2563eb;
  font-weight: 600;
}

.ui-loading {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ui-loading-box {
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  padding: calc(28 * var(--rpx)) calc(36 * var(--rpx));
  border-radius: calc(16 * var(--rpx));
}

.date-picker-sheet {
  background: #fff;
  border-radius: calc(20 * var(--rpx));
  padding: calc(20 * var(--rpx)) calc(16 * var(--rpx)) calc(8 * var(--rpx));
  width: min(78%, 320px);
  max-height: 80vh;
  overflow: auto;
}
.date-picker-sheet .cal-month-label {
  font-weight: 700;
  color: #0f172a;
}
.date-picker-grid {
  padding: calc(8 * var(--rpx));
  box-shadow: none;
}
.date-picker-grid .day-cell {
  border: none;
  font-family: inherit;
  width: auto;
  min-height: calc(52 * var(--rpx));
  padding: calc(8 * var(--rpx)) 0;
  margin: calc(2 * var(--rpx));
}
.date-picker-sheet .ui-modal-actions {
  margin: calc(8 * var(--rpx)) calc(-16 * var(--rpx)) calc(-8 * var(--rpx));
}
.date-picker-sheet .ui-modal-actions button {
  padding: calc(16 * var(--rpx));
  font-size: calc(28 * var(--rpx));
}
.day-cell.picked {
  background: #3b82f6;
  color: #fff;
}
.member-pick-list {
  display: flex;
  flex-direction: column;
  gap: calc(12 * var(--rpx));
  margin-bottom: calc(16 * var(--rpx));
  max-height: 50vh;
  overflow: auto;
}
.member-pick-item {
  width: 100%;
  text-align: left;
  background: #f8fafc;
  border: none;
  border-radius: calc(16 * var(--rpx));
  padding: calc(22 * var(--rpx));
  font-size: calc(30 * var(--rpx));
  font-family: inherit;
  cursor: pointer;
}

.blocked-screen {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(40 * var(--rpx));
  color: #64748b;
}
