/* ============================================================
   CSS VARIABLES - Scholarly Parchment Design
   ============================================================ */
:root {
    /* Core palette */
    --primary: #1a3c34;
    --primary-dark: #0d211c;
    --accent: #c5a059;
    --accent-muted: rgba(197, 160, 89, 0.6);
    --parchment: #f4f1ea;
    --parchment-dark: #ebe6db;
    --ink-dark: #1a1a1a;
    --ink-light: #4a4a4a;
    --ink-muted: #8a8578;
    --white: #ffffff;
    --red: #9b2c2c;
    --green-muted: #2d6a4f;

    /* Functional tokens */
    --bg-primary: var(--parchment);
    --bg-secondary: var(--parchment-dark);
    --bg-card: var(--white);
    --border: rgba(26, 60, 52, 0.1);
    --border-accent: rgba(197, 160, 89, 0.3);
    --text-primary: var(--ink-light);
    --text-heading: var(--primary);
    --text-muted: var(--ink-muted);

    /* Shadows */
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
}

/* ============================================================
   MATERIAL SYMBOLS
   ============================================================ */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ============================================================
   GLOBAL RESET & BASE
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Libre Baskerville', Georgia, serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

h1, h2, h3 {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--text-heading);
}

/* ============================================================
   CUSTOM SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--ink-muted);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--ink-light);
}

/* ============================================================
   FOCUS-VISIBLE
   ============================================================ */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

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

/* ============================================================
   CONTAINER
   ============================================================ */
.container {
    max-width: 100%;
    margin: 0 auto;
    background: var(--bg-primary);
    overflow-x: hidden;
}

/* ============================================================
   HEADER - Dark green gradient with gold accent
   ============================================================ */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 14px var(--space-lg) 12px;
    text-align: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    border-bottom: 3px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.new-chat-btn {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2;
    font-size: 13px;
    font-weight: 600;
    color: var(--white);
}

.new-chat-btn .material-symbols-outlined {
    font-size: 18px;
    color: var(--white);
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-50%) scale(1.02);
}

.new-chat-btn:active {
    transform: translateY(-50%) scale(0.98);
}

.user-area {
    position: absolute;
    right: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--white);
    font-size: 13px;
}

.user-display-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.9;
}

.sign-out-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 3px 6px;
    transition: background 0.2s;
}

.sign-out-btn .material-symbols-outlined {
    font-size: 16px;
}

.sign-out-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

.header-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-accent);
    margin-bottom: 8px;
}

.header-icon-badge .material-symbols-outlined {
    color: var(--accent);
    font-size: 22px;
}

header h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 18px;
    font-weight: 900;
    color: var(--white);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 2px;
    line-height: 1.2;
}

.tagline {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 9px;
    font-weight: 700;
    font-style: italic;
    color: var(--accent-muted);
    text-transform: uppercase;
    letter-spacing: 0.3em;
    margin-bottom: 0;
}

.header-rule {
    display: none;
}

/* ============================================================
   TAB NAVIGATION - Icon + label column style
   ============================================================ */
.tabs {
    background: rgba(244, 241, 234, 0.95);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: var(--space-md) var(--space-sm);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 95px;
    left: 0;
    right: 0;
    z-index: 50;
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: var(--space-sm) var(--space-md);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--ink-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast);
    user-select: none;
    -webkit-user-select: none;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn .tab-icon {
    font-size: 24px;
    transition: color var(--transition-fast);
}

.tab-btn .tab-label {
    font-size: 9px;
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active .tab-icon {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    display: block;
    width: 16px;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
    margin-top: 4px;
}

/* ============================================================
   TAB CONTENT
   ============================================================ */
.content {
    padding: 0;
    padding-top: 170px;
    min-height: 500px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
    min-height: calc(100vh - 280px);
}

.tab-content.active {
    display: block;
}

/* ============================================================
   CHAT INTERFACE
   ============================================================ */
.chat-study-layout {
    display: flex;
    gap: 0;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

.chat-study-layout .chat-container {
    flex: 1;
    min-width: 0;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 80vh;
    min-height: 600px;
    max-width: 840px;
    margin: 0 auto;
    padding: var(--space-lg);
}

/* ============================================================
   STUDY PANEL
   ============================================================ */

.study-panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    height: 100vh;
    border-left: 1px solid var(--border);
    background: var(--bg-primary);
    z-index: 400;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 20px rgba(0,0,0,0.12);
}

.study-panel.study-panel-open {
    transform: translateX(0);
}

/* Study panel is fixed overlay — no layout shift needed */

.study-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--primary);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    flex-shrink: 0;
}

.study-panel-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--white);
}

.study-panel-close {
    background: none;
    border: none;
    color: var(--accent-muted);
    font-size: 22px;
    cursor: pointer;
    padding: 0 var(--space-xs);
    line-height: 1;
    transition: color var(--transition-fast);
}

.study-panel-close:hover {
    color: var(--white);
}

.study-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    border: 1px solid var(--border);
    border-top: none;
}

/* Study panel verse cards */
.study-verse-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.study-verse-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    border-top: 2px solid var(--border-accent);
    border-right: 2px solid var(--border-accent);
    border-radius: 0 var(--radius-md) 0 0;
    pointer-events: none;
}

.study-verse-panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.study-verse-panel::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    border-top: 2px solid var(--border-accent);
    border-right: 2px solid var(--border-accent);
    border-radius: 0 var(--radius-md) 0 0;
    pointer-events: none;
}

.study-verse-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
}

.version-dropdown {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--ink);
    cursor: pointer;
    z-index: 1;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 22px;
}

.version-dropdown:hover {
    background-color: var(--bg-hover);
    border-color: var(--primary);
}

.study-verse-ref {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 18px;
    color: var(--primary);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
}

.study-verse-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    font-style: italic;
    margin-bottom: var(--space-sm);
}

.study-verse-num {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    margin-right: var(--space-xs);
    font-style: normal;
    vertical-align: super;
}

.compare-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: var(--space-sm);
    background: var(--bg-primary);
    border: 1px dashed var(--border-accent);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.compare-btn:hover {
    background: var(--parchment-dark);
    border-style: solid;
}

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

