*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root{
    --bg-primary: #0f172a;
    --bg-secondary: rgba(15, 23, 42, 0.85);

    --glass: rgba(255, 255, 255, 0.08);

    --border: rgba(96, 165, 250, 0.25);

    --text-primary: #fff;
    --text-secondary:#94a3b8;

    --button-bg: rgba(255, 255,255, 0.06);

    --operator: #0938a8;

    --hover: rgba(255, 255, 255, 0.12);
    --shadow: 0 8px 30px rgba(0,0,0,0.35);
    --blur: blur(18px);
    --transition: 0.25s ease;
}

body.light-mode{
    --bg-primary: #a0a5aa;
    --bg-secondary: rgba(255, 255, 255, 0.85);
    --glass: rgba(255, 255, 255, 0.55);
    --border: rgba(168, 85, 247, 0.25);
    --text-primary: #111827;
    --text-secondary: #64748b;
    --button-bg: rgba(255, 255, 255, 0.75);
    --operator: #a855f7;
    --hover: rgba(255, 255, 255, 0.9);
    --shadow: 0 8px 30px rgba(0,0,0,0.09);
}

body{
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;

    background: linear-gradient(135deg, #1e293b, #020617);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    color: var(--text-primary);
    overflow: hidden;
    transition: var(--transition);
}

body.light-mode{
    background: radial-gradient(circle at top, #e2e8f0, #cbd5e1);
}

.app{
    width: 340px;
    padding: 22px;
    border-radius: 34px;
    background: var(--bg-secondary);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.app::before{
    content: "";
    position: absolute;
    top: -120%;
    right: -120%;

    width: 220%;
    height: 220%;

    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.08), transparent);
    border-radius: 50%;
    pointer-events: none;
}

.topbar{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.logo{
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 600;
}

.logo i{
    color: #fff;
}

body.light-mode .logo i{
    color: var(--operator);
}

.top-actions{
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn{
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--button-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

body.light-mode .icon-btn{
    color: var(--operator);
}

.icon-btn:hover{
    transform: translateY(-2px);
    background: var(--hover);
}

.display{
    padding: 28px 10px;
    text-align: right;
    margin-bottom: 22px;
}

.previous-operation{
    min-height: 24px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-size: 1.3rem;
    font-weight: 400;
}

.current-operation{
    font-size: 3rem;
    font-weight: 300;
    letter-spacing: 1px;
    overflow-x: auto;
}

.current-operation, .previous-operation{
    transition: all 0.25s ease;
}

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

.buttons button{
    height: 50px;
    width: 50px;
    border: none;
    border-radius: 30px;
    background: var(--button-bg);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.04);
    align-items: center;
}

.buttons button:hover{
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    background: var(--hover);
    align-items: center;
}

.buttons button:active{
    transform: scale(0.94);
    transition: 0.08s ease;
    align-items: center;
}

.buttons button:last-child, .equals{
    background: var(--operator);
    color: #fff;
    font-weight: 500;
}

.buttons button:nth-child(1),
.buttons button:nth-child(2),
.buttons button:nth-child(3),
.buttons button:nth-child(4),
.buttons button:nth-child(8),
.buttons button:nth-child(12),
.buttons button:nth-child(16){

    background: rgba(18, 74, 204, 0.912);
    color: #ffffff;
    font-weight: 500;
}

body.light-mode .buttons button:nth-child(1),
body.light-mode .buttons button:nth-child(2),
body.light-mode .buttons button:nth-child(3),
body.light-mode .buttons button:nth-child(4),
body.light-mode .buttons button:nth-child(8),
body.light-mode .buttons button:nth-child(12),
body.light-mode .buttons button:nth-child(16){

    background: rgba(168, 85, 247, 0.12);
    color: #4b2887;
    border: 1px solid rgba(168, 85, 247, 0.08);
}

.history-panel{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 194px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-top: 10px;
    border-radius: 30px;
    overflow-y: auto;
    z-index: 50;
    animation: slideDown 0.25s ease;
}

body.light-mode .history-panel{
    background: rgba(255, 255, 255, 0.92)
}

.history-header{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-header button{
    border: none;
    background: var(--operator);
    color: #fff;
    padding: 8px 14px;
    border-radius: 12px;
    cursor: pointer;
}

.history-actions{
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-history{
    width: 34px;
    height: 34px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50% !important;
    padding: 0 !important;
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--text-primary) !important;
}

body.light-mode .close-history{
    background: rgba(168,85,247,0.20) !important;
    color: #7c3aed;
}

.close-history:hover{
    transform: scale(1.02);
}

.history-list{
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
}

.history-item {
    padding: 14px;
    border-radius: 14px;
    background: var(--button-bg);
    font-size: 0.95rem;
}

.modes-menu{
    position:absolute;
    top: 75px;
    right: 20px;
    width: 170px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
    animation: fadeIn 0.2s ease;
}

.modes-menu button{
    border: none;
    padding: 14px;
    border-radius: 14px;
    background: var(--button-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.modes-menu button:hover{
    background: var(--hover);
}

body.light-mode .modes-menu button:hover{
    background: rgba(168, 85, 247, 0.14);
    border: 1px solid rgba(168, 85, 247, 0.18);
}

body.light-mode .modes-menu button{
    background: rgba(168, 85, 247, 0.07);
    color: (--text-primary);
    border: 1px solid rgba(168, 85, 247, 0.08);
}

.currency-display{

    display: flex;
    flex-direction: column;
    gap: 10px;

    min-height: 150px;
}

.currency-line{

    display: flex;
    justify-content: flex-end;
}

.currency-info{

    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.currency-value{

    font-size: 2.2rem;
    font-weight: 300;
}

.currency-info select{

    border: none;
    background: transparent;

    color: var(--text-secondary);

    font-size: 0.9rem;

    outline: none;
}

.currency-switch{

    position: relative;

    display: flex;
    justify-content: center;
    align-items: center;

    margin: 4px 0;
}

.currency-switch::before{

    content: "";

    width: 100%;
    height: 1px;

    background: rgba(148, 163, 184, 0.18);

    position: absolute;
    pointer-events: none;
}

.currency-switch i{

    position: relative;

    z-index: 1;

    font-size: 0.73rem;

    color: var(--text-secondary);

    background: var(--bg-secondary);

    padding: 6px;

    border-radius: 50%;

    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);

    cursor: pointer;
}

.currency-switch:hover{

    transform: scale(1.05);

}

.hidden{
    display: none !important;
}

/* SCROLL PERSONALIZADO */

.history-list::-webkit-scrollbar{

    width: 2px;
}

.history-list::-webkit-scrollbar-track{

    background: transparent;
    margin: 8px 0;
    padding-right: 20px;
    margin-top: 50px;
    margin-bottom: auto;
}

.history-list::-webkit-scrollbar-thumb{

    background: rgba(148, 163, 184, 0.35);
    border-radius: 20px;
}

.history-list::-webkit-scrollbar-thumb:hover{

    background: rgba(148, 163, 184, 0.55);
}


body.light-mode .history-list::-webkit-scrollbar-thumb{

    background: rgba(168, 85, 247, 0.28);
}

body.light-mode .history-list::-webkit-scrollbar-thumb:hover{

    background: rgba(168, 85, 247, 0.42);
}

@keyframes slideIn{

    from{
        opacity: 0;
        transform: translateX(100%);
    }

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

@keyframes slideDown{

    from{
        opacity: 0;
        transform: translateY(-20px);
    }

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


@keyframes fadeIn{

    from{
        opacity: 0;
        transform: translateY(-10px);
    }

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

@media(max-width: 400px){

    .app{

        width: 95%;
    }

    .buttons button{

        height: 58px;
    }
}

.currency-display{
    min-height: 180px;
}