/* ── 在线计算器工具页 ── */

/* 布局：计算器 + 历史记录 */
.zcalc-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    align-items: start;
}

/* 计算器主体 */
.zcalc-wrapper {
    background: #f8f9fb;
    border: 1px solid #e8eaf0;
    border-radius: 12px;
    padding: 1.2rem;
    max-width: 440px;
    margin: 0 auto;
}

/* 显示屏 */
.zcalc-display {
    background: #1a1a2e;
    border-radius: 8px;
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
}

.zcalc-expr {
    color: #8888aa;
    font-size: 0.85rem;
    text-align: right;
    min-height: 1.2em;
    font-family: 'Fira Code', monospace;
    word-break: break-all;
}

.zcalc-screen {
    color: #fff;
    font-size: 2rem;
    font-weight: 600;
    text-align: right;
    font-family: 'Fira Code', monospace;
    line-height: 1.2;
    word-break: break-all;
}

/* 按键网格：5列 */
.zcalc-keys {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.45rem;
}

.zk {
    padding: 0.8rem 0.3rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    font-family: inherit;
    user-select: none;
}

.zk:active { transform: scale(0.95); }

.zk.num {
    background: #fff;
    color: #333;
    border: 1px solid #e8eaf0;
}
.zk.num:hover { background: #f0f0f0; }

.zk.func {
    background: #e8eaf0;
    color: #555;
}
.zk.func:hover { background: #d8dae0; }

.zk.op {
    background: #2563eb;
    color: #fff;
}
.zk.op:hover { background: #1d4ed8; }

.zk.eq {
    background: #059669;
    color: #fff;
}
.zk.eq:hover { background: #047857; }

.zk.zero { grid-column: span 2; }
.zk.wide { grid-column: span 2; }

/* 历史记录面板 */
.zcalc-history {
    background: #f8f9fb;
    border: 1px solid #e8eaf0;
    border-radius: 12px;
    overflow: hidden;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #e8eaf0;
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
}

.history-clear {
    background: none;
    border: none;
    color: #999;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
}
.history-clear:hover { color: #e74c3c; }

.history-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.history-empty {
    text-align: center;
    color: #bbb;
    font-size: 0.85rem;
    padding: 2rem 1rem;
}

.history-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f0f0f0;
}

.history-item:hover { background: #eef2ff; }
.history-item:last-child { border-bottom: none; }

.history-expr {
    font-size: 0.8rem;
    color: #999;
    font-family: 'Fira Code', monospace;
}

.history-result {
    font-size: 0.95rem;
    color: #333;
    font-weight: 500;
    font-family: 'Fira Code', monospace;
}

/* 快捷键表格 */
.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
    max-width: 720px;
    margin: 0 auto;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    background: white;
    border: 1px solid #e8eaf0;
    border-radius: 8px;
}

.shortcut-item kbd {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
    font-family: 'Fira Code', monospace;
    color: #333;
    white-space: nowrap;
}

.shortcut-item span {
    font-size: 0.85rem;
    color: #666;
}

/* ── Mobile ── */
@media (max-width: 900px) {
    .zcalc-layout {
        grid-template-columns: 1fr;
    }

    .zcalc-wrapper {
        max-width: 440px;
        margin: 0 auto;
    }

    .shortcut-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .zcalc-screen { font-size: 1.6rem; }

    .zk {
        padding: 0.7rem 0.2rem;
        font-size: 1rem;
    }

    .shortcut-grid {
        grid-template-columns: 1fr 1fr;
    }
}