:root {
    /* Deep Royal Theme */
    --bg-main: #0f172a;
    /* Deep Royal Blue */
    --bg-sidebar: rgba(15, 23, 42, 0.85);
    /* Glassy Dark Blue */
    --bg-chat: transparent;
    --bg-message-user: rgba(30, 41, 59, 0.8);
    --bg-message-ai: transparent;
    --bg-input: rgba(30, 41, 59, 0.9);
    --bg-button: rgba(51, 65, 85, 0.8);
    --bg-button-hover: rgba(71, 85, 105, 0.9);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-light: rgba(148, 163, 184, 0.1);
    --accent-primary: #d4af37;
    /* Classic Gold */
    --accent-gradient: linear-gradient(135deg, #d4af37, #f3e5ab);
    --accent-hover: #b8941f;

    /* Typography */
    --font-heading: 'Cinzel', serif;
    --font-body: 'Inter', sans-serif;

    /* Mobile-specific variables */
    --mobile-padding: 16px;
    --mobile-header-height: 60px;
    --mobile-input-height: auto;
    --mobile-font-size: 16px;
    /* Prevents zoom on iOS */
    --mobile-touch-target: 44px;
    /* Apple's recommended minimum */
}

/* CSS for handling virtual keyboard */
@supports (height: 100dvh) {
    :root {
        --viewport-height: 100dvh;
        /* Dynamic viewport height */
    }
}

@supports not (height: 100dvh) {
    :root {
        --viewport-height: 100vh;
    }
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    background-image: radial-gradient(circle at 50% 0%, #1e293b 0%, #0f172a 70%);
    color: var(--text-primary);
    height: var(--viewport-height);
    overflow: hidden;
    margin: 0;
    padding: 0;
    /* Support for virtual keyboard */
    padding-bottom: env(keyboard-inset-height, 0px);
}

/* Mobile overlay for sidebar */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: var(--viewport-height);
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* Prevent body scroll when mobile sidebar is open */
body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Mobile keyboard optimizations */
@media (max-width: 768px) {
    body.keyboard-open .chat-messages {
        padding-bottom: 20px;
    }

    body.keyboard-open .welcome-message {
        display: none;
        /* Hide welcome on small screens when keyboard is open */
    }
}

.app-container {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr;
    height: var(--viewport-height);
    width: 100vw;
}


.hamburger-line {
    width: 20px;
    height: 2px;
    background: currentColor;
    margin: 3px 0;
    transition: 0.3s;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 100;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    overflow-y: auto;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
}

.new-chat-btn {
    width: 100%;
    background: var(--accent-primary);
    color: var(--bg-main);
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.new-chat-btn:hover {
    background: var(--accent-hover);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.favorites-section {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s ease;
}

.favorites-section.collapsed {
    background: transparent;
}

.favorites-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.favorites-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.favorites-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.2s ease, background 0.2s ease;
}

.favorites-toggle:hover {
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.05);
}

.favorites-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 220px;
    overflow-y: auto;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.favorites-section.collapsed .favorites-list {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

.favorite-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.favorite-label {
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.favorite-preview {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-line;
}

.favorite-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.favorite-actions {
    display: flex;
    gap: 8px;
}

.favorite-actions button {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.favorite-actions button:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    background: rgba(212, 175, 55, 0.1);
}

.favorite-empty {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: left;
    transition: opacity 0.3s ease;
}

.favorites-section.collapsed .favorite-empty {
    display: none;
}

.chat-item {
    padding: 12px 16px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-item.active {
    background: var(--accent-primary);
    color: var(--bg-main);
}

.chat-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.chat-item:hover .chat-actions {
    opacity: 1;
}

.chat-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 12px;
}

.chat-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Profile Section */
.profile-section {
    padding: 20px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--border-light);
    position: relative;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 12px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--bg-main);
    font-size: 18px;
    line-height: 1;
}

/* Style for emoji avatars */
.user-avatar:has([emoji]),
.avatar-option {
    font-size: 20px;
}

/* Message avatar styling */
.message-avatar {
    font-size: 16px;
}

/* Markdown formatting styles */
.message-content strong {
    font-weight: 900;
    color: var(--accent-primary);
}

.message-content em {
    font-style: italic;
    color: var(--text-primary);
}

.message-content code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9em;
    border: 1px solid var(--border-light);
}

.message-content pre {
    background: var(--code-bg);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
    overflow-x: auto;
}

.message-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.9em;
    line-height: 1.5;
}

