body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

body.light {
    background-color: #f8f9fa;
    color: #333;
}

body.dark {
    background-color: #121212;
    color: #f0f0f0;
}

.calculator-container {
    height: 100vh;
    padding: 20px;
}

.calculator-main {
    display: flex;
    justify-content: center;
    align-items: center;
}

.calculator {
    width: 100%;
    max-width: 400px;
    background: var(--calculator-bg);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.display-panel {
    padding: 25px 20px;
    text-align: right;
    background: var(--display-bg);
    color: var(--display-color);
}

.history {
    min-height: 24px;
    font-size: 1.2rem;
    color: var(--history-color);
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.current-input {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result {
    font-size: 2rem;
    font-weight: 400;
    color: var(--result-color);
}

.keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--keypad-bg);
}

.keypad button {
    border: none;
    padding: 20px 10px;
    font-size: 1.5rem;
    background: var(--button-bg);
    color: var(--button-color);
    transition: background 0.2s;
}

.keypad button:hover {
    background: var(--button-hover-bg);
}

.keypad .number {
    font-weight: 300;
}

.keypad .operation {
    font-weight: 500;
}

.keypad .equals {
    grid-row: span 2;
}

.history-panel {
    padding: 20px;
    background: var(--history-panel-bg);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    height: fit-content;
    max-height: 90vh;
    overflow-y: auto;
}

.history-list {
    max-height: 70vh;
    overflow-y: auto;
}

.history-item {
    padding: 12px;
    border-bottom: 1px solid var(--history-border);
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover {
    background: var(--history-item-hover);
}

.history-expression {
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: var(--history-expression-color);
}

.history-result {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--history-result-color);
}

/* Light Theme Variables */
body.light {
    --calculator-bg: #ffffff;
    --display-bg: #f0f0f0;
    --display-color: #333333;
    --history-color: #666666;
    --result-color: #000000;
    --keypad-bg: #e0e0e0;
    --button-bg: #ffffff;
    --button-color: #333333;
    --button-hover-bg: #f0f0f0;
    --history-panel-bg: #ffffff;
    --history-border: #e0e0e0;
    --history-item-hover: #f8f9fa;
    --history-expression-color: #555555;
    --history-result-color: #000000;
}

/* Dark Theme Variables */
body.dark {
    --calculator-bg: #1e1e1e;
    --display-bg: #2d2d2d;
    --display-color: #f0f0f0;
    --history-color: #aaaaaa;
    --result-color: #ffffff;
    --keypad-bg: #333333;
    --button-bg: #2d2d2d;
    --button-color: #f0f0f0;
    --button-hover-bg: #3d3d3d;
    --history-panel-bg: #1e1e1e;
    --history-border: #333333;
    --history-item-hover: #2a2a2a;
    --history-expression-color: #cccccc;
    --history-result-color: #ffffff;
}

/* Responsive Design */
@media (max-width: 768px) {
    .calculator-container {
        padding: 10px;
    }
    
    .history-panel {
        margin-top: 20px;
        max-height: 40vh;
    }
    
    .history-list {
        max-height: 30vh;
    }
    
    .keypad button {
        padding: 15px 5px;
        font-size: 1.3rem;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}