:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --white: #ffffff;
    --bg-light: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-dark: #0f172a;
    --text-grey: #64748b;
    --search-input-bg: #f1f5f9;
    --live-red: #dc2626;
}

body.dark-mode {
    background-color: #020617;
    --bg-light: #020617;
    --white: #0f172a;
    --card-bg: #1e293b;
    --text-dark: #f8fafc;
    --text-grey: #94a3b8;
    --border: #334155;
    --search-input-bg: #1e293b;
}

* { box-sizing: border-box; }

.exam-page-container { display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: var(--bg-light); }

/* ── Sticky Header ─────────────────────────────────────────────────────── */
.sticky-header-section {
    flex-shrink: 0;
    background: var(--white);
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.header-top-row {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

/* Circular back button — FA icon inside circle, not emoji */
.back-circle-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: var(--bg-light);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 14px;
    transition: 0.2s;
}
.back-circle-btn:hover { background: var(--primary-light); color: var(--primary); }
.back-circle-btn i { line-height: 1; }

.header-title { margin: 0; font-weight: 700; font-size: 16px; color: var(--text-dark); }

/* ── Live Status Tabs (Upcoming / Live / Previous) ────────────────────── */
.live-status-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}
.live-status-tab {
    flex: 1;
    text-align: center;
    padding: 12px 8px;
    font-size: 12.5px;
    font-weight: 800;
    color: var(--text-grey);
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}
.live-status-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.live-status-tab .tab-count {
    display: inline-block;
    margin-left: 4px;
    font-size: 10px;
    background: var(--bg-light);
    color: var(--text-grey);
    border-radius: 20px;
    padding: 1px 6px;
    font-weight: 800;
}
.live-status-tab.active .tab-count { background: var(--primary-light); color: var(--primary); }

/* ── Search + Filters (same pill system as exam-style.css) ────────────── */
.search-input-wrap { padding: 8px 15px; }
.search-input-wrap input {
    width: 100%;
    padding: 8px 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--search-input-bg);
    color: var(--text-dark);
    font-size: 14px;
}

.filter-scroll-wrapper {
    display: flex;
    overflow-x: auto;
    gap: 0;
    padding: 0 5px;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
}
.filter-scroll-wrapper::-webkit-scrollbar { display: none; }

@media (min-width: 992px) {
    .filter-scroll-wrapper { scrollbar-width: thin; scrollbar-color: var(--primary) transparent; padding-bottom: 2px; }
    .filter-scroll-wrapper::-webkit-scrollbar { display: block; height: 5px; }
    .filter-scroll-wrapper::-webkit-scrollbar-track { background: transparent; }
    .filter-scroll-wrapper::-webkit-scrollbar-thumb { background-color: #cccccc; border-radius: 10px; }
    .filter-scroll-wrapper::-webkit-scrollbar-thumb:hover { background-color: #888888; }
}

.pill-filter {
    white-space: nowrap;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-grey);
    cursor: pointer;
    transition: 0.2s;
    position: relative;
    z-index: 1;
}
.pill-filter.active { color: var(--primary); border-bottom-color: var(--primary); }

.hidden { display: none !important; }

/* ── Scrollable Grid ───────────────────────────────────────────────────── */
.scrollable-grid-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 14px 12px 100px;
    background: var(--bg-light);
    -webkit-overflow-scrolling: touch;
}

/* Single column under 550px; fixed-width cards above that so a lone card
   doesn't stretch to fill the row — auto-fit's 1fr was doing that. */
.live-mock-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 551px) {
    .live-mock-grid { grid-template-columns: repeat(auto-fill, 320px); }
}

/* ── Live Mock Card — left-aligned header, icon meta rows, full-bleed button ── */
.live-mock-card {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden; /* keeps the full-bleed button's corners rounded */
    min-width: 0;
}

.live-mock-card .card-body { padding: 16px 16px 14px; }

.live-mock-card .card-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.live-mock-card .card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-mock-card .badge-type {
    flex-shrink: 0;
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 6px;
    font-weight: 600;
    white-space: nowrap;
    margin-top: 2px;
}
.free-badge { background: #dcfce7; color: #166534; }
.paid-badge { background: #fef3c7; color: #92400e; }

/* Countdown pill sits in the same top-right slot as the type badge when
   there's room, stacked below it on narrow cards */
.countdown-pill {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    background: rgba(220, 38, 38, 0.1);
    color: var(--live-red);
}
.countdown-pill.upcoming { background: var(--primary-light); color: var(--primary); }
.countdown-pill.ended { background: var(--bg-light); color: var(--text-grey); }

.live-mock-card .card-header-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.live-mock-card .card-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 14px 0 12px;
}

.live-mock-card .card-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14.5px;
    color: var(--text-grey);
    font-weight: 500;
    margin-bottom: 10px;
}
.live-mock-card .card-meta-row:last-of-type { margin-bottom: 0; }
.live-mock-card .card-meta-row i {
    width: 16px;
    text-align: center;
    color: var(--text-grey);
    font-size: 13px;
}

.live-mock-card .btn-grid {
    display: flex;
    margin-top: 16px;
}
.live-mock-card .btn-grid.btn-dual { gap: 1px; } /* hairline seam when 2 buttons split the width */

.action-btn {
    flex: 1;
    padding: 15px 12px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    display: block;
    transition: 0.15s;
    border-radius: 0; /* full-bleed — card's overflow:hidden rounds the outer corners */
}
.action-btn:active { filter: brightness(0.95); }

.start-btn { background: var(--primary); color: white; }
.start-btn:hover { background: #1d4ed8; color: white; }
.analysis-btn { background: #4f46e5; color: white; }
.reattempt-btn { background: transparent; color: var(--primary); border-top: 1px solid var(--border); }
.reattempt-btn:disabled, .reattempt-btn.disabled-live {
    opacity: 0.5; cursor: not-allowed; color: var(--text-grey);
}
.unlock-btn { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; }
.locked-btn, .waiting-btn, .ended-btn {
    background: var(--bg-light); color: var(--text-grey); opacity: 0.8; cursor: default; pointer-events: none;
}

/* ── Skeleton Loading ──────────────────────────────────────────────────── */
.skeleton-live-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.skeleton-line { background: var(--border); border-radius: 6px; animation: skeleton-blink 1.2s ease-in-out infinite; }
.skeleton-title { height: 20px; width: 70%; }
.skeleton-meta { height: 13px; width: 45%; }
.skeleton-btn { height: 44px; width: 100%; border-radius: 8px; margin-top: 6px; }

@keyframes skeleton-blink {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-grey);
    font-size: 14px;
}

/* ── Dark mode text-color fixes (same pattern as exam-style.css) ──────── */
body.dark-mode { color: var(--text-dark); }
body.dark-mode .header-title,
body.dark-mode .back-circle-btn { color: var(--text-dark) !important; }
body.dark-mode .pill-filter { color: var(--text-grey); }
body.dark-mode .pill-filter.active { color: var(--primary); }
body.dark-mode .live-status-tab { color: var(--text-grey); }
body.dark-mode .live-status-tab.active { color: var(--primary); }