/* --- Comparison split view --- */
.compare-split-view {
    margin-bottom: var(--space-md);
}

.compare-panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
}

.compare-panel-top {
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.compare-panel-bottom {
    border-top: 2px dashed var(--accent);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    background: var(--parchment);
}

.compare-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
}

.compare-panel-label {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
}

.compare-panel-tag {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    border: 1px solid var(--accent-muted);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
}

.compare-panel-body .study-verse-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    font-style: italic;
    margin-bottom: var(--space-sm);
}

.diff-highlight {
    background: rgba(197, 160, 89, 0.25);
    border-bottom: 2px solid var(--accent);
    padding: 1px 3px;
    border-radius: 2px;
    font-style: italic;
}

.close-compare-btn {
    display: block;
    width: 100%;
    padding: 8px;
    margin-top: var(--space-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.close-compare-btn:hover {
    background: var(--parchment-dark);
    color: var(--text-primary);
}

/* --- Interlinear toggle button --- */
.interlinear-toggle {
    display: block;
    width: 100%;
    padding: 8px;
    margin-top: var(--space-sm);
    background: var(--bg-primary);
    border: 1px dashed var(--border-accent);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    letter-spacing: 0.05em;
}

.interlinear-toggle:hover {
    background: var(--parchment-dark);
    border-style: solid;
}

/* --- Interlinear word grid --- */
.interlinear-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-sm);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-card);
}

.interlinear-ref {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border);
}

.interlinear-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding: var(--space-sm) 0;
}

.interlinear-grid.rtl {
    direction: rtl;
}

/* Disputed word highlighting (NWT changed/added this word) */
.interlinear-word.disputed {
    background: rgba(180, 40, 40, 0.08);
    border-color: rgba(180, 40, 40, 0.45);
    outline: 2px solid rgba(180, 40, 40, 0.3);
    outline-offset: 1px;
}

.interlinear-word.disputed .interlinear-original {
    color: #b42828;
}

.interlinear-word.disputed .interlinear-strongs {
    color: #b42828;
    font-weight: 700;
}

/* JW context note banner shown above the interlinear */
.jw-interlinear-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    background: rgba(180, 40, 40, 0.07);
    border: 1px solid rgba(180, 40, 40, 0.3);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 12px;
    color: #8b1a1a;
    line-height: 1.5;
    margin-bottom: 6px;
    font-style: italic;
}

.interlinear-word {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 8px;
    background: var(--parchment-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 60px;
    max-width: 120px;
    transition: border-color var(--transition-fast);
}

.interlinear-word:hover {
    border-color: var(--accent);
}

.interlinear-strongs {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    color: var(--text-muted);
    margin-bottom: 2px;
    letter-spacing: 0.03em;
}

.interlinear-translit {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    color: var(--accent);
    margin-bottom: 3px;
    text-align: center;
    direction: ltr;
}

.interlinear-original {
    font-size: 20px;
    line-height: 1.3;
    color: var(--ink-dark);
    margin-bottom: 3px;
    text-align: center;
}

.interlinear-original.hebrew {
    font-family: 'Noto Serif Hebrew', 'SBL Hebrew', 'Times New Roman', serif;
    font-size: 22px;
}

.interlinear-original.greek {
    font-family: 'Times New Roman', 'Noto Serif', serif;
    font-size: 18px;
}

.interlinear-gloss {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 2px;
    direction: ltr;
}

.interlinear-morph {
    font-family: 'Inter', monospace;
    font-size: 8px;
    color: var(--text-muted);
    text-align: center;
    direction: ltr;
}

.interlinear-original.arabic {
    font-family: 'Noto Naskh Arabic', 'Traditional Arabic', serif;
    font-size: 18px;
    line-height: 1.6;
    direction: rtl;
}

.qiraat-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.qiraat-pill {
    padding: 3px 10px;
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-surface);
    color: var(--text-muted);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
}

.qiraat-pill:hover {
    background: var(--bg-hover);
}

.qiraat-pill.active {
    background: var(--ink);
    color: var(--cream);
    border-color: var(--ink);
}

.interlinear-loading {
    text-align: center;
    padding: var(--space-md);
    color: var(--text-muted);
    font-size: 12px;
}

.study-section-label {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-top: var(--space-md);
    margin-bottom: var(--space-sm);
}

.study-arabic-text {
    font-size: 22px;
    line-height: 2;
    direction: rtl;
    text-align: right;
    color: var(--ink-dark);
    margin-bottom: var(--space-sm);
    padding: var(--space-md);
    background: var(--parchment-dark);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.study-translation-card {
    padding: var(--space-sm) var(--space-md);
    border-left: 2px solid var(--accent);
    margin-bottom: var(--space-sm);
    background: rgba(197, 160, 89, 0.04);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.study-translation-name {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: var(--space-xs);
}

.study-translation-text {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-primary);
}

.qiraat-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: var(--space-md);
}

.qiraat-tab {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-muted);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 11px;
    font-weight: 400;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.qiraat-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--accent-muted);
}

.qiraat-tab.active {
    background: var(--primary);
    color: var(--accent);
    border-color: var(--primary);
}

.study-loading {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

.study-error {
    text-align: center;
    padding: var(--space-lg);
    color: var(--red);
    font-size: 14px;
}

/* ============================================================
   CHAT MESSAGES AREA
   ============================================================ */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    border: 1px solid var(--border);
}

/* Welcome Message - Document card style */
.welcome-message {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.5s ease;
}

.welcome-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 64px;
    height: 64px;
    border-top: 3px solid var(--border-accent);
    border-right: 3px solid var(--border-accent);
    border-radius: 0 var(--radius-md) 0 0;
    pointer-events: none;
}

.welcome-message h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0;
    padding-bottom: 0;
    text-align: center;
}

.welcome-message h2::after {
    content: '';
    display: block;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--accent), transparent);
    margin: var(--space-md) 0;
}

.welcome-intro {
    color: var(--ink-light);
    margin-bottom: var(--space-sm);
    font-size: 13px;
    font-style: italic;
    line-height: 1.6;
}

