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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    padding: 2px;
}

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

header {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
}

header h1 {
    color: #333;
    font-size: 28px;
    text-align: center;
}

.main-content {
    display: flex;
    gap: 20px;
    flex-direction: column;
}

/* Settings Panel */
.settings-panel {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.settings-panel h2 {
    color: #333;
    font-size: 22px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4a90d9;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    color: #555;
    font-weight: 500;
    margin-bottom: 8px;
}

.setting-group select,
.setting-group input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.setting-group select:focus,
.setting-group input[type="number"]:focus {
    outline: none;
    border-color: #4a90d9;
}

.setting-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

.setting-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Stepper */
.stepper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stepper-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #4a90d9;
    background: white;
    color: #4a90d9;
    font-size: 24px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.stepper-btn:hover {
    background: #4a90d9;
    color: white;
}

.stepper input {
    text-align: center;
    font-weight: bold;
}

/* Buttons */
.btn-primary,
.btn-success {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #4a90d9;
    color: white;
}

.btn-primary:hover {
    background: #3a7bc8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.4);
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

/* Preview Panel */
.preview-panel {
    flex: 1;
    background: white;
    padding: 2px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.preview-container {
    background: #ffffff;
    padding: 0px;
    border-radius: 8px;
    overflow: hidden;
}

/* Worksheet scaling wrapper */
.worksheet-scale-wrapper {
    position: relative;
    margin: 0 auto;
    transition: height 0.2s ease;
}

/* Worksheet */
.worksheet {
    background: white;
    width: 210mm;
    min-height: 297mm;
    padding: 4mm;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
    transform-origin: top left;
}

/* Graph Grid */
.graph-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    flex: 1;
}

/* Graph Item */
.graph-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: #fafafa;
}

.graph-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.graph-svg {
    width: 100%;
    height: auto;
}

/* Complex graph items get more space */
.graph-item.complex {
    padding: 15px;
}

/* Watermark */
.watermark {
    font-size: 12px;
    color: #999;
    text-align: center;
    padding-top: 10px;
}

/* Answer Key Section */
.answer-key {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 3px solid #4a90d9;
}

.answer-key h3 {
    color: #4a90d9;
    margin-bottom: 12px;
    font-size: 18px;
}

.answer-key-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.answer-key-item {
    padding: 6px 10px;
    background: #f0f0f0;
    border-radius: 6px;
    font-size: 13px;
}

.answer-key-item strong {
    color: #4a90d9;
}

/* Responsive Design */
@media (min-width: 880px) {
    .main-content {
        flex-direction: row;
    }

    .settings-panel {
        width: 320px;
        flex-shrink: 0;
    }
}

@media (max-width: 879px) {
    .worksheet {
        width: 100%;
        min-height: auto;
        padding: 15px;
    }

    .graph-grid {
        gap: 10px;
    }

    .graph-item {
        padding: 8px;
    }
}

@media print {
    body {
        background: white;
        padding: 0;
    }

    .settings-panel,
    .preview-container {
        display: none;
    }

    .worksheet {
        box-shadow: none;
        margin: 0;
        padding: 15mm;
    }
}