/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --rose: #E8738A;
  --rose-light: #F9A8A8;
  --rose-dark: #BE6B7D;
  --bg: #FFF5F5;
  --bg-card: #FFFFFF;
  --text: #2D2D2D;
  --text-light: #8B7280;
  --text-muted: #B0A0A8;
  --gold: #FCD34D;
  --green: #34D399;
  --border: #FEE2E2;
  --border-light: #FFF0F0;
  --shadow: 0 4px 16px rgba(232, 115, 138, 0.08);
  --shadow-hover: 0 8px 24px rgba(232, 115, 138, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --nav-height: 64px;
  --header-height: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
}

/* The Android companion already places its WebView inside system-bar insets. */
html.native-companion {
  --safe-top: 0px;
  --safe-bottom: 0px;
  --header-height: 48px;
}

html.ios-standalone {
  --header-height: 40px;
  --nav-height: 50px;
}

html.ios-standalone .bottom-nav {
  padding-top: 2px;
  padding-bottom: calc(2px + var(--safe-bottom));
}

html.ios-standalone .nav-item {
  gap: 2px;
  padding-top: 4px;
  padding-bottom: 4px;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: linear-gradient(180deg, #FFF8F8 0%, var(--bg) 100%);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--rose); text-decoration: none; }
a:hover { color: var(--rose-dark); }

/* ─── App Container ─── */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-top: calc(var(--header-height) + var(--safe-top));
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

/* ─── Flash Messages ─── */
.flash-container {
  position: fixed;
  top: calc(var(--header-height) + var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: calc(100% - 32px);
  max-width: 448px;
}
.flash-message {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideDown 0.3s ease;
}
.flash-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.flash-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.flash-info { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
.flash-close { background: none; border: none; font-size: 20px; cursor: pointer; opacity: 0.6; color: inherit; padding: 0 4px; }
.flash-close:hover { opacity: 1; }

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ─── Top Navigation ─── */
.top-nav {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--header-height) + var(--safe-top));
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--safe-top) 16px 0;
  z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 8px; }
.brand-heart { display: flex; align-items: center; margin-top: 1px; }
.brand-mark { display: block; object-fit: contain; flex: 0 0 auto; }
.brand-mark-nav { width: 30px; height: 30px; }
.brand-name { font-size: 20px; font-weight: 700; color: var(--rose); letter-spacing: -0.5px; }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-name { font-weight: 600; color: var(--text); }
.partner-tag { color: var(--rose); font-size: 12px; background: var(--border); padding: 2px 8px 2px 5px; border-radius: 20px; display: inline-flex; align-items: center; gap: 3px; }
.brand-mark-tag { width: 16px; height: 16px; }
.logout-form { margin: 0; }
.btn-logout {
  font: inherit;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}
.btn-logout:hover { color: var(--rose); border-color: var(--rose); }

/* ─── Bottom Navigation ─── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-height) + var(--safe-bottom));
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 4px 0 calc(4px + var(--safe-bottom));
  z-index: 100;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  transition: all 0.2s;
  min-width: 60px;
}
.nav-item.active { color: var(--rose); }
.nav-item.active .nav-icon { transform: scale(1.1); }
.nav-item:hover { color: var(--rose); background: var(--border); }
.nav-icon { font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.nav-icon svg { display: block; }
.nav-label { font-size: 11px; font-weight: 500; }

/* ─── Main Content ─── */
.main-content { min-height: calc(100vh - var(--header-height) - var(--nav-height) - var(--safe-top) - var(--safe-bottom)); }
.page-container { padding: 16px; }
.page-header { margin-bottom: 16px; }
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--text); }
.page-header p { font-size: 13px; color: var(--text-light); margin-top: 2px; }

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
}
.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.section { margin-bottom: 20px; }
.section-title { font-size: 14px; font-weight: 600; color: var(--text-light); margin-bottom: 10px; padding-left: 4px; }