.welcome-list {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-md) 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: opacity 0.3s ease;
}

.welcome-list.welcome-list-fade {
    opacity: 0;
}

.welcome-list li {
    background: rgba(244, 241, 234, 0.3);
    border-left: 2px solid var(--accent);
    padding: 8px var(--space-md);
    font-size: 14px;
}

.welcome-list li span {
    color: var(--ink-dark);
    font-style: italic;
    line-height: 1.5;
}

/* Messages */
.message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    animation: slideIn 0.3s ease;
}

.message-wrapper.user {
    justify-content: flex-end;
}

.message-wrapper.assistant {
    justify-content: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--white);
    flex-shrink: 0;
}

.message-avatar.user-avatar {
    background: var(--primary);
    order: 2;
}

.message-avatar.ai-avatar {
    background: var(--accent);
    color: var(--primary-dark);
}

.message-bubble {
    max-width: 70%;
}

.message-role {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: var(--space-xs);
}

.message-role.user-role {
    text-align: right;
    color: rgba(26, 60, 52, 0.4);
}

.message-role.ai-role {
    color: var(--accent);
}

.message-content {
    padding: var(--space-md) var(--space-lg);
    font-size: 14px;
    line-height: 1.65;
}

.message-wrapper.user .message-content {
    background: var(--primary);
    color: var(--white);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
}

.message-wrapper.assistant .message-content {
    background: var(--white);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
    box-shadow: var(--shadow-card);
}

/* Markdown-rendered AI responses */
.message-content.markdown-body {
    white-space: normal;
}

.markdown-body h2 {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--primary);
    font-size: 1.15em;
    margin: 20px 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.markdown-body h2:first-child {
    margin-top: 5px;
}

/* Section icons — replace emojis with Material Symbols */
.section-icon {
    font-size: 20px;
    vertical-align: middle;
    margin-right: 4px;
}

.icon-pin {
    color: var(--primary);
}

.icon-warn {
    color: var(--accent);
}

.icon-target {
    color: var(--primary);
}

.icon-check {
    color: var(--green-muted);
    font-size: 16px;
}

.icon-book {
    color: var(--accent);
    font-size: 16px;
}

.icon-scroll {
    color: var(--accent);
    font-size: 16px;
}

.icon-church {
    color: var(--accent);
    font-size: 16px;
}

.icon-school {
    color: var(--primary);
    font-size: 16px;
}

.icon-cancel {
    color: var(--red, #c0392b);
    font-size: 16px;
}

.icon-x {
    color: var(--red, #c0392b);
    font-size: 16px;
}

.icon-dot {
    color: var(--red, #c0392b);
    font-size: 14px;
}

.markdown-body h3 {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--ink-dark);
    font-size: 1.05em;
    margin: 15px 0 8px 0;
}

.markdown-body p {
    margin: 8px 0;
}

.markdown-body ul, .markdown-body ol {
    margin: 8px 0;
    padding-left: 24px;
}

.markdown-body li {
    margin: 4px 0;
}

.markdown-body strong {
    color: var(--ink-dark);
}

.markdown-body blockquote {
    border-left: 2px solid var(--accent);
    padding: 8px 16px;
    margin: 10px 0;
    background: rgba(197, 160, 89, 0.05);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
    color: var(--ink-light);
}

.markdown-body hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--accent), transparent);
    margin: 16px 0;
}

.markdown-body code {
    background: var(--primary-dark);
    padding: 2px 6px;
    border-radius: 2px;
    font-size: 0.9em;
    color: var(--accent);
}

.markdown-body pre {
    background: var(--primary-dark);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 10px 0;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    color: var(--parchment);
}

/* Verse Links (clickable references in AI responses) */
.verse-link {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    cursor: pointer;
    font-weight: 700;
    transition: color var(--transition-fast), background var(--transition-fast);
    border-radius: 3px;
    padding: 0 2px;
}

.verse-link:hover {
    color: var(--primary);
    text-decoration-style: solid;
}

/* Active verse — the one currently loaded in the study panel */
.verse-link.verse-link-active {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--primary);
    text-decoration-style: solid;
}

/* Chat Input */
.chat-input-container {
    background: var(--white);
    border: 1px solid var(--border);
    padding: var(--space-sm);
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
}

.chat-input-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.input-icon {
    color: rgba(26, 60, 52, 0.3);
    padding: var(--space-sm);
    flex-shrink: 0;
}

#chatInput {
    flex: 1;
    border: none;
    background: transparent;
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 14px;
    color: var(--ink-dark);
    padding: var(--space-sm);
    resize: none;
    min-height: 40px;
    line-height: 1.5;
}

#chatInput::placeholder {
    color: var(--ink-muted);
    font-style: italic;
}

#chatInput:focus {
    outline: none;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: var(--accent);
    border: none;
    padding: var(--space-sm) var(--space-md);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: transparent;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--primary);
    color: var(--accent);
    border: none;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-sm);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--primary-dark);
}

.btn-secondary:active {
    transform: scale(0.97);
}

/* Loading Dots */
.loader {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.loader .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: dotBounce 1.4s infinite ease-in-out both;
}

.loader .dot:nth-child(1) { animation-delay: -0.32s; }
.loader .dot:nth-child(2) { animation-delay: -0.16s; }
.loader .dot:nth-child(3) { animation-delay: 0s; }

/* ============================================================
   SECTION CONTAINER (shared by Topics, Objections, Verses)
   ============================================================ */
.section-container {
    max-width: 840px;
    margin: 0 auto;
    padding: var(--space-lg);
}

.section-heading {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
}

/* ============================================================
   TOPICS & OBJECTIONS CARDS - Document card style
   ============================================================ */
.topic-card, .objection-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition-base), transform var(--transition-base), border-color var(--transition-base);
}

.topic-card:hover, .objection-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--border-accent);
}

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

.topic-card-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.topic-emoji {
    font-size: 24px;
}

.topic-title {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-dark);
}

.topic-card h3 {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-dark);
    margin-bottom: 0;
}

