:root {
    --bg-color: #f0f0f0;
    --calculator-bg: #333;
    --button-bg: #555;
    --button-color: #fff;
    --operator-bg: #ff9500;
    --memory-bg: #4CAF50;
    --equals-bg: #ff5722;
    --clear-bg: #f44336;
    --display-bg: #444;
    --display-color: #fff;
    --text-color: #fff;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: var(--bg-color);
    font-family: Arial, sans-serif;
    transition: background-color 0.3s;
}

body.dark-mode {
    --bg-color: #121212;
    --calculator-bg: #1e1e1e;
    --button-bg: #333;
    --button-color: #fff;
    --operator-bg: #ff9500;
    --memory-bg: #4CAF50;
    --equals-bg: #ff5722;
    --clear-bg: #f44336;
    --display-bg: #2c2c2c;
    --display-color: #fff;
    --text-color: #fff;
}

.calculator {
    background-color: var(--calculator-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    max-width: 800px;
    width: 100%;
}

.display {
    margin-bottom: 20px;
}

#expression, #result {
    width: 100%;
    height: 40px;
    font-size: 18px;
    text-align: right;
    padding: 5px;
    border: none;
    background-color: var(--display-bg);
    color: var(--display-color);
    border-radius: 5px;
    margin-bottom: 5px;
}

#result {
    font-size: 24px;
    font-weight: bold;
}

.settings {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.mode-toggle, .theme-toggle, .notation-toggle {
    color: var(--text-color);
}

.buttons, .advanced-functions {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.advanced-functions {
    grid-template-columns: repeat(4, 1fr);
}

button {
    width: 100%;
    height: 60px;
    font-size: 18px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.number {
    background-color: var(--button-bg);
    color: var(--button-color);
}

.operator {
    background-color: var(--operator-bg);
    color: var(--button-color);
}

.memory {
    background-color: var(--memory-bg);
    color: var(--button-color);
}

.equals {
    background-color: var(--equals-bg);
    color: var(--button-color);
    grid-column: span 2;
}

.clear {
    background-color: var(--clear-bg);
    color: var(--button-color);
}

button:hover {
    opacity: 0.8;
}

button:active {
    opacity: 0.6;
}

.equation-solver, .matrix-operations, .complex-numbers, .statistics, .graphing, .custom-functions, .unit-conversion {
    margin-bottom: 20px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

.equation-solver input, .equation-solver select,
.matrix-operations textarea, .matrix-operations select,
.complex-numbers input, .complex-numbers select,
.statistics textarea,
.graphing textarea,
.custom-functions input, .custom-functions select,
.unit-conversion input, .unit-conversion select {
    width: 100%;
    padding: 5px;
    margin-bottom: 10px;
    background-color: var(--display-bg);
    color: var(--display-color);
    border: none;
    border-radius: 3px;
}

.equation-solver button, .matrix-operations button, .complex-numbers button, .statistics button, .graphing button {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    background-color: var(--operator-bg);
    color: var(--button-color);
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

#equation-result, #matrix-result, #complex-result, #stats-result {
    margin-top: 10px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    color: var(--text-color);
}

.graph-container {
    width: 100%;
    height: 300px;
    margin-top: 20px;
}

.history {
    color: var(--text-color);
    max-height: 200px;
    overflow-y: auto;
}

.history h3 {
    margin-bottom: 10px;
}

#history-list {
    list-style-type: none;
    padding: 0;
}

#history-list li {
    margin-bottom: 5px;
    cursor: pointer;
}

#history-list li:hover {
    text-decoration: underline;
}

.highlight-parentheses {
    background-color: #ffff00;
    color: #000;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding:  20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 5px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}