/* ─── Design tokens ───────────────────────────────────────────────────────── */
:root {
  --bg:           #0a0a0a;
  --surface:      #111111;
  --card:         #161616;
  --card-hover:   #1c1c1c;
  --border:       #242424;
  --border-subtle:#1a1a1a;

  --text:         #f0f0f0;
  --text-secondary:#888888;
  --text-tertiary: #555555;

  --accent:       #4BAFD4;
  --accent-dim:   rgba(75, 175, 212, 0.12);
  --accent-ring:  rgba(75, 175, 212, 0.30);

  --danger:       #ef4444;
  --danger-dim:   rgba(239, 68, 68, 0.12);

  --warn:         #f59e0b;

  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    16px;
  --radius-xl:    20px;

  --font:         'Inter', system-ui, -apple-system, sans-serif;

  --ease:         cubic-bezier(0.22, 1, 0.36, 1);
  --duration:     200ms;

  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }

/* ─── App shell ──────────────────────────────────────────────────────────── */
#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}

/* ─── Splash / loading ───────────────────────────────────────────────────── */
.splash {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wordmark {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  animation: pulse 1.4s var(--ease) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ─── Page transitions ───────────────────────────────────────────────────── */
.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 20px;
  padding-bottom: calc(24px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: fadeUp 280ms var(--ease) both;
}

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

/* ─── Auth page ──────────────────────────────────────────────────────────── */
.auth-page {
  justify-content: center;
  gap: 40px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 40px);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-logo {
  width: 52px;
  margin-bottom: 10px;
}

.auth-brand h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.auth-brand p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-toggle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 8px;
}

.auth-toggle button {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ─── Onboarding ─────────────────────────────────────────────────────────── */
.onboarding-page {
  padding-top: calc(env(safe-area-inset-top, 0px) + 32px);
  gap: 32px;
}

.onboarding-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.onboarding-header p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-top: 6px;
}

.card-choice {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ─── Dashboard ──────────────────────────────────────────────────────────── */
.dashboard-page {
  gap: 28px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 24px);
}

.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.dash-date {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dash-pod-name {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-top: 4px;
}

.icon-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.icon-btn:hover { background: var(--card-hover); color: var(--text); }

/* Week strip */
.week-strip {
  display: flex;
  gap: 6px;
}

.week-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.week-day-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.week-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.week-dot.checked {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.week-dot.today {
  border-color: var(--text-tertiary);
}

/* Pod members */
.members-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.members-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  transition: background var(--duration) var(--ease);
}

.member-row:hover { background: var(--card); }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

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

.member-name {
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-you {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-left: 5px;
}

.member-note {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.status-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-dot.checked {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.status-dot svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

/* Check-in CTA */
.checkin-cta {
  margin-top: auto;
  padding-top: 16px;
}

.checkin-done {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  color: var(--accent);
  font-weight: 600;
  font-size: 1rem;
}

/* ─── Check-in page ──────────────────────────────────────────────────────── */
.checkin-page {
  padding-top: calc(env(safe-area-inset-top, 0px) + 32px);
  gap: 32px;
}

.checkin-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.checkin-header p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-top: 6px;
}

/* ─── Invite code display ────────────────────────────────────────────────── */
.invite-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.invite-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.invite-code {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.invite-hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Form elements ──────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

input[type="email"],
input[type="password"],
input[type="text"],
textarea {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 13px 14px;
  font-size: 0.9375rem;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  outline: none;
  width: 100%;
}

input::placeholder,
textarea::placeholder { color: var(--text-tertiary); }

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

textarea {
  resize: none;
  min-height: 96px;
  line-height: 1.5;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease), background var(--duration) var(--ease);
  letter-spacing: -0.01em;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
}

.btn-primary:hover:not(:disabled) { opacity: 0.9; }

.btn-ghost {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) { background: var(--card-hover); }

.btn-danger {
  background: var(--danger-dim);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn-lg {
  padding: 17px 20px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

/* ─── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ─── Divider ────────────────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-tertiary);
  font-size: 0.8125rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Error / notice ─────────────────────────────────────────────────────── */
.notice {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.4;
}

.notice-error {
  background: var(--danger-dim);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.notice-success {
  background: var(--accent-dim);
  border: 1px solid rgba(75, 175, 212, 0.3);
  color: #93d5ea;
}

/* ─── Bottom navigation ──────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 200;
  padding-bottom: var(--safe-bottom);
}

.bottom-nav.hidden { display: none; }

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color var(--duration) var(--ease);
  padding: 8px 0 4px;
}

.nav-tab svg { transition: transform var(--duration) var(--ease); }
.nav-tab:active svg { transform: scale(0.88); }

.nav-tab.active {
  color: var(--accent);
}

.nav-tab:not(.active):hover { color: var(--text); }

/* Push page content up when bottom nav is visible */
#app.has-bottom-nav .page {
  padding-bottom: calc(72px + var(--safe-bottom));
}

/* ─── Nav / settings ─────────────────────────────────────────────────────── */
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0;
  margin-bottom: 8px;
  transition: color var(--duration) var(--ease);
}

.back-btn:hover { color: var(--text); }

/* ─── Loading spinner ────────────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Push prompt ────────────────────────────────────────────────────────── */
.push-prompt {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.push-prompt p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ─── Settings page ──────────────────────────────────────────────────────── */
.settings-page {
  padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  gap: 24px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 4px;
  margin-bottom: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
}

.settings-row-label { font-weight: 500; }
.settings-row-value { color: var(--text-secondary); font-size: 0.875rem; }

.settings-pod-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-pod-row:last-of-type { border-bottom: none; }

.settings-pod-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-invite-code {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

.mt-auto { margin-top: auto; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.875rem; }

/* ─── Pod switcher ───────────────────────────────────────────────────────── */
.pod-switcher {
  display: flex;
  gap: 6px;
  padding: 8px 20px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border-subtle);
}
.pod-switcher::-webkit-scrollbar { display: none; }

.pod-chip {
  padding: 5px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all var(--duration) var(--ease);
  flex-shrink: 0;
}
.pod-chip:hover { background: var(--card); color: var(--text); }
.pod-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Activity check-in page ─────────────────────────────────────────────── */
.char-count {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 5px;
}

/* ─── My activity today card ─────────────────────────────────────────────── */
.status-today {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-today-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.status-today-text {
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.4;
}

/* ─── Member section (row + comment thread) ──────────────────────────────── */
.members-list { gap: 6px; }

.member-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
  transition: border-color var(--duration) var(--ease);
}

.member-section .member-row {
  border-radius: 0;
}

.member-section .member-row:hover {
  background: var(--card-hover);
}

.member-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.member-activity {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Comment badge ──────────────────────────────────────────────────────── */
.comment-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 8px 3px 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease),
              background var(--duration) var(--ease);
}

.comment-badge:hover,
.comment-badge.has-comments {
  border-color: var(--accent);
  color: var(--accent);
}

.comment-badge .badge-count:empty { display: none; }

/* ─── Comment thread ─────────────────────────────────────────────────────── */
.comment-thread {
  border-top: 1px solid var(--border-subtle);
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
}

.comment-thread.hidden { display: none; }

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.comment-item {
  font-size: 0.8125rem;
  color: var(--text);
  line-height: 1.45;
}

.comment-item-author {
  font-weight: 600;
  margin-right: 5px;
}

.comment-item-pending { opacity: 0.5; }

.comment-empty {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.comment-form {
  display: flex;
  gap: 6px;
  align-items: center;
}

.comment-input {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 0.8125rem;
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color var(--duration) var(--ease);
}

.comment-input::placeholder { color: var(--text-tertiary); }
.comment-input:focus { border-color: var(--accent); }

.comment-send-btn {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--duration) var(--ease);
}

.comment-send-btn:hover { background: rgba(75, 175, 212, 0.22); }
.comment-send-btn:disabled { opacity: 0.45; cursor: not-allowed; }
