:root {
    --bg: #1e1e1e;
    --calc: #1c1c1c;
    --screen: #000;
    --btn: #2e2e2e;
    --op: #ff9500;
    --clear: #ff3b30;
    --equal: #34c759;
    --text: #fff;
}

.light {
    --bg: #f2f2f2;
    --calc: #ffffff;
    --screen: #eaeaea;
    --btn: #dcdcdc;
    --op: #ff9500;
    --clear: #ff3b30;
    --equal: #34c759;
    --text: #000;
}

body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    height: 100vh;
    background: var(--bg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: system-ui, Arial;
}

.wrapper {
    display: flex;
    gap: 20px;
}

.calculator {
    width: 300px;
    background: var(--calc);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.5);
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.screen {
    background: var(--screen);
    color: var(--text);
    height: 60px;
    border-radius: 10px;
    padding: 14px;
    text-align: right;
    font-size: 37px;
    margin-bottom: 12px;
}

.toggle {
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}

.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

button {
    height: 52px;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    background: var(--btn);
    color: var(--text);
}

.operator { background: var(--op); color: #fff; }
.clear { background: var(--clear); color: #fff; }
.equal { background: var(--equal); color: #fff; grid-row: span 2; }
.zero { grid-column: span 2; }

.history {
    width: 200px;
    background: var(--calc);
    border-radius: 18px;
    padding: 14px;
    color: var(--text);
    font-size: 14px;
    overflow-y: auto;
}

.history h3 {
    margin-top: 0;
    font-size: 16px;
    text-align: center;
}

.history div {
    margin-bottom: 6px;
}

@media (max-width: 900px) {
    .wrapper {
        flex-direction: column;
        align-items: center;
    }

    .history {
        width: 300px;
        max-height: 200px;
    }
}
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .calculator {
        width: 100%;
        max-width: 340px;
    }

    .screen {
        font-size: 28px;
        height: 55px;
    }

    button {
        height: 48px;
        font-size: 16px;
    }

    .history {
        width: 100%;
        max-width: 340px;
        font-size: 13px;
    }
}
