:root {
    --plum: #6B46C1;
    --jade: #34D399;
    --surface-bg: #F5F5F7;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--surface-bg);
    overflow: visible;          /* important: prevent clipping of fixed modals */
    min-height: 100vh;
}

.screen {
    display: none;
    min-height: 100vh;
    position: relative;
}

.screen.active {
    display: block;
}

.gradient-bg {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, rgba(107, 70, 193, 0.3), rgba(52, 211, 153, 0.2));
    z-index: -1;
}

/* ───────────────────────────────────────────────
   Glass Effect (used by cards and modals)
─────────────────────────────────────────────── */
.glass-card,
.glass-card-inner {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.glass-card {
    padding: 24px;
}

.glass-card-inner {
    padding: 16px;
}

/* ───────────────────────────────────────────────
   Modal – core behavior
─────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex !important;
}

/* Force reliable visibility & positioning */
.modal.active {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 20px !important;                  /* breathing room on small screens */
    
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    
    background: rgba(0, 0, 0, 0.45) !important;
    backdrop-filter: blur(4px) !important;
    
    z-index: 10000 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.modal-content {
    background: rgba(255, 255, 255, 0.90) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 20px !important;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.22) !important;
    
    width: 90% !important;
    max-width: 560px !important;               /* ← this keeps it from going edge-to-edge */
    min-height: 300px !important;              /* prevents collapse */
    max-height: 88vh !important;
    overflow-y: auto !important;
    
    /* Remove any accidental left bias */
    margin: 0 auto !important;
    transform: none !important;
}

/* Profile modal specific sizing (prevents collapse) */
#profileModal .modal-content,
.profile-modal-content {
    min-height: 380px;
}

/* Profile avatar: fixed size so large images don't blow out the layout */
.avatar-preview-wrap {
    width: 120px;
    height: 120px;
    min-width: 120px;
    min-height: 120px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--glass-bg, rgba(255, 255, 255, 0.6));
    display: flex;
    align-items: center;
    justify-content: center;
}
.profile-avatar-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.profile-avatar-placeholder {
    width: 120px;
    height: 120px;
    min-width: 120px;
    min-height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #888;
    background: var(--glass-bg, rgba(255, 255, 255, 0.6));
}

/* Modal close button */
.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 36px;
    cursor: pointer;
    color: #555;
    line-height: 1;
}

/* ───────────────────────────────────────────────
   Inputs, Buttons, etc. (unchanged core styles)
─────────────────────────────────────────────── */
.glass-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin-bottom: 16px;
    outline: none;
}
textarea.glass-input {
    resize: vertical;
    min-height: 80px;
}

.glass-input:focus {
    border-color: var(--plum);
    box-shadow: 0 0 0 3px rgba(107, 70, 193, 0.15);
}

.glass-button {
    width: 100%;
    padding: 14px;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    border: 1.5px solid rgba(107, 70, 193, 0.4);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
}

.glass-button.primary {
    background: linear-gradient(135deg, var(--plum), var(--jade));
    color: white;
    border: none;
}

.glass-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(107, 70, 193, 0.25);
}

/* Rest of your original styles – kept mostly unchanged */

.login-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.logo {
    width: 150px;
    height: 150px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(107, 70, 193, 0.3);
}

.welcome-text {
    text-align: center;
}
.welcome-subtitle {
    font-size: 1rem;
    color: #555;
    margin: 0 0 4px 0;
}
.welcome-title {
    font-size: 52px;
    font-weight: 800;
    margin: 0;
}

.gradient-text {
    background: linear-gradient(90deg, var(--plum), var(--jade));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.error-message {
    background: rgba(255, 0, 0, 0.15);
    border: 2px solid rgba(200, 0, 0, 0.5);
    color: #b00;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin: 12px 0;
    text-align: center;
}

.hidden {
    display: none !important;
}
.error-message.hidden {
    display: none;
}

/* Login screen tweaks */
.forgot-password {
    display: block;
    width: 100%;
    text-align: center;
    background: none;
    border: none;
    color: var(--plum);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px 0;
    outline: none;
}
.toggle-auth {
    display: block;
    width: 100%;
    text-align: center;
    background: none;
    border: none;
    color: var(--plum);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px 0;
    outline: none;
}
.signup-hint {
    text-align: center;
}

/* Toolbar / Navbar icons, prayer cards, etc. – assuming you still want these */
.toolbar-icon, .nav-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--plum);
}

.nav-icon-back {
    font-size: 1.75rem;
    line-height: 1;
    padding: 4px 8px;
    min-width: 44px;
    min-height: 44px;
}

.nav-icon-with-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
}
.nav-icon-with-label .nav-icon-label {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.icon-button-with-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

.icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .modal-content {
        width: 94%;
        padding: 24px 16px;
    }
}
/* Reset any left bias and force true centering */
.modal.active {
    position: fixed !important;
    inset: 0 !important;
    margin: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    
    display: flex !important;
    flex-direction: column !important;     /* sometimes helps in edge cases */
    align-items: center !important;
    justify-content: center !important;
    
    background: rgba(0, 0, 0, 0.45) !important;
    backdrop-filter: blur(4px) !important;
    
    z-index: 10000 !important;
    opacity: 1 !important;
    visibility: visible !important;
    
    /* Explicitly kill left-side forcing */
    text-align: center !important;
    direction: ltr !important;
}