/* ─── Forms ─── */
.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-light); margin-bottom: 4px; }
.form-group small { font-size: 11px; color: var(--text-muted); display: block; margin-top: 2px; }
input[type="text"], input[type="password"], input[type="date"], input[type="time"], input[type="number"],
textarea, select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: white;
  transition: all 0.2s;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 4px rgba(232, 115, 138, 0.12);
  background: #fffbfc;
}
textarea { resize: vertical; min-height: 60px; }
select { cursor: pointer; }
.form-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: flex-end; }
.form-row .form-group { margin-bottom: 0; }
.flex-grow { flex: 1; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; color: var(--text-light); }
.checkbox-label input[type="checkbox"] { width: auto; }

/* ─── Buttons ─── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 22px;
  background: linear-gradient(135deg, var(--rose), var(--rose-dark));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: var(--font);
  box-shadow: 0 4px 12px rgba(232, 115, 138, 0.25);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--rose-dark), var(--rose)); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(232, 115, 138, 0.35); }
.btn-primary:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(232, 115, 138, 0.2); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-full { width: 100%; }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text-light);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--rose); color: var(--rose); background: #FFF8FA; }
.btn-secondary:disabled { cursor: not-allowed; opacity: 0.5; }
.btn-text {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 8px;
}
.btn-text:hover { color: var(--rose-dark); }
.btn-icon {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.2s;
  line-height: 1;
  font-family: var(--font);
}
.btn-icon:hover { color: var(--rose); background: var(--border); }

/* ─── Auth Pages ─── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: white;
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.logo-heart { margin-bottom: 16px; display: flex; justify-content: center; }
.logo-heart img { display: block; }
.brand-mark-auth { width: 120px; height: 120px; filter: drop-shadow(0 8px 14px rgba(232, 115, 138, 0.2)); }
.auth-logo h1 { font-size: 36px; font-weight: 800; color: var(--rose); letter-spacing: -1px; }
.logo-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.auth-form { margin-bottom: 16px; }
.auth-link { text-align: center; font-size: 13px; color: var(--text-light); }
.auth-link a { font-weight: 600; }
.icp-footer {
  margin-top: 22px;
  margin-right: -20px;
  margin-left: -20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-size: 11px;
}
.beian-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; }
.beian-links a { display: inline-flex; align-items: center; justify-content: center; min-height: 20px; }
.gongan-beian { gap: 5px; }
.gongan-beian img { display: block; width: 18px; height: 20px; object-fit: contain; }
.icp-footer a { color: var(--text-muted); }
.icp-footer a:hover { color: var(--rose); }

/* ─── Feed ─── */
.create-post-card {
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.post-input { width: 100%; border: none; resize: none; font-size: 14px; outline: none; font-family: var(--font); }
.post-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.btn-upload { font: inherit; font-size: 13px; color: var(--text-light); cursor: pointer; padding: 6px 10px; border-radius: 6px; border: 0; background: transparent; transition: background 0.2s, color 0.2s; display: inline-flex; align-items: center; gap: 5px; }
.btn-upload:hover { background: var(--border); }
.post-composer-actions { gap: 10px; }
.post-media-tools { display: flex; align-items: center; gap: 2px; min-width: 0; }
.btn-record.is-recording { color: #B42318; background: #FEE4E2; }
.btn-record.is-recording > span:first-child { animation: recordPulse 1s ease-in-out infinite; }
.audio-file-fallback { display: none; }
.audio-file-fallback.is-visible { display: inline-flex; }
.post-upload-status { min-height: 20px; margin-top: 6px; color: var(--text-muted); font-size: 12px; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }
.post-media-preview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.post-media-preview:empty { display: none; }
.composer-media-item { position: relative; aspect-ratio: 1; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: #FFF8F8; }
.composer-media-item img,
.composer-media-item video { width: 100%; height: 100%; display: block; object-fit: cover; }
.composer-audio-icon { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--rose-dark); font-size: 12px; font-weight: 700; background: #FFF0F2; }
.composer-media-state { position: absolute; left: 4px; right: 4px; bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 1px 4px; border-radius: 4px; background: rgba(45,45,45,0.72); color: white; font-size: 10px; text-align: center; }
.composer-media-item.is-ready .composer-media-state { background: rgba(6,95,70,0.82); }
.composer-media-item.is-failed .composer-media-state { background: rgba(153,27,27,0.9); }
.composer-media-remove { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(45,45,45,0.76); color: white; font-size: 18px; line-height: 22px; cursor: pointer; }
.composer-media-retry { display: none; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border: 0; border-radius: 6px; padding: 6px 10px; background: rgba(255,255,255,0.94); color: #991B1B; font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.composer-media-item.is-failed .composer-media-retry { display: block; }
.post-media-grid { display: grid; gap: 2px; overflow: hidden; background: var(--border-light); }
.post-media-grid.media-count-1 { grid-template-columns: 1fr; }
.post-media-grid.media-count-2,
.post-media-grid.media-count-3,
.post-media-grid.media-count-4,
.post-media-grid.media-count-many { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.post-media-grid.media-count-3 .post-media-item:first-child { grid-row: span 2; }
.post-media-item { position: relative; min-width: 0; aspect-ratio: 1; background: #F7EDEE; overflow: hidden; }
.post-media-grid.media-count-1 .post-media-item { aspect-ratio: auto; max-height: 520px; }
.post-media-item img,
.post-media-item video { width: 100%; height: 100%; min-height: 180px; display: block; object-fit: cover; background: #F7EDEE; }
.post-media-grid.media-count-1 .post-media-item img,
.post-media-grid.media-count-1 .post-media-item video { height: auto; max-height: 520px; }
.voice-player { margin: 10px 14px; min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid #F8CBD3; border-radius: 8px; background: #FFF7F8; }
.voice-play-button { width: 32px; height: 32px; flex: 0 0 32px; border: 0; border-radius: 50%; background: var(--rose); color: white; font-size: 13px; cursor: pointer; }
.voice-track { flex: 1; min-width: 0; }
.voice-wave { height: 20px; display: flex; align-items: center; gap: 2px; overflow: hidden; }
.voice-wave span { width: 2px; flex: 0 0 2px; border-radius: 2px; background: var(--rose-light); }
.voice-progress { height: 2px; background: #FADCE1; margin-top: 3px; overflow: hidden; }
.voice-progress span { display: block; width: 0; height: 100%; background: var(--rose); }
.voice-duration { min-width: 34px; text-align: right; color: var(--text-light); font-size: 12px; font-variant-numeric: tabular-nums; }
.voice-player audio { display: none; }
.post-media-item video::-webkit-media-controls-fullscreen-button { display: none; }
.btn-primary:disabled { cursor: not-allowed; opacity: 0.55; }
.post-media-tools .btn-upload:focus-visible,
.composer-media-remove:focus-visible,
.voice-play-button:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
@keyframes recordPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.image-preview { margin-top: 8px; }
.image-preview img { border-radius: var(--radius-sm); max-height: 200px; object-fit: cover; }

.post-card {
  background: white;
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 0;
}
.post-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), var(--rose-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.post-user { flex: 1; }
.post-name { font-size: 13px; font-weight: 600; display: block; }
.post-time { font-size: 11px; color: var(--text-muted); }
.post-delete-form { margin-left: auto; }
.post-content { padding: 10px 14px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.post-image img { width: 100%; display: block; }
.post-stats { padding: 8px 14px; font-size: 12px; color: var(--text-muted); display: flex; gap: 16px; border-top: 1px solid var(--border-light); }
.post-actions-bar { display: flex; border-top: 1px solid var(--border-light); }
.btn-action {
  flex: 1;
  text-align: center;
  padding: 8px;
  font-size: 13px;
  color: var(--text-light);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  font-family: var(--font);
}
.btn-action:hover { background: var(--border); }
.btn-action.liked { color: var(--rose); font-weight: 600; }
.like-btn:active { transform: scale(0.95); }
.like-btn.liked .like-icon { animation: likePop 0.3s ease; }
@keyframes likePop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.comment-section { padding: 0 14px 12px; }
.comment-form { display: flex; gap: 8px; margin-bottom: 8px; }
.comment-form input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; }
.comment-form input:focus { border-color: var(--rose); }
.comments-list { margin-top: 6px; }
.comment-item { font-size: 13px; padding: 4px 0; }
.comment-item strong { color: var(--rose); margin-right: 6px; }

.feed-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 8px;
}
.pagination-link {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}
.pagination-link:hover { border-color: var(--rose); color: var(--rose); }
.pagination-link.active { background: var(--rose); border-color: var(--rose); color: white; }
.pagination-nav { min-width: 64px; }
.pagination-gap { color: var(--text-muted); padding: 0 2px; }
.feed-pagination-summary { text-align: center; color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }

/* ─── Todos ─── */
.todo-list { margin-top: 4px; }
.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: white;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid var(--border-light);
  transition: all 0.2s;
}
.todo-item:hover { border-color: var(--rose-light); }
.todo-item.completed { opacity: 0.7; }
.todo-item.completed .todo-title { text-decoration: line-through; color: var(--text-muted); }
.todo-check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: white;
  transition: all 0.2s;
  flex-shrink: 0;
}
.todo-check.checked { background: var(--green); border-color: var(--green); }
.todo-content { flex: 1; min-width: 0; }
.todo-title { font-size: 14px; font-weight: 500; }
.todo-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.todo-meta { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--border); color: var(--rose-dark); }

.create-todo-card .form-extras { margin-top: 8px; }

/* ─── Badges ─── */
.badge-types-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.badge-type-option {
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  text-align: center;
  transition: all 0.2s;
  background: var(--bg-card);
}
.badge-type-option:hover { border-color: var(--rose-light); }
.badge-type-option.selected, .badge-type-option input:checked + .badge-type-icon { border-color: var(--rose); background: #FFF0F0; }
.badge-type-option input { display: none; }
.badge-type-icon { font-size: 28px; margin-bottom: 4px; display: block; }
.badge-type-name { font-size: 13px; font-weight: 600; }
.badge-type-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.badges-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.badge-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid var(--border-light);
  transition: transform 0.2s;
}
.badge-card:hover { transform: translateY(-2px); }
.badge-card.received { border-color: var(--gold); }
.badge-card.given { border-color: var(--rose-light); }
.badge-banner { font-size: 32px; margin-bottom: 6px; }
.badge-title { font-size: 13px; font-weight: 600; }
.badge-message { font-size: 11px; color: var(--text-muted); margin-top: 4px; font-style: italic; }
.badge-from { font-size: 11px; color: var(--rose); margin-top: 6px; }
.badge-date { font-size: 10px; color: var(--text-muted); }

.bind-reminder { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; }
.bind-reminder p { font-size: 14px; }

/* ─── Calendar ─── */
.calendar-card { padding: 16px; }
.calendar-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.calendar-nav h3 { font-size: 16px; font-weight: 600; }
.calendar-grid { }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.cal-weekdays span { padding: 4px; }
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border-radius: 50%;
  cursor: default;
  transition: background 0.2s;
  position: relative;
}
.cal-day.today { background: var(--rose); color: white; font-weight: 700; }
.cal-day.has-event::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--rose);
}
.cal-day.today.has-event::after { background: white; }
.cal-day.empty { }

.calendar-legend { margin-top: 12px; }
.cal-event-tag { font-size: 12px; padding: 4px 8px; margin-bottom: 4px; border-left: 3px solid; display: flex; gap: 8px; }
.cal-event-tag span:first-child { color: var(--text-muted); }

.month-group { margin-bottom: 12px; }
.month-label { font-size: 14px; font-weight: 600; color: var(--rose); margin-bottom: 6px; padding-left: 4px; }
.event-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: white;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.event-color { width: 4px; height: 36px; border-radius: 2px; flex-shrink: 0; }
.event-info { flex: 1; }
.event-title { font-size: 14px; font-weight: 500; }
.event-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── Countdown ─── */
.countdown-list { margin-top: 4px; }
.countdown-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--rose);
  position: relative;
}
.countdown-card.today { border-left-color: var(--gold); background: linear-gradient(135deg, #FFF8F0, white); }
.countdown-main { flex: 1; }
.countdown-title { font-size: 15px; font-weight: 600; }
.countdown-date { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.countdown-years { font-size: 12px; color: var(--rose); margin-top: 2px; }
.countdown-number { text-align: center; min-width: 60px; }
.countdown-value { font-size: 28px; font-weight: 800; color: var(--rose); line-height: 1; }
.countdown-card.today .countdown-value { font-size: 16px; color: var(--gold); }
.countdown-label { font-size: 11px; color: var(--text-muted); }
.countdown-delete { position: absolute; top: 8px; right: 8px; }

/* ─── Moods ─── */
.mood-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.mood-option {
  cursor: pointer;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  text-align: center;
  transition: all 0.2s;
}
.mood-option:hover { border-color: var(--rose-light); background: #FFF8F8; }
.mood-option.selected { border-color: var(--rose); background: #FFF0F0; }
.mood-option input { display: none; }
.mood-emoji { font-size: 24px; display: block; margin-bottom: 2px; }
.mood-label { font-size: 11px; color: var(--text-light); }

.mood-record {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: white;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.mood-record-emoji { font-size: 22px; }
.mood-record-info { flex: 1; }
.mood-record-name { font-size: 13px; font-weight: 600; display: block; }
.mood-record-note { font-size: 12px; color: var(--text-muted); }
.mood-record-date { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ─── Letters ─── */
.letter-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: white;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid var(--border-light);
}
.letter-card.unopened { border-left: 3px solid var(--rose); }
.letter-icon { width: 30px; min-width: 30px; min-height: 30px; font-size: 24px; display: flex; align-items: center; justify-content: center; }
.brand-mark-letter { width: 28px; height: 28px; }
.letter-info { flex: 1; }
.letter-title { font-size: 14px; font-weight: 600; }
.letter-from { font-size: 12px; color: var(--text-muted); }
.letter-date { font-size: 11px; color: var(--text-muted); }
.letter-open-date { font-size: 11px; color: var(--rose); margin-top: 2px; }

.letter-detail-page { max-width: 480px; margin: 0 auto; }
.back-link { display: inline-block; font-size: 14px; color: var(--text-light); margin-bottom: 12px; }
.back-link:hover { color: var(--rose); }
.letter-detail-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.letter-detail-header { text-align: center; margin-bottom: 20px; }
.letter-detail-envelope { font-size: 48px; margin-bottom: 8px; }
.letter-detail-header h2 { font-size: 20px; font-weight: 700; }
.letter-detail-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 12px; justify-content: center; }
.letter-detail-content { font-size: 15px; line-height: 1.9; white-space: pre-wrap; }
.letter-detail-content p { margin-bottom: 8px; }
.letter-detail-footer { margin-top: 20px; text-align: center; color: var(--text-muted); font-size: 12px; border-top: 1px solid var(--border-light); padding-top: 16px; }

/* ─── Wishes ─── */
.wish-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: white;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid var(--border-light);
}
.wish-card.fulfilled { opacity: 0.7; }
.wish-card.fulfilled .wish-title { text-decoration: line-through; color: var(--text-muted); }
.wish-icon { font-size: 24px; }
.wish-content { flex: 1; }
.wish-title { font-size: 14px; font-weight: 500; }
.wish-desc { font-size: 12px; color: var(--text-muted); }
.wish-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 8px; }
.wish-actions { display: flex; gap: 4px; }

/* ─── More / Hub Page ─── */
.more-couple-card {
  position: relative;
  background: linear-gradient(135deg, var(--rose), #F472B6);
  color: white;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(232, 115, 138, 0.3);
}
.more-avatars { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 10px; }
.more-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}
.more-heart { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; animation: heartbeat 1.5s ease-in-out infinite; }
.brand-mark-couple { width: 48px; height: 48px; padding: 3px; border-radius: 50%; background: rgba(255,255,255,0.92); box-shadow: 0 4px 12px rgba(110, 40, 65, 0.18); }
@keyframes heartbeat {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 1; }
}
.more-couple-info h3 { font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 5px; }
.brand-mark-name { width: 22px; height: 22px; padding: 1px; border-radius: 50%; background: rgba(255,255,255,0.9); }

.more-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.more-item {
  background: white;
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
}
.more-item:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(232, 115, 138, 0.15); }
.more-item-icon { font-size: 32px; margin-bottom: 8px; display: flex; align-items: center; justify-content: center; color: var(--rose); opacity: 0.9; }
.more-item-icon svg { display: block; }
.more-item-name { font-size: 13px; font-weight: 600; }
.more-item-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── Medication Reminders ─── */
.medication-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.medication-page-header > div { min-width: 0; }
.medication-list { display: grid; gap: 10px; }
.medication-occurrence,
.medication-plan,
.medication-form-section {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 10px rgba(45, 45, 45, 0.04);
}
.medication-occurrence,
.medication-plan { padding: 14px; }
.medication-occurrence { border-left: 3px solid var(--rose); }
.medication-occurrence.status-taken { border-left-color: #2F9E72; }
.medication-occurrence.status-skipped,
.medication-occurrence.status-missed { border-left-color: #D08A3C; }
.medication-occurrence-head,
.medication-plan-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.medication-occurrence-head > div,
.medication-plan-main > div { min-width: 0; }
.medication-occurrence h4,
.medication-plan h4 { font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.medication-occurrence-head p,
.medication-plan-main p,
.medication-owner { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.medication-note { margin-top: 10px; color: var(--text-light); font-size: 13px; white-space: pre-wrap; }
.medication-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #F3F4F6;
  color: #6B7280;
  font-size: 11px;
  font-weight: 700;
}
.medication-status.status-taken,
.medication-status.status-active { background: #E8F7F0; color: #247A58; }
.medication-status.status-snoozed { background: #FFF5D9; color: #9A681D; }
.medication-status.status-skipped,
.medication-status.status-missed { background: #FFF0E0; color: #A45D20; }
.medication-status.status-pending { background: #FFF0F3; color: var(--rose-dark); }
.medication-status.status-paused { background: #F3F4F6; color: #6B7280; }
.medication-confirm-actions {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) minmax(180px, 1.8fr);
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}
.medication-confirm-actions form:first-child .btn-primary { width: 100%; min-height: 40px; }
.medication-snooze-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.medication-snooze-form select { min-width: 0; padding: 8px 10px; }
.medication-skip-form { grid-column: 1 / -1; text-align: right; }
.medication-result-time { margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.medication-times {
  margin-top: 7px;
  color: var(--rose-dark);
  font-size: 18px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.medication-plan-rule { margin-top: 10px; font-size: 12px; color: var(--text-light); }
.medication-plan-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.medication-plan.is-paused { opacity: 0.72; }
.medication-empty {
  padding: 24px 16px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
}
.medication-empty a { display: inline-block; margin-top: 5px; font-weight: 600; }
.medication-history {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.medication-history-row {
  min-height: 56px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
}
.medication-history-row:last-child { border-bottom: 0; }
.medication-history-row > div { min-width: 0; }
.medication-history-row strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.medication-history-row span:not(.medication-status) { display: block; font-size: 11px; color: var(--text-muted); }
.medication-form-section { padding: 16px; margin-bottom: 12px; }
.medication-form-section > h3 { font-size: 15px; margin-bottom: 12px; }
.medication-time-list { display: grid; gap: 8px; margin-bottom: 8px; }
.medication-time-row { display: grid; grid-template-columns: minmax(0, 1fr) 38px; gap: 8px; }
.medication-time-row input { font-size: 17px; font-variant-numeric: tabular-nums; }
.medication-time-row .btn-icon { width: 38px; min-height: 38px; font-size: 24px; }
.medication-days-group { margin-top: 16px; }
.medication-day-options { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.medication-day-option input { position: absolute; opacity: 0; pointer-events: none; }
.medication-day-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-light);
  font-size: 12px;
  cursor: pointer;
}
.medication-day-option input:checked + span { border-color: var(--rose); background: var(--rose); color: white; }
.medication-day-option input:focus-visible + span { outline: 3px solid rgba(232, 115, 138, 0.25); }
.medication-date-row { margin-top: 14px; }
.medication-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  cursor: pointer;
}
.medication-toggle-row span { min-width: 0; }
.medication-toggle-row strong { display: block; font-size: 13px; }
.medication-toggle-row small { display: block; color: var(--text-muted); font-size: 11px; }
.medication-toggle-row input { width: 20px; height: 20px; accent-color: var(--rose); }
.medication-privacy-options { display: grid; gap: 8px; }
.medication-privacy-options label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.medication-privacy-options input { margin-top: 3px; accent-color: var(--rose); }
.medication-privacy-options strong,
.medication-privacy-options small { display: block; }
.medication-privacy-options strong { font-size: 13px; }
.medication-privacy-options small { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.medication-form-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 8px; }
.medication-form-actions > * { min-height: 44px; }
.medication-feed-alert {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  margin-bottom: 12px;
  background: #FFFDF5;
  border: 1px solid #F4D99A;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(154, 104, 29, 0.07);
}
.medication-feed-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9A681D;
  background: #FFF2C9;
  border-radius: 8px;
}
.medication-feed-copy { min-width: 0; }
.medication-feed-copy strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.medication-feed-copy span { display: block; font-size: 11px; color: #8B6D3F; }
.medication-feed-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.medication-feed-actions button { width: 100%; min-height: 38px; }
.push-settings .btn-primary,
.companion-settings .btn-primary { width: 100%; }
.companion-download {
    display: block;
    text-align: center;
    margin-bottom: 10px;
}
.companion-device-list { margin-top: 14px; }
.companion-device-row {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--border);
}
.pair-code-result { text-align: center; padding-top: 14px; }
.pair-code-result[hidden] { display: none; }
.pair-code-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--rose);
  font-variant-numeric: tabular-nums;
}
.pair-code-result p { font-size: 12px; color: var(--text-muted); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid var(--border-light);
}
.stat-value { font-size: 24px; font-weight: 800; color: var(--rose); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── Bind ─── */
.bind-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.bind-code-box { text-align: center; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border-light); }
.bind-code-box label { font-size: 13px; color: var(--text-light); font-weight: 500; }
.code-display {
  font-size: 28px;
  font-weight: 800;
  color: var(--rose);
  letter-spacing: 4px;
  padding: 12px;
  margin: 8px 0;
  background: var(--border);
  border-radius: var(--radius-sm);
}
.bind-code-box p { font-size: 12px; color: var(--text-muted); }

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-icon { margin-bottom: 16px; display: flex; justify-content: center; }
.empty-icon img { box-shadow: 0 8px 24px rgba(232, 115, 138, 0.15); }
.empty-state h3 { font-size: 17px; font-weight: 600; color: var(--text-light); margin-bottom: 6px; }
.empty-state p { font-size: 14px; line-height: 1.6; }
.empty-hint { text-align: center; font-size: 13px; color: var(--text-muted); padding: 20px; }

/* ─── Responsive ─── */
@media (min-width: 768px) {
  .app-container { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
@media (max-width: 480px) {
  .mood-grid { grid-template-columns: repeat(5, 1fr); }
  .more-grid { grid-template-columns: repeat(2, 1fr); }
  .badge-types-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 360px) {
  .mood-grid { grid-template-columns: repeat(3, 1fr); }
  .medication-confirm-actions { grid-template-columns: 1fr; }
  .medication-skip-form { grid-column: 1; }
  .medication-date-row { flex-direction: column; align-items: stretch; }
}

/* ─── Album ─── */
.album-upload-form { }
.upload-dropzone {
  display: block;
  border: 2px dashed var(--rose-light);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 12px;
  background: #FFF8F8;
}
.upload-dropzone:hover { border-color: var(--rose); background: #FFF0F0; }
.upload-icon { font-size: 40px; margin-bottom: 8px; display: flex; justify-content: center; opacity: 0.6; }
.upload-dropzone p { font-size: 14px; color: var(--text-light); }
.album-upload-status { min-height: 20px; margin: 8px 0 0; color: var(--text-muted); font-size: 12px; text-align: center; }
.album-upload-status.is-error { color: #B42318; }

.album-timeline { margin-top: 4px; }
.timeline-month { margin-bottom: 20px; }
.timeline-month-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 10px;
}
.timeline-month-label { font-size: 15px; font-weight: 700; color: var(--rose-dark); }
.timeline-month-count { font-size: 12px; color: var(--text-muted); }
.timeline-photos { display: grid; gap: 8px; }
.timeline-photo-card {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  align-items: flex-start;
  position: relative;
}
.timeline-photo-img {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
}
.timeline-photo-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.timeline-photo-info { flex: 1; min-width: 0; }
.timeline-photo-caption { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.timeline-photo-meta { font-size: 11px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 8px; }
.photo-delete { position: absolute; top: 6px; right: 6px; }
.feed-photo { opacity: 0.85; border-style: dashed; }


}
.cal-day.selected { background: var(--rose-light); color: white; font-weight: 700; box-shadow: 0 0 0 2px var(--rose); }
.cal-day:hover { background: var(--border); cursor: pointer; }
.cal-day.selected:hover { background: var(--rose); }
.cal-day.today.selected { background: var(--rose-dark); }
.selected-date-info { margin-top: 8px; }
.selected-date-header {
    padding: 8px 12px; background: #FFF0F0; border-radius: 8px;
    font-size: 13px; color: var(--rose-dark); font-weight: 500;
    border: 1px solid var(--border);
}

/* ─── Gender Colors ─── */
.male-bg { background: linear-gradient(135deg, #4A90D9, #7BB3E0) !important; }
.female-bg { background: linear-gradient(135deg, #E8738A, #F9A8A8) !important; }
.male-text { color: #4A90D9 !important; }
.female-text { color: #E8738A !important; }
.male-border { border-left: 3px solid #4A90D9 !important; }
.female-border { border-left: 3px solid #E8738A !important; }

/* Notifications */
.notif-bell{position:relative;margin-left:auto;padding:6px 8px;font-size:20px;text-decoration:none;cursor:pointer;color:var(--text-light);display:flex;align-items:center;transition:color 0.2s;}
.notif-bell:hover{color:var(--rose);}
.notif-badge{position:absolute;top:2px;right:4px;background:#e74c3c;color:#fff;font-size:10px;font-weight:700;min-width:16px;height:16px;line-height:16px;border-radius:8px;text-align:center;padding:0 4px;display:none}
.notif-list{display:flex;flex-direction:column;gap:2px}
.notif-item{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#fff;border-radius:10px}
.notif-item.unread{background:#fef3f3;border-left:3px solid #e8738a}
.notif-icon{font-size:22px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background:#f5f5f5;border-radius:50%;flex-shrink:0}
.notif-body{flex:1;min-width:0}
.notif-text{font-size:14px;color:#333;line-height:1.4}
.notif-text strong{font-weight:600}
.notif-time{font-size:12px;color:#999;margin-top:2px}
.notif-dot{width:8px;height:8px;background:#e8738a;border-radius:50%;flex-shrink:0}
.empty-state{text-align:center;padding:60px 20px;color:#999}
.empty-icon{font-size:48px;margin-bottom:12px}
