:root {
    --bg-dark: #070b14;
    --primary: #38bdf8;
    --secondary: #fb7185;
    --operator: #fbbf24;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-heavy: rgba(15, 23, 42, 0.8);
    --sidebar-width: 300px;
    --transition-smooth: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    height: 100vh;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(251, 113, 133, 0.1) 0px, transparent 50%);
    display: flex;
    overflow: hidden;
    color: #f8fafc;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--glass-heavy);
    backdrop-filter: blur(40px);
    border-right: 1px solid var(--glass-border);
    position: fixed;
    left: calc(-1 * var(--sidebar-width));
    transition: var(--transition-smooth);
    z-index: 2000;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    box-shadow: 20px 0 80px rgba(0,0,0,0.8);
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4rem;
}

.sidebar h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-sidebar {
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: 0.3s;
    opacity: 0.6;
}

.close-sidebar:hover {
    background: var(--glass-border);
    opacity: 1;
}

.nav-item {
    padding: 1.2rem 1.5rem;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 1.2rem;
    color: #94a3b8;
    margin-bottom: 0.8rem;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
    transform: translateX(5px);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.15), transparent);
    color: var(--primary);
    border-left: 3px solid var(--primary);
    border-radius: 0 20px 20px 0;
    padding-left: 2rem;
}

/* Floating Menu Button */
.menu-trigger {
    position: fixed;
    top: 2rem;
    left: 2rem;
    z-index: 1000;
    cursor: pointer;
    background: var(--glass-heavy);
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    transition: var(--transition-smooth);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.menu-trigger:hover {
    transform: scale(1.1) rotate(5deg);
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.menu-trigger.active {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-100px);
}

/* App Layout & Scale Effect */
.app-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition-smooth);
    perspective: 1000px;
}

.app-container.pushed {
    transform: translateX(180px) scale(0.85) rotateY(-5deg);
    filter: blur(2px) grayscale(0.5);
    pointer-events: none;
}

/* Calculator Card */
.calc-card {
    width: 100%;
    max-width: 380px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(30px);
    border-radius: 40px;
    border: 1px solid var(--glass-border);
    padding: 2.5rem;
    box-shadow: 0 50px 100px -20px rgba(0,0,0,0.7);
    transition: var(--transition-smooth);
}

.calc-card.scientific {
    max-width: 580px;
}

/* Display */
.display-wrapper {
    margin-bottom: 2.5rem;
    position: relative;
}

#display {
    width: 100%;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    color: #fff;
    font-size: 2.8rem;
    font-weight: 300;
    text-align: right;
    padding: 1.8rem;
    outline: none;
    box-shadow: inset 0 2px 20px rgba(0,0,0,0.4);
    transition: var(--transition-smooth);
}

#display::placeholder {
    color: rgba(255,255,255,0.1);
}

/* Grid */
.btn-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.2rem;
}

.scientific .btn-grid {
    grid-template-columns: repeat(5, 1fr);
}

button {
    height: 68px;
    border: none;
    border-radius: 22px;
    background: rgba(255,255,255,0.03);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    display: flex;
    justify-content: center;
    align-items: center;
}

button:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-4px);
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

button:active {
    transform: translateY(0) scale(0.92);
}

.btn-op {
    color: var(--operator);
    background: rgba(251, 191, 36, 0.08);
}

.btn-pri {
    color: var(--primary);
    background: rgba(56, 189, 248, 0.08);
}

.btn-sec {
    color: var(--secondary);
    background: rgba(251, 113, 133, 0.08);
}

.btn-equal {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 10px 30px rgba(56, 189, 248, 0.3);
}

.btn-equal:hover {
    box-shadow: 0 15px 40px rgba(56, 189, 248, 0.5);
    background: linear-gradient(135deg, var(--primary), #4f46e5);
}

/* Animations */
.sci-only {
    display: none;
    animation: fadeIn 0.5s ease;
}

.scientific .sci-only {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Responsive */
@media (max-width: 768px) {
    .calc-card { padding: 1.8rem; border-radius: 30px; }
    button { height: 60px; border-radius: 18px; }
    .sidebar { width: 100%; border: none; }
}
