:root {
    --bg-color: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --btn-hover: rgba(255, 255, 255, 0.15);
    --btn-active: rgba(255, 255, 255, 0.25);
    --accent-color: #38bdf8;
    /* Light Blue */
    --accent-glow: rgba(56, 189, 248, 0.5);
    --op-color: #f472b6;
    /* Pink */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    color: var(--text-primary);
}

.site-logo {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 150px;
    z-index: 100;
    display: block;
}

.site-logo img {
    width: 100%;
    display: block;
}

/* Background Animations */
.background-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 10s infinite alternate ease-in-out;
}

.shape-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: #4f46e5;
    /* Indigo */
    animation-delay: 0s;
}

.shape-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: #ec4899;
    /* Pink */
    animation-delay: -2s;
}

.shape-3 {
    top: 40%;
    left: 40%;
    width: 300px;
    height: 300px;
    background: #0ea5e9;
    /* Sky */
    animation-delay: -4s;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 50px);
    }
}

/* Calculator Container */
.calculator-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 24px;
    width: 360px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Top Controls */
.top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

.mode-switcher {
    flex: 1;
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 0;
    /* Override previous margin */
}

/* Icon Buttons */
.icon-controls {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--btn-hover);
    transform: scale(1.05);
}

.icon-btn.recording {
    background: #ef4444;
    /* Red */
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* History Panel */
.history-panel {
    position: absolute;
    top: 0;
    right: -100%;
    /* Hidden by default */
    width: 80%;
    /* Cover most of the calculator */
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(25px);
    z-index: 10;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--glass-border);
    border-radius: 0 24px 24px 0;
    /* Match container radius roughly */
}

.history-panel.open {
    right: 0;
    border-radius: 24px;
    /* Full radius when open overlapping */
}

.history-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.history-expression {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-align: right;
}

.history-result {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-color);
    text-align: right;
}

.history-placeholder {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 40px;
}

.clear-history-btn {
    margin: 20px;
    padding: 12px;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.clear-history-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}


.mode-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* Mode Content */
.mode-content {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Currency Controls */
.currency-controls {
    margin-bottom: 20px;
}

.currency-select-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.currency-select {
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 12px;
    font-size: 1rem;
    appearance: none;
    cursor: pointer;
    outline: none;
    text-align: center;
}

.currency-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

.currency-select option {
    background: var(--bg-color);
    /* Fallback for dropdown background */
    color: var(--text-primary);
}

.arrow-icon {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

/* Screen */
.screen {
    width: 100%;
    height: 120px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    padding: 16px;
    word-break: break-all;
    word-wrap: break-word;
}

.previous-operand {
    font-size: 1.2rem;
    color: var(--text-secondary);
    min-height: 1.5rem;
}

.current-operand {
    font-size: 3.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Buttons Grid */
.buttons-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-size: 1.5rem;
    height: 64px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    outline: none;
}

.btn:hover {
    background: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.btn:active {
    background: var(--btn-active);
    transform: translateY(0);
}

/* Button Variants */
.btn.fn {
    color: var(--accent-color);
    font-weight: 600;
}

.btn.op {
    color: var(--op-color);
    font-size: 1.8rem;
    font-weight: 600;
}

.btn.eq {
    background: var(--accent-color);
    color: #fff;
    border: none;
    box-shadow: 0 0 15px var(--accent-glow);
}

.btn.eq:hover {
    background: #0ea5e9;
    box-shadow: 0 0 25px var(--accent-glow);
}

.btn.zero {
    grid-column: span 2;
}