* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Inter', system-ui, sans-serif;
}

body {
    background: linear-gradient(145deg, #eef2f9 0%, #e0e8f2 100%);
    padding: 2rem;
    min-height: 100vh;
    transition: background 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Activity 7 special styling */
.activity-7 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    border-radius: 1.5rem;
}

.activity-7 h2 {
    color: white;
    border-bottom: none;
}

.activity-7 .btn-primary {
    background: white;
    color: #764ba2;
    font-size: 1.1rem;
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 2rem;
    cursor: pointer;
    font-weight: bold;
    margin: 1rem 0;
}

.activity-7 .btn-primary:hover {
    transform: scale(1.05);
}

.main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.card {
    background: #ffffff;
    border-radius: 2rem;
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.2);
    padding: 1.8rem 2rem;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

h1, h2 {
    font-weight: 700;
    margin-bottom: 1.5rem;
    padding-left: 1rem;
}

h1 {
    background: linear-gradient(135deg, #1e293b, #2c3e66);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    border-left: 5px solid #f97316;
}

h2 {
    color: #1e293b;
    border-left: 5px solid #3b82f6;
}

h3 {
    color: #2c3e66;
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

h4 {
    color: #3b82f6;
    margin-bottom: 0.8rem;
}

.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

label {
    font-weight: 600;
    color: #1e2a3e;
    font-size: 0.85rem;
    text-transform: uppercase;
}

input, select {
    padding: 0.8rem 1rem;
    border-radius: 1rem;
    border: 1.5px solid #e2e8f0;
    font-size: 0.95rem;
    transition: all 0.2s;
    outline: none;
}

input:focus, select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn, .btn-primary, .btn-secondary, .btn-calc, .btn-reset {
    border: none;
    padding: 0.7rem 1.6rem;
    border-radius: 2rem;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #ef4444;
    color: white;
}

.btn-secondary:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

.btn-calc {
    background: #10b981;
    color: white;
}

.btn-calc:hover {
    background: #059669;
    transform: translateY(-2px);
}

.btn-reset {
    background: #6c757d;
    color: white;
}

.btn-reset:hover {
    background: #495057;
    transform: translateY(-2px);
}

.activity-btn {
    background: #8b5cf6;
    color: white;
    padding: 0.5rem 1.2rem;
}

.activity-btn:hover {
    background: #7c3aed;
    transform: translateY(-2px);
}

.small-btn {
    background: #64748b;
    color: white;
    border: none;
    padding: 0.3rem 1rem;
    border-radius: 1.5rem;
    cursor: pointer;
    font-weight: 600;
}

.small-btn:hover {
    background: #475569;
}

.preview-section {
    background: #fef9f0;
    border-radius: 1.5rem;
    padding: 1.2rem;
    margin-top: 1.8rem;
    border: 2px solid #ffe2bf;
}

.preview-content {
    background: white;
    border-radius: 1rem;
    padding: 1rem;
    font-family: monospace;
    line-height: 1.6;
}

.info-line {
    margin: 0.4rem 0;
    border-bottom: 1px dashed #ffddb0;
    padding: 0.3rem 0;
}

.grade-result {
    background: #f0f9ff;
    border-radius: 1.2rem;
    padding: 1rem;
    margin-top: 1.5rem;
    text-align: center;
}

.activities-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 2rem;
    box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.1);
}

.activities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.exercise3-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.info-box, .activity-card {
    background: #f8fafc;
    border-radius: 1rem;
    padding: 1.2rem;
    border: 1px solid #e2e8f0;
}

.info-box p, .activity-card p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.activity-card ul {
    margin-top: 0.5rem;
    margin-left: 1.2rem;
}

.calc-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.calc-row input {
    width: 100px;
    padding: 0.4rem;
}

/* Activity 7 - Image Controls */
.image-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
    margin-top: 0.8rem;
}

.upload-section {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.upload-label {
    background: #10b981;
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 1.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.25s ease;
}

.upload-label:hover {
    background: #059669;
    transform: translateY(-2px);
}

#imageUpload {
    display: none;
}

#dynamicImage {
    display: block;
    margin: 0.8rem 0;
    border-radius: 0.8rem;
    width: 150px;
    height: 100px;
    object-fit: cover;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

#dynamicImage:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#loopResult {
    max-height: 150px;
    overflow-y: auto;
    background: #1e293b;
    color: #10b981;
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
}

/* Dark mode */
body.dark-mode {
    background: #0f172a;
}

body.dark-mode .card,
body.dark-mode .activities-section,
body.dark-mode .info-box,
body.dark-mode .activity-card {
    background: #1e293b;
    color: #e2e8f0;
}

body.dark-mode h2, body.dark-mode h3, body.dark-mode h4 {
    color: #f1f5f9;
}

body.dark-mode input, body.dark-mode select {
    background: #334155;
    color: white;
    border-color: #475569;
}

body.dark-mode .preview-section {
    background: #334155;
}

body.dark-mode .preview-content {
    background: #0f172a;
    color: #cbd5e1;
}

body.dark-mode #dynamicImage {
    border-color: #475569;
}

body.dark-mode #loopResult {
    background: #0f172a;
}

@media (max-width: 768px) {
    body {
        padding: 1rem;
    }
    .main-grid {
        grid-template-columns: 1fr;
    }
}