.topic-card p {
    color: var(--text-primary);
    font-size: 14px;
    margin: var(--space-sm) 0;
}

.objection-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-sm);
}

.objection-card-header h3 {
    flex: 1;
}

.objection-card h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-dark);
    margin-bottom: var(--space-md);
    line-height: 1.5;
}

.objection-summary {
    color: var(--text-muted);
    margin: var(--space-sm) 0 var(--space-md) 0;
    font-style: italic;
    font-size: 14px;
}

/* Badges */
.badge {
    display: inline-block;
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 2px;
    white-space: nowrap;
    margin-right: var(--space-xs);
    margin-top: var(--space-sm);
    letter-spacing: 0.02em;
}

.topic-category {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 10px;
    font-weight: 700;
    padding: var(--space-xs) var(--space-sm);
    border-radius: 2px;
    background: rgba(26, 60, 52, 0.08);
    color: var(--primary);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.badge-islam {
    background: rgba(180, 100, 40, 0.1);
    color: #9c5520;
}

.badge-atheism {
    background: rgba(100, 100, 140, 0.1);
    color: #5a5a80;
}

.badge-judaism {
    background: rgba(160, 130, 50, 0.1);
    color: #8a7030;
}

.badge-skepticism {
    background: rgba(120, 120, 120, 0.1);
    color: #6a6a6a;
}

.badge-jw {
    background: rgba(60, 90, 140, 0.1);
    color: #3c5a8c;
}

.badge-unitarianism {
    background: rgba(130, 80, 130, 0.1);
    color: #7a4a7a;
}

.badge-frequency {
    background: rgba(197, 160, 89, 0.15);
    color: var(--accent);
}

.badge-easy {
    background: rgba(45, 106, 79, 0.1);
    color: var(--green-muted);
}

.badge-medium {
    background: rgba(197, 160, 89, 0.15);
    color: #9a7d40;
}

.badge-hard {
    background: rgba(155, 44, 44, 0.1);
    color: var(--red);
}

.badge-default {
    background: rgba(26, 60, 52, 0.08);
    color: var(--primary);
}

.objection-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

/* ============================================================
   FILTERS
   ============================================================ */
.filters {
    margin-bottom: var(--space-lg);
}

.filters select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%234a4a4a' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E") no-repeat right 14px center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-xl) var(--space-sm) var(--space-md);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    min-width: 200px;
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition-fast);
}

.filters select:hover {
    border-color: var(--accent);
}

/* ============================================================
   VERSE LOOKUP
   ============================================================ */
.verse-lookup {
    background: var(--white);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
}

/* ── Unified Lookup card ──────────────────────────────────── */
.lookup-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.card-clear-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 11px;
    font-family: 'Libre Baskerville', Georgia, serif;
    padding: 3px 10px;
    cursor: pointer;
    transition: border-color var(--transition-fast), color var(--transition-fast);
}
.card-clear-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.lookup-mode-pills {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px;
}

.mode-pill {
    padding: 4px 14px;
    border: none;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.mode-pill.active {
    background: var(--primary);
    color: var(--white);
}

.mode-pill:not(.active):hover {
    color: var(--primary);
}

/* ── Compare Sources card ─────────────────────────────────── */
.compare-sources-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.compare-source-panel {
    flex: 1;
    min-width: 220px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
}

.compare-source-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.compare-vs-badge {
    align-self: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    padding: 0 var(--space-xs);
    flex-shrink: 0;
}

.compare-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-top: var(--space-lg);
    border-top: 1px solid var(--border);
    padding-top: var(--space-lg);
}

.compare-col {
    display: flex;
    flex-direction: column;
}

.compare-col-header {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--accent);
    margin-bottom: var(--space-md);
}

.compare-result-item {
    padding: var(--space-sm) var(--space-md);
    border-left: 2px solid var(--border-accent);
    margin-bottom: var(--space-sm);
}

.compare-empty,
.compare-loading {
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
    padding: var(--space-sm);
}

@media (max-width: 600px) {
    .compare-results-grid { grid-template-columns: 1fr; }
    .compare-sources-row  { flex-direction: column; }
}

/* Hadith collection badge in search results */
.hadith-collection-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--primary);
    color: var(--white);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
    margin-right: 4px;
}

.hadith-number {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    vertical-align: middle;
}

.verse-lookup h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 16px;
    color: var(--primary);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.verse-lookup h3 .material-symbols-outlined {
    color: var(--accent);
}

.lookup-form {
    display: flex;
    gap: var(--space-md);
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.input-group label {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.15em;
}

.lookup-form input,
.lookup-form select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 13px;
    color: var(--ink-dark);
    background: var(--bg-primary);
    transition: border-color var(--transition-fast);
    width: 140px;
}

.lookup-form input:focus,
.lookup-form select:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 1px var(--accent);
}

.lookup-form input[type="number"] {
    width: 80px;
}

.lookup-form select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%234a4a4a' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E") no-repeat right 10px center;
    padding-right: var(--space-xl);
    cursor: pointer;
    width: auto;
    min-width: 80px;
}

.verse-result {
    margin-top: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius-sm);
}

.verse-result.empty {
    display: none;
}

.verse-reference {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    margin-bottom: var(--space-sm);
}

.verse-version {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
}

.verse-text {
    line-height: 1.7;
    font-size: 15px;
    color: var(--text-primary);
    font-style: italic;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 60, 52, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    animation: fadeIn 0.2s ease;
}

.modal-panel {
    background: var(--bg-primary);
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: slideIn 0.3s ease;
}

.modal-heading {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 20px;
    color: var(--primary);
    margin-bottom: var(--space-lg);
}

.modal-objection-text {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    line-height: 1.6;
}

.modal-response-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-card);
}

.modal-response-label {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    margin-bottom: var(--space-sm);
}

.modal-response-heading {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 16px;
    color: var(--primary);
    margin-bottom: var(--space-sm);
}

.modal-response-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.65;
    margin-bottom: var(--space-md);
}

