/* ============ 在线科学计算器 ============ */
.calc-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 2px;
}
.calc-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.calc-head h1 {
    font-size: clamp(1.55rem, 3.4vw, 2.15rem);
    font-weight: 800;
    margin: 0 0 6px;
    letter-spacing: -.4px;
}
.calc-head-text p {
    margin: 0;
    max-width: 660px;
    color: var(--text-dim);
    font-size: .93rem;
}
.calc-meta { display: flex; gap: 8px; }
.meta-chip {
    font-size: .76rem;
    color: var(--text-dim);
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 20px;
    padding: 4px 12px;
    white-space: nowrap;
}

/* ---- 计算器主体 ---- */
.calc-board {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .07);
}

/* ---- 显示屏 ---- */
.disp {
    position: relative;
    padding: 14px 18px 14px;
    border: 1px solid #f2e4dd;
    border-radius: 16px;
    background: linear-gradient(158deg, #fff7f3 0%, #fffdfb 46%, #fbfcfd 100%);
    box-shadow: inset 0 1px 0 #fff, 0 2px 8px rgba(255, 106, 61, .05);
    overflow: hidden;
}
.disp::after {
    content: "";
    position: absolute;
    right: -60px;
    top: -80px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 106, 61, .09), transparent 70%);
    pointer-events: none;
}
.disp-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}
.mode-btn {
    border: 1px solid rgba(255, 106, 61, .45);
    background: #fff;
    color: var(--accent);
    font-weight: 800;
    font-size: .72rem;
    letter-spacing: 1px;
    padding: 4px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.mode-btn:hover { background: #fff1ec; }
.mode-btn.rad {
    color: var(--accent-2);
    border-color: rgba(43, 108, 176, .42);
}
.mode-btn.rad:hover { background: #eef4fb; }
.mode-hint { font-size: .76rem; color: #a99c95; }
.copy-btn {
    margin-left: auto;
    border: 1px solid rgba(31, 36, 48, .07);
    background: #fff;
    color: var(--text-dim);
    font-size: .76rem;
    padding: 4px 11px;
    border-radius: 8px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.copy-btn:hover { color: var(--accent); border-color: rgba(255, 106, 61, .45); }

.disp-input {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 0;
    border: 0;
    background: transparent;
    outline: none;
    text-align: right;
    font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: clamp(1.05rem, 2.1vw, 1.5rem);
    font-weight: 600;
    color: #6c6570;
    letter-spacing: .4px;
}
.disp-input::placeholder { color: #c3b9b3; font-weight: 500; }
/* 计算器显示屏是嵌入式无边框输入，不套用全站聚焦光圈 */
.disp-input:focus { box-shadow: none; border-color: transparent; }

.disp-result {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 10px;
    min-height: 66px;
    margin-top: 2px;
}
.disp-eq {
    font-size: 1.35rem;
    font-weight: 700;
    color: rgba(255, 106, 61, .38);
}
#resultVal {
    font-size: clamp(2.1rem, 5.2vw, 3.4rem);
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: -1.2px;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    word-break: break-all;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}
#resultVal.preview { color: #b9aca6; }
.disp-err {
    position: relative;
    z-index: 1;
    min-height: 18px;
    margin-top: 2px;
    text-align: right;
    font-size: .78rem;
    color: #c53030;
}
.disp-err.hint { color: #b3a9a2; }

/* ---- 键盘 ---- */
.pads {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.pad {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.key {
    height: 60px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .13s, border-color .13s, transform .07s, box-shadow .13s;
    -webkit-tap-highlight-color: transparent;
}
.key:hover {
    background: #f7f8fa;
    border-color: var(--border-strong);
    box-shadow: 0 3px 10px rgba(15, 23, 42, .06);
}
.key:active { transform: translateY(1px) scale(.992); }

.key.fn {
    background: #f8f9fb;
    color: #5b6675;
    font-size: .92rem;
    letter-spacing: .2px;
}
.key.fn:hover { background: #eef1f5; }
.key.num { font-size: 1.3rem; font-weight: 700; }
.key.num:hover { background: #fdf6f3; }
.key.op {
    background: #fff7f4;
    border-color: #ffe2d6;
    color: var(--accent);
    font-size: 1.3rem;
    font-weight: 700;
}
.key.op:hover { background: #ffefe8; border-color: #ffd0bd; }
.key.warn { color: #c0442a; font-weight: 700; }
.key.warn.fn { background: #fff5f2; }
.key.accent {
    background: #fff1ec;
    border-color: #ffd9cb;
    color: var(--accent);
    font-weight: 700;
}

/* 等号条 */
.eq-bar {
    height: 64px;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, #ff8054 0%, #ff5c2b 100%);
    color: #fff;
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(255, 106, 61, .26);
    transition: filter .15s, transform .07s, box-shadow .15s;
}
.eq-bar:hover { filter: brightness(1.04); box-shadow: 0 10px 26px rgba(255, 106, 61, .32); }
.eq-bar:active { transform: translateY(1px); box-shadow: 0 5px 14px rgba(255, 106, 61, .24); }

/* ---- 历史记录 ---- */
.hist {
    padding-top: 14px;
    border-top: 1px dashed var(--border);
}
.hist-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.hist-head h2 {
    margin: 0;
    font-size: .95rem;
    font-weight: 700;
}
.hist-count { font-size: .76rem; color: #a2a9b4; }
.hist-line { flex: 1; height: 1px; background: var(--border); }
.hist-clear {
    border: 0;
    background: transparent;
    color: #a2a9b4;
    font-size: .8rem;
    cursor: pointer;
    padding: 2px 4px;
}
.hist-clear:hover { color: var(--accent); }

.hist-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px;
    max-height: 264px;
    overflow: auto;
    padding-right: 2px;
}
.hist-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    text-align: left;
    cursor: pointer;
    transition: border-color .13s, background .13s;
    font-family: inherit;
}
.hist-item:hover { border-color: rgba(255, 106, 61, .5); background: #fffaf8; }
.hist-item .he {
    font-size: .78rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: ui-monospace, Consolas, monospace;
}
.hist-item .hr {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.hist-empty {
    grid-column: 1 / -1;
    padding: 30px 16px;
    text-align: center;
    color: #b6bcc6;
    font-size: .85rem;
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
}

/* ---- 响应式 ---- */
@media (max-width: 820px) {
    .calc-board { padding: 14px; gap: 12px; border-radius: 18px; }
    .pads { grid-template-columns: minmax(0, 1fr); }
    .num-pad { order: -1; }
    .key { height: 54px; }
    .eq-bar { height: 58px; }
    .calc-meta { display: none; }
    .hist-list { grid-template-columns: minmax(0, 1fr); max-height: 220px; }
}
@media (max-width: 420px) {
    .key { height: 50px; font-size: .98rem; }
    .key.num { font-size: 1.15rem; }
    .disp { padding: 12px 14px; }
    .disp-result { min-height: 54px; }
}
