:root {
    --color-1: #ff9a9e;
    --color-2: #fecfef;
    --color-3: #a18cd1;
    --color-4: #fbc2eb;
    --color-5: #8fd3f4;
    
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.6);
    --text-dark: #4a4a4a;
    --text-light: #ffffff;
    --shadow-soft: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(45deg, var(--color-1), var(--color-3), var(--color-5));
    overflow: hidden; 
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    z-index: -1;
    opacity: 0.8;
    animation: float 8s infinite ease-in-out;
}
.blob-1 { top: -5%; left: 10%; width: 300px; height: 300px; background: var(--color-4); }
.blob-2 { bottom: -5%; right: 10%; width: 350px; height: 350px; background: var(--color-3); animation-delay: 2s; }
.blob-3 { top: 40%; left: 40%; width: 200px; height: 200px; background: var(--color-2); animation-delay: 4s; }

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-20px) scale(1.05); }
}

.wrapper {
    display: flex;
    gap: 25px;
    height: 650px;
    align-items: center;
}

.calculator {
    width: 420px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 25px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
}

.calc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.mode-toggle {
    font-size: 12px;
    background: rgba(255,255,255,0.4);
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-dark);
    transition: 0.3s;
}
.mode-toggle:hover { background: rgba(255,255,255,0.7); }
.mode-active { color: var(--color-3); }

.screen-container {
    margin-bottom: 20px;
    text-align: right;
    padding: 15px;
    background: rgba(255,255,255,0.3);
    border-radius: 15px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
}

#history-preview {
    height: 20px;
    color: var(--text-dark);
    font-size: 13px;
    opacity: 0.7;
    margin-bottom: 2px;
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis;
}

#display {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-dark);
    font-size: 32px;
    font-weight: 600;
    text-align: right;
    outline: none;
}

.buttons-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    flex-grow: 1;
}

button {
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 500;
    background: rgba(255,255,255,0.3);
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
    height: 50px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

button:hover {
    background: rgba(255,255,255,0.6);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

button:active { transform: scale(0.96); }

.btn-op { color: #fff; background: var(--color-3); }
.btn-sci { 
    font-size: 14px; 
    font-weight: bold; 
    color: var(--color-3);
    background: rgba(255,255,255,0.45);
}
.btn-clear { background: var(--color-1); color: white; }
.btn-equal { 
    grid-column: span 2; 
    background: linear-gradient(135deg, var(--color-5), var(--color-3));
    color: white;
    font-weight: bold;
}

.history-panel {
    width: 240px;
    height: 650px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 20px;
    overflow-y: auto;
    box-shadow: var(--shadow-soft);
}

.history-panel h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dark);
    opacity: 0.8;
    margin-bottom: 15px;
    border-bottom: 2px solid rgba(255,255,255,0.4);
    padding-bottom: 8px;
}

.history-item {
    font-size: 13px;
    margin-bottom: 10px;
    padding: 12px;
    background: rgba(255,255,255,0.4);
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
    color: var(--text-dark);
}
.history-item:hover { background: rgba(255,255,255,0.8); }
.h-eq { margin-bottom: 4px; opacity: 0.7; word-wrap: break-word; }
.h-res { font-size: 16px; font-weight: bold; text-align: right; color: var(--color-3); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.5); border-radius: 10px; } 
