:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --accent-primary: #3b82f6;
    --accent-secondary: #2dd4bf;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top right, #1e293b, #0f172a);
    color: var(--text-main);
}

.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
}

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

.hidden-view {
    display: none !important;
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Flashcard Styles */
.flip-card {
    background-color: transparent;
    perspective: 1000px;
    cursor: pointer;
    min-height: 16rem;
}
.flip-card-inner {
    position: relative;
    width: 100%;
    min-height: 16rem;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}
.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}
.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    min-height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.flip-card-back {
    transform: rotateY(180deg);
    position: relative; /* allow back to size to content */
}
/* When flipped, back becomes the visible positioned element */
.flip-card.flipped .flip-card-back {
    position: absolute;
    top: 0; left: 0;
}
.flip-card.flipped .flip-card-front {
    position: absolute;
    top: 0; left: 0;
}

/* KaTeX custom highlights */
.katex .letter-target {
    color: #f87171 !important;
    background-color: rgba(248, 113, 113, 0.15);
    border-radius: 4px;
    padding: 2px 4px;
    box-shadow: 0 0 8px rgba(248, 113, 113, 0.4);
}

/* Quiz Buttons */
.quiz-option {
    transition: all 0.2s;
}
.quiz-option:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateX(5px);
}
.quiz-option.correct {
    background: rgba(16, 185, 129, 0.2) !important;
    border-color: #10b981 !important;
    color: #34d399;
}
.quiz-option.wrong {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: #ef4444 !important;
    color: #f87171;
}

/* Drag and Drop Zones */
.dropzone {
    min-height: 3.5rem;
    min-width: 3.5rem;
    border: 2px dashed rgba(148, 163, 184, 0.5);
    border-radius: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    background: rgba(15, 23, 42, 0.5);
    transition: all 0.2s;
}
/* show · between multiple drag-items in a dropzone */
.dropzone .drag-item + .drag-item::before {
    content: '·';
    color: #94a3b8;
    font-size: 1.2rem;
    margin-right: 4px;
}
.dropzone.dragover {
    border-color: var(--accent-secondary);
    background: rgba(45, 212, 191, 0.15);
    box-shadow: inset 0 0 10px rgba(45, 212, 191, 0.2);
}
.dropzone.filled {
    border: 2px solid var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}
.drag-item {
    cursor: grab;
    user-select: none;
    touch-action: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s;
}
.drag-item:active {
    cursor: grabbing;
    transform: scale(1.05);
}

.sortable-ghost {
    opacity: 0.4;
    background-color: #475569;
}

.sortable-fallback {
    opacity: 1 !important;
    z-index: 9999 !important;
}

/* Layout for Builder Equation */
.equation-builder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1.5rem;
}
.equation-fraction {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    pointer-events: none;
}
.equation-fraction > .dropzone {
    pointer-events: auto;
}
.fraction-line {
    width: 100%;
    min-width: 3.5rem;
    height: 2px;
    background-color: white;
    margin: 0.25rem 0;
    pointer-events: none;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.shake {
    animation: shake 0.4s ease-in-out;
}
@keyframes pop {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.pop-in {
    animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Grade Selector Buttons */
.grade-btn {
    background: #1e293b;
    border: 2px solid #334155;
    color: #94a3b8;
    min-width: 3rem;
    transition: all 0.2s;
}
.grade-btn:hover {
    border-color: #64748b;
    color: #e2e8f0;
}
.grade-btn.grade-active {
    background: linear-gradient(135deg, #3b82f6, #2dd4bf);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

/* Stats Period Buttons */
.stat-period-btn {
    background: #1e293b;
    border: 2px solid #334155;
    color: #94a3b8;
}
.stat-period-btn:hover {
    border-color: #64748b;
    color: #e2e8f0;
}
.stat-period-btn.stat-period-active {
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}
