:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --background: #0f172a;
    --calculator-bg: #1e293b;
    --display-bg: #0f172a;
    --button-bg: #334155;
    --button-hover: #475569;
    --number-btn: #3b82f6;
    --number-btn-hover: #2563eb;
    --operator-btn: #8b5cf6;
    --operator-btn-hover: #7c3aed;
    --equals-btn: #10b981;
    --equals-btn-hover: #059669;
    --clear-btn: #ef4444;
    --clear-btn-hover: #dc2626;
    --delete-btn: #f59e0b;
    --delete-btn-hover: #d97706;
    --func-btn: #06b6d4;
    --func-btn-hover: #0891b2;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(
        135deg,
        var(--primary-color) 0%,
        var(--secondary-color) 100%
    );
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-primary);
}

.calculator-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 500px;
    width: 100%;
}

.calculator-1 {
    background: var(--calculator-bg);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 20px 60px var(--shadow);
    backdrop-filter: blur(10px);
}

/* Display Section */
.display-section {
    background: var(--display-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

.expression {
    font-size: 16px;
    color: var(--text-secondary);
    min-height: 24px;
    word-wrap: break-word;
    word-break: break-all;
    margin-bottom: 8px;
}

.result {
    font-size: 36px;
    font-weight: bold;
    color: var(--text-primary);
    text-align: right;
    word-wrap: break-word;
    word-break: break-all;
}

/* Mode Toggle */
.mode-toggle {
    margin-bottom: 16px;
}

.toggle-btn {
    width: 100%;
    padding: 12px;
    background: var(--button-bg);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
}

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

.toggle-btn.active {
    background: linear-gradient(
        135deg,
        var(--primary-color),
        var(--secondary-color)
    );
}

/* Scientific Panel */
.scientific-panel {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 16px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.scientific-panel.active {
    max-height: 500px;
    opacity: 1;
    margin-bottom: 16px;
}

/* Buttons Grid */
.buttons-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

/* Button Styles */
.btn {
    padding: 20px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.number-btn {
    background: var(--number-btn);
}

.number-btn:hover {
    background: var(--number-btn-hover);
}

.operator-btn {
    background: var(--operator-btn);
}

.operator-btn:hover {
    background: var(--operator-btn-hover);
}

.equals-btn {
    background: var(--equals-btn);
}

.equals-btn:hover {
    background: var(--equals-btn-hover);
}

.clear-btn {
    background: var(--clear-btn);
}

.clear-btn:hover {
    background: var(--clear-btn-hover);
}

.delete-btn {
    background: var(--delete-btn);
}

.delete-btn:hover {
    background: var(--delete-btn-hover);
}

.func-btn {
    background: var(--func-btn);
    font-size: 14px;
    padding: 12px 8px;
}

.func-btn:hover {
    background: var(--func-btn-hover);
}

/* Instructions */
.instructions {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    color: var(--text-primary);
}

.instructions h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.instructions ul {
    list-style: none;
}

.instructions li {
    padding: 6px 0;
    font-size: 14px;
    line-height: 1.5;
}

.instructions strong {
    color: #fff;
}

/* Responsive Design */
@media (max-width: 600px) {
    .calculator {
        padding: 16px;
    }

    .result {
        font-size: 28px;
    }

    .expression {
        font-size: 14px;
    }

    .btn {
        padding: 16px;
        font-size: 16px;
    }

    .func-btn {
        font-size: 12px;
        padding: 10px 6px;
    }

    .scientific-panel {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .buttons-grid {
        gap: 8px;
    }
}

@media (max-width: 400px) {
    .scientific-panel {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Animation for button press */
@keyframes buttonPress {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

.btn.pressed {
    animation: buttonPress 0.1s ease;
}

/* Error state */
.result.error {
    color: var(--clear-btn);
}
