:root {
    --portal-bg: #f5f7fb;
    --portal-surface: rgba(255, 255, 255, 0.88);
    --portal-surface-solid: #ffffff;
    --portal-border: rgba(31, 41, 55, 0.10);
    --portal-text: #111827;
    --portal-muted: #6b7280;
    --portal-primary: #4f46e5;
    --portal-primary-dark: #3730a3;
    --portal-success: #16a34a;
    --portal-danger: #dc2626;
    --portal-warning: #f59e0b;
    --portal-shadow: 0 18px 45px rgba(15, 23, 42, 0.10);
    --portal-radius: 24px;
}

[data-bs-theme="dark"] {
    --portal-bg: #0f172a;
    --portal-surface: rgba(15, 23, 42, 0.82);
    --portal-surface-solid: #111827;
    --portal-border: rgba(255, 255, 255, 0.12);
    --portal-text: #e5e7eb;
    --portal-muted: #9ca3af;
    --portal-primary: #818cf8;
    --portal-primary-dark: #6366f1;
    --portal-shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--portal-primary) transparent;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(79, 70, 229, 0.18), transparent 32rem),
        radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.14), transparent 28rem),
        var(--portal-bg);
    color: var(--portal-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--portal-primary);
    text-decoration: none;
}

a:hover {
    color: var(--portal-primary-dark);
}

.glass-nav {
    background: var(--portal-surface);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--portal-border);
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 15px;
    display: inline-grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--portal-primary), #06b6d4);
    box-shadow: 0 12px 24px rgba(79, 70, 229, 0.25);
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--portal-border);
    border-radius: 50%;
    background: var(--portal-surface-solid);
    color: var(--portal-text);
}

.hero-section {
    padding: 6rem 0 4rem;
}

.eyebrow {
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--portal-primary);
}

.hero-card,
.portal-card,
.auth-card,
.feature-card,
.lesson-card,
.quick-start-card,
.stat-card,
.live-stat {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
}

.portal-card,
.auth-card,
.feature-card,
.lesson-card,
.quick-start-card {
    padding: 1.5rem;
}

.floating-card {
    animation: floatCard 5s ease-in-out infinite;
}

@keyframes floatCard {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.rssb-topbar,
.rssb-exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #111827, #3730a3);
    color: #fff;
    border-radius: 20px;
}

.typing-preview {
    padding: 1.5rem;
}

.typed-ok {
    color: var(--portal-success);
}

.typed-bad {
    color: var(--portal-danger);
    background: rgba(220, 38, 38, 0.12);
}

.keyboard-mini {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.keyboard-mini span,
.keyboard-key {
    border: 1px solid var(--portal-border);
    background: var(--portal-surface-solid);
    color: var(--portal-text);
    border-radius: 12px;
    min-width: 42px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 -3px 0 rgba(15, 23, 42, 0.08);
}

.metric-tile {
    padding: 1rem;
    border-radius: 18px;
    background: rgba(79, 70, 229, 0.10);
}

.metric-tile span,
.stat-card span,
.live-stat span {
    display: block;
    color: var(--portal-muted);
    font-size: 0.82rem;
}

.metric-tile strong,
.stat-card strong,
.live-stat strong {
    display: block;
    font-size: 1.7rem;
    line-height: 1.1;
}

.hero-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.hero-stats div {
    min-width: 130px;
    padding: 1rem;
    border-radius: 18px;
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
}

.hero-stats strong {
    display: block;
    font-size: 1.4rem;
}

.hero-stats span {
    color: var(--portal-muted);
    font-size: 0.85rem;
}

.feature-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover,
.lesson-card:hover {
    transform: translateY(-4px);
}

.feature-card i {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.4rem;
    background: linear-gradient(135deg, var(--portal-primary), #06b6d4);
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.1rem;
}

.feature-card p,
.lesson-card p {
    color: var(--portal-muted);
    margin-bottom: 0;
}

.auth-section {
    padding: 5rem 0;
}

.auth-card {
    max-width: 100%;
}

.dashboard-hero {
    padding: 3.5rem 0 1rem;
}

.stat-card {
    position: relative;
    display: block;
    padding: 1.25rem;
    overflow: hidden;
    color: var(--portal-text);
}

.stat-card i {
    position: absolute;
    right: 1rem;
    bottom: 0.7rem;
    font-size: 2.5rem;
    color: rgba(79, 70, 229, 0.18);
}

.stat-link:hover {
    transform: translateY(-2px);
    color: var(--portal-text);
}

.training-path {
    display: grid;
    gap: 0.75rem;
}

.training-path a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem;
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    background: var(--portal-surface-solid);
    color: var(--portal-text);
}

.training-path i {
    color: var(--portal-primary);
}

.portal-footer {
    border-top: 1px solid var(--portal-border);
    background: var(--portal-surface);
}

.typing-shell {
    max-width: 1540px;
}

.exam-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.exam-meta span {
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.13);
}

.typing-workspace {
    min-height: 640px;
}

.module-selector .form-select {
    width: auto;
    min-width: 120px;
}

.test-toolbar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
}

.timer-pill {
    min-width: 130px;
    padding: 0.65rem 1.2rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--portal-primary), #06b6d4);
    color: #fff;
    font-size: 1.45rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 0.05em;
}

.passage-card {
    min-height: 220px;
    max-height: 320px;
    overflow-y: auto;
    padding: 1.25rem;
    border: 1px solid var(--portal-border);
    border-radius: 20px;
    background: var(--portal-surface-solid);
    line-height: 2;
    font-size: 1.14rem;
    word-break: break-word;
}

