:root {
    --primary: #1a1a3e;
    --primary-light: #2d2a5e;
    --secondary: #6c2bd9;
    --accent: #c9a84c;
    --accent-light: #e8d5a3;
    --dark: #0f0e1a;
    --light: #f8f6f0;
    --success: #2d8f6f;
    --warning: #c97d2b;
    --error: #a83232;
    --binary: #2d5f8f;
    --octal: #6c2bd9;
    --hex: #2d8f6f;
    --decimal: #c97d2b;
    --gold: #c9a84c;
    --gold-bg: rgba(201,168,76,0.12);
    --shadow: 0 8px 32px rgba(15,14,26,0.25);
    --shadow-hover: 0 12px 48px rgba(15,14,26,0.35);
    --border: rgba(26,26,62,0.08);
    --border2: rgba(26,26,62,0.15);
    --radius: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(145deg, #0f0e1a 0%, #1a1a3e 40%, #2d2a5e 100%);
    color: var(--dark);
    min-height: 100vh;
    line-height: 1.6;
    background-attachment: fixed;
}

.app-container {
    max-width: 1400px;
    margin: 20px auto;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px rgba(15,14,26,0.4);
    overflow: hidden;
    min-height: calc(100vh - 40px);
    border: 1px solid rgba(201,168,76,0.1);
}

.header {
    background: linear-gradient(145deg, #1a1a3e, #2d2a5e);
    color: white;
    padding: 2.5rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 50%, rgba(201,168,76,0.08) 0%, transparent 60%);
    pointer-events: none;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent), var(--secondary), var(--accent), transparent);
    opacity: 0.6;
}

.logo {
    font-size: 3.2rem;
    margin-bottom: 0.5rem;
    display: inline-block;
    animation: bounce 2s infinite;
    filter: drop-shadow(0 4px 12px rgba(201,168,76,0.3));
}

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

h1 {
    font-size: 3.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 30%, var(--accent-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    margin-bottom: 0.25rem;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.85;
    font-weight: 300;
    color: rgba(255,255,255,0.8);
}

.welcome-banner {
    background: linear-gradient(135deg, rgba(26,26,62,0.06), rgba(108,43,217,0.06));
    border: 1px solid rgba(201,168,76,0.15);
    color: var(--dark);
    padding: 1.5rem;
    margin: 1.5rem 2rem;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: 0 4px 20px rgba(201,168,76,0.06);
}

.welcome-banner h2 {
    color: var(--primary);
    font-weight: 600;
}

/* ===== LAYOUT — PRESERVED ===== */
.main-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 600px;
}

.sidebar {
    background: var(--light);
    padding: 2rem 1rem;
    border-right: 1px solid var(--border);
    /* No flex — keeps original vertical layout */
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.9rem 1.5rem;
    margin: 0.4rem 0;
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1.5px solid transparent;
    font-weight: 500;
    color: var(--dark);
    box-shadow: 0 2px 8px rgba(15,14,26,0.04);
}

.nav-item:hover {
    transform: translateX(6px);
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(201,168,76,0.15);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 20px rgba(108,43,217,0.3);
    border-color: var(--accent);
}

.nav-icon {
    margin-right: 1rem;
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.content-area {
    padding: 2rem;
    background: white;
}

.module {
    display: none;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.module.active { display: block; }

.module-header {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.module-icon {
    font-size: 2rem;
    margin-right: 1rem;
    color: var(--primary);
}

.module-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
}

.calculator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.calc-card {
    background: var(--light);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.calc-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--secondary));
}

.calc-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent);
}

.calc-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--dark);
}

.input-group { margin: 1rem 0; }

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark);
}

input, select, button, textarea {
    width: 100%;
    padding: 0.9rem 1.2rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}

button {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    margin-top: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(108,43,217,0.25);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(108,43,217,0.35);
}

.result {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f0edf8, #f8f6f0);
    border-radius: var(--radius);
    border-left: 4px solid var(--accent);
    font-weight: 600;
    font-size: 1.1rem;
}