.bible-verse {
    background: rgba(212, 175, 55, 0.15);
    color: var(--accent-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    border-left: 3px solid var(--accent-primary);
}

/* Clickable Bible verse links */
.bible-verse-link {
    background: rgba(212, 175, 55, 0.15);
    color: var(--accent-primary);
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    border-left: 3px solid var(--accent-primary);
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    cursor: pointer;
}

.bible-verse-link:hover {
    background: rgba(212, 175, 55, 0.25);
    border-color: var(--accent-primary);
    color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.bible-verse-link::after {
    content: '📱';
    font-size: 0.8em;
    margin-left: 4px;
    opacity: 0.7;
}

/* Streaming cursor animation */
.streaming-cursor {
    display: inline-block;
    background-color: var(--accent-primary);
    color: var(--accent-primary);
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

/* Biblical/theological content headers */
.main-header {
    color: var(--accent-primary);
    font-weight: 700;
    font-size: 1.3em;
    margin: 20px 0 12px 0;
    padding: 8px 0;
    border-bottom: 2px solid var(--accent-primary);
    line-height: 1.3;
}

.major-header {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 1.15em;
    margin: 16px 0 10px 0;
    padding: 6px 0 4px 0;
    border-bottom: 1px solid var(--border-light);
    line-height: 1.3;
}

.section-header {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 1.1em;
    margin: 18px 0 10px 0;
    line-height: 1.3;
}

.minor-header {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 1.05em;
    margin: 16px 0 8px 0;
    line-height: 1.3;
}

.sub-header {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1em;
    margin: 14px 0 6px 0;
    line-height: 1.3;
}

.main-header:first-child,
.major-header:first-child,
.section-header:first-child,
.minor-header:first-child,
.sub-header:first-child {
    margin-top: 0;
}

.response-list {
    margin: 12px 0;
    padding-left: 0;
    list-style: none;
}

.response-list-item {
    position: relative;
    padding: 4px 0 4px 24px;
    margin: 4px 0;
    line-height: 1.5;
}

.response-list ul .response-list-item:before {
    content: '•';
    color: var(--accent-primary);
    font-weight: bold;
    position: absolute;
    left: 8px;
    top: 4px;
}

.response-list ol {
    counter-reset: list-counter;
}

.response-list ol .response-list-item {
    counter-increment: list-counter;
}

.response-list ol .response-list-item:before {
    content: counter(list-counter) '.';
    color: var(--accent-primary);
    font-weight: bold;
    position: absolute;
    left: 0;
    top: 4px;
    min-width: 20px;
}

.response-quote {
    border-left: 4px solid var(--accent-primary);
    background: rgba(212, 175, 55, 0.08);
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--text-secondary);
}

/* Additional markdown improvements */
.message-content p {
    margin: 8px 0;
    line-height: 1.6;
}

.message-content p:first-child {
    margin-top: 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Horizontal rules */
.message-content hr {
    border: none;
    border-top: 2px solid var(--border-light);
    margin: 20px 0;
}

/* Links */
.message-content a {
    color: var(--accent-primary);
    text-decoration: underline;
    transition: color 0.2s;
}

.message-content a:hover {
    color: var(--accent-hover);
}

/* Improved readability for AI responses */
.message.ai .message-content {
    line-height: 1.7;
    font-size: 14px;
}

/* Special styling for reflection sections */
.message-content strong:contains("Reflection") {
    display: block;
    margin: 16px 0 8px 0;
    font-size: 1.1em;
}

.user-info {
    flex: 1;
}

.display-username {
    font-weight: 600;
    font-size: 14px;
}

.user-stats {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Profile Menu */
.profile-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    margin-bottom: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s;
}

.profile-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: left;
}

.profile-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Main Chat Area */
.chat-container {
    margin-left: 280px;
    display: grid;
    grid-template-rows: auto 1fr auto env(keyboard-inset-height, 0px);
    grid-template-areas:
        "header"
        "messages"
        "input"
        "keyboard";
    background: var(--bg-chat);
    transition: margin-left 0.3s ease;
    width: calc(100vw - 280px);
    height: var(--viewport-height);
    overflow: hidden;
    position: relative;
}

.chat-container.sidebar-hidden {
    margin-left: 0;
    width: 100vw;
}

.chat-header {
    grid-area: header;
    padding: 20px 20px 20px 70px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.chat-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-primary);
    text-shadow: 0 2px 10px rgba(212, 175, 55, 0.2);
}

.download-btn {
    background: #d4af37;
    color: #1a1b23;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.download-btn:hover {
    background: #e6c547;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.download-btn:active {
    transform: translateY(0);
}

/* Header download button - positioned in top right corner */
.header-download-btn {
    position: absolute;
    top: 20px;
    right: 70px;
    /* Moved left to make room for docs button */
    background: rgba(212, 175, 55, 0.2);
    color: var(--accent-primary);
    border: 1px solid rgba(212, 175, 55, 0.3);
    padding: 8px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
}

.header-download-btn:hover {
    background: rgba(212, 175, 55, 0.3);
    border-color: rgba(212, 175, 55, 0.5);
    transform: translateY(-1px);
}

.header-download-btn:active {
    transform: translateY(0);
}

/* Google Docs export button */
.header-docs-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #4285f4;
    /* Google blue */
    color: white;
    border: 1px solid #3367d6;
    padding: 8px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
}

.header-docs-btn:hover {
    background: #3367d6;
    border-color: #2c5aa0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

.header-docs-btn:active {
    transform: translateY(0);
}

.header-docs-btn:disabled {
    background: #ccc;
    border-color: #999;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.header-docs-btn.loading {
    opacity: 0.6;
    cursor: wait;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}


.chat-messages {
    grid-area: messages;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Important for grid overflow */
}

.scroll-to-latest {
    position: absolute;
    right: 30px;
    bottom: 140px;
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    background: var(--accent-primary);
    color: var(--bg-main);
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1200;
}

.scroll-to-latest.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.scroll-to-latest:active {
    transform: scale(0.98);
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
}

.welcome-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.welcome-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.5;
}

.book-study-launch {
    margin-top: 40px;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    text-align: left;
}

.book-study-launch h3 {
    margin: 0;
    font-size: 22px;
}

.book-study-launch p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.book-study-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
    border-radius: 18px;
    padding: 16px 28px;
    min-width: 210px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    background: linear-gradient(120deg, #d4af37, #f2e49c);
    color: #1a1c2c;
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.25);
    text-decoration: none;
}

.book-study-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
}

@media (max-width: 640px) {
    .book-study-launch {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 18px;
    }

    .book-study-link {
        width: 100%;
        min-width: 0;
        font-size: 15px;
        padding: 14px 20px;
    }
}

