/* === I'm Fine — Design System === */
:root {
  --warm-50: #fef6ee;
  --warm-100: #fde8d0;
  --warm-200: #fad2a0;
  --warm-300: #f6b876;
  --warm-400: #f09c55;
  --warm-500: #e8823a;
  --warm-600: #d16a2a;
  --warm-700: #b0531f;

  --accent: var(--warm-500); /* purchasable accent color (points) */

  --rose-50: #fff1f2;
  --rose-100: #ffe4e6;
  --rose-200: #fecdd3;
  --rose-300: #fea3b1;
  --rose-400: #fc6f8e;
  --rose-500: #f43f6e;

  --teal-50: #edfafa;
  --teal-100: #d5f5f5;
  --teal-200: #a8ecec;
  --teal-300: #6fd9d9;
  --teal-400: #3dbdbd;
  --teal-500: #2a9d8f;

  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --gray-50: #fafafa;
  --gray-100: #f4f4f5;
  --gray-200: #e4e4e7;
  --gray-300: #d4d4d8;
  --gray-400: #a1a1aa;
  --gray-500: #71717a;
  --gray-600: #52525b;
  --gray-700: #3f3f46;
  --gray-800: #27272a;
  --gray-900: #18181b;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.08);
  --transition: 0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(145deg, var(--warm-50) 0%, #fff 100%);
  color: var(--gray-800);
  min-height: 100vh;
}

/* === Auth Page === */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--warm-50) 0%, var(--rose-50) 50%, #fff 100%);
}

.auth-container {
  width: 100%;
  max-width: 440px;
  padding: 24px;
}

.auth-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px 32px;
  animation: fadeUp 0.5s ease;
}

.logo { text-align: center; margin-bottom: 32px; }
.logo-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.5px;
}
.logo-sub {
  color: var(--gray-500);
  font-size: 15px;
  margin-top: 4px;
}

.tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: var(--transition);
}
.tab.active {
  background: #fff;
  color: var(--gray-900);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form.hidden { display: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}
.field input {
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
  background: var(--gray-50);
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.btn-primary {
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-primary:active { transform: translateY(0); }

.auth-error {
  background: var(--rose-100);
  color: var(--rose-500);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 16px;
}

/* === Dashboard Page === */
.dashboard-page {
  background: linear-gradient(180deg, var(--warm-50) 0%, #fff 100%);
  min-height: 100vh;
}

.dashboard-header {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-100);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-inner h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  cursor: pointer;
  user-select: none;
}
.header-inner .logo-icon { font-size: 24px; display: inline; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.points-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* Points modal & perks */
.points-balance { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 600; }
.points-hint { font-size: 13px; color: var(--gray-500); margin-bottom: 12px; }
.perk-block { margin-top: 14px; padding: 14px; border: 1px solid var(--gray-100); border-radius: var(--radius-sm); }
.perk-block h4 { font-size: 14px; margin: 0 0 10px; font-weight: 600; }
.accent-picker { display: flex; gap: 10px; }
.accent-swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--gray-200); cursor: pointer; transition: var(--transition); }
.accent-swatch.selected { border-color: var(--gray-900); transform: scale(1.15); }
#message-text { width: 100%; padding: 10px 12px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; resize: vertical; }
#message-text:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.btn-message { border: 1px solid var(--gray-200); background: transparent; padding: 6px 10px; border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; transition: var(--transition); }
.btn-message:hover { background: var(--gray-100); }

.btn-ghost {
  border: 1px solid var(--gray-200);
  background: transparent;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: var(--transition);
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.dashboard-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px;
}

.add-section { margin-bottom: 24px; }
.add-section h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 16px;
}

.add-form {
  display: flex;
  gap: 8px;
}
.add-form input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
  background: #fff;
}
.add-form input:focus {
  border-color: var(--warm-400);
  box-shadow: 0 0 0 3px rgba(240, 156, 85, 0.15);
}

/* Linked (registered-user) loved-one badge */
.linked-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--warm-600);
  background: var(--warm-100);
  border-radius: 20px;
  padding: 2px 8px;
  margin-left: 8px;
  white-space: nowrap;
  vertical-align: middle;
}

