* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    padding: 20px;
}

.calculator {
    width: 100%;
    max-width: 400px;
    background: rgba(20, 25, 40, 0.95);
    border-radius: 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    backdrop-filter: blur(20px);
}

/* 显示屏 */
.display {
    padding: 24px 24px 16px;
    background: rgba(0, 0, 0, 0.25);
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    text-align: right;
}

.history {
    color: rgba(255, 255, 255, 0.35);
    font-size: 13px;
    min-height: 18px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.expression {
    color: rgba(255, 255, 255, 0.6);
    font-size: 20px;
    min-height: 26px;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    margin-bottom: 6px;
    font-weight: 300;
}

.result {
    color: #fff;
    font-size: 42px;
    font-weight: 300;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    line-height: 1.1;
    letter-spacing: -1px;
}

.result.error {
    color: #ff6b6b;
    font-size: 28px;
}

.result.preview {
    opacity: 0.45;
}

/* 模式栏 */
.mode-bar {
    display: flex;
    gap: 8px;
    padding: 12px 16px 0;
    background: rgba(0, 0, 0, 0.25);
}

.mode-btn {
    flex: 1;
    padding: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.mode-btn.active {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: #0f1e3d;
    border-color: transparent;
    font-weight: 600;
}

/* 按钮网格 */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    padding: 16px;
    background: transparent;
}

.btn {
    height: 64px;
    border: none;
    border-radius: 14px;
    font-size: 20px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4px;
}

.btn:hover {
    filter: brightness(1.3);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0) scale(0.95);
}

.btn.number {
    background: rgba(255, 255, 255, 0.1);
    font-weight: 600;
}

.btn.func {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.75);
    font-size: 16px;
}

.btn.sci {
    background: rgba(79, 172, 254, 0.12);
    color: #4facfe;
    font-size: 16px;
    font-weight: 600;
}

.btn.operator {
    background: rgba(79, 172, 254, 0.2);
    color: #4facfe;
    font-size: 24px;
}

.btn.equals {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: #0f1e3d;
    font-size: 26px;
    font-weight: 700;
}

.btn.equals:hover {
    filter: brightness(1.1);
}

/* 数字按钮 0 占两格 */
.btn[data-value="0"] {
    grid-column: span 1;
}

/* 提示文字 */
.hint {
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.3);
    font-size: 12px;
    text-align: center;
}

/* 响应式 */
@media (max-width: 420px) {
    .calculator {
        border-radius: 0;
        max-width: 100%;
    }

    body {
        padding: 0;
        justify-content: flex-end;
    }

    .hint {
        display: none;
    }

    .btn {
        height: 70px;
    }

    .result {
        font-size: 36px;
    }
}

/* 滚动条隐藏 */
.expression::-webkit-scrollbar,
.result::-webkit-scrollbar,
.history::-webkit-scrollbar {
    display: none;
}