.book-study-page {
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Allow body to scroll on book study page */
body.book-study-page {
    overflow: auto;
    height: auto;
}

.book-study-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px 30px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.book-control-panel {
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(10, 14, 28, 0.95);
    padding: 24px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.book-control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.control-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pill-group {
    display: inline-flex;
    gap: 10px;
}

.book-control-footer {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.book-control-status {
    font-size: 13px;
    color: var(--accent-primary);
    min-height: 18px;
}

.book-control-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.book-study-page-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    align-items: flex-end;
}

.book-study-page-header h1 {
    margin: 8px 0;
    font-size: 32px;
    font-family: 'Cinzel', serif;
}

.book-study-page-header p {
    margin: 0;
    color: var(--text-secondary);
}

.book-study-back {
    display: inline-block;
    margin-bottom: 4px;
    color: var(--accent-primary);
}

.book-study-header-copy h1 {
    margin: 8px 0;
    font-size: 32px;
    font-family: 'Cinzel', serif;
}

.book-study-header-copy p {
    margin: 0;
    color: var(--text-secondary);
}

.book-study-header-focus {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 240px;
}

.book-study-header-focus label {
    font-size: 13px;
    color: var(--text-secondary);
}

.book-study-focus {
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 12px 44px 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 15px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #d4af37 50%), linear-gradient(135deg, #d4af37 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
    background-size: 7px 7px, 7px 7px;
    background-repeat: no-repeat;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

.book-study-focus:focus {
    outline: none;
    border: 1px solid rgba(212, 175, 55, 0.9);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.book-study-focus option {
    background: #0c101c;
}

.book-study-workspace {
    display: grid;
    grid-template-columns: minmax(340px, 420px) 1fr;
    gap: 32px;
    align-items: start;
}

.study-steps {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.step-card {
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(12, 16, 32, 0.92);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
}

.step-heading span {
    font-size: 12px;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

.step-heading h3 {
    margin: 4px 0 0;
    font-size: 20px;
}

.step-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.button-group {
    display: inline-flex;
    gap: 8px;
}

.pill-button {
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    padding: 8px 16px;
    background: transparent;
    color: var(--text-primary);
    font-weight: 600;
}

.pill-button.active {
    background: var(--accent-primary);
    color: var(--bg-main);
}

.control-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.control-input {
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
    padding: 10px 12px;
    color: var(--text-primary);
}

.scope-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scope-radio {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.scope-radio input {
    margin-top: 6px;
}

.chapter-select-group {
    display: none;
    flex-direction: column;
    gap: 6px;
}

.chapter-select-group.active {
    display: flex;
}

.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.option-checkbox {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    background: rgba(255, 255, 255, 0.01);
}

.book-follow-ups {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.book-follow-up-btn {
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
}

.step-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

.book-info-card,
.book-study-output-card,
.book-study-chat-card {
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.65);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.book-study-output-card {
    background: radial-gradient(circle at top, rgba(255, 255, 255, 0.08), rgba(15, 23, 42, 0.7));
}

.book-info-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.book-chapter-select {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.book-chapter-select label {
    font-size: 13px;
    color: var(--text-secondary);
}

.book-chapter-select select {
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background: var(--bg-input);
    color: var(--text-primary);
    padding: 8px 10px;
}

.book-study-start {
    border: none;
    border-radius: 14px;
    padding: 12px 24px;
    font-weight: 600;
    background: linear-gradient(120deg, #d4af37, #f3e49c);
    color: #1a1c2c;
    cursor: pointer;
}

.book-study-start:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.book-study-secondary {
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    padding: 10px 16px;
    font-weight: 500;
}

.book-study-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.study-thread-shell {
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(12, 16, 32, 0.92);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

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

.book-study-thread {
    max-height: 540px;
    overflow-y: auto;
    padding-right: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

@media (max-width: 768px) {
    .book-study-thread {
        max-height: clamp(260px, 60vh, 540px);
    }
}

.study-message {
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(20, 26, 40, 0.95);
    line-height: 1.6;
}

.study-message.skeleton {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(148, 163, 184, 0.18);
}

.skeleton-line {
    height: 12px;
    width: 100%;
    border-radius: 999px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.15);
}

.skeleton-line:last-child {
    margin-bottom: 0;
}

.skeleton-line::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: translateX(-100%);
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.skeleton-line.skeleton-title {
    height: 18px;
    width: 70%;
    margin-bottom: 16px;
}

.skeleton-line.skeleton-medium {
    width: 80%;
}

.skeleton-line.skeleton-short {
    width: 45%;
}

.skeleton-chat .skeleton-line.skeleton-title {
    width: 55%;
}

@keyframes skeleton-shimmer {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(100%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton-line::after {
        animation: none;
    }
}

.study-message.user {
    align-self: flex-end;
    background: rgba(212, 175, 55, 0.15);
}

.study-message.system {
    background: rgba(148, 163, 184, 0.15);
}

.follow-up-bar {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.follow-up-btn {
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
}

.follow-up-btn.selected {
    background: var(--accent-primary);
    color: var(--bg-main);
}

.book-study-chat-card {
    gap: 14px;
    background: rgba(12, 18, 32, 0.9);
}

.book-study-chat-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.book-study-chat-header h4 {
    margin: 0;
}

.book-study-chat-header p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.book-chat-tag {
    border-radius: 999px;
    padding: 6px 14px;
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-primary);
    font-size: 12px;
}

.book-study-chat-input {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.book-study-chat-input textarea {
    flex: 1;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: var(--bg-input);
    color: var(--text-primary);
    padding: 10px 12px;
}

.book-study-chat-input button {
    border-radius: 12px;
    border: none;
    background: var(--accent-primary);
    color: var(--bg-main);
    font-weight: 600;
    padding: 10px 16px;
}

.study-export-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
    z-index: 5000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.study-export-modal.open {
    opacity: 1;
    pointer-events: auto;
}

.study-export-shell {
    width: min(960px, 100%);
    height: min(90vh, 720px);
    background: #0e1424;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 40px 90px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.study-export-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 12px;
}

.study-export-title {
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
    font-weight: 600;
}

.study-export-title small {
    color: var(--text-secondary);
    font-weight: normal;
}

.study-export-actions {
    display: flex;
    gap: 10px;
}

.study-export-actions button#study-export-download {
    background: linear-gradient(120deg, #6a82fb, #fc5c7d);
    color: #fff;
}

.study-export-actions button {
    border-radius: 10px;
    border: none;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    background: var(--accent-primary);
    color: var(--bg-main);
}

.study-export-actions button.ghost {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.study-export-shell iframe {
    flex: 1;
    border: none;
    width: 100%;
    background: #fff;
}

@media (max-width: 720px) {
    .study-export-modal {
        padding: 12px;
    }
    .study-export-shell {
        height: 90vh;
    }
    .study-export-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .study-export-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

.study-library-shell {
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(10, 14, 28, 0.9);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.library-header h4 {
    margin: 0;
}

.library-header p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.library-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.library-entry {
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(20, 26, 40, 0.9);
}

.export-history {
    margin-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 16px;
}

.export-history h5 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

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

.export-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(30, 36, 52, 0.85);
    font-size: 13px;
}

.export-history-item button {
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
}

.library-entry h5 {
    margin: 0;
    font-size: 16px;
}

.library-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.library-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.library-actions button {
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
}

.library-actions button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.library-empty {
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.book-resources {
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(10, 14, 28, 0.9);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.resources-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.resources-header h4 {
    margin: 0;
}

.resources-header p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.resources-status {
    font-size: 13px;
    color: var(--text-secondary);
}

.resources-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.resource-card {
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 14px 16px;
    background: rgba(20, 26, 40, 0.95);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.resource-card div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.resource-card button {
    border-radius: 10px;
    border: none;
    padding: 8px 16px;
    background: var(--accent-primary);
    color: var(--bg-main);
    font-weight: 600;
    cursor: pointer;
}

.resource-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 15px;
    z-index: 6000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.resource-modal.open {
    opacity: 1;
    pointer-events: auto;
}

.resource-shell {
    width: min(95vw, 5000px);
    height: min(90vh, 3000px);
    background: #0e1424;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.resource-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    background: #0e1424;
}

.resource-toolbar button {
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    cursor: pointer;
}

.resource-iframe {
    flex: 1;
    border: none;
    width: 100%;
    height: 100%;
    min-height: 0;
    background: black;
}

/* Mobile adjustments for resource modal */
@media (max-width: 768px) {
    .resource-modal {
        padding: 5px;
    }

    .resource-shell {
        width: 100%;
        height: 90vh;
        border-radius: 12px;
    }
}
.daily-devotional {
    margin: clamp(16px, 4vw, 28px) auto;
    width: min(720px, 100%);
    padding: 0 clamp(12px, 4vw, 20px);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.devotional-verse {
    font-style: italic;
    margin-bottom: 8px;
}

.devotional-reference {
    font-weight: 600;
    text-align: right;
    margin-bottom: 12px;
}

.devotional-thought {
    font-size: 14px;
    line-height: 1.6;
}

.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.refresh-starters-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.refresh-starters-btn:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

.refresh-starters-btn:active {
    transform: translateY(0);
}

.suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
    transition: opacity 0.3s ease;
}

.theme-carousel {
    position: relative;
    max-width: 800px;
    margin: 32px auto 0 auto;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    background: var(--bg-input);
    padding: 24px 24px 40px 24px;
    overflow: hidden;
}

.theme-carousel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.theme-carousel-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-carousel-header > div {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-carousel-count {
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    min-width: 50px;
    text-align: right;
}

.theme-refresh-btn {
    background: none;
    border: 1px solid var(--accent-primary);
    border-radius: 20px;
    color: var(--accent-primary);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.theme-refresh-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.theme-refresh-btn.loading {
    opacity: 0.7;
    cursor: wait;
}

.theme-card {
    opacity: 0;
    transform: translateX(16px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-card.active {
    opacity: 1;
    transform: translateX(0);
}

.theme-card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-card-summary {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 14px;
    margin-bottom: 16px;
}

.theme-card-verses {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
    text-align: left;
}

.theme-card-verses li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-primary);
}

.theme-card-verses li span {
    color: var(--accent-primary);
    font-weight: 600;
}

.theme-card-prompts {
    font-size: 13px;
    line-height: 1.6;
    text-align: left;
    color: var(--text-primary);
}

.theme-card-prompts ul {
    margin: 8px 0 0 0;
    padding-left: 18px;
}

.theme-card-prompts li {
    margin-bottom: 6px;
}

.theme-card-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

.theme-card-btn {
    background: var(--accent-primary);
    color: var(--bg-main);
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.theme-card-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.theme-card-btn:active {
    transform: translateY(0);
}

.theme-nav {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    transform: translateY(-50%);
    pointer-events: none;
}

.theme-nav button {
    pointer-events: auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    background: rgba(15, 20, 25, 0.85);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.theme-nav button:hover {
    border-color: var(--accent-primary);
    background: rgba(212, 175, 55, 0.15);
}

.theme-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    position: absolute;
    bottom: 16px;
    left: 0;
    width: 100%;
}

.theme-dots button {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: var(--border-light);
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.theme-dots button.active {
    background: var(--accent-primary);
    transform: scale(1.2);
}

@media (max-width: 680px) {
    .theme-carousel {
        padding: 18px 18px 50px 18px;
    }
    .theme-carousel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .theme-carousel-header > div {
        width: 100%;
        justify-content: space-between;
    }
    .theme-carousel-count {
        font-size: 13px;
        min-width: auto;
    }
    .theme-refresh-btn {
        width: 100%;
        justify-content: center;
    }
    .theme-card-title {
        font-size: 18px;
    }
    .theme-card-summary {
        font-size: 13px;
    }
    .theme-card-verses li,
    .theme-card-prompts {
        font-size: 12.5px;
    }
    .theme-card-actions {
        flex-direction: column;
        gap: 10px;
    }
    .theme-card-btn {
        width: 100%;
        justify-content: center;
    }
    .theme-nav {
        position: static;
        margin: 16px 0 0;
        transform: none;
    }
    .theme-dots {
        position: static;
        margin-top: 12px;
    }
}

.suggestions.refreshing {
    opacity: 0.6;
}

.suggestion-item {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.suggestion-item:hover {
    background: var(--bg-button);
    border-color: var(--accent-primary);
}

.message {
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--bg-main);
    font-size: 14px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--bg-button);
    color: var(--text-primary);
}

.message-content {
    flex: 1;
    max-width: 70%;
}

.message.user .message-content {
    background: var(--bg-message-user);
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
}

.message.ai .message-content {
    background: var(--bg-message-ai);
    padding: 12px 0;
}

.message.skeleton .message-content {
    background: rgba(15, 23, 42, 0.85);
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}

.message.skeleton {
    pointer-events: none;
}

.response-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 16px 0;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(15, 23, 42, 0.6);
    -webkit-overflow-scrolling: touch;
}

.response-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
    font-size: 0.95rem;
}

.response-table th,
.response-table td {
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    text-align: left;
    vertical-align: top;
}

.response-table th {
    background: rgba(212, 175, 55, 0.15);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.response-table tbody tr:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.response-table td:first-child {
    font-weight: 600;
}

@media (max-width: 640px) {
    .response-table {
        min-width: 100%;
        font-size: 0.85rem;
    }
}

.message.study-placeholder .message-content {
    font-style: italic;
    color: var(--text-secondary);
}

.message.study-card .message-content {
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 18px;
    padding: 18px 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.message.study-card .message-content .section-header,
.message.study-card .message-content .major-header,
.message.study-card .message-content .main-header {
    margin-bottom: 10px;
}

.message.study-card .message-content ul {
    margin: 8px 0 0 0;
    padding-left: 18px;
}

.message-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.message-btn {
    background: var(--bg-button);
    border: none;
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.message-btn:hover {
    background: var(--bg-button-hover);
}

/* Chat Input */
.chat-input-container {
    grid-area: input;
    padding: 20px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-main);
    position: relative;
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    max-width: 1000px;
    margin: 0 auto;
}

.suggestion-status {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin: 10px auto 0;
    max-width: 1000px;
    flex-wrap: wrap;
}

.suggestion-chip {
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(70, 130, 180, 0.15);
    color: var(--accent-primary);
    transition: background 0.2s ease, color 0.2s ease;
}

.suggestion-chip.secondary {
    background: var(--bg-button);
    color: var(--text-primary);
}

.suggestion-chip:hover {
    background: rgba(70, 130, 180, 0.25);
}

.suggestion-chip.secondary:hover {
    background: var(--bg-button-hover);
}

.suggestion-chip.off {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-secondary);
}

.suggestion-status.off .suggestion-chip.secondary {
    opacity: 0.7;
}

.suggestion-menu {
    position: absolute;
    right: 30px;
    bottom: 110px;
    width: 280px;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    z-index: 1500;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.suggestion-menu[aria-hidden="false"] {
    display: flex;
}

.suggestion-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--border-light);
}

.suggestion-menu-title {
    font-weight: 600;
    color: var(--text-primary);
}

.suggestion-menu-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.suggestion-menu-close {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

.suggestion-menu-body {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}

.suggestion-menu-item {
    border: none;
    background: transparent;
    text-align: left;
    padding: 12px 18px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.suggestion-menu-item:hover,
.suggestion-menu-item.active {
    background: rgba(70, 130, 180, 0.12);
}

.suggestion-menu-item.active .item-title {
    color: var(--accent-primary);
}

.suggestion-menu-item .item-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-primary);
}

.suggestion-menu-item .item-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.suggestion-menu-item .item-check {
    font-size: 12px;
    color: var(--accent-primary);
    opacity: 0;
}

.suggestion-menu-item.active .item-check {
    opacity: 1;
}

.suggestion-menu-footer {
    border-top: 1px solid var(--border-light);
    padding: 10px 16px;
    background: var(--bg-light);
}

.suggestion-menu-link {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--accent-primary);
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.suggestion-menu-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    display: none;
    z-index: 1400;
}

.suggestion-menu-backdrop.active {
    display: block;
}

.message-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    min-height: 44px;
    max-height: 200px;
    transition: height 0.1s ease;
    overflow-y: hidden;
}

.message-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.send-btn {
    background: var(--accent-primary);
    border: none;
    color: var(--bg-main);
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Profile Modal */
.profile-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.profile-modal.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 480px;
    transform: scale(0.95);
    transition: transform 0.3s;
}

.profile-modal.open .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-note {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

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

.toggle-labels {
    flex: 1;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-light);
    border-radius: 999px;
    transition: background 0.2s ease;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--bg-main);
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn.secondary {
    background: var(--bg-button);
    color: var(--text-primary);
}

.modal-btn.secondary:hover {
    background: var(--bg-button-hover);
}

.modal-btn.primary {
    background: var(--accent-primary);
    color: var(--bg-main);
}

.modal-btn.primary:hover {
    background: var(--accent-hover);
}

/* Bible Verse Styling */
.verse-link {
    color: var(--accent-primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
    transition: color 0.2s ease;
    background: rgba(212, 175, 55, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
}

.verse-link:hover {
    color: var(--accent-hover);
    background: rgba(212, 175, 55, 0.2);
}

#verse-content {
    padding: 20px 0;
}

/* Verse Modal Specific Sizing */
#verse-modal .modal-content {
    max-width: 90vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    margin: 2.5vh auto;
}

#verse-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    /* Important for flex overflow */
    -webkit-overflow-scrolling: touch;
    /* iOS momentum scrolling */
    overscroll-behavior: contain;
    /* Prevent scroll chaining */
    touch-action: pan-y;
}

.verse-text {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.verse-reference {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 14px;
}

.verse-controls {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.verse-btn {
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.verse-btn:hover {
    background: var(--accent-primary);
    color: var(--bg-main);
    border-color: var(--accent-primary);
}

.audio-btn {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.audio-btn:hover {
    background: #218838;
    border-color: #218838;
}

.audio-btn.playing {
    background: #dc3545;
    border-color: #dc3545;
}

.verse-context {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 8px;
    border-left: 4px solid var(--accent-primary);
}

.verse-context h4 {
    margin: 0 0 10px 0;
    color: var(--accent-primary);
    font-size: 16px;
}

.context-text {
    line-height: 1.6;
    color: var(--text-primary);
}

.original-verse {
    background: rgba(212, 175, 55, 0.15);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid var(--accent-primary);
    margin: 5px 0;
}

.related-verses {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 8px;
    border-left: 4px solid #28a745;
}

.related-verses h4 {
    margin: 0 0 10px 0;
    color: #28a745;
    font-size: 16px;
}

.related-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.related-item:hover {
    background: rgba(40, 167, 69, 0.1);
    border-radius: 4px;
}

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

.related-ref {
    font-weight: 600;
    color: #28a745;
    margin-bottom: 4px;
}

.related-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Study Tools Styling */
.study-tools {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 8px;
    border-left: 4px solid #6f42c1;
}

.study-tools h4 {
    margin: 0 0 15px 0;
    color: #6f42c1;
    font-size: 16px;
}

.study-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.study-tab {
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.study-tab:hover {
    background: #6f42c1;
    color: white;
    border-color: #6f42c1;
}

.study-tab.active {
    background: #6f42c1;
    color: white;
    border-color: #6f42c1;
}

.study-content {
    min-height: 200px;
    max-height: var(--dynamic-height, 50vh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
}

/* Dynamic height adjustment when multiple sections are open */
.verse-context.expanded+.study-tools .study-content,
.study-tools.expanded+.verse-context {
    max-height: 35vh;
}

/* Translation Comparison */
.translation-item {
    margin-bottom: 15px;
    padding: 12px;
    background: var(--bg-main);
    border-radius: 6px;
    border-left: 3px solid var(--accent-primary);
}

.translation-version {
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 6px;
    font-size: 14px;
}

.translation-text {
    line-height: 1.5;
    color: var(--text-primary);
}

/* Original Words */
.original-word {
    background: rgba(111, 66, 193, 0.1);
    color: #6f42c1;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.original-word:hover {
    background: rgba(111, 66, 193, 0.2);
    transform: translateY(-1px);
}

.word-study-item {
    padding: 12px;
    margin-bottom: 10px;
    background: var(--bg-main);
    border-radius: 6px;
    border-left: 3px solid #6f42c1;
}

.word-english {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.word-original {
    font-size: 18px;
    color: #6f42c1;
    margin-bottom: 4px;
}

.word-definition {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.strongs-number {
    font-size: 11px;
    background: #6f42c1;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
}

/* Study Enhancement Additional Styles */
.translation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.translation-style {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-light);
    padding: 2px 6px;
    border-radius: 3px;
}

.original-words-study .highlighted-verse {
    background: var(--bg-light);
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    line-height: 1.6;
}

.study-instructions {
    margin: 15px 0;
    padding: 10px;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 6px;
    font-size: 13px;
}

.word-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-light);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.word-item:hover {
    background: rgba(111, 66, 193, 0.1);
    transform: translateX(4px);
}

.word-strongs {
    font-size: 11px;
    background: #6f42c1;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
}

.commentary-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--bg-light);
    border-top: 2px solid #6f42c1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.commentary-content {
    line-height: 1.6;
}

.commentary-reference {
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.commentary-text {
    white-space: pre-line;
}

.commentary-error {
    color: #dc3545;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

/* Auto-complete dropdown */
.verse-autocomplete {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 9999;
    margin-bottom: 5px;
}

.autocomplete-header {
    padding: 12px 16px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-primary);
}

.autocomplete-results {
    max-height: 240px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.2s ease;
}

.autocomplete-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.autocomplete-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(212, 175, 55, 0.15);
    color: var(--accent-primary);
}

.autocomplete-badge.curated,
.autocomplete-badge.default {
    background: rgba(212, 175, 55, 0.15);
    color: var(--accent-primary);
}

.autocomplete-badge.favorite {
    background: rgba(68, 148, 74, 0.15);
    color: #2f7a3b;
}

.autocomplete-badge.recent {
    background: rgba(70, 130, 180, 0.15);
    color: #2f5d85;
}

.autocomplete-badge.topic {
    background: rgba(128, 90, 213, 0.15);
    color: #6a3fb3;
}

.autocomplete-badge.ai {
    background: rgba(100, 116, 139, 0.2);
    color: #475569;
}

.autocomplete-badge.starter {
    background: rgba(15, 118, 110, 0.15);
    color: #0f766e;
}

.autocomplete-item:hover {
    background: var(--bg-light);
}

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

.autocomplete-item .verse-reference {
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.verse-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* === iOS-specific modal layout (works with detectIOSDevice) === */
body.ios-device #verse-modal .modal-content {
    display: flex !important;
    flex-direction: column !important;
    height: 95dvh !important;
    /* dynamic viewport accounts for iOS chrome */
    max-height: 95dvh !important;
    width: 90vw !important;
    margin: 2.5vh auto !important;
    overflow: hidden !important;
    transform: none !important;
    /* avoid iOS scrolling bugs with transforms */
}

body.ios-device #verse-modal .modal-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 0 !important;
    touch-action: auto !important;
    /* critical: not 'manipulation' */
}

/* === Mobile verse modal (iOS + Android) unified === */
@media (max-width: 768px) {
    #verse-modal .modal-content {
        /* full-viewport modal with 3 rows (header / body / actions) */
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100dvh;
        /* use dynamic viewport on iOS */
        margin: 0;
        border-radius: 0;
        display: grid !important;
        grid-template-rows: auto 1fr auto !important;
        overflow: hidden;
        /* contain the scroller inside the body */
    }

    #verse-modal .modal-header,
    #verse-modal .modal-actions {
        background: var(--bg-sidebar) !important;
        border-color: var(--border-light) !important;
        padding: 15px 20px !important;
        flex-shrink: 0;
    }

    #verse-modal .modal-body {
        /* the ONLY scroll container */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        min-height: 0 !important;
        /* critical in grid/flex for overflow */
        padding: 20px !important;

        /* REMOVE touch-action; it breaks iOS scrolling in nested contexts */
        touch-action: auto !important;
        transform: translateZ(0) !important;
        /* OK for momentum */
        will-change: scroll-position !important;
        background: var(--bg-sidebar) !important;
    }

    /* Ensure ONLY .modal-body scrolls - kill any other scroll containers */
    #verse-modal #verse-content {
        height: auto !important;
        overflow: visible !important;
        touch-action: auto !important;
        -webkit-transform: none !important;
        transform: none !important;
    }

    #verse-modal .study-content,
    #verse-modal .verse-context,
    #verse-modal .related-verses {
        overflow: visible !important;
        /* body provides the scroll */
        touch-action: auto !important;
    }

    /* Mobile chat management - always show buttons */
    .chat-actions {
        opacity: 1 !important;
        position: relative !important;
    }

    .chat-item {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 12px 16px !important;
    }

    .chat-title {
        flex: 1 !important;
        margin-right: 10px !important;
        cursor: pointer !important;
    }

    .chat-btn {
        opacity: 1 !important;
        visibility: visible !important;
        margin-left: 5px !important;
        padding: 6px 8px !important;
        font-size: 12px !important;
        min-width: 32px !important;
    }

    .verse-controls {
        justify-content: center;
    }

    .verse-btn {
        flex: 1;
        justify-content: center;
        min-width: 120px;
    }


    /* Reduce button sizes on mobile */
    .verse-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Better spacing for mobile */
    .verse-controls {
        gap: 8px;
        flex-wrap: wrap;
    }

    .verse-autocomplete {
        max-height: 250px;
        top: auto;
        bottom: 100%;
        border-radius: 8px 8px 0 0;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
        margin-top: 0;
        margin-bottom: 5px;
    }
}

/* Avatar Grid */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 20px 0;
}

.avatar-option {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid var(--border-light);
    transition: all 0.2s;
    color: var(--bg-main);
}

.avatar-option:hover {
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: #00d4ff;
    /* Bright cyan blue - contrasts with all avatar colors */
    box-shadow: 0 0 0 3px #00d4ff;
    /* Slightly thicker for better visibility */
}

/* Enhanced form styling */
select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0aec0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Enhanced chat messages with better spacing */
.message {
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Enhanced suggestions with better hover effects */
.suggestion-item {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.suggestion-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.1), transparent);
    transition: left 0.5s;
}

.suggestion-item:hover::before {
    left: 100%;
}

.suggestion-item:hover {
    background: var(--bg-button);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}

/* Enhanced sidebar with better visual hierarchy */
.chat-item {
    padding: 16px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.chat-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-primary);
    border-radius: 0 3px 3px 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-light);
    transform: translateX(4px);
}

.chat-item:hover::before {
    opacity: 1;
}

.chat-item.active {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Verse of the Day Card */
.votd-card {
    background: radial-gradient(circle at top left, rgba(255, 220, 130, 0.25), transparent 55%),
        linear-gradient(135deg, rgba(17, 28, 53, 0.95), rgba(32, 24, 10, 0.92));
    border: 1px solid rgba(255, 208, 122, 0.25);
    border-radius: 18px;
    padding: clamp(18px, 3vw, 28px);
    margin: 0;
    position: relative;
    overflow: hidden;
    box-shadow: 0 14px 30px rgba(6, 8, 20, 0.4);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.votd-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(120deg, rgba(212, 175, 55, 0.6), rgba(255, 255, 255, 0.05));
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
}

.votd-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 22px 40px rgba(6, 8, 20, 0.55);
    border-color: rgba(255, 220, 130, 0.4);
}

.votd-card::after {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 220, 130, 0.35), transparent 65%);
    filter: blur(8px);
}

.votd-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Cinzel', serif;
    font-size: clamp(0.8rem, 1.7vw, 0.95rem);
    color: #1a1c2c;
    margin-bottom: 14px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    background: rgba(255, 208, 122, 0.9);
    padding: 6px 16px;
    border-radius: 999px;
    box-shadow: 0 8px 22px rgba(10, 10, 10, 0.35);
    font-weight: 700;
}

.votd-label::before {
    content: '✨';
    font-size: 1rem;
}

.votd-text {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.1rem, 2.5vw, 1.55rem);
    line-height: 1.65;
    color: #fffdf5;
    margin-bottom: 16px;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
    font-weight: 600;
}

.votd-reference {
    font-family: var(--font-body);
    color: rgba(255, 255, 255, 0.85);
    font-size: clamp(0.85rem, 1.6vw, 1rem);
    margin-bottom: 18px;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    letter-spacing: 0.5px;
}

.votd-reference::before {
    content: '—';
    opacity: 0.6;
}

.votd-thought {
    font-family: var(--font-body);
    color: rgba(255, 255, 255, 0.92);
    font-size: clamp(0.9rem, 1.6vw, 1rem);
    line-height: 1.6;
    margin-bottom: 20px;
    font-style: italic;
}

.votd-action {
    background: linear-gradient(120deg, rgba(255, 220, 130, 0.95), rgba(240, 182, 96, 0.95));
    border: none;
    color: #1f1a0f;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    letter-spacing: 0.2px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.votd-action::after {
    content: '→';
    font-size: 1rem;
}

.votd-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

@media (max-width: 768px) {
    .votd-card {
        padding: 18px;
    }
    .votd-action {
        width: 100%;
        justify-content: center;
    }
}

/* Quick Study Chips */
.study-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.study-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.study-chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(212, 175, 55, 0.3);
    transform: translateY(-1px);
}

.study-chip i {
    font-size: 1rem;
    opacity: 0.8;
}

/* Enhanced buttons with better feedback */
.new-chat-btn {
    width: 100%;
    background: var(--accent-gradient);
    color: #1a1b23;
    border: none;
    border-radius: 12px;
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2);
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.3);
    filter: brightness(1.1);
}

/* Enhanced hamburger menu */
.hamburger-menu {
    position: fixed;
    top: 20px;
    left: 300px;
    /* Back to original position - right side of sidebar */
    z-index: 1000;
    background: rgba(74, 85, 104, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.hamburger-menu:hover {
    background: rgba(90, 101, 120, 0.9);
    transform: scale(1.05);
}

.hamburger-menu.sidebar-hidden {
    left: 20px;
    /* Move to left when sidebar is hidden */
}

/* Enhanced profile section */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 16px;
    border-radius: 12px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-light);
}

/* Loading state */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.typing-indicator {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 0;
    width: 100%;
}

.typing-indicator .typing-label {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    :root {
        --mobile-header-height: 56px;
        --mobile-padding: 12px;
    }

    body {
        /* Disable overscroll on mobile */
        overscroll-behavior: none;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1001;
        position: fixed;
        height: var(--viewport-height);
        width: min(280px, 80vw);
        top: 0;
        left: 0;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .chat-container {
        margin-left: 0;
        width: 100vw;
        grid-template-rows: var(--mobile-header-height) 1fr auto env(keyboard-inset-height, 0px);
    }

    .app-container {
        grid-template-columns: 1fr;
        position: relative;
    }

    .chat-messages {
        /* Improved mobile scrolling */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: var(--mobile-padding);
    }

    .chat-header {
        padding: var(--mobile-padding);
        min-height: var(--mobile-header-height);
        justify-content: center;
        padding-left: 60px;
        /* Account for hamburger menu */
        padding-right: 60px;
        /* Account for download button */
    }

    .chat-title {
        font-size: 16px;
        text-align: center;
    }

    .header-download-btn {
        top: 12px;
        right: 60px;
        /* Moved left for docs button */
        min-width: 32px;
        height: 32px;
        padding: 6px;
        font-size: 14px;
    }

    .header-docs-btn {
        top: 12px;
        right: 12px;
        min-width: 32px;
        height: 32px;
        padding: 6px;
        font-size: 14px;
    }

    .hamburger-menu {
        left: 20px;
        top: 12px;
        padding: 8px;
    }

    .hamburger-menu.sidebar-hidden {
        left: 20px;
    }

    .chat-messages {
        padding: var(--mobile-padding);
        /* Ensure messages don't go behind notch on iOS */
        padding-top: max(var(--mobile-padding), env(safe-area-inset-top));
    }

    .chat-input-container {
        padding: var(--mobile-padding);
        /* Ensure input area is above home indicator on iOS */
        padding-bottom: max(var(--mobile-padding), env(safe-area-inset-bottom));
    }

    .message-input {
        font-size: var(--mobile-font-size);
        /* Prevents zoom on iOS */
        min-height: var(--mobile-touch-target);
        max-height: 150px;
        /* Smaller max height on mobile */
        line-height: 1.4;
        padding: 12px 16px;
    }

    .send-btn {
        min-height: var(--mobile-touch-target);
        min-width: var(--mobile-touch-target);
        padding: 0 16px;
        font-size: 14px;
    }

    .suggestions {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .suggestion-item {
        padding: 16px;
        font-size: 14px;
        min-height: var(--mobile-touch-target);
    }

    .message {
        margin-bottom: 16px;
    }

    .message-content {
        max-width: 85%;
        font-size: 15px;
        line-height: 1.5;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .welcome-message {
        padding: 20px var(--mobile-padding);
    }

    .welcome-title {
        font-size: 24px;
        margin-bottom: 12px;
    }

    .welcome-subtitle {
        font-size: 16px;
        line-height: 1.5;
    }

    /* Profile menu adjustments */
    .profile-menu {
        bottom: calc(60px + env(safe-area-inset-bottom));
        left: var(--mobile-padding);
        right: var(--mobile-padding);
        width: auto;
    }

    .profile-menu-item {
        padding: 16px;
        min-height: var(--mobile-touch-target);
    }

    /* Modal adjustments */
    .modal-content {
        margin: var(--mobile-padding);
        width: calc(100vw - 2 * var(--mobile-padding));
        max-height: calc(var(--viewport-height) - 2 * var(--mobile-padding));
    }

    .avatar-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .avatar-option {
        min-height: var(--mobile-touch-target);
        font-size: 20px;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-header {
        padding: 8px var(--mobile-padding);
        padding-left: 60px;
        /* Account for hamburger menu */
        padding-right: 60px;
        /* Account for download button */
        min-height: 48px;
        justify-content: center;
    }

    .header-download-btn {
        top: 8px;
        right: 56px;
        /* Moved left for docs button */
    }

    .header-docs-btn {
        top: 8px;
        right: 8px;
    }

    .hamburger-menu {
        top: 8px;
    }

    .welcome-message {
        padding: 16px var(--mobile-padding);
    }

    .suggestions {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .chat-input-wrapper {
        gap: 8px;
    }

    .message-input {
        font-size: var(--mobile-font-size);
        padding: 10px 12px;
    }

    .send-btn {
        padding: 0 12px;
        font-size: 12px;
    }

    .message-content {
        max-width: 90%;
        font-size: 14px;
    }
}

/* Modal Overlay Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-sidebar);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    border: 1px solid var(--border-light);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mobile-header-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s;
}

.mobile-header-btn:active {
    transform: scale(0.9);
}

.modal-title {
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.5px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-button-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-btn {
    display: block;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    text-align: center;
    text-decoration: none;
}

.modal-btn.primary {
    background: var(--accent-gradient);
    color: #1a1b23;
    border: none;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.modal-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
    filter: brightness(1.1);
}

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

.modal-btn.secondary:hover {
    background: var(--bg-button-hover);
    transform: translateY(-1px);
}

/* Profile Modal - similar to modal-overlay but using different class name */
.profile-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.profile-modal.open {
    display: flex;
}

/* Modal actions styling */
.modal-actions {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-light);
}

.modal-actions .modal-btn {
    flex: 1;
    margin: 0;
}

/* Prayer form iframe responsive styles */
#prayer-modal iframe {
    border-radius: 8px;
    min-height: 400px;
    max-height: 500px;
}

/* Ensure modal actions are visible */
#prayer-modal .modal-actions {
    margin-top: 0;
    padding: 15px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 12px 12px;
}

/* Mobile styles for prayer form */
@media (max-width: 768px) {
    #prayer-modal .modal-content {
        width: calc(100vw - 20px);
        max-width: none;
        margin: 10px;
        padding: 16px;
    }

    #prayer-modal iframe {
        height: 60vh;
        min-height: 350px;
        max-height: 450px;
    }
}

/* Feedback form iframe responsive styles */
#feedback-modal iframe {
    border-radius: 8px;
    min-height: 400px;
    max-height: 500px;
}

/* Ensure modal actions are visible */
#feedback-modal .modal-actions {
    margin-top: 0;
    padding: 15px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 12px 12px;
}

/* Mobile styles for feedback form */
@media (max-width: 768px) {
    #feedback-modal .modal-content {
        width: calc(100vw - 20px);
        max-width: none;
        margin: 10px;
        padding: 16px;
    }

    #feedback-modal iframe {
        height: 60vh;
        min-height: 350px;
        max-height: 450px;
    }
}