/* Inner card – explicit centering + no left drift */
.modal-content {
    background: rgba(255, 255, 255, 0.90) !important;
    backdrop-filter: blur(16px) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 20px !important;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.22) !important;
    
    /* Centering trio – this combination almost always wins */
    margin: 0 auto !important;
    width: 90% !important;
    max-width: 540px !important;           /* ← adjust this number if you want wider/narrower */
    
    min-height: 320px !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    
    /* Extra safety against left jam */
    left: auto !important;
    right: auto !important;
    transform: translateX(0) !important;
    text-align: left !important;           /* content inside can still be left-aligned */
}

/* About modal – center all inner content (logo, text, quote, email) */
#aboutModal .modal-content {
    text-align: center !important;
}

#aboutModal .about-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

#aboutModal .about-section {
    width: 100%;
}

/* Profile-specific minimum size (prevents squish) */
#profileModal .modal-content,
.profile-modal-content {
    min-height: 420px !important;
}
/* Force main content area to use full available width and center children */
.content {
    width: 100% !important;
    max-width: 1200px !important;       /* or 1000px / 90vw — adjust to taste */
    margin: 0 auto !important;
    padding: 0 20px !important;         /* side padding for breathing room */
}

/* Navbar – make it full-width and center title/buttons properly */
.navbar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    max-width: 1200px !important;
    margin: 0 auto !important;
    padding: 16px 20px !important;
}

/* Groups list – centered vertical stack of cards */
.groups-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    padding: 20px 0 !important;
    max-width: 600px !important;
    margin: 0 auto !important; /* center the column */
}

.groups-list > div:not(.empty-state) {
    width: 100% !important;
    margin: 0 !important;
}

/* Individual group cards: icon left, text middle, arrow right */
.group-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.group-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.group-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(107, 70, 193, 0.3);
    flex-shrink: 0;
}

.group-info {
    flex: 1;
}

.group-info h3 {
    font-size: 20px;
    margin-bottom: 4px;
}

.group-info p {
    font-size: 14px;
    color: #666;
}

/* Group view: prayer sections and separators */
.prayer-section {
    margin-top: 24px;
}
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--plum);
    margin-bottom: 12px;
    letter-spacing: 0.02em;
}
.section-separator {
    height: 1px;
    margin: 28px 0;
    background: linear-gradient(90deg, transparent, rgba(107, 70, 193, 0.35), rgba(52, 211, 153, 0.35), transparent);
    border: none;
}
.section-separator::after {
    content: '';
    display: block;
    height: 4px;
    margin-top: -2px;
    background: linear-gradient(90deg, transparent 20%, var(--plum) 50%, var(--jade) 80%, transparent);
    opacity: 0.4;
    border-radius: 2px;
}

.prayer-card {
    padding: 14px 18px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.prayer-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(107, 70, 193, 0.12);
}
.prayer-title {
    font-weight: 600;
    font-size: 1rem;
}
.prayer-meta {
    font-size: 13px;
    color: #666;
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Add Prayer modal: type slider */
.prayer-type-slider {
    display: flex;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 4px;
    margin-top: 8px;
}
.prayer-type-slider label {
    flex: 1;
    text-align: center;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}
.prayer-type-slider input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.prayer-type-slider label:has(input:checked) span {
    background: linear-gradient(135deg, var(--plum), var(--jade));
    color: white;
}
.prayer-type-slider label span {
    display: block;
    border-radius: 8px;
    padding: 10px 12px;
}

/* Prayer detail modal: consistent typography for view and edit */
#prayerDetailModal .modal-content,
#prayerDetailContent {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}
#prayerDetailContent h2 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
#prayerDetailContent .prayer-detail-label,
#prayerDetailContent .form-group label {
    display: block;
    font-size: 0.8125rem;
    color: #666;
    margin-bottom: 4px;
    font-weight: 400;
}
#prayerDetailContent .prayer-detail-value,
#prayerDetailContent .prayer-detail-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
}
#prayerDetailContent .prayer-detail-body {
    font-size: 1rem;
    font-weight: 400;
    color: #333;
}
#prayerDetailContent .form-group {
    margin-top: 1rem;
}
#prayerDetailContent .form-group .glass-input {
    font-size: 1rem;
    font-family: inherit;
}

/* Bottom toolbar – center icons horizontally */
.bottom-toolbar {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 1200px !important;
    margin: 0 auto !important;
    padding: 16px 20px !important;
}

/* Kill any accidental left-only alignment */
body, .screen.active, .content, .groups-list, .navbar, .bottom-toolbar {
    text-align: initial !important;
    direction: ltr !important;
}