:root {
    --ink: #19162b;
    --muted: #756f82;
    --paper: #f4f0e7;
    --card: #fffdf8;
    --purple: #6d50e6;
    --purple-dark: #5740be;
    --lavender: #eee9ff;
    --orange: #ff825c;
    --line: #e3ddd2;
    --shadow: 0 28px 70px rgba(39, 30, 73, 0.17);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    color-scheme: light;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 7% 12%, rgba(255, 130, 92, 0.14), transparent 24rem),
        radial-gradient(circle at 92% 86%, rgba(109, 80, 230, 0.13), transparent 28rem),
        var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    content: "";
    opacity: 0.32;
    background-image: radial-gradient(rgba(25, 22, 43, 0.18) 0.7px, transparent 0.7px);
    background-size: 18px 18px;
    mask-image: linear-gradient(to right, black, transparent 34%, transparent 66%, black);
}

button {
    font: inherit;
}

.page-shell {
    width: min(1080px, calc(100% - 40px));
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 430px);
    align-items: center;
    gap: clamp(64px, 10vw, 140px);
    padding: 64px 0;
}

.intro {
    max-width: 510px;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 20px;
    color: var(--purple);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.intro h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(3.5rem, 7.2vw, 6.35rem);
    font-weight: 500;
    letter-spacing: -0.065em;
    line-height: 0.88;
}

.intro h1 em {
    color: var(--orange);
    font-weight: inherit;
}

.intro > p {
    max-width: 430px;
    margin: 30px 0 0;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.72;
}

.shortcut-hint {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 38px;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.45;
}

.shortcut-hint strong {
    color: var(--ink);
    font-size: 0.88rem;
}

.hint-icon {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(255, 253, 248, 0.7);
    box-shadow: 0 5px 15px rgba(39, 30, 73, 0.05);
    font-size: 1.15rem;
}

.calculator-card {
    position: relative;
    padding: 26px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.84);
    border-radius: 30px;
    background: rgba(255, 253, 248, 0.92);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.calculator-card::after {
    position: absolute;
    right: -65px;
    top: -75px;
    width: 180px;
    height: 180px;
    border: 32px solid rgba(109, 80, 230, 0.05);
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.card-topline {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.12rem;
    font-weight: 700;
}

.brand-mark {
    width: 13px;
    height: 13px;
    border: 3px solid var(--purple);
    border-radius: 4px;
    transform: rotate(45deg);
}

.server-status {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.server-status i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #31b67a;
    box-shadow: 0 0 0 3px rgba(49, 182, 122, 0.13);
}

.server-status.is-busy i {
    background: #e9a23b;
    box-shadow: 0 0 0 3px rgba(233, 162, 59, 0.15);
    animation: status-pulse 850ms ease-in-out infinite alternate;
}

.server-status.is-error {
    color: #b53c23;
}

.server-status.is-error i {
    background: #e25338;
    box-shadow: 0 0 0 3px rgba(226, 83, 56, 0.14);
}

@keyframes status-pulse {
    to {
        opacity: 0.45;
        transform: scale(0.82);
    }
}

.display {
    position: relative;
    display: flex;
    height: 124px;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    margin-bottom: 16px;
    padding: 21px 22px;
    overflow: hidden;
    border-radius: 20px;
    background: var(--ink);
    color: white;
    font-variant-numeric: tabular-nums;
}

.display::before {
    position: absolute;
    inset: 0;
    content: "";
    background: linear-gradient(125deg, transparent 55%, rgba(109, 80, 230, 0.19));
}

.calculation,
.result {
    position: relative;
    z-index: 1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calculation {
    min-height: 18px;
    margin-bottom: 8px;
    color: #a8a2bb;
    font-size: 0.77rem;
    letter-spacing: 0.02em;
}

.result {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.25rem, 7vw, 3rem);
    font-weight: 500;
    letter-spacing: -0.04em;
    line-height: 1;
}

.error-message {
    margin: -4px 0 12px;
    padding: 9px 12px;
    border-radius: 10px;
    background: #fff0eb;
    color: #b53c23;
    font-size: 0.75rem;
    text-align: center;
}

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

.key {
    position: relative;
    min-height: 59px;
    border: 1px solid #e7e1d8;
    border-radius: 16px;
    color: var(--ink);
    background: #fff;
    box-shadow: 0 3px 0 #ded8ce;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 700;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
    -webkit-tap-highlight-color: transparent;
}

.key:hover {
    background: #faf8f4;
    transform: translateY(-1px);
    box-shadow: 0 4px 0 #ded8ce;
}

.key:active,
.key.is-pressed {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #ded8ce;
}

.key:focus-visible {
    outline: 3px solid rgba(109, 80, 230, 0.3);
    outline-offset: 2px;
}

.key-utility {
    color: var(--purple-dark);
    background: var(--lavender);
    border-color: #ded4ff;
    box-shadow: 0 3px 0 #d5caf9;
}

.key-utility:hover {
    background: #e7dfff;
    box-shadow: 0 4px 0 #d5caf9;
}

.key-operator {
    color: var(--purple);
    font-size: 1.35rem;
}

.key-operator.is-active {
    border-color: var(--purple);
    color: white;
    background: var(--purple);
    box-shadow: 0 3px 0 var(--purple-dark);
}

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

.key-equals {
    color: white;
    background: var(--purple);
    border-color: var(--purple);
    box-shadow: 0 3px 0 var(--purple-dark), 0 8px 18px rgba(109, 80, 230, 0.2);
    font-size: 1.3rem;
}

.key-equals:hover {
    background: var(--purple-dark);
    box-shadow: 0 4px 0 #46329c, 0 8px 18px rgba(109, 80, 230, 0.2);
}

.key:disabled {
    cursor: wait;
    opacity: 0.62;
}

.card-footer {
    margin: 18px 0 0;
    color: #9b95a4;
    font-size: 0.7rem;
    text-align: center;
}

.card-footer span {
    display: inline-block;
    margin-right: 4px;
    color: var(--purple);
}

@media (max-width: 800px) {
    .page-shell {
        width: min(460px, calc(100% - 32px));
        grid-template-columns: 1fr;
        gap: 42px;
        padding: 48px 0;
    }

    .intro {
        text-align: center;
    }

    .intro h1 {
        font-size: clamp(3.4rem, 16vw, 5.2rem);
    }

    .intro > p {
        margin-inline: auto;
    }

    .shortcut-hint {
        justify-content: center;
        text-align: left;
    }
}

@media (max-width: 430px) {
    .page-shell {
        width: calc(100% - 20px);
        padding: 30px 0;
    }

    .calculator-card {
        padding: 17px;
        border-radius: 24px;
    }

    .key {
        min-height: 56px;
        border-radius: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