.passage-char {
    border-radius: 4px;
    padding: 0.08rem 0.02rem;
}

.passage-char.correct {
    color: var(--portal-success);
    background: rgba(22, 163, 74, 0.10);
}

.passage-char.incorrect {
    color: var(--portal-danger);
    background: rgba(220, 38, 38, 0.14);
}

.passage-char.current {
    color: var(--portal-text);
    background: rgba(245, 158, 11, 0.24);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}

.space-char {
    min-width: 0.38rem;
    display: inline-block;
}

.typing-input {
    width: 100%;
    min-height: 170px;
    margin-top: 1rem;
    padding: 1rem;
    border: 2px solid transparent;
    border-radius: 20px;
    outline: none;
    resize: vertical;
    font-size: 1.12rem;
    line-height: 1.7;
    color: var(--portal-text);
    background: var(--portal-surface-solid);
    box-shadow: inset 0 0 0 1px var(--portal-border);
}

.typing-input:focus {
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.16);
}

.stats-sticky {
    position: sticky;
    top: 90px;
}

.live-stat {
    padding: 1rem;
}

.result-message {
    border-radius: 18px;
}

.virtual-keyboard {
    display: grid;
    gap: 0.45rem;
}

.keyboard-row {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}

.keyboard-key {
    flex: 0 1 50px;
    font-weight: 700;
    transition: transform 0.08s ease, background 0.12s ease, color 0.12s ease;
}

.keyboard-key small {
    display: block;
    font-size: 0.72rem;
    color: var(--portal-muted);
    margin-left: 0.25rem;
}

.keyboard-key.space-key {
    flex-basis: 42%;
}

.keyboard-key.active {
    transform: translateY(3px) scale(0.97);
    background: var(--portal-primary);
    color: #fff;
}

.keyboard-key.next {
    outline: 3px solid rgba(245, 158, 11, 0.38);
    background: rgba(245, 158, 11, 0.14);
}

.hands-guide {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.65rem;
}

.finger {
    min-height: 92px;
    border: 1px solid var(--portal-border);
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: var(--portal-surface-solid);
    transition: transform 0.18s ease, border 0.18s ease;
}

.finger span {
    width: 26px;
    height: 44px;
    border-radius: 999px 999px 14px 14px;
    background: linear-gradient(180deg, rgba(79, 70, 229, 0.22), rgba(6, 182, 212, 0.22));
    display: block;
}

.finger small {
    color: var(--portal-muted);
    font-size: 0.68rem;
    text-align: center;
}

.finger.active {
    transform: translateY(-5px);
    border-color: rgba(245, 158, 11, 0.75);
    box-shadow: 0 14px 28px rgba(245, 158, 11, 0.20);
}

.finger.active span {
    background: linear-gradient(180deg, #fbbf24, #f97316);
    animation: fingerPulse 0.6s ease infinite alternate;
}

@keyframes fingerPulse {
    from { transform: scaleY(1); }
    to { transform: scaleY(1.08); }
}

.devlys-text {
    font-family: "DevLys 010", "Kruti Dev 010", "Mangal", "Noto Sans Devanagari", system-ui, sans-serif;
}

.lesson-level {
    color: var(--portal-muted);
    font-size: 0.85rem;
}

.lesson-snippet {
    padding: 0.9rem;
    border-radius: 16px;
    background: var(--portal-surface-solid);
    border: 1px solid var(--portal-border);
    color: var(--portal-muted);
    min-height: 80px;
}

.filter-pills .btn {
    border-radius: 999px;
}

.leaderboard-hero,
.admin-title {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
}

.rank-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    font-weight: 800;
    background: var(--portal-surface-solid);
    border: 1px solid var(--portal-border);
}

.rank-1 {
    background: linear-gradient(135deg, #fbbf24, #f97316);
    color: #111827;
}

.rank-2 {
    background: linear-gradient(135deg, #e5e7eb, #94a3b8);
    color: #111827;
}

.rank-3 {
    background: linear-gradient(135deg, #d97706, #92400e);
    color: #fff;
}

.current-student-row {
    --bs-table-bg: rgba(22, 163, 74, 0.08);
}

.admin-search {
    display: flex;
    gap: 0.5rem;
    min-width: min(100%, 440px);
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--portal-text);
    --bs-table-border-color: var(--portal-border);
}

.table thead th {
    color: var(--portal-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.form-control,
.form-select {
    border-color: var(--portal-border);
    background-color: var(--portal-surface-solid);
    color: var(--portal-text);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.16);
}

@media (max-width: 991.98px) {
    .hero-section {
        padding-top: 3rem;
    }

    .rssb-exam-header,
    .leaderboard-hero,
    .admin-title {
        align-items: stretch;
        flex-direction: column;
    }

    .stats-sticky {
        position: static;
    }

    .module-selector .form-select {
        flex: 1 1 120px;
    }
}

@media (max-width: 767.98px) {
    .hero-stats,
    .test-toolbar,
    .admin-search {
        flex-direction: column;
    }

    .keyboard-row {
        gap: 0.22rem;
    }

    .keyboard-key {
        min-width: 28px;
        min-height: 36px;
        border-radius: 9px;
        font-size: 0.78rem;
    }

    .keyboard-key small {
        display: none;
    }

    .hands-guide {
        grid-template-columns: repeat(3, 1fr);
    }

    .passage-card {
        font-size: 1rem;
        max-height: 280px;
    }
}
