:root {
    /* Color Palette - Apple Antik */
    --bg-primary: #fbfbfd;
    --bg-secondary: #f2f2f7;
    --bg-card: rgba(255, 255, 255, 0.85);

    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-accent: #8b7355;
    /* Antique Bronze/Gold */

    --accent-gold: #ceb175;
    --accent-red: #8b2525;
    /* Roman Red */
    --accent-red-light: #fce8e8;

    --success: #34c759;
    --success-light: #e0f8e5;
    --error: #ff3b30;
    --error-light: #ffe5e4;

    /* Typography */
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Cinzel', serif;

    /* Effects */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px rgba(89, 74, 54, 0.12);
    /* Slightly warm shadow */
    --blur: blur(20px);
    --radius-sm: 6px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-primary);
    background-image: radial-gradient(circle at top right, rgba(206, 177, 117, 0.05) 0%, transparent 40%),
        radial-gradient(circle at bottom left, rgba(139, 37, 37, 0.03) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Navigation --- */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(251, 251, 253, 0.7);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-accent);
}

.logo ion-icon {
    font-size: 1.5rem;
}

.nav-links {
    display: flex;
    gap: 32px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.nav-links a:hover {
    color: var(--text-primary);
}

.nav-links a.active {
    color: var(--text-primary);
}

.nav-links a.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.badge {
    background: var(--bg-secondary);
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

/* --- User Stats Header --- */
.user-stats {
    display: flex;
    align-items: center;
    gap: 16px;
}

.level-indicator {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-accent);
}

.xp-bar-container {
    width: 100px;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.xp-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), #e8c784);
    box-shadow: 0 0 10px rgba(206, 177, 117, 0.5);
    transition: width 0.5s ease-out;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.icon-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--error);
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
}

.hidden {
    display: none !important;
}

/* --- Main Structure --- */
.app-container {
    max-width: 1200px;
    margin: 100px auto 40px;
    padding: 0 24px;
}

.module-header {
    text-align: center;
    margin-bottom: 48px;
}

.module-header h1 {
    font-size: 3rem;
    letter-spacing: 2px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.module-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* --- Layouts --- */
.dashboard {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
}

.card {
    background: var(--bg-card);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 32px;
}

.card-header {
    margin-bottom: 24px;
}

.card-header h2 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.card-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.card-body-child {
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 16px;

    padding: 16px;
    border-radius: var(--radius-md);
}

/* --- Options Grid --- */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.training-option {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.training-option:hover:not(.disabled-option) {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-gold);
}

.option-icon {
    font-size: 2rem;
    color: var(--text-accent);
    background: rgba(139, 115, 85, 0.1);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.training-option h3 {
    font-size: 1.1rem;
    margin: 0;
    font-family: var(--font-ui);
    /* keep UI font here for readability */
}

.training-option p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0;
}

.disabled-option {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-secondary);
}

/* --- Side Widget --- */
.widget-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.widget-header h3 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.widget-body {
    text-align: center;
}

.main-level {
    font-family: var(--font-heading);
    font-size: 4rem;
    line-height: 1;
    color: var(--accent-gold);
    margin-bottom: 8px;
    text-shadow: 0 4px 12px rgba(206, 177, 117, 0.3);
}

.level-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.xp-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.recent-achievements {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* --- Exercise View --- */
.exercise-view {
    max-width: 800px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.score-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-gold);
    font-weight: 600;
}

.secondary-btn {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.secondary-btn:hover {
    background: var(--bg-secondary);
}

.primary-btn {
    background: var(--text-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: #000;
}

.exercise-card {
    text-align: center;
    padding: 48px 32px;
}

.task-prompt {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.word-display {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    color: var(--text-primary);
    margin-bottom: 40px;
    letter-spacing: 1px;
}

/* UI for Multiple Choice form input */
.interactive-area {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 500px;
    margin: 0 auto;
}

.choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.choice-btn {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 16px;
    border-radius: 12px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
}

.choice-btn:hover {
    border-color: var(--text-accent);
    background: rgba(139, 115, 85, 0.05);
}

.choice-btn.correct {
    background: var(--success-light);
    border-color: var(--success);
    color: #1a632d;
}

.choice-btn.wrong {
    background: var(--error-light);
    border-color: var(--error);
    color: #8a1d17;
}

.feedback-area {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: slideUp 0.3s ease-out;
}

.feedback-message {
    font-weight: 500;
    font-size: 1.1rem;
}

.feedback-message.success {
    color: var(--success);
}

.feedback-message.error {
    color: var(--error);
}

/* --- Summary View --- */
.summary-view {
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

.summary-card {
    text-align: center;
    padding: 48px;
}

.summary-card h1 {
    font-size: 2.5rem;
    margin-bottom: 40px;
}

.summary-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
}

.stat-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 4px solid var(--bg-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stat-circle.gold {
    border-color: var(--accent-gold);
    background: linear-gradient(135deg, rgba(206, 177, 117, 0.1), transparent);
}

.stat-val {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-circle.gold .stat-val {
    color: var(--accent-gold);
}

.stat-lbl {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Modals & Badges --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: rgba(251, 251, 253, 0.9);
    backdrop-filter: blur(10px);
}

.modal-body {
    padding: 32px;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 24px;
}

.badge-item {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 0.4;
    transition: var(--transition);
    filter: grayscale(100%);
}

.badge-item.unlocked {
    opacity: 1;
    filter: grayscale(0%);
}

.badge-item.unlocked:hover {
    transform: translateY(-4px);
}

.badge-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e8c784, var(--accent-gold));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    box-shadow: var(--shadow-sm);
}

.badge-item:not(.unlocked) .badge-icon {
    background: #e5e5ea;
    color: #8e8e93;
}

.badge-info h4 {
    font-size: 0.9rem;
    margin-bottom: 4px;
    font-family: var(--font-ui);
}

.badge-info p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

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

/* Responsive */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .module-header h1 {
        font-size: 2.2rem;
    }

    .word-display {
        font-size: 2.5rem;
    }

    .summary-stats {
        flex-direction: column;
        align-items: center;
    }
}

/* --- Tense Info Cards --- */
.tense-card, .declension-card {
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.tense-card:hover, .declension-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-gold) !important;
}

.tense-card::after, .declension-card::after {
    content: '';
    position: absolute;
    top: 16px;
    right: 16px;
    width: 24px;
    height: 24px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%238b7355"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"></path></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0;
    transition: var(--transition);
    transform: translateX(-10px);
}

.tense-card:hover::after, .declension-card:hover::after {
    opacity: 0.5;
    transform: translateX(0);
}

/* --- Rule Tables --- */
.rules-table-container {
    margin-bottom: 24px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.rules-table-container h4 {
    background: var(--bg-secondary);
    padding: 12px 16px;
    margin: 0;
    font-size: 1.05rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.rules-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.rules-table th,
.rules-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.rules-table tr:last-child td {
    border-bottom: none;
}

.rules-table th {
    background: rgba(0, 0, 0, 0.02);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.rules-table td:nth-child(2) {
    font-weight: 600;
    color: var(--accent-gold);
}


.verb-select {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(220, 220, 220, 0.8);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    outline: none;
}

.start-training-btn {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);

    justify-content: center;
    align-items: center;

    width: 100%;
    padding: 14px;
    font-family: var(--font-ui);

    gap: 8px;
}

.start-training-btn:hover {

    border: 1px solid var(--accent-gold);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}