/* === Connections (requests + "who tracks me") === */
.connections {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.connections h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 12px;
}
.requests-list { display: flex; flex-direction: column; gap: 8px; }
.request-item {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--gray-700);
}
.request-item .request-email { font-weight: 600; color: var(--gray-900); }
.request-item.empty { justify-content: center; color: var(--gray-400); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.tracking-block { margin-top: 12px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.tracking-block p { font-size: 14px; color: var(--gray-600); }

body.dark .connections { background: #2a2a30; }
body.dark .request-item { background: var(--gray-200); color: var(--gray-600); }
body.dark .request-item .request-email { color: var(--gray-900); }
body.dark .linked-badge { background: var(--gray-200); color: var(--warm-400); }

/* === List tools (search + sort) === */
.list-tools { display: flex; gap: 8px; margin-top: 16px; }
.search-input, .sort-select {
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: #fff;
  outline: none;
  transition: var(--transition);
}
.search-input { flex: 1; }
.search-input:focus, .sort-select:focus {
  border-color: var(--warm-400);
  box-shadow: 0 0 0 3px rgba(240, 156, 85, 0.15);
}
.sort-select { cursor: pointer; }

/* === Summary === */
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.summary-pill { font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 20px; }
.summary-pill.green { background: rgba(34, 197, 94, 0.12); color: #15803d; }
.summary-pill.yellow { background: rgba(234, 179, 8, 0.12); color: #a16207; }
.summary-pill.red { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }

/* === Loved Ones List === */
.loved-ones-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.loved-one-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: var(--transition);
  animation: fadeUp 0.3s ease;
  position: relative;
}
.loved-one-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.loved-one-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.status-dot.green {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}
.status-dot.yellow {
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.2);
}
.status-dot.red {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.loved-one-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.loved-one-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.loved-one-meta {
  font-size: 13px;
  color: var(--gray-400);
}
.loved-one-note {
  font-size: 13px;
  color: var(--warm-600);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loved-one-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.status-label {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-label.green {
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
}
.status-label.yellow {
  background: rgba(234, 179, 8, 0.1);
  color: #a16207;
}
.status-label.red {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

.token-link {
  font-size: 12px;
  color: var(--gray-400);
  background: var(--gray-50);
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--gray-200);
  white-space: nowrap;
}
.token-link:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-delete {
  border: none;
  background: transparent;
  color: var(--gray-400);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
}
.btn-delete:hover {
  background: var(--rose-100);
  color: var(--rose-500);
}

.thresholds {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}
.thresholds .field { flex: 1; }
.thresholds input {
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  background: var(--gray-50);
}
.thresholds input:focus {
  border-color: var(--warm-400);
  box-shadow: 0 0 0 3px rgba(240, 156, 85, 0.15);
}

.btn-danger {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--rose-100);
  color: var(--rose-500);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-danger:hover {
  background: var(--rose-200);
  color: var(--rose-600);
}

.btn-check {
  border: none;
  background: transparent;
  color: var(--gray-400);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
}
.btn-check:hover {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.btn-edit {
  border: none;
  background: transparent;
  color: var(--gray-400);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
}
.btn-edit:hover {
  background: rgba(240, 156, 85, 0.15);
  color: var(--warm-600);
}

/* Missed alert flash on the card */
.loved-one-card.flash {
  animation: missedFlash 1.2s ease;
}
@keyframes missedFlash {
  0% { background: #fff; box-shadow: var(--shadow); }
  40% { background: rgba(239, 68, 68, 0.12); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3); }
  100% { background: #fff; box-shadow: var(--shadow); }
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 56px; display: block; margin-bottom: 16px; }
.empty-state h3 {
  font-size: 18px;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--gray-400);
  font-size: 14px;
}

/* === Checkin Page === */
.checkin-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--teal-50) 0%, var(--warm-50) 100%);
}

.checkin-container {
  width: 100%;
  max-width: 480px;
  padding: 24px;
}

.checkin-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 48px 32px 40px;
  text-align: center;
  animation: fadeUp 0.5s ease;
}

.checkin-icon {
  font-size: 72px;
  display: block;
  margin-bottom: 16px;
}

.checkin-card h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.checkin-sub {
  color: var(--gray-500);
  font-size: 16px;
  margin-bottom: 32px;
  line-height: 1.5;
}

.btn-checkin {
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--teal-400), var(--teal-500));
  color: #fff;
  padding: 0;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}
.btn-checkin:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(42, 157, 143, 0.3);
}
.btn-checkin:active { transform: scale(0.98); }

