/* Existing Styles remain... */
.flashcard-container {
    perspective: 1000px;
    margin-bottom: 20px;
}

.flashcard {
    width: 100%;
    height: 300px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 50vh;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Center content vertically */
    align-items: center;
    /* Center content horizontally */
    padding: 32px;
    border-radius: 16px;
    background: white;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.flashcard-back {
    transform: rotateY(180deg);
    background: white;
    /* Match front for consistency in light theme */
    border-color: var(--accent);
    /* Subtle difference */
}

/* Card Content Styling */
.card-content {
    text-align: center;
    width: 100%;
    max-width: 600px;
}

.card-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 16px;
}

.card-text {
    font-size: 24px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* When a card has MCQ options, shrink the question text so everything fits */
.has-options #studyQuestion {
    font-size: 16px;
    margin-bottom: 12px;
}

.card-options {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    text-align: left;
}

.card-option-item {
    font-size: 14px;
    color: #374151;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 8px 12px;
    line-height: 1.4;
}

.card-hint-area {
    margin-top: 16px;
    padding: 12px;
    background: rgba(245, 158, 11, 0.1);
    color: #D97706;
    border-radius: 8px;
    font-size: 14px;
}

.tap-instruction {
    position: absolute;
    bottom: 20px;
    font-size: 12px;
    color: var(--muted);
    opacity: 0.7;
}

.small-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 12px;
    font-size: 12px;
}

/* Study View Layout */
.study-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding: 0 10px;
}

.study-info {
    text-align: center;
}

.study-info h2 {
    margin: 0;
    font-size: 18px;
    color: #111827;
}

.study-info span {
    font-size: 12px;
    color: var(--muted);
}

.study-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.flashcard-wrapper {
    width: 100%;
    max-width: 600px;
    height: 350px;
    position: relative;
    /* contain absolute-positioned card faces */
}

.flashcard-wrapper .flashcard {
    height: 100%;
}

.card-internal-counter {
    position: absolute;
    top: 16px;
    left: 20px;
    font-size: 12px;
    color: var(--muted);
}

.nav-arrow {
    background: white;
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.nav-arrow:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: scale(1.1);
}

/* Controls */
.study-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 32px;
    padding: 0 16px;
}

.nav-arrow-ctrl {
    background: white;
    border: 1px solid var(--border);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    font-size: 16px;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.nav-arrow-ctrl:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.btn-missed,
.btn-got {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 28px;
    border-radius: 30px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    font-size: 15px;
    transition: transform 0.2s;
    box-shadow: var(--shadow);
    min-width: 110px;
    justify-content: center;
}

.btn-missed {
    background: rgba(239, 68, 68, 0.12);
    color: #DC2626;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-got {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.btn-missed:hover,
.btn-got:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.study-feedback-row {
    position: fixed;
    bottom: 80px;
    /* above the bottom nav bar */
    left: 16px;
    display: flex;
    flex-direction: row;
    gap: 10px;
    z-index: 10;
}

.feedback-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

.feedback-btn:hover {
    color: var(--accent);
}

.btn-count {
    background: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

/* Progress Footer */
.study-footer {
    margin-top: 40px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.progress-container {
    height: 6px;
    background: #E5E7EB;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
}

/* Responsive */
@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 24px;
    }
}

@media (max-width: 768px) {

    /* Dashboard Adjustments */
    .flashcard-stats {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .flashcard-stats .stat {
        padding: 12px;
        min-width: auto;
    }

    .flashcard-stats .stat strong {
        font-size: 20px;
    }

    /* Study View Adjustments */
    .study-area {
        gap: 0;
        padding: 0 16px;
        margin-top: 10px;
    }

    .flashcard-wrapper {
        height: 50vh;
        /* Takes up half screen vertically */
        min-height: 420px;
        /* Minimum height for content */
        width: 100%;
        position: relative;
    }

    .flashcard-front,
    .flashcard-back {
        padding: 24px 16px;
        /* Center content */
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .card-text {
        font-size: 20px;
        /* Readable on mobile */
        margin-bottom: 20px;
    }

    .card-label {
        font-size: 11px;
    }

    /* Controls - Stacked or Grid */
    .study-controls {
        gap: 10px;
        width: 100%;
        margin-top: 20px;
        padding: 0 8px;
    }

    .btn-missed,
    .btn-got {
        flex: 1;
        padding: 12px 16px;
        justify-content: center;
        font-size: 14px;
        min-width: 0;
    }

    .study-header {
        margin-bottom: 10px;
        padding: 0 16px;
    }

    .main-content {
        padding-bottom: 100px;
        /* Extra scroll space */
    }
}

@media (max-width: 480px) {
    .flashcard-wrapper {
        height: 55vh;
        min-height: 380px;
    }

    .card-text {
        font-size: 18px;
    }

    .flashcard-stats {
        gap: 8px;
    }
}

/* Dashboard Styles (Existing) */
.flashcard-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.flashcard-stats .stat {
    text-align: center;
    padding: 16px;
    background: var(--card);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.flashcard-stats .stat strong {
    display: block;
    font-size: 24px;
    color: var(--accent);
}

.decks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.deck-card {
    padding: 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.deck-ai-badge {
    display: flex;
    align-items: center;
    color: #FACC15;
    filter: drop-shadow(0 0 3px rgba(250, 204, 21, 0.5));
    flex-shrink: 0;
}

.deck-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
}

.deck-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.deck-count {
    font-size: 12px;
    color: var(--muted);
}

.deck-progress {
    margin-bottom: 12px;
}

.deck-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}