:root {
    --primary: #007bff;
    --bg: #f8f9fa;
    --text: #333;
    --border: #ddd;
    --danger: #e11d48;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    padding: 20px;
}

.main-container {
    max-width: 750px;
    margin: 0 auto;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.aufgabe-card { border-top: 6px solid var(--primary); }

.badge {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: inline-block;
    margin-bottom: 0px;
}

.meta-info {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.email-header {
    border-bottom: 1px solid var(--border);
    margin-bottom: 15px;
    padding-bottom: 10px;
}

.email-row {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.email-row label {
    width: 80px;
    font-weight: bold;
    color: #64748b;
    font-size: 0.9rem;
}

.email-row input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    color: var(--text);
    font-family: sans-serif;
}

textarea {
    width: 100%;
    min-height: 300px;
    padding: 10px 0;
    border: none;
    font-size: 1.1rem;
    box-sizing: border-box;
    outline: none;
    resize: vertical;
    font-family: sans-serif;
}

/* Hilfsklasse für den Druck-Spiegel */
.print-only {
    display: none;
}

.editor-footer {
    border-top: 1px solid var(--border);
    padding-top: 10px;
    text-align: left;
    font-size: 0.85rem;
    color: #64748b;
}

.neue-aufgabe {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.controls {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    justify-content: space-between; 
    align-items: center;
    flex-wrap: wrap;
}

.left-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.btn-main { background: var(--primary); color: white; }
.btn-secondary { background: #e2e8f0; color: #4a5568; }
.btn-danger { background: var(--danger); color: white; }
.btn-reset { background-color: #e2e8f0; color: #4a5568; border: 1px solid #fee2e2; }

.btn-pdf {
    background-color: #10b981;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

.hilfen-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.hilfe-box {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.hidden { display: none !important; }

#rechen-input {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 100px;
    margin-right: 10px;
}

#sol-text {
    margin-top: 15px;
    padding: 10px 0;
    color: #444;
}

@media print {
    /* 1. UI-Elemente ausblenden */
    header, 
    .neue-aufgabe, 
    .controls, 
    .hilfen-container, 
    .footer-info, 
    /*.editor-footer,*/
    #btn-loesung-starten,
    #rechenaufgabe-container,
    #musterloesung-anzeige {
        display: none !important;
    }

    /* 2. Layout-Fixes */
    body { 
        background: white !important; 
        padding: 0 !important; 
    }

    .main-container {
        max-width: 100% !important;
        margin: 0 !important;
    }

    .card { 
        box-shadow: none !important; 
        border: none !important; 
        padding: 0 !important; 
        margin-bottom: 20px !important;
    }

    /* 3. Textarea durch Spiegel-Div ersetzen */
    #text-editor {
        display: none !important;
    }

    .print-only {
        display: block !important;
        width: 100%;
        height: auto !important;
        overflow: visible !important;
        white-space: pre-wrap; /* Wichtig für Zeilenumbrüche */
        word-wrap: break-word;
        font-family: sans-serif;
        font-size: 1.1rem;
        line-height: 1.5;
    }

    /* 4. Aufgabe und Email-Kopf sichtbar halten */
    #aufgabe-bereich {
        display: block !important;
        border-top: 2px solid var(--primary) !important;
        margin-bottom: 30px !important;
        padding-bottom: 10px !important;
    }

    .email-row {
        border-bottom: 1px solid #eee !important;
    }

    .email-row input {
        border: none !important;
        background: transparent !important;
    }

    /* Seitenumbrüche optimieren */
    h2, .email-header {
        page-break-after: avoid;
    }
}