:root {
  --bg: #f0f4fa;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --text: #1a2332;
  --muted: #64748b;
  --line: rgba(30, 58, 95, 0.12);
  --primary: #1e3a5f;
  --primary-deep: #0f2540;
  --secondary: #dbeafe;
  --secondary-text: #1e40af;
  --accent: #60a5fa;
  --shadow: 0 24px 70px rgba(30, 58, 95, 0.12);
  --radius-xl: 36px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: 'Inter', sans-serif;
}

body.public-bg {
  background-image: url('/prayer-bg.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

body.public-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: rgba(220, 230, 245, 0.22);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.03em;
}

p {
  margin: 0;
}

button,
input,
select,
textarea,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 64px;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.4);
  margin-bottom: 24px;
  position: relative;
  z-index: 2;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.brand__logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
}

.topbar__actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ─── Layout grid ────────────────────────────────────────────────────────────── */

.layout,
.page-view,
.stack,
.landing-view,
.auth-view {
  display: grid;
  gap: 20px;
}

.hero__copy,
.card {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

/* ─── Hero ───────────────────────────────────────────────────────────────────── */

.hero--home {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  min-height: 82vh;
  position: relative;
}

.hero--home::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(
    100deg,
    rgba(8, 18, 42, 0.82) 0%,
    rgba(8, 18, 42, 0.60) 55%,
    rgba(8, 18, 42, 0.12) 80%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 0;
}

.hero__copy--home {
  background: none;
  border: none;
  backdrop-filter: none;
  box-shadow: none;
  border-radius: 0;
  padding: 48px 0;
  width: 100%;
  text-align: left;
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.hero__copy--home .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.hero--home h1 {
  color: #ffffff;
  font-size: clamp(2rem, 3.8vw, 3.4rem);
  line-height: 1.1;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
}

.hero__copy--home .hero__text {
  color: rgba(255, 255, 255, 0.82);
  max-width: 52ch;
}

.hero__copy--home .button--primary {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
}

.hero__copy--home .button--ghost {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.36);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 14px;
}

.hero__text,
.section-subtitle,
.field span,
.prayer-meta,
#paginationLabel {
  color: var(--muted);
}

.hero__text {
  margin-top: 18px;
  max-width: 52ch;
  font-size: 1.03rem;
  line-height: 1.75;
}

.hero__actions {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 28px;
}

/* ─── Cards ──────────────────────────────────────────────────────────────────── */

.card {
  border-radius: var(--radius-lg);
}

.auth-screen,
.card {
  padding: 24px;
}

/* ─── Auth screens ───────────────────────────────────────────────────────────── */

.auth-view {
  justify-items: center;
}

#loginSection:not(.hidden),
#registerSection:not(.hidden) {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-image: url('/prayer-bg.jpg');
  background-size: cover;
  background-position: center;
}

#loginSection:not(.hidden)::before,
#registerSection:not(.hidden)::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(6, 12, 28, 0.45);
}

#loginSection:not(.hidden) .auth-screen,
#registerSection:not(.hidden) .auth-screen {
  position: relative;
  z-index: 1;
  background: #ffffff;
  backdrop-filter: none;
  border: none;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.45);
}

.auth-screen {
  width: min(560px, 100%);
}

.auth-screen__logo {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  object-fit: cover;
  margin: 0 auto 20px;
}

.auth-screen__intro {
  margin-bottom: 18px;
}

.auth-screen__footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

/* ─── Section heading ────────────────────────────────────────────────────────── */

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.section-heading--compact {
  align-items: center;
}

.section-heading h2,
.section-heading h3 {
  margin-bottom: 6px;
}

