:root{--bg:#f1f1f1;--card:#fff;--text:#303030;--muted:#6b6b6b;--key:#f4f4f4;--key-hover:#e9e9e9;--fn:#e4e4e4;--op:#ffe9d6;--op-text:#b54a00;--eq:#303030;--eq-text:#fff;--line:#e3e3e3}
@media (prefers-color-scheme:dark){:root{--bg:#1a1a1a;--card:#262626;--text:#f1f1f1;--muted:#a0a0a0;--key:#333;--key-hover:#3d3d3d;--fn:#404040;--op:#4a2f1a;--op-text:#ffb57a;--eq:#f1f1f1;--eq-text:#1a1a1a;--line:#3a3a3a}}
*{box-sizing:border-box}
body{margin:0;padding:16px;background:var(--bg);color:var(--text);font:14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,Roboto,sans-serif}
.wrap{display:flex;justify-content:center}
.calc{width:100%;max-width:380px;background:var(--card);border-radius:12px;padding:16px;box-shadow:0 1px 0 rgba(0,0,0,.06),0 1px 3px rgba(0,0,0,.08)}
.screen{padding:8px 4px 16px;text-align:right;min-height:96px;display:flex;flex-direction:column;justify-content:flex-end}
.expr{color:var(--muted);font-size:16px;min-height:22px;word-break:break-all}
.result{font-size:40px;font-weight:600;line-height:1.15;word-break:break-all;font-variant-numeric:tabular-nums}
.result.err{font-size:20px;color:#c4302b}
.keys{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.k{font:inherit;font-size:20px;height:56px;border:0;border-radius:10px;background:var(--key);color:var(--text);cursor:pointer;transition:background .1s}
.k:hover{background:var(--key-hover)}
.k:active{transform:translateY(1px)}
.k:focus-visible{outline:2px solid #2c6ecb;outline-offset:2px}
.fn{background:var(--fn);font-size:17px}
.op{background:var(--op);color:var(--op-text);font-size:22px}
.eq{background:var(--eq);color:var(--eq-text);grid-row:span 2}
.wide{grid-column:span 2;font-size:15px}
.history{margin-top:16px;border-top:1px solid var(--line);padding-top:12px}
.history-head{display:flex;justify-content:space-between;align-items:center;color:var(--muted);font-size:13px;margin-bottom:6px}
.link{background:none;border:0;color:#2c6ecb;cursor:pointer;font:inherit;font-size:13px;padding:0}
#history{list-style:none;margin:0;padding:0;max-height:180px;overflow:auto}
#history li{display:flex;justify-content:space-between;gap:12px;padding:6px 4px;border-radius:6px;cursor:pointer;font-variant-numeric:tabular-nums}
#history li:hover{background:var(--key)}
#history .h-expr{color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#history .h-val{font-weight:600}
#history .empty{color:var(--muted);cursor:default}
#history .empty:hover{background:none}
