:root {
    --primary-color: #4a6bff;
    --secondary-color: #5c7fff;
    --background-color: #f5f7ff;
    --display-color: #ffffff;
    --text-color: #333333;
    --button-color: #e9ecef;
    --operator-color: #ff9500;
    --function-color: #4a6bff;
    --memory-color: #ff4757;
    --dark-primary: #1a1a2e;
    --dark-secondary: #16213e;
    --dark-background: #0f0f1a;
    --dark-display: #0f3460;
    --dark-text: #e1e1ff;
}

body {
    font-family: 'Orbitron', 'Arial', sans-serif;
    background-color: var(--background-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
    --background-color: var(--dark-background);
    --display-color: var(--dark-display);
    --text-color: var(--dark-text);
    --button-color: #252a48;
    --operator-color: #ff6b35;
    --function-color: #5c7fff;
    --memory-color: #ff5252;
}

.calculator-container {
    background-color: var(--background-color);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 20px;
    width: 100%;
    max-width: 400px;
    color: var(--text-color);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header h1 {
    margin: 0;
    font-size: 20px;
    color: var(--primary-color);
}

.header span {
    color: var(--operator-color);
}

.toggle-buttons {
    display: flex;
    gap: 10px;
}

.toggle-buttons button {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
}

.toggle-buttons button:hover {
    color: var(--primary-color);
}

.calculator {
    background: linear-gradient(145deg, var(--primary-color), var(--secondary-color));
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.display {
    background-color: var(--display-color);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    text-align: right;
    height: 100px;
    overflow-y: auto;
    color: var(--text-color);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.previous-operations {
    color: rgba(0, 0, 0, 0.5);
    font-size: 14px;
    height: 40px;
    overflow-y: auto;
}

.current-operation {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-color);
}

.buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.btn {
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background-color: var(--button-color);
    color: var(--text-color);
}

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

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

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

.btn.function {
    background-color: var(--function-color);
    color: white;
}

.btn.memory {
    background-color: var(--memory-color);
    color: white;
}

.history {
    background-color: var(--display-color);
    border-radius: 15px;
    padding: 15px;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-header h2 {
    margin: 0;
    font-size: 18px;
}

.history-buttons {
    display: flex;
    gap: 10px;
}

.history-buttons button {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
}

.history-buttons button:hover {
    color: var(--primary-color);
}

#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#history-list li {
    padding: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 14px;
    cursor: pointer;
}

#history-list li:hover {
    background-color: rgba(74, 107, 255, 0.1);
}

#history-list li:last-child {
    border-bottom: none;
}

@media (max-width: 480px) {
    .calculator-container {
        width: 95%;
    }

    .btn {
        width: 45px;
        height: 45px;
        font-size: 14px;
    }
}