.number-system-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.system-card {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.system-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 32px rgba(0,0,0,0.2);
}

.system-card small {
    opacity: 0.8;
    font-weight: 400;
}

.binary { background: linear-gradient(145deg, var(--binary), #1a4a7a); }
.octal { background: linear-gradient(145deg, var(--octal), #5a1aaa); }
.hex { background: linear-gradient(145deg, var(--hex), #1a6a5a); }
.decimal { background: linear-gradient(145deg, var(--decimal), #a0601a); }

.system-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* ===== EXERCISES ===== */
.exercise-container {
    background: linear-gradient(135deg, #f0edf8, #e8e4f0);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin: 2rem 0;
    border: 1px solid rgba(201,168,76,0.1);
}

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

.exercise-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

.difficulty-badge {
    padding: 0.4rem 1.2rem;
    border-radius: 100px;
    font-weight: 600;
    font-size: 0.8rem;
}

.difficulty-beginner { background: var(--success); color: white; }
.difficulty-intermediate { background: var(--warning); color: white; }
.difficulty-advanced { background: var(--error); color: white; }

.exercise-content {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    margin: 1rem 0;
}

/* ===== QUIZ ===== */
.quiz-container { max-width: 800px; margin: 0 auto; }

.quiz-progress {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    margin: 1.5rem 0;
    overflow: hidden;
}

.quiz-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--secondary));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.quiz-question {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    margin: 1.5rem 0;
}

.question-text {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--dark);
}

.exercise-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.exercise-option {
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.exercise-option:hover {
    border-color: var(--accent);
    background: var(--gold-bg);
}

.exercise-option.selected {
    border-color: var(--success);
    background: rgba(45,143,111,0.08);
}

.exercise-option.correct {
    border-color: var(--success);
    background: rgba(45,143,111,0.12);
}

.exercise-option.incorrect {
    border-color: var(--error);
    background: rgba(168,50,50,0.08);
}

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 4px 16px rgba(15,14,26,0.06);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 8px 24px rgba(201,168,76,0.1);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.25rem;
}

.stat-label {
    color: #64748b;
    font-weight: 500;
    font-size: 0.9rem;
}

/* ===== LEARNING GUIDE ===== */
.learning-guide {
    background: linear-gradient(135deg, #f0edf8, #e8e4f0);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin: 2rem 0;
    border-left: 6px solid var(--accent);
}

.guide-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
}

.guide-icon {
    font-size: 2rem;
    margin-right: 1rem;
    color: var(--accent);
}

.guide-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

.guide-content { line-height: 1.8; }

.guide-step {
    background: white;
    padding: 1.5rem;
    margin: 1rem 0;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

.guide-step h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.example-box {
    background: #f8f6f0;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 1rem 0;
}

.example-title {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.hint {
    background: #fef9e7;
    border: 1px solid #f9e79f;
    padding: 0.75rem;
    border-radius: var(--radius);
    margin: 0.5rem 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.step-by-step {
    background: #f8f6f0;
    border-left: 4px solid var(--primary);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* ===== ACHIEVEMENTS ===== */
.achievement-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, var(--success), #1a6a5a);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 100px;
    margin: 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(45,143,111,0.3);
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 1rem;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .nav-item {
        flex: 1 1 auto;
        padding: 0.7rem 1.2rem;
        margin: 0;
        font-size: 0.85rem;
        min-width: auto;
    }
    .nav-item:hover {
        transform: none;
    }
}

@media (max-width: 768px) {
    .header { padding: 1.5rem; }
    h1 { font-size: 2rem; }
    .logo { font-size: 2.4rem; }
    .calculator-grid, .number-system-grid {
        grid-template-columns: 1fr;
    }
    .welcome-banner {
        margin: 1rem;
        padding: 1rem;
    }
    .content-area {
        padding: 1rem;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .sidebar {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        padding: 0.8rem;
    }
    .nav-item {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
        flex: 1 1 auto;
        min-width: 60px;
    }
    .nav-icon {
        margin-right: 0.4rem;
        font-size: 0.9rem;
        width: auto;
    }
}
