* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', 'PingFang SC', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  background: linear-gradient(160deg, #1b2242 0%, #2a2f5e 40%, #3b3160 70%, #4a3a6b 100%);
  background-attachment: fixed;
  color: #e6e9ff;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  -webkit-font-smoothing: antialiased;
  padding: 1rem;
  padding-top: calc(1rem + env(safe-area-inset-top));
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* 星空 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 60% 15%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 80% 40%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 15% 70%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 45% 85%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 90% 80%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 50%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 70% 65%, #fff 50%, transparent 51%);
  opacity: 0.7;
  animation: twinkle 6s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes twinkle {
  0% { opacity: 0.5; }
  100% { opacity: 0.9; }
}

/* 通用返回按钮 */
.back-fab {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top));
  left: 1rem;
  z-index: 9999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e6e9ff;
  font-size: 1.3rem;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: all 0.22s ease;
}

.back-fab:active { transform: scale(0.92); }

/* ============ 主容器 ============ */
.days-app {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* 顶部标题 */
.app-header {
  text-align: center;
  padding: 0.5rem 0.5rem 0.8rem;
  margin-top: 0.5rem;
}

.title-icon {
  font-size: 2.4rem;
  margin-bottom: 0.3rem;
  filter: drop-shadow(0 0 16px rgba(255, 220, 160, 0.4));
  animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.title-text {
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(120deg, #ffd9b3, #ffb3d9, #b3c7ff, #ffd9b3);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 6s ease-in-out infinite;
  margin-bottom: 0.3rem;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.title-sub {
  font-size: 0.85rem;
  color: rgba(230, 235, 255, 0.6);
  letter-spacing: 0.3px;
}

/* ============ 主卡片 ============ */
.main-card {
  background: linear-gradient(135deg, rgba(160, 180, 255, 0.18), rgba(200, 160, 255, 0.18));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(180, 200, 255, 0.3);
  border-radius: 26px;
  padding: 1.8rem 1.5rem;
  text-align: center;
  box-shadow: 0 12px 36px rgba(120, 140, 220, 0.25);
}

.main-emoji {
  font-size: 2.6rem;
  margin-bottom: 0.4rem;
  filter: drop-shadow(0 4px 12px rgba(255, 200, 180, 0.4));
}

.main-label {
  font-size: 0.95rem;
  color: rgba(230, 235, 255, 0.75);
  margin-bottom: 0.6rem;
  letter-spacing: 1px;
}

.main-days {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.main-days-num {
  font-size: clamp(3rem, 14vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(120deg, #ffd9b3, #ffb3d9, #b3c7ff, #ffd9b3);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 6s ease-in-out infinite;
  font-variant-numeric: tabular-nums;
}

.main-days-unit {
  font-size: 1.2rem;
  color: rgba(230, 235, 255, 0.75);
  font-weight: 500;
}

.main-date {
  font-size: 0.82rem;
  color: rgba(230, 235, 255, 0.5);
  letter-spacing: 0.3px;
}

/* ============ 区块标题 ============ */
.section-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  font-weight: 600;
  color: #e6e9ff;
  padding: 0.4rem 0.3rem;
  margin-top: 0.5rem;
}

.section-title .add-btn {
  margin-left: auto;
  background: linear-gradient(135deg, #a0b4ff, #c7a0ff);
  color: #1b2242;
  border: none;
  border-radius: 30px;
  padding: 0.42rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(140, 160, 240, 0.4);
  letter-spacing: 0.5px;
}

.section-title .add-btn:active { transform: scale(0.95); }

/* ============ 纪念日列表 ============ */
.days-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.day-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.15rem;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.day-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(180, 200, 255, 0.35);
  transform: translateY(-2px);
}

.day-card:active { transform: scale(0.98); }

.day-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(255, 200, 180, 0.3));
}

.day-info {
  flex: 1;
  min-width: 0;
}

.day-name {
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-date {
  font-size: 0.76rem;
  color: rgba(230, 235, 255, 0.5);
  letter-spacing: 0.2px;
}

.day-countdown {
  text-align: right;
  flex-shrink: 0;
}

.day-countdown-num {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: #ffd9b3;
  font-variant-numeric: tabular-nums;
}

.day-countdown-label {
  font-size: 0.7rem;
  color: rgba(230, 235, 255, 0.5);
  margin-top: 3px;
  letter-spacing: 0.3px;
}

/* 高亮今天 */
.day-card.is-today {
  background: linear-gradient(120deg, rgba(255, 180, 170, 0.22), rgba(255, 220, 160, 0.22));
  border-color: rgba(255, 200, 180, 0.5);
  box-shadow: 0 8px 24px rgba(255, 180, 150, 0.2);
}

.day-card.is-today .day-countdown-num {
  color: #ffb3a0;
}

/* ============ 空状态 ============ */
.empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
  color: rgba(230, 235, 255, 0.5);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 20px;
}

.empty-icon { font-size: 2.5rem; margin-bottom: 0.6rem; opacity: 0.6; }
.empty-text { font-size: 0.95rem; margin-bottom: 0.3rem; color: rgba(230, 235, 255, 0.7); }
.empty-sub { font-size: 0.8rem; }

/* ============ 底部状态 ============ */
.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: rgba(230, 235, 255, 0.4);
  padding: 0.5rem 0 1rem;
  letter-spacing: 0.3px;
}

#syncStatus.saving { color: rgba(255, 220, 150, 0.8); }
#syncStatus.success { color: rgba(180, 230, 180, 0.75); }
#syncStatus.error { color: rgba(255, 150, 150, 0.85); }

/* ============ 弹窗 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 30, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(160deg, #232849, #2e2a52);
  border: 1px solid rgba(180, 200, 255, 0.2);
  border-radius: 24px;
  padding: 1.6rem 1.4rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.show .modal-card {
  transform: scale(1);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.2rem;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: rgba(230, 235, 255, 0.7);
  margin-bottom: 0.45rem;
  letter-spacing: 0.3px;
}

.form-group input[type="text"],
.form-group input[type="date"] {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #f0f3ff;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}

.form-group input:focus {
  border-color: rgba(180, 200, 255, 0.6);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(140, 160, 220, 0.15);
}

.form-group input[type="date"] {
  color-scheme: dark;
}

/* 类型选项 */
.type-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.type-option {
  position: relative;
  cursor: pointer;
}

.type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.7rem 0.5rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  color: rgba(230, 235, 255, 0.75);
  transition: all 0.2s;
  text-align: center;
}

.type-option input:checked + .type-label {
  border-color: rgba(180, 200, 255, 0.6);
  background: rgba(160, 180, 255, 0.18);
  color: #ffffff;
}

.type-icon {
  font-size: 1.2rem;
}

/* Emoji 选择器 */
.emoji-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.emoji-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  font-size: 1.4rem;
  cursor: pointer;
  transition: all 0.2s;
}

.emoji-opt:hover {
  background: rgba(255, 255, 255, 0.12);
}

.emoji-opt.selected {
  border-color: rgba(180, 200, 255, 0.7);
  background: rgba(160, 180, 255, 0.25);
  box-shadow: 0 0 0 2px rgba(140, 160, 240, 0.3);
}

/* 弹窗按钮 */
.modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.4rem;
}

