.mep-calc-window {
    --calc-primary: #563d7c;
    position: fixed;
    top: 88px;
    right: 24px;
    width: min(392px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    border-radius: 24px;
    overflow: hidden;
    z-index: 99;
    border: 1px solid rgba(255, 255, 255, 0.82);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(244, 246, 251, 0.98) 100%);
    box-shadow: 0 24px 48px rgba(31, 44, 77, 0.24);
    backdrop-filter: blur(10px);
}

.mep-calc {
    color: #22314d;
}

.mep-calc__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 14px;
    background: linear-gradient(135deg, var(--calc-primary) 0%, #29456c 100%);
    color: #ffffff;
    cursor: move;
    user-select: none;
}

.mep-calc__title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.mep-calc__title-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 20px;
}

.mep-calc__title-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mep-calc__title-text strong {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
}

.mep-calc__title-text small {
    font-size: 12px;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.78);
}

.mep-calc__close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-size: 28px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease, transform 0.18s ease;
}

.mep-calc__close:hover,
.mep-calc__close:focus-visible {
    background: rgba(255, 255, 255, 0.24);
    transform: translateY(-1px);
    outline: none;
}

.mep-calc__body {
    padding: 14px 16px 16px;
}

.mep-calc__memory {
    min-width: 28px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.88);
    font-weight: 700;
    font-size: 12px;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}

.mep-calc__memory.is-active {
    opacity: 1;
    transform: translateY(0);
}

.mep-calc__display-card {
    padding: 14px 16px 16px;
    margin-bottom: 14px;
    border-radius: 20px;
    background: linear-gradient(160deg, rgba(19, 28, 49, 0.98) 0%, rgba(41, 59, 95, 0.96) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.mep-calc__display-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.mep-calc__history {
    min-height: 20px;
    flex: 1;
    min-width: 0;
    text-align: right;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.62);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mep-calc__display {
    width: 100%;
    border: 0;
    padding: 0;
    background: transparent;
    text-align: right;
    color: #ffffff;
    font-size: 38px;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.02em;
    box-shadow: none;
}

.mep-calc__display:focus {
    outline: none;
}

.mep-calc__display.is-error {
    font-size: 22px;
    color: #ffb5c2;
    letter-spacing: 0;
    text-align: left;
}

.mep-calc__grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.mep-calc__key {
    height: 52px;
    border: 0;
    border-radius: 16px;
    background: #ffffff;
    color: #22314d;
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 10px 18px rgba(45, 65, 105, 0.1);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.mep-calc__key:hover,
.mep-calc__key:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 14px 22px rgba(45, 65, 105, 0.16);
    outline: none;
}

.mep-calc__key:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 8px 14px rgba(45, 65, 105, 0.12);
}

.mep-calc__key--memory {
    background: rgba(86, 61, 124, 0.08);
    color: var(--calc-primary);
}

.mep-calc__key--function {
    background: rgba(34, 49, 77, 0.08);
    color: #31435f;
}

.mep-calc__key--operator {
    background: rgba(41, 123, 255, 0.1);
    color: #2454a3;
}

.mep-calc__key--danger {
    background: rgba(214, 76, 90, 0.12);
    color: #b53b48;
}

.mep-calc__key--primary {
    background: var(--calc-primary);
    color: #ffffff;
}

.mep-calc__key--span-2 {
    grid-column: span 2;
}

.mep-calc-window.is-focused {
    box-shadow: 0 28px 58px rgba(31, 44, 77, 0.28);
}

@media (max-width: 576px) {
    .mep-calc-window {
        top: 72px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
    }

    .mep-calc__body {
        padding: 14px;
    }

    .mep-calc__grid {
        gap: 8px;
    }

    .mep-calc__key {
        height: 48px;
        font-size: 17px;
    }

    .mep-calc__display {
        font-size: 32px;
    }
}
