/* ========================================
   VOXQUIZ - GLOBAL STYLES
======================================== */

:root {
    --bg: #0b0a12;
    --bg-secondary: #100e1b;
    --surface: #151321;
    --surface-light: #1c192b;
    --surface-hover: #242036;
    --border: #2c2740;
    --primary: #a78bfa;
    --primary-light: #c4b5fd;
    --primary-dark: #7c3aed;
    --primary-glow: rgba(167, 139, 250, 0.16);
    --text: #f5f3ff;
    --text-secondary: #b5afc9;
    --muted: #817a98;
    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.12);
    --danger: #fb7185;
    --danger-bg: rgba(251, 113, 133, 0.12);
    --sidebar-width: 260px;
    --radius: 16px;
    --radius-small: 10px;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient( circle at 70% 0%, rgba(124, 58, 237, 0.09), transparent 35% ), var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

    button:focus-visible,
    select:focus-visible,
    input:focus-visible {
        outline: 2px solid var(--primary-light);
        outline-offset: 3px;
    }

    button:disabled {
        cursor: not-allowed;
        opacity: 0.45;
    }

[hidden] {
    display: none !important;
}

::selection {
    background: rgba(167, 139, 250, 0.35);
    color: white;
}

/* ========================================
   APP LAYOUT
======================================== */

.app-shell {
    min-height: 100vh;
}

.main-shell {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.content {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 42px 48px 24px;
    flex: 1;
}

    .content > section {
        width: 100%;
        animation: fade-in 0.25s ease;
    }

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   SIDEBAR
======================================== */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;
    width: var(--sidebar-width);
    padding: 24px 17px;
    display: flex;
    flex-direction: column;
    background: rgba(16, 14, 27, 0.97);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    transition: transform 0.25s ease;
}

.sidebar-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 5px 28px;
}

.brand-icon {
    width: 43px;
    height: 43px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: linear-gradient( 135deg, var(--primary-dark), var(--primary) );
    box-shadow: 0 5px 20px rgba(124, 58, 237, 0.24);
}

    .brand-icon span {
        font-size: 23px;
        font-weight: 800;
        color: white;
    }

.brand-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

    .brand-text strong {
        font-size: 18px;
        letter-spacing: -0.5px;
    }

    .brand-text small {
        color: var(--muted);
        font-size: 11px;
    }

.online-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.35);
}

