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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.magnetic-field-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    padding: 30px;
}

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

.canvas-section h3 {
    color: #1d4ed8;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

#fieldCanvas {
    width: 100%;
    height: 500px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: crosshair;
    display: block;
}

.canvas-info {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
    padding: 15px;
    background: #f1f5f9;
    border-radius: 8px;
}

.info-item {
    font-size: 1rem;
    color: #334155;
    font-weight: 500;
}

.info-item span:last-child {
    color: #3b82f6;
    font-weight: 700;
}

.controls-panel {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.controls-panel h3 {
    color: #1d4ed8;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.control-group {
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.control-group h4 {
    color: #334155;
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: 600;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: #475569;
    font-size: 0.95rem;
}

.select-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.select-input:focus {
    outline: none;
    border-color: #3b82f6;
}

input[type="range"] {
    width: 100%;
    margin-bottom: 15px;
    accent-color: #3b82f6;
}

.checkbox-input {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    accent-color: #3b82f6;
    cursor: pointer;
}

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

.preset-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}

.preset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.preset-btn:active {
    transform: translateY(0);
}

.formulas-section {
    background: #f0f9ff;
    border-left: 4px solid #3b82f6;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.formulas-section h3 {
    color: #1d4ed8;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.formula-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.formula-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: white;
    border-radius: 6px;
}

.formula-label {
    font-weight: 600;
    color: #334155;
    min-width: 150px;
}

.formula {
    font-family: 'Courier New', monospace;
    color: #3b82f6;
    font-weight: 600;
}

.instructions {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 20px;
    border-radius: 8px;
}

.instructions h4 {
    color: #92400e;
    margin-bottom: 12px;
    font-size: 1.2rem;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    padding: 6px 0;
    color: #78350f;
    position: relative;
    padding-left: 20px;
}

.instructions li:before {
    content: "▸";
    position: absolute;
    left: 0;
    color: #f59e0b;
    font-weight: bold;
}

.explanation {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.explanation h2 {
    color: #1d4ed8;
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.explanation h3 {
    color: #334155;
    margin-top: 25px;
    margin-bottom: 12px;
    font-size: 1.4rem;
}

.explanation p {
    color: #475569;
    line-height: 1.7;
    margin-bottom: 15px;
    font-size: 1rem;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.6rem;
    }

    header .subtitle {
        font-size: 0.95rem;
    }

    #fieldCanvas {
        height: 350px;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .canvas-info {
        flex-direction: column;
        gap: 10px;
    }

    .explanation h2 {
        font-size: 1.4rem;
    }

    .explanation h3 {
        font-size: 1.2rem;
    }
}