.modal-response-md h2,
.modal-response-md h3 {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--primary);
    font-size: 15px;
    margin: var(--space-md) 0 var(--space-xs);
}
.modal-response-md h3 { font-size: 13px; }
.modal-response-md p { margin-bottom: var(--space-sm); }
.modal-response-md strong { color: var(--primary); }
.modal-response-md hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-md) 0;
}
.modal-response-md ul,
.modal-response-md ol {
    padding-left: 1.4em;
    margin-bottom: var(--space-sm);
}
.modal-response-md li { margin-bottom: 4px; }

.modal-key-points {
    margin-top: var(--space-md);
}

.modal-key-points strong {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.modal-key-points ul {
    margin-top: var(--space-sm);
    padding-left: var(--space-lg);
}

.modal-key-points li {
    margin: var(--space-xs) 0;
    font-size: 14px;
    color: var(--text-primary);
}

.modal-bottom-line {
    border-left: 2px solid var(--accent);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-lg);
    background: rgba(197, 160, 89, 0.05);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.modal-bottom-line strong {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 0.1em;
}

.modal-bottom-line p {
    font-size: 14px;
    color: var(--ink-dark);
    font-weight: 700;
    margin-top: var(--space-xs);
}

.modal-close-btn {
    background: var(--primary);
    color: var(--accent);
    border: none;
    padding: var(--space-sm) var(--space-xl);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition-fast);
    display: block;
    margin-left: auto;
}

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

/* ============================================================
   LOADING STATE
   ============================================================ */
.loading {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
}

.loading::before {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--bg-secondary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto var(--space-md);
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-top: 4px solid var(--accent);
    padding: var(--space-lg) var(--space-lg);
    text-align: center;
}

.footer-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--white);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.footer-subtitle {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 10px;
    color: var(--accent-muted);
    font-style: italic;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.footer-links a {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 10px;
    color: var(--accent-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.footer-divider {
    color: rgba(255, 255, 255, 0.2);
    font-size: 10px;
}

.footer-copyright {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    margin-top: var(--space-sm);
    letter-spacing: 0.05em;
}

/* ── Legal Modals ── */
.legal-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.legal-modal-content {
    background: var(--parchment);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 700px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

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

.legal-modal-header h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 20px;
    color: var(--primary);
    margin: 0;
}

.legal-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.legal-modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text);
}

.legal-modal-body h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 15px;
    color: var(--primary);
    margin: var(--space-md) 0 var(--space-xs);
}

.legal-modal-body p {
    margin-bottom: var(--space-sm);
}

.legal-modal-body ul {
    margin: var(--space-xs) 0 var(--space-sm) var(--space-md);
}

.legal-modal-body li {
    margin-bottom: var(--space-xs);
}

.legal-modal-body a {
    color: var(--accent);
    text-decoration: none;
}

.legal-modal-body a:hover {
    text-decoration: underline;
}

.legal-updated {
    font-style: italic;
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: var(--space-md);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .study-panel {
        width: 100vw;
        border-left: none;
        border-top: 1px solid var(--border);
    }

}

@media (max-width: 768px) {
    header {
        padding: 8px var(--space-sm);
        padding-top: calc(8px + env(safe-area-inset-top));
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
    }

    /* Push content below fixed header + status bar */
    .content {
        margin-top: calc(50px + env(safe-area-inset-top));
    }

    header h1 {
        font-size: 13px;
        letter-spacing: 0.08em;
    }

    .header-icon-badge {
        width: 28px;
        height: 28px;
        margin-bottom: 4px;
    }

    .header-icon-badge .material-symbols-outlined {
        font-size: 16px;
    }

    .tagline {
        display: none;
    }

    /* Compact new-chat: icon only */
    .new-chat-btn {
        padding: 8px;
        gap: 0;
        left: var(--space-sm);
    }

    .new-chat-btn span:not(.material-symbols-outlined) {
        display: none;
    }

    /* Compact user area: hide name */
    .user-area {
        right: var(--space-sm);
    }

    .user-display-name {
        display: none;
    }

    /* Reduce chat container padding on mobile */
    .chat-container {
        padding: var(--space-sm);
        height: calc(100vh - 140px);
        min-height: unset;
    }

    /* Bottom navigation for mobile thumb reach */
    .tabs {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 500;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        border-bottom: none;
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        flex-wrap: nowrap;
    }

    .tab-btn {
        flex: 1;
        min-height: 44px;
    }

    /* Pad content so it doesn't hide behind bottom nav */
    .content {
        padding-bottom: 72px;
    }

    .lookup-form {
        flex-direction: column;
        align-items: stretch;
    }

    .lookup-form input,
    .lookup-form input[type="number"] {
        width: 100%;
    }

    .message-bubble {
        max-width: 85%;
    }

    /* Touch-friendly targets */
    .btn-primary,
    .verse-link,
    .section-chip,
    .mode-btn,
    .level-btn,
    .mode-pill {
        min-height: 44px;
    }

}

/* Prevent pull-to-refresh in standalone/installed mode */
@media (display-mode: standalone) {
    html { overscroll-behavior: none; }
}

@media (max-width: 480px) {
    .tab-btn .tab-label {
        display: none;
    }

    .tab-btn {
        padding: var(--space-md);
        justify-content: center;
        flex: 1;
    }

    .tab-btn .tab-icon {
        font-size: 22px;
    }

    .chat-input-container {
        flex-direction: column;
    }

    .btn-primary {
        width: 100%;
    }

    .welcome-message h2 {
        font-size: 22px;
    }
}

/* ============================================================
   SECTION CHIP BAR — Sticky above chat input
   ============================================================ */
.section-chip-bar {
    flex-direction: column;
    gap: 0;
    padding: 0;
    border-top: 1px solid var(--border-accent);
    background: var(--parchment-dark);
}

/* Toggle header row */
.chip-bar-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}