.sidebar-label {
    margin: 10px 9px 12px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.6px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    width: 100%;
    min-height: 46px;
    padding: 11px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

    .nav-item:hover {
        background: var(--surface-light);
        color: var(--text);
    }

    .nav-item.active {
        background: var(--primary-glow);
        border-color: rgba(167, 139, 250, 0.18);
        color: var(--primary-light);
    }

.nav-icon {
    width: 23px;
    flex-shrink: 0;
    display: inline-grid;
    place-items: center;
    font-size: 18px;
}

.sidebar-bottom {
    margin-top: auto;
    padding-top: 28px;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.stat-box {
    padding: 13px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

    .stat-box strong {
        font-size: 22px;
        color: var(--primary-light);
    }

    .stat-box span {
        color: var(--muted);
        font-size: 11px;
    }

.sidebar-note {
    margin: 16px 4px 0;
    color: var(--muted);
    font-size: 11px;
}

.close-menu {
    display: none !important;
}

.sidebar-overlay {
    display: none;
}

/* ========================================
   TOPBAR
======================================== */

.topbar {
    min-height: 73px;
    padding: 14px 35px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid rgba(44, 39, 64, 0.7);
    background: rgba(11, 10, 18, 0.65);
    backdrop-filter: blur(16px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text-secondary);
    font-size: 12px;
}

.icon-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
    transition: background 0.2s ease;
}

    .icon-button:hover {
        background: var(--surface-hover);
    }

.menu-button {
    display: none;
}

.hamburger {
    font-size: 18px;
}

.mobile-brand {
    display: none;
    font-size: 18px;
    font-weight: 800;
}

    .mobile-brand span {
        color: var(--primary-light);
    }

/* ========================================
   TYPOGRAPHY
======================================== */

.eyebrow {
    margin-bottom: 10px;
    color: var(--primary-light);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    font-size: clamp(27px, 3vw, 40px);
    font-weight: 750;
    line-height: 1.2;
    letter-spacing: -1.2px;
}

h2 {
    line-height: 1.35;
}

h3 {
    line-height: 1.4;
}

.hero-description {
    max-width: 650px;
    margin: 17px 0 30px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.8;
}

/* ========================================
   DASHBOARD
======================================== */

.welcome-section {
    padding-top: 22px;
}

.hero-icon {
    width: 55px;
    height: 55px;
    margin-bottom: 23px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(167, 139, 250, 0.22);
    border-radius: 17px;
    background: var(--primary-glow);
    color: var(--primary-light);
    font-size: 28px;
}

.welcome-section h1 span {
    color: var(--primary-light);
}

.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    max-width: 850px;
}

.suggestion-card {
    min-height: 92px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient( 145deg, rgba(28, 25, 43, 0.96), rgba(21, 19, 33, 0.96) );
    text-align: left;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

    .suggestion-card:hover {
        transform: translateY(-3px);
        border-color: rgba(167, 139, 250, 0.55);
        background: var(--surface-light);
    }

.suggestion-emoji {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: var(--primary-glow);
    font-size: 23px;
}

.suggestion-card > span:nth-child(2) {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.suggestion-card strong {
    font-size: 13px;
}

.suggestion-card small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.card-arrow {
    margin-left: auto;
    color: var(--muted);
    font-size: 18px;
}

.primary-button,
.secondary-button {
    min-height: 43px;
    padding: 11px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.primary-button {
    background: linear-gradient( 135deg, var(--primary-dark), #8b5cf6 );
    color: white;
    box-shadow: 0 5px 18px rgba(124, 58, 237, 0.15);
}

    .primary-button:hover:not(:disabled) {
        transform: translateY(-1px);
        background: linear-gradient( 135deg, #8b5cf6, #a78bfa );
    }

.secondary-button {
    border-color: var(--border);
    background: var(--surface-light);
    color: var(--text-secondary);
}

    .secondary-button:hover:not(:disabled) {
        border-color: var(--primary);
        color: var(--text);
    }

.hero-start {
    margin-top: 25px;
}

/* ========================================
   QUIZ
======================================== */

.quiz-heading {
    margin-bottom: 25px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

    .quiz-heading p {
        margin: 8px 0 0;
        color: var(--text-secondary);
        font-size: 13px;
    }

.quiz-chip {
    padding: 9px 12px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--primary-light);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.7px;
}

.quiz-card {
    max-width: 900px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 19px;
    background: linear-gradient( 145deg, rgba(24, 21, 38, 0.98), rgba(17, 15, 27, 0.98) );
    box-shadow: var(--shadow);
}

.progress-meta {
    margin-bottom: 9px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
}

    .progress-meta strong {
        color: var(--primary-light);
    }

.progress-track {
    width: 100%;
    height: 6px;
    overflow: hidden;
    border-radius: 20px;
    background: #2b263b;
}

.progress-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient( 90deg, var(--primary-dark), var(--primary-light) );
    transition: width 0.3s ease;
}

.question-number {
    margin-top: 34px;
    color: var(--primary-light);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
}

#question-text {
    margin: 10px 0;
    font-size: clamp(20px, 2.3vw, 27px);
    font-weight: 700;
    line-height: 1.5;
}

.question-hint {
    margin: 9px 0 22px;
    color: var(--muted);
    font-size: 12px;
}

.answers {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.answer {
    min-width: 0;
    min-height: 64px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

    .answer:hover:not(:disabled) {
        transform: translateY(-1px);
        border-color: var(--primary);
        background: var(--surface-hover);
    }

.answer-letter {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--primary-light);
    font-size: 12px;
    font-weight: 800;
}

.answer-text {
    font-size: 13px;
    overflow-wrap: anywhere;
}

.answer.correct {
    border-color: rgba(74, 222, 128, 0.6);
    background: var(--success-bg);
    color: #dcfce7;
}

    .answer.correct .answer-letter {
        border-color: var(--success);
        color: var(--success);
    }

.answer.wrong {
    border-color: rgba(251, 113, 133, 0.6);
    background: var(--danger-bg);
    color: #ffe4e6;
}

    .answer.wrong .answer-letter {
        border-color: var(--danger);
        color: var(--danger);
    }

.answer.selected {
    box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.1);
}

.feedback {
    min-height: 44px;
    margin-top: 17px;
    padding: 11px 13px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--text-secondary);
    font-size: 12px;
}

    .feedback.success {
        border-color: rgba(74, 222, 128, 0.2);
        background: var(--success-bg);
        color: var(--success);
    }

    .feedback.error {
        border-color: rgba(251, 113, 133, 0.2);
        background: var(--danger-bg);
        color: #fda4af;
    }

.quiz-actions {
    margin-top: 17px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.voice-panel {
    margin-top: 25px;
    padding: 17px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: rgba(10, 9, 17, 0.45);
}

.mic-orb {
    width: 43px;
    height: 43px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border: 1px solid rgba(167, 139, 250, 0.25);
    border-radius: 50%;
    background: var(--primary-glow);
    font-size: 19px;
}

    .mic-orb.listening {
        animation: mic-pulse 1.3s infinite;
    }

@keyframes mic-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.3);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(167, 139, 250, 0);
    }
}

.voice-copy {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

    .voice-copy strong {
        font-size: 12px;
    }

    .voice-copy span {
        color: var(--muted);
        font-size: 11px;
    }

.voice-toggle {
    min-height: 36px;
    padding: 8px 12px;
    flex-shrink: 0;
    border: 1px solid rgba(167, 139, 250, 0.3);
    border-radius: 9px;
    background: var(--primary-glow);
    color: var(--primary-light);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

    .voice-toggle:hover:not(:disabled) {
        background: rgba(167, 139, 250, 0.25);
    }

.command-help {
    max-width: 900px;
    margin-top: 23px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: rgba(21, 19, 33, 0.55);
}

.command-title {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.3px;
}

.command-list {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

    .command-list span {
        padding: 7px 10px;
        border: 1px solid var(--border);
        border-radius: 7px;
        background: var(--surface);
        color: var(--text-secondary);
        font-size: 11px;
    }

/* ========================================
   RESULTS
======================================== */

.result-card {
    max-width: 570px;
    margin: 25px auto;
    padding: 38px 28px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: linear-gradient( 145deg, var(--surface-light), var(--surface) );
    box-shadow: var(--shadow);
    text-align: center;
}

.result-icon {
    width: 65px;
    height: 65px;
    margin: 0 auto 22px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(167, 139, 250, 0.3);
    border-radius: 20px;
    background: var(--primary-glow);
    color: var(--primary-light);
    font-size: 33px;
}

.result-card h1 {
    font-size: 30px;
}

.result-card > p {
    color: var(--text-secondary);
    font-size: 13px;
}

.score-circle {
    width: 155px;
    height: 155px;
    margin: 25px auto 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 6px solid rgba(167, 139, 250, 0.25);
    border-radius: 50%;
    background: var(--primary-glow);
    box-shadow: 0 0 35px rgba(124, 58, 237, 0.1);
}

    .score-circle strong {
        color: var(--primary-light);
        font-size: 40px;
        line-height: 1.2;
    }

    .score-circle span {
        margin-top: 5px;
        color: var(--muted);
        font-size: 9px;
        font-weight: 800;
        letter-spacing: 1px;
    }

.result-card .primary-button,
.result-card .secondary-button {
    width: 100%;
    margin-top: 10px;
}

/* ========================================
   STUDY MODE
======================================== */

.study-card {
    max-width: 900px;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.study-empty {
    padding: 25px 10px;
    text-align: center;
}

    .study-empty .hero-icon {
        margin: 0 auto 20px;
    }

    .study-empty h2 {
        margin-bottom: 8px;
    }

    .study-empty p {
        margin-bottom: 22px;
        color: var(--text-secondary);
        font-size: 13px;
    }

.study-controls {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

    .study-controls label {
        color: var(--text-secondary);
        font-size: 12px;
    }

    .study-controls select {
        max-width: 100%;
        min-height: 40px;
        padding: 8px 12px;
        border: 1px solid var(--border);
        border-radius: 9px;
        background: var(--surface-light);
        color: var(--text);
    }

.study-card > h2 {
    margin: 12px 0 20px;
    font-size: 22px;
}

.study-card > ol {
    padding-left: 28px;
    color: var(--text-secondary);
}

    .study-card > ol li {
        margin: 9px 0;
        padding-left: 5px;
    }

.study-answer {
    margin-top: 22px;
    padding: 15px;
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: 10px;
    background: var(--success-bg);
    color: #bbf7d0;
    font-size: 13px;
}

.study-navigation {
    margin-top: 23px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ========================================
   ACHIEVEMENTS
======================================== */

.achievement-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
}

.achievement-card {
    min-width: 0;
    padding: 21px;
    border: 1px solid rgba(167, 139, 250, 0.35);
    border-radius: 15px;
    background: linear-gradient( 145deg, rgba(124, 58, 237, 0.12), var(--surface) );
    transition: transform 0.2s ease, border-color 0.2s ease;
}

    .achievement-card:hover {
        transform: translateY(-2px);
        border-color: var(--primary);
    }

    .achievement-card.locked {
        border-color: var(--border);
        background: var(--surface);
        opacity: 0.72;
    }

.achievement-icon,
.achievement-symbol {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--primary-glow);
    font-size: 24px;
}

.achievement-card h3,
.achievement-card strong {
    display: block;
    margin: 0 0 7px;
    font-size: 14px;
}

.achievement-card p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.7;
}

.achievement-status {
    display: inline-block;
    margin-top: 12px;
    color: var(--muted);
    font-size: 10px;
}

/* ========================================
   PROGRESS AND STATISTICS
======================================== */

.statistics-grid {
    margin: 27px 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 13px;
}

.stat-card {
    min-width: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.stat-card-icon {
    font-size: 21px;
}

.stat-card-label {
    color: var(--text-secondary);
    font-size: 11px;
}

.stat-card strong {
    color: var(--primary-light);
    font-size: 28px;
    line-height: 1.3;
}

.statistics-card {
    margin-bottom: 18px;
    padding: 23px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface);
}

    .statistics-card h2 {
        margin: 0 0 18px;
        font-size: 16px;
    }

    .statistics-card p {
        margin: 0;
        color: var(--text-secondary);
        font-size: 13px;
        line-height: 1.8;
    }

.category-stat {
    margin: 17px 0;
}

.category-stat-label {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

    .category-stat-label span {
        color: var(--text-secondary);
        font-size: 12px;
    }

    .category-stat-label strong {
        color: var(--primary-light);
        font-size: 11px;
        text-align: right;
    }

.category-stat-track {
    height: 7px;
    overflow: hidden;
    border-radius: 20px;
    background: #2b263b;
}

.category-stat-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient( 90deg, var(--primary-dark), var(--primary-light) );
    transition: width 0.3s ease;
}

/* ========================================
   QUIZ HISTORY
======================================== */

.history-description {
    margin: 12px 0 25px;
    color: var(--text-secondary);
    font-size: 13px;
}

.history-card {
    max-width: 950px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface);
}

    .history-card > p {
        margin: 0;
        color: var(--muted);
        font-size: 13px;
    }

.history-entry {
    padding: 15px 3px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    border-bottom: 1px solid var(--border);
}

    .history-entry:first-child {
        padding-top: 3px;
    }

    .history-entry:last-child {
        padding-bottom: 3px;
        border-bottom: none;
    }

    .history-entry > div {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .history-entry strong {
        font-size: 13px;
    }

    .history-entry small {
        color: var(--muted);
        font-size: 11px;
    }

    .history-entry > span {
        flex-shrink: 0;
        color: var(--primary-light);
        font-size: 16px;
        font-weight: 800;
    }

.history-section > .primary-button {
    margin-top: 20px;
}

/* ========================================
   FOOTER
======================================== */

.page-footer {
    margin-top: 50px;
    padding: 22px 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border-top: 1px solid rgba(44, 39, 64, 0.65);
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.2px;
}

    .page-footer > span:first-child {
        color: var(--primary-light);
    }

.footer-dot {
    color: var(--primary);
}

/* ========================================
   RESPONSIVE TABLET
======================================== */

@media (max-width: 1100px) {
    :root {
        --sidebar-width: 235px;
    }

    .content {
        padding: 35px 28px 22px;
    }

    .achievement-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .statistics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quiz-card {
        padding: 23px;
    }
}

/* ========================================
   RESPONSIVE MOBILE
======================================== */

@media (max-width: 760px) {
    .main-shell {
        margin-left: 0;
    }

    .sidebar {
        width: min(290px, 85vw);
        transform: translateX(-100%);
        box-shadow: none;
    }

        .sidebar.open {
            transform: translateX(0);
            box-shadow: 15px 0 50px rgba(0, 0, 0, 0.35);
        }

    .close-menu {
        display: grid !important;
        margin-left: auto;
    }

    .menu-button {
        display: grid;
    }

    .mobile-brand {
        display: block;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 999;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(3px);
    }

        .sidebar-overlay.visible {
            display: block;
        }

    .topbar {
        min-height: 64px;
        padding: 12px 18px;
    }

    .content {
        padding: 29px 19px 20px;
    }

    .welcome-section {
        padding-top: 10px;
    }

    .hero-description {
        margin-bottom: 24px;
    }

    .suggestion-grid {
        gap: 10px;
    }

    .suggestion-card {
        min-height: 85px;
        padding: 12px;
        gap: 10px;
    }

    .suggestion-emoji {
        width: 37px;
        height: 37px;
        font-size: 19px;
    }

    .suggestion-card strong {
        font-size: 11px;
    }

    .suggestion-card small {
        font-size: 10px;
    }

    .card-arrow {
        font-size: 14px;
    }

    .quiz-heading {
        flex-direction: column;
        gap: 13px;
    }

    .quiz-card {
        padding: 20px;
    }

    .answers {
        grid-template-columns: 1fr;
    }

    .answer {
        min-height: 57px;
    }

    .voice-panel {
        flex-wrap: wrap;
        padding: 13px;
    }

    .voice-copy {
        flex-basis: calc(100% - 65px);
    }

    .voice-toggle {
        width: 100%;
    }

    .achievement-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .achievement-card {
        padding: 15px;
    }

    .statistics-grid {
        gap: 10px;
    }

    .stat-card {
        padding: 15px;
    }

        .stat-card strong {
            font-size: 24px;
        }

    .statistics-card {
        padding: 18px;
    }

    .result-card {
        padding: 28px 20px;
    }

    .page-footer {
        margin-top: 35px;
        font-size: 8px;
    }
}

/* ========================================
   SMALL MOBILE
======================================== */

@media (max-width: 420px) {
    .topbar {
        padding: 11px 13px;
    }

    .topbar-status {
        max-width: 145px;
        font-size: 10px;
    }

    .content {
        padding: 24px 13px 18px;
    }

    h1 {
        font-size: 27px;
    }

    .suggestion-grid {
        grid-template-columns: 1fr;
    }

    .suggestion-card {
        min-height: 75px;
        padding: 13px;
    }

    .quiz-card {
        padding: 16px;
    }

    .quiz-actions {
        flex-direction: column;
    }

        .quiz-actions button {
            width: 100%;
        }

    .achievement-grid {
        grid-template-columns: 1fr;
    }

    .statistics-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stat-card {
        padding: 13px;
    }

    .stat-card-label {
        font-size: 10px;
    }

    .stat-card strong {
        font-size: 22px;
    }

    .study-card {
        padding: 17px;
    }

    .study-navigation {
        flex-direction: column;
    }

        .study-navigation button {
            width: 100%;
        }

    .history-card {
        padding: 14px;
    }

    .history-entry strong {
        font-size: 11px;
    }

    .history-entry > span {
        font-size: 14px;
    }
}

/* ========================================
   REDUCED MOTION ACCESSIBILITY
======================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== VOXQUIZ AI CHATBOT DESIGN ===== */

.chatbot-card {
    background: var(--card-bg, #171326);
    color: var(--text-primary, #f5f1ff);
    border: 1px solid var(--border-color, #34294b);
    border-radius: 20px;
    padding: 24px;
    margin-top: 28px;
    min-width: 0;
    overflow: hidden;
    box-shadow: 0 12px 35px rgba(0, 0, 0, .12);
}

.chatbot-header,
.chatbot-heading {
    display: flex;
    align-items: center;
}

.chatbot-header {
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 20px;
    border-bottom: 1px solid #34294b;
}

.chatbot-heading {
    gap: 12px;
}

.chatbot-avatar,
.message-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, #8758ff, #6136d9);
    color: white;
    font-weight: 800;
}

.chatbot-avatar {
    width: 46px;
    height: 46px;
    border-radius: 15px;
    font-size: 25px;
}

.chatbot-heading h2 {
    font-size: 1.12rem;
    margin: 0 0 5px;
}

.chatbot-heading p {
    margin: 0;
    font-size: .85rem;
    color: #aaa0bf;
}

.chatbot-status {
    white-space: nowrap;
    font-size: .78rem;
    color: #c0b5d7;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 5px;
    border-radius: 50%;
    background: #51d69b;
}

.chatbot-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 310px;
    overflow-y: auto;
    padding: 20px 2px;
    scrollbar-width: thin;
    scrollbar-color: #51416e transparent;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 9px;
}

.user-message {
    justify-content: flex-end;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    font-size: 17px;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 15px;
    border-radius: 15px;
    font-size: .92rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.assistant-message .message-bubble {
    background: #262039;
    border: 1px solid #34294b;
    border-top-left-radius: 5px;
}

.user-message .message-bubble {
    color: white;
    background: linear-gradient(135deg, #8050ef, #6539d5);
    border-top-right-radius: 5px;
}

.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.chat-suggestion {
    background: transparent;
    color: #c7b8e9;
    border: 1px solid #51416e;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: .8rem;
    cursor: pointer;
    transition: background .2s, border-color .2s;
}

    .chat-suggestion:hover {
        background: rgba(128, 80, 239, .12);
        border-color: #8050ef;
    }

.chatbot-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px;
    border: 1px solid #51416e;
    background: #100d1b;
    border-radius: 16px;
}

    .chatbot-form:focus-within {
        border-color: #8050ef;
        box-shadow: 0 0 0 3px rgba(128, 80, 239, .12);
    }

    .chatbot-form textarea {
        flex: 1;
        min-width: 0;
        max-height: 120px;
        resize: none;
        border: 0;
        outline: 0;
        background: transparent;
        color: inherit;
        font: inherit;
        font-size: .92rem;
        line-height: 1.5;
        padding: 9px 7px;
    }

        .chatbot-form textarea::placeholder {
            color: #9589ae;
        }

#chatbot-send {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #7849e8;
    color: white;
    cursor: pointer;
}

    #chatbot-send:hover {
        background: #916bfa;
    }

    #chatbot-send svg {
        width: 20px;
        height: 20px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    #chatbot-send:disabled {
        opacity: .65;
        cursor: wait;
    }

.chatbot-disclaimer {
    text-align: center;
    color: #9589ae;
    font-size: .74rem;
    margin: 12px 0 0;
}

@media (max-width: 600px) {
    .chatbot-card {
        padding: 16px;
        border-radius: 16px;
    }

    .chatbot-status {
        font-size: 0;
    }

    .chatbot-messages {
        height: 280px;
    }

    .message-bubble {
        max-width: 88%;
        font-size: .88rem;
    }

    .chat-suggestion {
        font-size: .76rem;
        padding: 7px 10px;
    }
}

/* ========================================
   VOXQUIZ CHATBOT VOICE CHAT
======================================== */

/* Microphone button */
#chatbot-mic {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #51416e;
    border-radius: 12px;
    background: #211a35;
    color: #c4b5fd;
    font-size: 19px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

    #chatbot-mic:hover:not(:disabled) {
        background: #342451;
        border-color: #a78bfa;
        transform: translateY(-1px);
    }

    #chatbot-mic:focus-visible {
        outline: 2px solid #c4b5fd;
        outline-offset: 3px;
    }

    /* Microphone active / listening state */
    #chatbot-mic.listening,
    #chatbot-mic.is-listening {
        background: rgba(251, 113, 133, 0.16);
        border-color: #fb7185;
        color: #fda4af;
        animation: chatbot-mic-pulse 1.2s infinite;
    }

