@font-face{
  font-family: "Andresiana";
  src: url("FuenteAndresiana-Regular.ttf") format("truetype");
  font-display: swap;
}

:root{
  --bg:#f6f7fb;
  --panel:#ffffff;
  --stroke:#e6e8f0;
  --text:#0e1020;
  --muted:#6c7288;
  --op:#e9f2ff;
  --opText:#0b5cff;
  --eq:#2f80ff;
  --eqText:#ffffff;
  --key:#f1f2f6;
  --keyText:#1b1f33;
  --shadow: 0 10px 30px rgba(0,0,0,.06);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
}

.app{
  max-width:430px;
  height:100%;
  margin:0 auto;
  display:flex;
  flex-direction:column;
  padding:14px;
  gap:12px;
}

.bar{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 12px;
  background:var(--panel);
  border:1px solid var(--stroke);
  border-radius:16px;
  box-shadow: var(--shadow);
}

.brand{
  font-weight:700;
  letter-spacing:.2px;
}

.menuBtn{
  border:0;
  background:transparent;
  font-size:22px;
  padding:6px 10px;
  border-radius:10px;
  cursor:pointer;
}

.menu{
  position:absolute;
  right:10px;
  top:52px;
  background:var(--panel);
  border:1px solid var(--stroke);
  border-radius:14px;
  box-shadow: var(--shadow);
  overflow:hidden;
  min-width:180px;
  z-index:10;
}
.menuItem{
  width:100%;
  text-align:left;
  border:0;
  background:transparent;
  padding:12px 12px;
  cursor:pointer;
  font-weight:600;
}
.menuItem:hover{ background:#f3f5fb; }
.menuItem.ghost{ color:var(--muted); font-weight:600; }

.display{
  background:var(--panel);
  border:1px solid var(--stroke);
  border-radius:20px;
  padding:14px 16px;
  box-shadow: var(--shadow);
  min-height:120px;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  gap:8px;
}
.expr{
  color:var(--muted);
  font-size:14px;
  min-height:18px;
  text-align:right;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.value{
  font-size:46px;
  font-weight:700;
  text-align:right;
  line-height:1;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.keys{
  flex:1;
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:10px;
}

.key{
  border:0;
  border-radius:18px;
  padding:18px 0;
  font-size:22px;
  font-weight:700;
  cursor:pointer;
  background:var(--key);
  color:var(--keyText);
  box-shadow: 0 6px 18px rgba(0,0,0,.05);
  user-select:none;
  -webkit-tap-highlight-color: transparent;
}
.key:active{ transform: translateY(1px); }

.key.op{ background:var(--op); color:var(--opText); }
.key.eq{ background:var(--eq); color:var(--eqText); }
.key.fn{ background:#fff1f1; color:#d23b3b; }
.key.zero{ grid-column: span 2; }

.hint{
  color:var(--muted);
  font-size:12px;
  text-align:center;
  padding:2px 0;
}

.toast{
  position:fixed;
  left:50%;
  bottom:20px;
  transform:translateX(-50%);
  background:#111427;
  color:#fff;
  padding:10px 12px;
  border-radius:12px;
  font-size:13px;
  box-shadow: 0 10px 25px rgba(0,0,0,.18);
  max-width:92vw;
  z-index:50;
}

.helpDialog{
  border:1px solid var(--stroke);
  border-radius:16px;
  padding:14px 14px 12px;
  width:min(520px, 92vw);
}
.helpDialog h3{ margin:0 0 8px; }
.helpDialog p{ margin:8px 0; }
.helpDialog .muted{ color:var(--muted); font-size:13px; }
.dlgActions{
  display:flex;
  justify-content:flex-end;
  margin-top:12px;
}
.btn{
  border:0;
  border-radius:12px;
  padding:10px 12px;
  font-weight:800;
  cursor:pointer;
}
.btn.primary{ background:var(--eq); color:var(--eqText); }