.btn-checkin-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 32px;
  font-size: 18px;
  font-weight: 600;
}

.checkmark {
  font-size: 24px;
  font-weight: 700;
}

.checkin-result {
  margin-top: 20px;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  animation: fadeUp 0.3s ease;
}
.checkin-result.success {
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
}
.checkin-result.error {
  background: var(--rose-100);
  color: var(--rose-500);
}

.checkin-footer {
  margin-top: 32px;
  color: var(--gray-400);
  font-size: 13px;
}

/* === Modal / History === */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 24, 27, 0.5);
  backdrop-filter: blur(4px);
}

.modal {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: fadeUp 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
}
.modal-close {
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
}
.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.history-item .history-time {
  color: var(--gray-600);
  font-weight: 500;
}
.history-item .history-label {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
}

.history-empty {
  text-align: center;
  padding: 40px 24px;
  color: var(--gray-400);
  font-size: 14px;
}

.history-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
}
.history-pagination.hidden { display: none; }

.btn-page {
  border: 1px solid var(--gray-200);
  background: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  transition: var(--transition);
}
.btn-page:hover:not(:disabled) {
  background: var(--gray-100);
  border-color: var(--gray-300);
}
.btn-page:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-info {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
}

/* === Messenger (Telegram-style chat) === */
.messenger-modal { max-width: 640px; height: 70vh; }

.messenger-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 16px 24px 0;
}

.messenger-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

.msg-row {
  display: flex;
}
.msg-row.msg-out { justify-content: flex-end; } /* my messages → right, like Telegram */
.msg-row.msg-in { justify-content: flex-start; } /* their replies → left */

.msg-bubble {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 70%;
  padding: 8px 10px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 14%, white);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: var(--shadow);
}

.msg-row.msg-out .msg-bubble {
  border-top-right-radius: 4px;
}

.msg-row.msg-in .msg-bubble {
  background: var(--gray-100);
  border-top-left-radius: 4px;
}

/* Centered "service" row for calls in the merged message+call timeline. */
.msg-row.msg-center { justify-content: center; }
.msg-row.msg-center .msg-bubble {
  align-items: center;
  max-width: 80%;
  padding: 6px 14px;
  background: var(--gray-100);
  border-radius: 12px;
  font-size: 13px;
  text-align: center;
}
.msg-row.msg-center .msg-time { align-self: center; }

.msg-text { display: block; }

.msg-time {
  align-self: flex-end;
  margin-top: 4px;
  font-size: 11px;
  color: var(--gray-500);
  white-space: nowrap;
}

.messenger-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 24px;
  border-top: 1px solid var(--gray-100);
}

.messenger-composer textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  resize: none;
}

.messenger-composer textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.messenger-composer .btn-primary:disabled { opacity: 0.4; cursor: default; }

.messenger-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 0;
}
.messenger-pagination.hidden { display: none; }

.messenger-hint { text-align: center; margin: 0; padding: 8px 0 4px; }

/* === Video Call === */
.modal-call-btn {
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
}
.modal-call-btn:hover { background: var(--gray-100); }

.call-incoming { max-width: 380px; }
.call-from { font-size: 15px; color: var(--gray-700); margin-bottom: 16px; }
.call-actions { display: flex; gap: 10px; justify-content: flex-end; }

.call-modal { max-width: 720px; height: 80vh; }
.call-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #000;
}
#call-remote {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
#call-local {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 24%;
  height: 32%;
  min-width: 120px;
  min-height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transform: scaleX(-1); /* mirror the local preview */
  transition: opacity 0.2s ease;
  opacity: 0.92;
}
#call-local:hover { opacity: 1; }

/* Clicked "swap": the local camera becomes main, the remote moves to the corner */
.call-body.swapped #call-local {
  position: static;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  cursor: default;
}
.call-body.swapped #call-remote {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 24%;
  height: 32%;
  min-width: 120px;
  min-height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: opacity 0.2s ease;
  opacity: 0.92;
}
.call-body.swapped #call-remote:hover { opacity: 1; }

