:root {
    /* Light Theme (Default) */
    --bg-gradient-1: #e0f2fe; /* Light Blue */
    --bg-gradient-2: #f0f9ff; /* Whiter Blue */
    --shape-1: #bae6fd;
    --shape-2: #7dd3fc;
    
    --calc-bg: rgba(255, 255, 255, 0.65);
    --display-color: #334155;
    --display-sub-color: #64748b;
    
    --btn-bg: rgba(255, 255, 255, 0.5);
    --btn-hover: rgba(255, 255, 255, 0.8);
    --btn-text: #1e293b;
    
    --accent-color: #0ea5e9; /* Sky Blue */
    --accent-text: #ffffff;
    
    --operator-text: #0ea5e9;
    --function-text: #64748b;
    
    --shadow-light: -8px -8px 20px rgba(255, 255, 255, 0.9);
    --shadow-dark: 8px 8px 20px rgba(174, 190, 205, 0.4);
    
    --border-color: rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] {
    --bg-gradient-1: #0f172a;
    --bg-gradient-2: #1e293b;
    --shape-1: #1e40af;
    --shape-2: #3b82f6;

    --calc-bg: rgba(30, 41, 59, 0.7);
    --display-color: #f8fafc;
    --display-sub-color: #94a3b8;
    
    --btn-bg: rgba(51, 65, 85, 0.5);
    --btn-hover: rgba(71, 85, 105, 0.8);
    --btn-text: #f1f5f9;
    
    --accent-color: #3b82f6;
    --accent-text: #ffffff;
    
    --operator-text: #60a5fa;
    --function-text: #cbd5e1;
    
    --shadow-light: -4px -4px 10px rgba(50, 60, 80, 0.3);
    --shadow-dark: 4px 4px 10px rgba(0, 0, 0, 0.5);
    
    --border-color: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-1), var(--bg-gradient-2));
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: background 0.5s ease;
}

/* Background Shapes */
.background-shapes {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: floating 10s infinite alternate ease-in-out;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: var(--shape-1);
    top: -50px;
    left: -100px;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: var(--shape-2);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

@keyframes floating {
    0% { transform: translate(0, 0); }
    100% { transform: translate(30px, 50px); }
}

/* Calculator Container */
.calculator-container {
    width: 380px;
    background: var(--calc-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 35px;
    padding: 25px;
    box-shadow: var(--shadow-dark), var(--shadow-light);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

.logo {
    font-weight: 600;
    color: var(--display-color);
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

/* Theme Switch */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
}

.theme-switch {
    display: inline-block;
    height: 26px;
    position: relative;
    width: 50px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: rgba(0,0,0,0.1);
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 34px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
}

.slider:before {
    background-color: #fff;
    bottom: 3px;
    content: "";
    height: 20px;
    left: 3px;
    position: absolute;
    transition: .4s;
    width: 20px;
    border-radius: 50%;
    z-index: 10;
}

input:checked + .slider {
    background-color: rgba(255,255,255,0.2);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.icon {
    font-size: 12px;
    z-index: 1;
    line-height: normal;
}

/* Display */
.display {
    text-align: right;
    margin-bottom: 25px;
    padding: 10px 15px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.previous-operand {
    color: var(--display-sub-color);
    font-size: 1rem;
    min-height: 1.2rem;
    margin-bottom: 5px;
}

.current-operand {
    color: var(--display-color);
    font-size: 2.5rem;
    font-weight: 500;
    word-wrap: break-word;
    word-break: break-all;
}

/* Keypad */
.keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.btn {
    height: 65px;
    border-radius: 20px;
    border: none;
    background: var(--btn-bg);
    color: var(--btn-text);
    font-size: 1.25rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(5px);
    box-shadow: 2px 2px 5px rgba(0,0,0,0.05);
}

.btn:hover {
    background: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 4px 4px 10px rgba(0,0,0,0.1);
}

.btn:active {
    transform: scale(0.95);
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.05);
}

.btn-sci {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--function-text);
    background: transparent;
    box-shadow: none;
    height: 50px;
}

.btn-function {
    color: var(--function-text);
    font-weight: 600;
}

.btn-operator {
    color: var(--operator-text);
    font-size: 1.5rem;
    font-weight: 600;
}

.btn-equals {
    grid-column: span 2;
    background: var(--accent-color);
    color: var(--accent-text);
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
}

.btn-equals:hover {
    background: var(--accent-color);
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
}

.btn-zero {
    grid-column: span 2;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .calculator-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        padding-bottom: 30px;
        background: var(--calc-bg); 
    }
    
    .display {
        flex-grow: 1;
        justify-content: flex-end;
        padding-bottom: 20px;
    }

    .keypad {
        gap: 10px;
    }

    .btn {
        height: 60px;
        border-radius: 16px;
        font-size: 1.5rem;
    }

    .btn-sci {
        height: 45px;
        font-size: 0.9rem;
    }
}
