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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--course-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    min-height: 100vh;
    padding: 0;
    line-height: 1.6;
}

.top-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 8px 0;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: opacity 0.2s ease;
}

.header-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.container {
    max-width: 210mm; /* A4 width */
    margin: 25px auto;
    background: white;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    border-radius: 16px;
    overflow: hidden;
}

.paper {
    padding: 40px;
    min-height: 297mm; /* A4 height */
    position: relative;
}

.header {
    text-align: center;
    border-bottom: 3px solid var(--course-color, #6c5ce7);
    padding-bottom: 20px;
    margin-bottom: 30px;
    background: var(--course-color, #6c5ce7);
    color: white;
    margin: -40px -40px 30px -40px;
    padding: 30px 40px 20px 40px;
    position: relative;
}

.course-link {
    position: absolute;
    top: 15px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
}

.course-link:hover {
    color: white;
    transform: translateX(-3px);
}

.course-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}

.header h1 {
    color: white;
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 10px;
}

.header .meta {
    color: rgba(255,255,255,0.9);
    font-size: 16px;
    font-weight: 400;
}

.question-section {
    margin-bottom: 40px;
}

.question-content {
    background: transparent;
    padding: 0;
    font-size: 20px;
    line-height: 1.8;
    color: #2d3748;
}

.math-expression {
    color: #fd79a8;
    font-weight: 600;
}

.answer-toggle {
    background: var(--course-color, #00b894);
    color: white;
    border: none;
    padding: 20px 40px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    margin: 40px 0 30px 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: block;
    width: 80%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.answer-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    filter: brightness(110%);
}

.answer-section {
    display: none;
    margin-top: 30px;
}

.answer-section.show {
    display: block;
    animation: fadeInUp 0.5s ease;
}

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

.section-title {
    color: #2d3748;
    font-size: 18px;
    font-weight: 600;
    margin: 30px 0 15px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-content {
    background: transparent;
    padding: 0;
    margin-bottom: 25px;
    color: #4a5568;
}

.answer-content {
    background: #f0fff4;
    padding: 20px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    color: #22543d;
}

.step {
    background: linear-gradient(135deg, #fff5e6 0%, #ffeaa7 100%);
    padding: 20px;
    margin: 15px 0;
    border-left: 5px solid #fdcb6e;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(253, 203, 110, 0.2);
}

.step-number {
    background: linear-gradient(135deg, #fdcb6e 0%, #e17055 100%);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 12px;
    font-size: 14px;
}

.exercise-item {
    background: linear-gradient(135deg, #f3e5ff 0%, #e3d5ff 100%);
    padding: 20px;
    margin: 15px 0;
    border-left: 5px solid #a29bfe;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(162, 155, 254, 0.2);
}

.knowledge-item {
    background: linear-gradient(135deg, #fff0e6 0%, #ffeaa7 100%);
    padding: 20px;
    margin: 15px 0;
    border-left: 5px solid #fd79a8;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(253, 121, 168, 0.2);
}

.importance-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 10px;
}

.importance-grundläggande {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    color: white;
}

.importance-viktigt {
    background: linear-gradient(135deg, #fdcb6e 0%, #e17055 100%);
    color: white;
}

.importance-nödvändigt {
    background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%);
    color: white;
}

.thinking-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

.thinking-item {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.1);
    border: 1px solid rgba(162, 155, 254, 0.2);
}

.thinking-item h4 {
    color: #6c5ce7;
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 600;
}

.key-concepts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.concept-tag {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 18px;
    font-size: 12px;
    font-weight: 600;
}

.disclaimer {
    margin-top: 40px;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 12px;
    color: #6c757d;
    text-align: center;
    line-height: 1.4;
}

.disclaimer strong {
    color: #495057;
}

.exercise-navigation {
    position: absolute;
    top: 15px;
    right: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.nav-button {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.nav-button:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.nav-button.active {
    background: rgba(255,255,255,0.4);
    font-weight: 600;
}

.exercise-numbers {
    display: flex;
    gap: 5px;
}

.exercise-numbers .nav-button {
    min-width: 30px;
    text-align: center;
    padding: 8px;
}

/* Responsiv design */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
        margin: 25px 0 0 0;
        border-radius: 0;
    }
    
    .paper {
        padding: 20px;
        min-height: auto;
    }
    
    .header {
        margin: -20px -20px 20px -20px;
        padding: 20px 20px 5px 20px; /* Mindre bottom padding för navigation */
    }
    
    .header h1 {
        font-size: 24px;
        margin-top: 10px;
    }
    
    .header .meta {
        font-size: 14px;
    }
    
    .course-link {
        top: 10px;
        left: 15px;
        font-size: 12px;
        gap: 8px;
        z-index: 10; /* Säkerställ att den ligger ovanpå navigation */
    }
    
    .course-icon {
        width: 24px;
        height: 24px;
    }
    
    /* Anpassa navigationsknappar på tablet */
    .exercise-navigation {
        position: static;
        justify-content: center;
        margin: 15px 0 0 0;
        padding: 15px 0 0 0;
        border-top: 1px solid rgba(255,255,255,0.2);
    }
    
    .nav-button {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .question-content {
        font-size: 16px;
        padding: 20px;
    }
    
    .thinking-grid {
        grid-template-columns: 1fr;
    }
    
    .answer-toggle {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .paper {
        padding: 10px;
    }
    
    .header {
        margin: -10px -10px 15px -10px;
        padding: 15px 10px 5px 10px; /* Mindre bottom padding för navigation */
        text-align: left;
    }
    
    .header h1 {
        font-size: 18px;
        margin-top: 35px; /* Plats för course-link */
        margin-bottom: 8px;
    }
    
    .header .meta {
        font-size: 12px;
        line-height: 1.4;
    }
    
    .course-link {
        top: 8px;
        left: 10px;
        font-size: 11px;
        gap: 6px;
        max-width: calc(100% - 20px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .course-link span {
        display: none; /* Dölj "Tillbaka till" texten på mycket små skärmar */
    }
    
    .course-icon {
        width: 20px;
        height: 20px;
    }
    
    /* Anpassa navigationsknappar för mobil */
    .exercise-navigation {
        position: static;
        justify-content: center;
        margin: 10px 0 0 0;
        padding: 10px 0 0 0;
        border-top: 1px solid rgba(255,255,255,0.2);
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .nav-button {
        padding: 10px 12px; /* Större touch targets */
        font-size: 12px;
        min-width: 44px; /* Minimum touch target size */
        min-height: 44px;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .exercise-numbers {
        gap: 4px;
    }
    
    .question-content {
        font-size: 14px;
        padding: 15px;
    }
    
    /* Kompaktare knappar på mobil */
    .answer-toggle {
        padding: 15px 30px;
        font-size: 14px;
        width: 100%;
    }
}

/* Print-friendly */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
        margin: 25px 0 0 0;
        max-width: 100%;
    }
    
    .answer-toggle {
        display: none;
    }
    
    .answer-section {
        display: block !important;
    }
}

/* Annons styling */
.ad-container {
    margin: 25px auto;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #b6c0ca;
    border-radius: 8px;
    text-align: center;
    min-width: 350px;
}

.ad-container--display {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.ad-container--flow {
    min-width: 320px; /* Säkerställ alltid minst 320px */
    max-width: 100%;
    width: 100%;
    margin: 20px auto;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.ad-container--flow .adsbygoogle {
    min-width: 300px !important; /* Garantera minst 300px för flow ads */
    min-height: 100px !important;
    display: block !important;
    width: 100% !important;
}

/* Responsiv annons styling */
@media (max-width: 768px) {
    .ad-container {
        margin: 15px 10px;
        padding: 10px;
        border-radius: 6px;
    }
    
    /* På mobil, säkerställ att flow ads fortfarande har tillräcklig bredd */
    .ad-container--flow {
        min-width: 320px; /* Bibehåll minsta bredd även på mobil */
        margin: 15px auto; /* Centrera om det behövs */
        overflow-x: auto; /* Tillåt horisontell scroll om nödvändigt */
    }
    
    .ad-label {
        font-size: 10px;
        margin-bottom: 8px;
    }
}

.ad-label {
    font-size: 11px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    font-weight: 500;
}

.adsbygoogle {
    display: block !important;
}

/* Responsiv annons styling */
@media (max-width: 768px) {
    .ad-container {
        margin: 15px 10px;
        padding: 10px;
        border-radius: 6px;
    }
    
    .ad-label {
        font-size: 10px;
        margin-bottom: 8px;
    }
}