/* iOS Scroll Fix */
body.verse-modal-open {
    overflow: hidden;
    width: 100%;
}

@media (min-width: 769px) {
    body.verse-modal-open {
        position: fixed;
        height: 100%;
    }
}

/* Mobile Full Screen Modal Fix */
@media (max-width: 768px) {
    #verse-modal .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        margin: 0;
        border-radius: 0;
        border: none;
        display: flex;
        flex-direction: column;
    }

    #verse-modal .modal-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 40px;
        /* Extra padding for bottom safe area */
    }

    /* Force show on mobile */
    .mobile-header-btn {
        display: block !important;
    }

    /* Hide bottom actions on mobile to prevent overlap */
    #verse-modal .modal-actions {
        display: none !important;
    }

    .mobile-scroll-controls {
        display: flex !important;
        /* Force show on mobile */
        flex-direction: row;
        gap: 15px;
        position: fixed;
        bottom: 20px;
        left: 20px;
        z-index: 2000;
    }

    .mobile-scroll-btn {
        background: var(--accent-primary);
        color: white;
        border: none;
        border-radius: 30px;
        padding: 12px 20px;
        font-weight: bold;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        cursor: pointer;
        opacity: 0.9;
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 100px;
    }

    .mobile-scroll-btn:active {
        transform: scale(0.95);
        opacity: 1;
    }
}

/* Default hidden state for scroll controls */
.mobile-scroll-controls {
    display: none;
}

/* Default hidden state for scroll button */
.mobile-scroll-btn {
    display: none;
}
