:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --surface-light: rgba(255, 255, 255, 0.05);
    --surface-border: rgba(255, 255, 255, 0.1);
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --accent: #f43f5e;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --error: #ef4444;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    --radius-lg: 1.5rem;
    --radius-md: 1rem;
    --radius-sm: 0.5rem;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1.5;
}

.app-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: relative;
}

@media (min-width: 600px) {
    .app-container {
        padding: 3rem 10%;
        min-height: 100vh;
        background: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
}

.header {
    margin-bottom: 2rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(to right, #a855f7, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
    text-align: left;
}

/* Tabs */
.nav-tabs {
    display: flex;
    background: var(--surface-light);
    border-radius: var(--radius-md);
    padding: 0.35rem;
    margin-bottom: 2rem;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Views */
.content-area {
    flex: 1;
    position: relative;
}

.view-section {
    display: none;
    height: 100%;
    flex-direction: column;
    animation: fadeIn 0.4s ease forwards;
}

.view-section.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.view-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Controls */
.glass-select {
    background: var(--surface-light);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    appearance: none;
}

.glass-select.small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.glass-select.full-width {
    width: 100%;
}

select option {
    background: #1e1b4b;
    color: white;
}

.glass-btn {
    background: var(--surface-light);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.glass-btn.primary {
    background: var(--primary);
    border-color: var(--primary);
}

.glass-btn.primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.4);
}

.glass-btn.large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.glass-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.glass-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.icon-btn:hover {
    color: var(--primary);
    background: var(--surface-light);
}

/* Utilities */
.mb-4 {
    margin-bottom: 1rem;
}

.mt-4 {
    margin-top: 1rem;
}

.w-full {
    width: 100%;
}

.center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    gap: 1.5rem;
}

.hidden {
    display: none !important;
}

.badge {
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 1rem;
    vertical-align: super;
}

/* Flashcards */
.flashcard-container {
    perspective: 1000px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
}

.flashcard {
    width: 100%;
    height: 300px;
    max-width: 350px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.flashcard.is-flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    transform: translateZ(0);
}

.flashcard-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(236, 72, 153, 0.1));
    border-color: rgba(139, 92, 246, 0.3);
}

.card-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.card-word {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.counter {
    font-family: var(--font-heading);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Quiz UI */
.quiz-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-bottom: 2rem;
}

.quiz-status {
    color: var(--primary);
    font-weight: 600;
    font-family: var(--font-heading);
}

.progress-bar {
    height: 6px;
    background: var(--surface-light);
    border-radius: 3px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success);
    width: 100%;
    transition: width 0.1s linear, background-color 0.3s;
}

.question-container {
    text-align: center;
    margin-bottom: 2rem;
}

.quiz-word {
    font-size: 2.5rem;
    margin-top: 0.5rem;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.option-btn {
    background: var(--surface-light);
    border: 1px solid var(--surface-border);
    padding: 1rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.option-btn.correct {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
}

.option-btn.wrong {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--error);
}

.final-score {
    font-size: 2rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--primary);
}

.setup-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    text-align: center;
}

.memory-dashboard {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.memory-dashboard h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--surface-border);
    padding-bottom: 0.5rem;
}

.memory-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.memory-card h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.memory-card ul {
    list-style-position: inside;
    font-size: 0.85rem;
    color: var(--text-main);
}

.memory-card ul li {
    margin-bottom: 0.25rem;
}

.italian-flag-text {
    background: linear-gradient(to right, #009246 0%, #009246 33%, #ffffff 33%, #ffffff 66%, #ce2b37 66%, #ce2b37 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Conversation UI */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--surface-border);
    min-height: 400px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-right: 0.5rem;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.bubble {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.95rem;
    line-height: 1.4;
    animation: fadeIn 0.3s ease;
}

.bubble.tutor {
    align-self: flex-start;
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-bottom-left-radius: 0.25rem;
}

.bubble.student {
    align-self: flex-end;
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-bottom-right-radius: 0.25rem;
}

.bubble.system {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
}

.chat-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.mic-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--surface-light);
    border: 2px solid var(--surface-border);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mic-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.mic-btn.listening {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--error);
    color: var(--error);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.mic-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    height: 1.2rem;
}

.transcript-preview {
    min-height: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.5rem;
}

/* Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: var(--bg-gradient);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.setting-group label {
    font-weight: 600;
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.help-text a:hover {
    text-decoration: underline;
}