.scientific-calculator {
    width: min(100%, 620px);
    padding: 9px;
}

.calculator-display {
    min-height: 76px;
    padding: 7px 10px;
    margin-bottom: 6px;
    background: #fff;
    border: 1px solid #aaa;
    text-align: right;
    overflow: hidden;
}

#scientific-expression {
    height: 23px;
    color: #777;
    font-family: "Courier New", monospace;
    white-space: nowrap;
    overflow: hidden;
}

#scientific-result {
    display: block;
    height: 35px;
    color: #111;
    font-family: "Courier New", monospace;
    font-size: 27px;
    line-height: 35px;
    white-space: nowrap;
    overflow-x: auto;
}

.calculator-modes {
    display: flex;
    gap: 3px;
    margin-bottom: 5px;
}

.calculator-modes button {
    min-height: 29px;
    padding: 3px 10px;
    border: 1px solid #bbb;
    background: #f7f7f7;
    cursor: pointer;
}

.calculator-modes button.is-active {
    background: #d0d0d0;
    font-weight: 700;
}

.calculator-keypad {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 3px;
}

.calculator-keypad button {
    min-height: 38px;
    border: 1px solid #bcbcbc;
    border-radius: 2px;
    background: #f7f7f7;
    color: #111;
    cursor: pointer;
}

.calculator-keypad button:hover {
    background: #e9e9e9;
}

.calculator-keypad button:active {
    background: #d8d8d8;
}

.calculator-keypad .equals {
    background: #d4d4d4;
    font-size: 18px;
    font-weight: 700;
}

.calculator-history {
    display: none;
    margin-top: 7px;
    padding-top: 5px;
    border-top: 1px solid #c4c4c4;
    max-height: 160px;
    overflow-y: auto;
}

.history-item {
    padding: 4px;
    border-bottom: 1px solid #ccc;
    color: #555;
    font-family: "Courier New", monospace;
    font-size: 12px;
    text-align: right;
}

@media (max-width: 560px) {
    .scientific-calculator {
        padding: 6px;
    }

    .calculator-keypad {
        gap: 2px;
    }

    .calculator-keypad button {
        min-height: 35px;
        font-size: 11px;
    }

    .calculator-modes button {
        padding-inline: 7px;
        font-size: 11px;
    }
}