@keyframes chatbot-mic-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.3);
    }

    50% {
        box-shadow: 0 0 0 7px rgba(251, 113, 133, 0);
    }
}

/* Voice settings row */
.chatbot-voice-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(16, 14, 27, 0.75);
}

.chatbot-speak-toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

    .chatbot-speak-toggle input {
        width: 16px;
        height: 16px;
        margin: 0;
        accent-color: var(--primary);
        cursor: pointer;
    }

/* Stop text-to-speech button */
#chatbot-stop-speaking {
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-light);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

    #chatbot-stop-speaking:hover {
        border-color: var(--danger);
        background: var(--danger-bg);
        color: #fda4af;
    }

/* Thinking indicator */
.chat-loading .message-bubble {
    color: var(--primary-light);
    animation: chatbot-thinking 1.2s ease-in-out infinite;
}

@keyframes chatbot-thinking {
    0%, 100% {
        opacity: 0.55;
    }

    50% {
        opacity: 1;
    }
}

/* Keyboard and touch accessibility */
#chatbot-mic:disabled,
#chatbot-stop-speaking:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Mobile voice controls */
@media (max-width: 600px) {
    .chatbot-voice-controls {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }

    #chatbot-stop-speaking {
        width: 100%;
        min-height: 38px;
    }

    #chatbot-mic,
    #chatbot-send {
        width: 40px;
        height: 40px;
        border-radius: 11px;
    }

    .chatbot-form {
        gap: 7px;
        padding: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #chatbot-mic.listening,
    #chatbot-mic.is-listening,
    .chat-loading .message-bubble {
        animation: none;
    }
}