.chip-bar-toggle .chip-label {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.chip-bar-toggle .chip-count {
    font-size: 10px;
    background: var(--accent);
    color: var(--white);
    border-radius: 10px;
    padding: 1px 6px;
    font-weight: 600;
}

.chip-bar-toggle .chip-arrow {
    margin-left: auto;
    font-size: 18px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.chips-collapsed .chip-arrow {
    transform: rotate(180deg);
}

/* Chips wrapper */
.chip-bar-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 10px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
    max-height: 300px;
    opacity: 1;
}

.chips-collapsed .chip-bar-chips {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.chip-label {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-right: 4px;
    white-space: nowrap;
}

.section-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border-accent);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--primary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.section-chip .material-symbols-outlined {
    font-size: 16px;
}

.section-chip:hover:not(.chip-loading) {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
    box-shadow: var(--shadow-card);
}

.section-chip.chip-loading {
    opacity: 0.6;
    cursor: wait;
}

.section-chip.chip-loading::after {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--accent-muted);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: chip-spin 0.6s linear infinite;
    margin-left: 4px;
}

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

/* Fade-out animation when chip is removed */
.section-chip.chip-removing {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
}

/* Fade-in animation for the bar appearing */
.section-chip-bar.bar-entering {
    animation: chipBarSlideIn 0.3s ease forwards;
}

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

/* ── Chat Mode Toggle ── */
.toggle-label {
    font-size: 11px;
    color: var(--text-muted);
    font-family: inherit;
    font-style: italic;
    align-self: center;
    margin-right: 4px;
}

.chat-mode-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
}

.mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-btn .material-symbols-outlined {
    font-size: 14px;
}

.mode-btn:hover {
    color: var(--primary);
    border-color: var(--accent-muted);
}

.mode-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* ── Response Level Toggle ── */
.response-level-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 16px 8px;
}

.level-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.level-btn .material-symbols-outlined {
    font-size: 14px;
}

.level-btn:hover {
    color: var(--accent);
    border-color: var(--accent-muted);
}

.level-btn.active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

/* ── Debate Predictive Suggestions ── */
.debate-autocomplete {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    display: flex;
    gap: 6px;
    padding: 6px 12px;
    overflow-x: auto;
    white-space: nowrap;
    background: var(--parchment-dark);
    border-bottom: 1px solid var(--border);
    z-index: 10;
    scrollbar-width: none;
}

.debate-autocomplete::-webkit-scrollbar {
    display: none;
}

.predict-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--white);
    color: var(--text-body);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.predict-chip:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.predict-chip .predict-match {
    font-weight: 700;
    color: var(--primary);
}

.predict-chip:hover .predict-match {
    color: var(--white);
}


/* ============================================================
   SUGGESTED QUESTIONS MODAL
   ============================================================ */

.suggestions-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(26, 60, 52, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    animation: fadeIn 0.2s ease;
}

.suggestions-modal-panel {
    background: var(--bg-primary);
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    max-width: 520px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: slideIn 0.3s ease;
}

.suggestions-modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0 0 var(--space-md) 0;
}

.suggestions-modal-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 var(--space-md) 0;
    line-height: 1.5;
}

.suggestions-chip-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.suggestion-chip {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--primary);
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1.4;
}

.suggestion-chip:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.suggestion-chip.chip-selected {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
    cursor: default;
}

.chip-confirm-popup {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    box-shadow: var(--shadow-md);
    margin-top: 4px;
    animation: fadeIn 0.15s ease;
}

.chip-confirm-text {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

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

.chip-confirm-run {
    flex: 1;
    padding: 7px 12px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.chip-confirm-run:hover { background: var(--primary-dark, #14523a); }

.chip-confirm-edit {
    flex: 1;
    padding: 7px 12px;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chip-confirm-edit:hover {
    background: var(--primary);
    color: var(--white);
}

.send-original-link {
    display: block;
    width: 100%;
    margin-top: var(--space-md);
    padding: 6px 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-family: inherit;
    text-decoration: underline;
    cursor: pointer;
    text-align: center;
    transition: color var(--transition-fast);
}

.send-original-link:hover { color: var(--text-body); }

/* Input tip line */
.chat-input-tip {
    font-size: 11px;
    color: var(--text-muted);
    margin: 4px 0 0 4px;
    opacity: 0.75;
}

@media (max-width: 768px) {
    .chat-input-tip { display: none; }
}

/* ============================================================
   MASTER CLASS - Filter bar (religion tabs + sub-category chips)
   ============================================================ */
.mc-filters {
    padding: var(--space-sm) var(--space-md) 0;
}

/* Tab row — search is now above this in its own row */
.mc-tabs-row {
    display: flex;
    align-items: flex-end;
    border-bottom: 2px solid var(--border);
    margin-bottom: var(--space-sm);
}

.mc-tabs {
    display: flex;
    gap: 6px;
    flex: 1;
    overflow: visible;
}

.mc-tab {
    padding: 8px 18px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.mc-tab:hover {
    color: var(--primary);
}

.mc-tab.mc-tab-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.mc-tab-count {
    display: inline-block;
    background: var(--parchment-dark);
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font-body);
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
    vertical-align: middle;
}

.mc-tab.mc-tab-active .mc-tab-count {
    background: var(--primary);
    color: var(--white);
}

/* Sub-category chips */
.mc-subcats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: var(--space-sm);
}

.mc-chip {
    padding: 4px 12px;
    background: var(--parchment-light);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mc-chip:hover {
    background: var(--parchment-dark);
    color: var(--primary);
    border-color: var(--primary);
}

.mc-chip.mc-chip-active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.mc-chip-count {
    font-size: 11px;
    opacity: 0.8;
    margin-left: 3px;
}

/* Search + Saved button sit together in one row above the category tabs */
.mc-search-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.mc-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
}

.mc-search-icon {
    position: absolute;
    left: 10px;
    font-size: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.mc-search-input {
    width: 100%;
    padding: 6px 32px 6px 32px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--parchment-light);
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.mc-search-input:focus {
    outline: none;
    background: var(--white);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 63, 44, 0.1);
}

.mc-search-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.mc-search-clear {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 50%;
    line-height: 1;
    transition: all var(--transition-fast);
}

.mc-search-clear:hover {
    background: var(--parchment-dark);
    color: var(--text-primary);
}

/* Saved button — pill style sitting next to the search bar */
.mc-tab.mc-tab-saved {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-bottom: 1px solid var(--border);  /* override tab underline style */
    border-radius: 20px;
    background: var(--parchment-light);
    white-space: nowrap;
    flex-shrink: 0;
}

.mc-tab.mc-tab-saved.mc-tab-active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
    border-bottom-color: var(--primary);
}

.mc-tab-icon {
    font-size: 15px;
    vertical-align: middle;
}

.mc-tab.mc-tab-saved.mc-tab-active .mc-tab-icon {
    color: var(--accent);
}

/* Bookmark button on cards */
.mc-fav-btn {
    margin-left: auto;
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition-fast);
    line-height: 1;
}

.mc-fav-btn .material-symbols-outlined {
    font-size: 20px;
    display: block;
}

.mc-fav-btn:hover {
    color: var(--accent);
    background: var(--parchment-dark);
}

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

.mc-fav-btn.mc-fav-active .material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
}

/* Like button */
.masterclass-card-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
}