/* ─── Authenticated page layout ─────────────────────────────────────────────── */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.page-header--back {
  justify-content: flex-start;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

/* ─── Form elements ──────────────────────────────────────────────────────────── */

.form-row,
.filter-grid {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.88rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(30, 58, 95, 0.14);
  background: rgba(255, 255, 255, 0.9);
  padding: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(30, 58, 95, 0.5);
  box-shadow: 0 0 0 4px rgba(30, 58, 95, 0.1);
  transform: translateY(-1px);
}

.field--readonly input {
  background: rgba(226, 234, 231, 0.72);
}

.field--error input,
.field--error select,
.field--error textarea {
  border-color: rgba(220, 38, 38, 0.6);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.field__error {
  font-size: 0.8rem;
  color: #dc2626;
  font-weight: 500;
}

.form-error {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(220, 38, 38, 0.07);
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: #dc2626;
  font-size: 0.88rem;
  font-weight: 500;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button--primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-deep) 100%);
  color: #eff6ff;
  box-shadow: 0 14px 30px rgba(30, 58, 95, 0.28);
}

.button--secondary {
  background: var(--secondary);
  color: var(--secondary-text);
  box-shadow: 0 14px 30px rgba(96, 165, 250, 0.2);
}

.button--ghost {
  background: rgba(30, 58, 95, 0.08);
  color: var(--primary);
}

.button--text {
  padding-inline: 0;
  background: transparent;
  color: var(--primary);
}

.button--nav {
  min-width: 108px;
}

/* ─── Filter ─────────────────────────────────────────────────────────────────── */

.filter-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.filter-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ─── Prayer list ────────────────────────────────────────────────────────────── */

.prayer-list {
  display: grid;
  gap: 14px;
}

.prayer-card {
  border-radius: var(--radius-md);
  border: 1px solid rgba(30, 58, 95, 0.08);
  background: rgba(255, 255, 255, 0.72);
  padding: 18px;
  display: grid;
  gap: 14px;
  animation: rise 260ms ease;
}

.prayer-card__header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.prayer-card h4 {
  font-size: 1.3rem;
  margin-bottom: 6px;
}

.prayer-description {
  line-height: 1.65;
}

.prayer-meta,
.pill-row,
.prayer-actions,
.pagination-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ─── Pills ──────────────────────────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(30, 58, 95, 0.06);
}

.pill--open {
  background: rgba(30, 58, 95, 0.12);
  color: var(--primary);
}

.pill--answered {
  background: rgba(96, 165, 250, 0.18);
  color: #1d4ed8;
}

.pill--archived {
  background: rgba(99, 113, 107, 0.12);
  color: #596660;
}

.pill--category {
  background: rgba(219, 234, 254, 0.76);
  color: var(--secondary-text);
}

/* ─── Comment feed ───────────────────────────────────────────────────────────── */

.comment-feed {
  display: grid;
  gap: 12px;
}

.comment-item {
  border-radius: var(--radius-md);
  border: 1px solid rgba(30, 58, 95, 0.08);
  background: rgba(255, 255, 255, 0.72);
  padding: 16px 18px;
  display: grid;
  gap: 8px;
  animation: rise 260ms ease;
}

.comment-item__meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.comment-item__edited {
  font-style: italic;
  opacity: 0.7;
}

.comment-item__content {
  line-height: 1.65;
  white-space: pre-wrap;
}

.comment-item__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ─── Prayer modal ───────────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 12, 28, 0.5);
  backdrop-filter: blur(6px);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(29, 36, 33, 0.94);
  color: #fff;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
}

/* ─── Empty state ────────────────────────────────────────────────────────────── */

.empty-state {
  border: 1px dashed rgba(30, 58, 95, 0.14);
  border-radius: var(--radius-md);
  padding: 22px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
}

/* ─── Animation ──────────────────────────────────────────────────────────────── */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .hero--home,
  .filter-grid,
  .account-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 100%);
    padding-top: 18px;
  }

  .topbar,
  .section-heading,
  .prayer-card__header,
  .auth-screen__footer,
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .hero__copy--home,
  .card {
    padding: 20px;
  }

  .hero__actions,
  .filter-actions,
  .pagination-controls,
  .prayer-actions,
  .topbar__actions {
    width: 100%;
  }

  .button {
    width: 100%;
  }

  .button--text {
    width: auto;
  }

  .comment-item__actions {
    justify-content: flex-start;
  }
}
