:root {
    /* Light Mode Variables */
    --bg-color: #e0e5ec;
    --calc-bg: #f1f3f6;
    --text-color: #444;
    --shadow-light: #ffffff;
    --shadow-dark: #bfc3c9;
    --display-bg: #e0e5ec;
    --display-text: #2c3e50;
    --accent-color: #3498db;
    --plot-color: #9b59b6;
}

body.dark-mode {
    /* Dark Mode Variables */
    --bg-color: #2c3e50;
    --calc-bg: #34495e;
    --text-color: #ecf0f1;
    --shadow-light: #3e5871;
    --shadow-dark: #202d3a;
    --display-bg: #2c3e50;
    --display-text: #ecf0f1;
}

body {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    gap: 20px;
    background-color: var(--bg-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.3s ease;
    padding: 80px 20px 20px 20px;
    flex-wrap: wrap;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
}

#theme-btn {
    padding: 10px 20px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    background-color: var(--calc-bg);
    color: var(--text-color);
    box-shadow: 5px 5px 10px var(--shadow-dark), 
                -5px -5px 10px var(--shadow-light);
    font-weight: bold;
    transition: all 0.3s ease;
}

.calculator {
    background-color: var(--calc-bg);
    padding: 25px;
    border-radius: 30px;
    box-shadow: 10px 10px 20px var(--shadow-dark), 
                -10px -10px 20px var(--shadow-light);
    width: 100%;
    max-width: 440px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.display {
    background-color: var(--display-bg);
    padding: 15px 25px;
    text-align: right;
    border-radius: 20px;
    margin-bottom: 25px;
    min-height: 80px;
    box-shadow: inset 6px 6px 12px var(--shadow-dark), 
                inset -6px -6px 12px var(--shadow-light);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    transition: all 0.3s ease;
    word-break: break-all;
    word-wrap: break-word;
}

.expression {
    color: var(--text-color);
    font-size: 1rem;
    min-height: 1.5rem;
    opacity: 0.7;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow-x: auto;
    width: 100%;
}

.result {
    color: var(--display-text);
    font-size: 2rem;
    font-weight: bold;
    white-space: nowrap;
    overflow-x: auto;
    width: 100%;
}

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

.btn {
    padding: 15px 5px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background-color: var(--calc-bg);
    color: var(--text-color);
    box-shadow: 4px 4px 8px var(--shadow-dark), 
                -4px -4px 8px var(--shadow-light);
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn:active {
    box-shadow: inset 3px 3px 6px var(--shadow-dark), 
                inset -3px -3px 6px var(--shadow-light);
    transform: translateY(2px);
}

.operator {
    color: #e67e22;
}

.func {
    color: var(--accent-color);
    font-size: 0.9rem;
}

.plot-btn {
    color: var(--plot-color);
    font-size: 0.85rem;
}

.equal {
    background: linear-gradient(145deg, #2ecc71, #27ae60);
    color: white;
}

.clear {
    color: #e74c3c;
}

/* Graph Container */
.graph-container {
    background-color: var(--calc-bg);
    padding: 25px;
    border-radius: 30px;
    box-shadow: 10px 10px 20px var(--shadow-dark), 
                -10px -10px 20px var(--shadow-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 450px;
}

#graphCanvas {
    background-color: var(--display-bg);
    border-radius: 20px;
    box-shadow: inset 6px 6px 12px var(--shadow-dark), 
                inset -6px -6px 12px var(--shadow-light);
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    max-width: 400px;
}

.range-controls {
    margin-top: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.range-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-color);
}

.range-group input {
    width: 70px;
    padding: 8px;
    border-radius: 10px;
    border: none;
    background-color: var(--display-bg);
    color: var(--display-text);
    box-shadow: inset 2px 2px 5px var(--shadow-dark), 
                inset -2px -2px 5px var(--shadow-light);
    text-align: center;
}

.graph-info {
    margin-top: 15px;
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.7;
    text-align: center;
}

/* Media Query for Mobile */
@media (max-width: 950px) {
    body {
        flex-direction: column;
        align-items: center;
        padding-top: 80px;
    }
}
