:root {
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #1c1e21;
  --text-muted: #6b7280;
  --border: #eceef1;
  --accent: #4f7cff;
  --accent-warm: #ff9500;
  --danger: #ff3b30;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(20, 20, 40, 0.06);
  --shadow-lg: 0 8px 24px rgba(20, 20, 40, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- Auth screens ---------- */

.hidden {
  display: none !important;
}

#main-screen {
  display: flex;
}

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #4f7cff 0%, #7d5fff 100%);
}

.auth-card {
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-card h1 {
  font-size: 22px;
  margin: 8px 0 4px;
}

.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.auth-card input[type="password"],
.auth-card input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  text-align: center;
  letter-spacing: 4px;
  margin-bottom: 12px;
}

.big-emoji {
  font-size: 40px;
}

.people-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.person-pick-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 16px;
  cursor: pointer;
  text-align: left;
}

.person-pick-btn:active {
  transform: scale(0.98);
}

/* ---------- Buttons ---------- */

button {
  font-family: inherit;
}

.btn {
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn.danger {
  background: #fff0ef;
  color: var(--danger);
}

.btn.full {
  width: 100%;
}

.btn.small {
  padding: 8px 14px;
  font-size: 13px;
}

/* ---------- Avatars ---------- */

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.avatar.sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 18px 18px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h2 {
  margin: 0;
  font-size: 20px;
}

.topbar .who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

/* ---------- Views / pages ---------- */

.view {
  flex: 1;
  padding: 8px 16px 90px;
  overflow-y: auto;
}

.view.hidden {
  display: none;
}

/* ---------- Cards ---------- */

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}

.topic-card {
  background: linear-gradient(135deg, #4f7cff 0%, #7d5fff 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
}

.topic-card .eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.85;
  margin-bottom: 6px;
}

.topic-card h3 {
  margin: 0 0 6px;
  font-size: 22px;
}

.topic-card p {
  margin: 0;
  opacity: 0.92;
  font-size: 14px;
  line-height: 1.4;
}

.topic-card .edit-link {
  margin-top: 12px;
  display: inline-block;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.95;
  cursor: pointer;
  text-decoration: underline;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 18px 4px 8px;
}

.empty-hint {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 24px 12px;
}

/* ---------- Home preview rows ---------- */

.preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}

.preview-row:last-child {
  border-bottom: none;
}

.preview-row .line1 {
  font-weight: 600;
  font-size: 14px;
}

.preview-row .line2 {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Chat ---------- */

.chat-scroll {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 10px;
}

.msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.msg-row.mine {
  flex-direction: row-reverse;
}

.msg-bubble {
  max-width: 72%;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

.msg-row.mine .msg-bubble {
  background: var(--accent);
  color: #fff;
}

.msg-bubble .msg-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.msg-row.mine .msg-bubble .msg-name {
  color: rgba(255, 255, 255, 0.8);
}

.msg-bubble .msg-body {
  font-size: 15px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-input-bar {
  position: sticky;
  bottom: 66px;
  display: flex;
  gap: 8px;
  padding: 10px 0;
  background: var(--bg);
}

.chat-input-bar input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 15px;
}

.chat-input-bar button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
}

/* ---------- Calendar ---------- */

.cal-entry {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.cal-date-badge {
  background: var(--bg);
  border-radius: 12px;
  padding: 8px 10px;
  text-align: center;
  min-width: 56px;
}

.cal-date-badge .dow {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
}

.cal-date-badge .dom {
  font-size: 18px;
  font-weight: 700;
}

.cal-entry .cal-title {
  font-weight: 600;
  font-size: 15px;
}

.cal-entry .cal-speaker {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent, #4f7cff);
  margin-top: 2px;
}

.cal-entry .cal-notes {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.cal-entry .cal-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  background: #eaf0ff;
  color: var(--accent);
}

/* ---------- Forms ---------- */

.form-field {
  margin-bottom: 12px;
}

.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-field input[type="text"],
.form-field input[type="date"],
.form-field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
}

.form-field textarea {
  min-height: 80px;
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ---------- Modal sheet ---------- */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.sheet-overlay.hidden {
  display: none;
}

.sheet {
  background: var(--card-bg);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 640px;
  max-height: 86vh;
  overflow-y: auto;
}

.sheet h3 {
  margin: 0 0 14px;
}

@media (min-width: 700px) {
  .sheet-overlay {
    align-items: center;
  }
  .sheet {
    border-radius: 20px;
    max-width: 480px;
  }
}

/* ---------- Members list ---------- */

.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}

.member-row:last-child {
  border-bottom: none;
}

.member-row .name {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}

.swatch.selected {
  border-color: var(--text);
}

/* ---------- Prayer ---------- */

.prayer-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.prayer-item:last-child {
  border-bottom: none;
}

.prayer-item.answered {
  opacity: 0.6;
}

.prayer-item .prayer-body {
  font-size: 14px;
  line-height: 1.4;
}

.prayer-item .prayer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 20;
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
}

.nav-btn .icon {
  font-size: 20px;
}

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

.fab-space {
  height: 4px;
}

/* ---------- Desktop layout ---------- */

@media (min-width: 860px) {
  #app {
    max-width: 960px;
    flex-direction: row;
  }

  .bottom-nav {
    position: sticky;
    top: 0;
    left: 0;
    transform: none;
    width: 220px;
    max-width: 220px;
    height: 100vh;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 24px 12px;
    gap: 4px;
  }

  .nav-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
  }

  .nav-btn.active {
    background: #eaf0ff;
  }

  .main-col {
    flex: 1;
    min-width: 0;
  }

  .view {
    padding-bottom: 40px;
    max-width: 640px;
    margin: 0 auto;
  }

  .chat-input-bar {
    bottom: 0;
  }
}

/* ---------- Misc ---------- */

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

.muted {
  color: var(--text-muted);
}

.push-toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