.modal-actions button {
  flex: 1;
  padding: 0.8rem;
  border-radius: 12px;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
  font-family: inherit;
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(230, 235, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.btn-cancel:active { background: rgba(255, 255, 255, 0.15); }

.btn-delete {
  background: rgba(255, 120, 120, 0.2);
  color: #ffb0b0;
  border: 1px solid rgba(255, 150, 150, 0.3) !important;
}

.btn-delete:active { background: rgba(255, 120, 120, 0.35); }

.btn-save {
  background: linear-gradient(135deg, #a0b4ff, #c7a0ff);
  color: #1b2242;
  box-shadow: 0 6px 16px rgba(140, 160, 240, 0.4);
}

.btn-save:active { transform: scale(0.97); }

/* ============ 响应式 ============ */
@media (max-width: 480px) {
  .days-app { gap: 0.8rem; }
  .app-header { padding: 0.3rem 0.3rem 0.5rem; margin-top: 0.3rem; }
  .title-icon { font-size: 2rem; }
  .main-card { padding: 1.4rem 1rem; border-radius: 22px; }
  .main-emoji { font-size: 2.2rem; }
  .main-label { font-size: 0.85rem; }
  .main-days-unit { font-size: 1rem; }
  .main-date { font-size: 0.75rem; }
  .day-card { padding: 0.85rem 0.95rem; gap: 0.85rem; border-radius: 18px; }
  .day-icon { width: 46px; height: 46px; font-size: 1.4rem; border-radius: 14px; }
  .day-name { font-size: 0.92rem; }
  .day-date { font-size: 0.7rem; }
  .day-countdown-num { font-size: 1.4rem; }
  .day-countdown-label { font-size: 0.65rem; }
  .modal-card { padding: 1.4rem 1.2rem; border-radius: 20px; }
}