.masterclass-card-footer .masterclass-view-btn {
    flex: 1;
}

.mc-like-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-muted);
    padding: 8px 10px;
    transition: color 0.2s, border-color 0.2s;
}

.mc-like-btn .material-symbols-outlined {
    font-size: 18px;
}

.mc-like-btn:hover {
    color: #e25555;
    border-color: #e25555;
}

.mc-like-btn.liked {
    color: #e25555;
    border-color: #e25555;
}

.mc-like-btn.liked .material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
}

.mc-like-count {
    font-size: 13px;
    font-weight: 600;
    min-width: 8px;
    text-align: center;
}

/* No results state */
.mc-no-results {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    color: var(--text-muted);
}

.mc-no-results .material-symbols-outlined {
    font-size: 48px;
    display: block;
    margin-bottom: var(--space-sm);
    opacity: 0.4;
}

.mc-no-results p {
    font-size: 14px;
}

/* ============================================================
   MASTER CLASS - Premium argument cards
   ============================================================ */
.masterclass-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: var(--space-md);
    padding: var(--space-md);
}

.masterclass-card {
    display: flex;
    flex-direction: column;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: all var(--transition-normal);
    cursor: pointer;
}

.masterclass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: var(--accent);
}

.masterclass-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: var(--space-sm);
}

.masterclass-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.masterclass-icon .mc-cat-icon,
.mc-cat-icon {
    font-size: 24px;
    color: var(--accent);
}

.masterclass-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    flex: 1;
    line-height: 1.3;
}

.masterclass-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: var(--space-sm);
    padding: var(--space-sm);
    background: var(--parchment-light);
    border-radius: var(--radius-sm);
}

.masterclass-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.masterclass-meta-item .material-symbols-outlined {
    font-size: 14px;
}

.masterclass-category {
    display: inline-block;
    padding: 4px 10px;
    background: var(--accent-muted);
    color: var(--primary);
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.masterclass-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-md);
    font-style: italic;
}