.call-status {
  text-align: center;
  font-size: 13px;
  color: var(--gray-500);
  padding: 8px 0;
}

body.dark .modal-call-btn:hover { background: var(--gray-200); }
body.dark .call-from { color: var(--gray-300); }


/* === Toast === */
.toast {
  position: fixed;
  bottom: 48px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: fit-content;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: fadeUp 0.3s ease;
}
.toast.success {
  background: rgba(34, 197, 94, 0.9);
  color: #fff;
}
.toast.error {
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
}

/* === Animations === */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Confetti === */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  z-index: 200;
  pointer-events: none;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(85vh) rotate(720deg); opacity: 0; }
}

/* === Dark Theme === */
body.dark {
  --warm-50: #1f1a17;
  --gray-50: #232327;
  --gray-100: #2c2c31;
  --gray-200: #3a3a41;
  --gray-300: #4b4b54;
  --gray-400: #8b8b95;
  --gray-500: #a1a1aa;
  --gray-600: #c0c0c8;
  --gray-700: #d4d4da;
  --gray-800: #e4e4ea;
  --gray-900: #f4f4f8;
  background: linear-gradient(180deg, #232327 0%, #18181b 100%);
}
body.dark.auth-page, body.dark.checkin-page { background: #18181b; }

.theme-fab {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 150;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-700);
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.theme-fab:hover { transform: translateY(-1px); }
body.dark .theme-fab { background: #2a2a30; color: var(--gray-300); border-color: var(--gray-300); }
body.dark .auth-card,
body.dark .modal,
body.dark .loved-one-card,
body.dark .add-form input,
body.dark .field input,
body.dark .search-input,
body.dark .sort-select,
body.dark .btn-page,
body.dark .history-item,
body.dark .checkin-card { background: #2a2a30; color: var(--gray-800); }
body.dark .dashboard-header { background: rgba(26, 26, 30, 0.9); border-bottom: 1px solid var(--gray-200); }
body.dark .tab { color: var(--gray-500); }
body.dark .tab.active { background: #2a2a30; color: var(--gray-900); box-shadow: none; }
body.dark .btn-ghost { color: var(--gray-400); border-color: var(--gray-300); }
body.dark .btn-ghost:hover { background: var(--gray-200); color: var(--gray-800); }
body.dark .points-badge { background: var(--gray-200); color: var(--gray-800); }
body.dark .accent-swatch.selected { border-color: #fff; }
body.dark .perk-block { border-color: var(--gray-300); }
body.dark .btn-message:hover { background: var(--gray-200); }
body.dark .msg-bubble { background: color-mix(in srgb, var(--accent) 30%, #2a2a30); color: var(--gray-800); }
body.dark .msg-row.msg-in .msg-bubble { background: #3a3a42; }
body.dark .msg-row.msg-center .msg-bubble { background: #3a3a42; }
body.dark .msg-time { color: var(--gray-400); }
body.dark .messenger-composer { border-top-color: var(--gray-300); }
body.dark .messenger-composer textarea { background: #2a2a30; color: var(--gray-800); border-color: var(--gray-300); }
body.dark .btn-check, body.dark .btn-edit, body.dark .btn-delete { color: var(--gray-500); }
body.dark .token-link { background: var(--gray-200); color: var(--gray-400); border-color: var(--gray-300); }
body.dark .loved-one-note { color: var(--warm-400); }
body.dark .checkin-card h1, body.dark .checkin-sub, body.dark .checkin-footer { color: var(--gray-800); }
body.dark .summary-pill.green { color: #4ade80; }
body.dark .summary-pill.yellow { color: #facc15; }
body.dark .summary-pill.red { color: #f87171; }

/* === Responsive === */
@media (max-width: 600px) {
  .auth-card { padding: 28px 20px; }
  .dashboard-main { padding: 20px 16px; }
  .loved-one-card { padding: 16px; flex-wrap: wrap; gap: 12px; }
  .loved-one-actions { width: 100%; justify-content: flex-end; }
  .add-form { flex-direction: column; }
  .checkin-card { padding: 32px 20px; }
}