.masterclass-view-btn {
    width: 100%;
    padding: 10px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.masterclass-view-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* ── Expanded Argument View ─────────────────────────── */
.masterclass-expanded {
    max-width: 860px;
    margin: 0 auto;
    padding: var(--space-lg);
}

.masterclass-expanded-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.mc-expand-toggle {
    flex: 1;
    display: flex;
    justify-content: center;
}

.mc-expand-all-btn {
    background: none;
    border: 1px dashed var(--border-accent);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.mc-expand-all-btn:hover {
    border-style: solid;
    color: var(--primary);
    border-color: var(--primary);
}

.masterclass-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.masterclass-back-btn:hover {
    background: var(--parchment-dark);
    border-color: var(--accent);
}

/* Title + pills row */
.mc-expanded-meta {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.masterclass-expanded-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 28px;
    font-weight: 900;
    color: var(--primary);
    margin-bottom: var(--space-xs);
    display: flex;
    align-items: center;
    gap: 10px;
}

.masterclass-expanded-title .mc-cat-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.mc-expanded-pills {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.masterclass-expanded-category {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    padding: 3px 10px;
    border-radius: 20px;
}

.mc-step-count {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

/* ── Accordion ────────────────────────────────────────── */
.mc-accordion {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mc-acc-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--white);
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.mc-acc-item.mc-acc-open {
    border-color: var(--accent);
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

/* Accordion header — the clickable trigger */
.mc-acc-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition-fast);
}

.mc-acc-header:hover {
    background: var(--parchment-light);
}

.mc-acc-item.mc-acc-open .mc-acc-header {
    background: var(--parchment-light);
    border-bottom: 1px solid var(--border);
    /* Stick to top of scroll container so you can always collapse without scrolling back up */
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Step badge — number or icon */
.mc-acc-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-width: 28px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-muted);
    font-family: 'Playfair Display', Georgia, serif;
    letter-spacing: 0;
    transition: color var(--transition-fast);
    flex-shrink: 0;
}

.mc-acc-badge .material-symbols-outlined {
    font-size: 16px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.mc-acc-item.mc-acc-open .mc-acc-badge .material-symbols-outlined {
    color: var(--accent);
}

.mc-acc-item.mc-acc-open .mc-acc-badge {
    color: var(--accent);
}

/* Label — section title */
.mc-acc-label {
    flex: 1;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.3;
}

/* Verse count chip */
.mc-acc-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.mc-acc-verses {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

/* Chevron — rotates when open */
.mc-acc-chevron {
    font-size: 20px;
    color: var(--text-muted);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.mc-acc-item.mc-acc-open .mc-acc-chevron {
    transform: rotate(180deg);
    color: var(--accent);
}

/* Body — grid animation (modern, no max-height hacks) */
.mc-acc-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.mc-acc-item.mc-acc-open .mc-acc-body {
    grid-template-rows: 1fr;
}

.mc-acc-content {
    overflow: hidden;
    padding: 0;
    transition: padding 0.35s ease;
}

.mc-acc-item.mc-acc-open .mc-acc-content {
    padding: var(--space-md) var(--space-lg) var(--space-lg);
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
}

/* Markdown rendered inside accordion content */
.mc-acc-content h1, .mc-acc-content h2, .mc-acc-content h3,
.mc-acc-content h4, .mc-acc-content h5 {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--primary);
    margin: var(--space-md) 0 var(--space-xs);
    font-size: 14px;
    font-weight: 700;
}
.mc-acc-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-sm) 0;
}
.mc-acc-content p { margin: 0 0 var(--space-sm); }
.mc-acc-content ul, .mc-acc-content ol {
    padding-left: var(--space-lg);
    margin: 0 0 var(--space-sm);
}
.mc-acc-content li { margin-bottom: 2px; }
.mc-acc-content strong { color: var(--primary); }

/* Legacy section styles (used in older views) */
.masterclass-section-content {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
}

.masterclass-verse {
    background: var(--parchment-light);
    border-left: 4px solid var(--accent);
    padding: var(--space-sm);
    margin: var(--space-sm) 0;
    font-family: 'Libre Baskerville', Georgia, serif;
}

.masterclass-note {
    color: var(--text-muted);
    font-size: 13px;
}

.masterclass-section-content strong {
    color: var(--primary);
    font-weight: 700;
}

/* ── Chat Options Collapsible Wrapper ── */
.chat-options-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    border-top: 1px solid var(--border);
}

.chat-options-toggle .material-symbols-outlined:first-child {
    font-size: 16px;
    color: var(--text-muted);
}

.chat-options-summary {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.chat-options-arrow {
    margin-left: auto;
    font-size: 16px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.chat-options-body {
    transition: max-height 0.3s ease, opacity 0.2s ease;
    max-height: 200px;
    opacity: 1;
    overflow: hidden;
}

.chat-options-wrapper.opts-collapsed .chat-options-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0;
}

.chat-options-wrapper.opts-collapsed .chat-options-arrow {
    transform: rotate(180deg);
}

/* ============================================================
   MOBILE OVERRIDES — must be last to win specificity
   ============================================================ */
@media (max-width: 768px) {
    .masterclass-grid {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
        padding: var(--space-sm);
    }

    .masterclass-card {
        padding: 10px;
    }

    .masterclass-card-header {
        gap: 8px;
        margin-bottom: 4px;
    }

    .masterclass-title {
        font-size: 13px;
        line-height: 1.2;
    }

    .masterclass-meta {
        display: none !important;
    }

    .masterclass-preview {
        display: none !important;
    }

    .masterclass-category {
        font-size: 9px;
        padding: 2px 6px;
        margin-top: 2px;
    }

    .masterclass-icon .mc-cat-icon,
    .mc-cat-icon {
        font-size: 18px;
    }

    .masterclass-card-footer {
        gap: 8px;
        margin-top: 6px;
    }

    .masterclass-view-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .mc-like-btn {
        padding: 4px 8px;
    }

    /* Compact chat input for mobile */
    .chat-input-container {
        padding: 4px 6px !important;
        gap: 4px !important;
        flex-direction: row !important;
        align-items: flex-end;
    }

    #chatInput {
        min-height: 24px;
        max-height: 80px;
        font-size: 13px;
        padding: 5px 8px;
    }

    .btn-primary {
        width: auto !important;
        padding: 5px 10px;
        font-size: 13px;
        min-height: 32px;
    }

    .input-icon {
        padding: 2px;
    }

    /* Compact mode/level toggles */
    .chat-mode-toggle {
        padding: 4px 8px;
        gap: 2px;
    }

    .response-level-toggle {
        padding: 0 8px 4px;
        gap: 2px;
    }

    .mode-btn,
    .level-btn {
        padding: 2px 8px;
        font-size: 11px;
    }

    .mode-btn .material-symbols-outlined,
    .level-btn .material-symbols-outlined {
        font-size: 12px;
    }

    /* Compact section chips on mobile */
    .section-chip {
        min-height: unset !important;
        padding: 4px 10px;
        font-size: 11px;
    }

    .section-chip .material-symbols-outlined {
        font-size: 14px;
    }

    .chip-bar-chips {
        gap: 6px;
        padding: 0 10px 8px;
    }

    .chip-bar-toggle {
        padding: 6px 10px;
    }

    /* Hide footer on mobile — reclaim space */
    footer {
        display: none !important;
    }


    /* Fix entire chat container between pinned header and pinned tab bar.
       Messages scroll inside; chips, options, and input stay pinned at bottom. */
    .chat-container {
        position: fixed !important;
        top: calc(50px + env(safe-area-inset-top));
        left: 0;
        right: 0;
        bottom: 132px;
        height: auto !important;
        min-height: unset !important;
        max-width: unset !important;
        margin: 0 !important;
        z-index: 10;
        background: var(--bg-main);
        overflow: hidden;
    }

    /* Center Compare Sources card content on mobile */
    .compare-source-panel {
        min-width: unset;
        width: 100%;
    }

    .compare-card {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: var(--space-md);
    }

    .compare-card .lookup-card-header,
    .compare-card .compare-sources-row,
    .compare-card #compareQuerySplit,
    .compare-card #compareQueryShared {
        width: 100%;
        justify-content: center;
    }

    .compare-card .input-group {
        width: 100% !important;
        flex: unset !important;
        text-align: center;
    }

    .compare-card .input-group label {
        display: block;
        text-align: center;
    }

    .compare-card .input-group input {
        text-align: center;
        width: 80% !important;
        margin: 0 auto;
        display: block;
    }

    .compare-card .compare-vs-badge {
        align-self: center;
    }

    .compare-card .lookup-form,
    .compare-card .compare-sources-row {
        flex-direction: column;
        align-items: center;
    }

    .compare-card .btn-primary {
        align-self: center !important;
    }

    /* Horizontal scroll for masterclass & objection category tabs on mobile */
    .mc-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .mc-tabs::-webkit-scrollbar {
        display: none;
    }

    .mc-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Study panel: sit above tab bar, pad bottom so content isn't hidden */
    .study-panel {
        z-index: 600;
        height: 100dvh;
    }

    .study-panel-content {
        padding-bottom: 72px;
    }
}
